Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
feat: update link system and UI (#12)
Browse files Browse the repository at this point in the history
* Add placeholder values to font setting selects, keep font colorpicker not set when no value, etc

* Show infobox creation button on datasets too, show dataset title field, name default field area Template for dataset

* fix bug where default fields showed on dataset children

* update placeholders for typography fields

* dont show dataset name on infobox pane, show unique template name for dataset, textBlock, imageBlock, etc

* wip: link popup, add icons, etc

* wip: update UI and fix restrictions

* feat: plug-ins install page (#625)

Co-authored-by: KaWaite <[email protected]>

* wip:link system, dataset parent/children right panel mostly working

* wip: fix storybook files that used deleted props

* update dynamic colours for noneditablefield, get infoboxes working correctly with passed fields, etc

* remove old console logs

* fix colors, clean up some logic, etc

* filter overrides correctly for layers(will now use any overridden values)

* Update storybook files, condense logic, remove unused code, etc

* change so only layers that are layerGroups can link dataset data

* revert change that had non-linked items passing as linked

* update storybook file, change group prop to isTemplate for better understanding

* fix dependency flow

* fix error

* update gql

* chore: lock file maintenance (#653)

Co-authored-by: Renovate Bot <[email protected]>

* chore: fix deployment workflow

* fix: gql schema

* chore: fix trigger_staging workflow

* remove conditional that isn't necessary anymore

* fix logic to work for all usecases: override, link, prop passing, nothing, parent, child

* revert code to show backend bug again, fix linting

* convert selectableType to string if URL since url from a dataset can be/probably will be of type string

* missed yaml in last commit

Co-authored-by: KaWaite <[email protected]>
Co-authored-by: HideBa <[email protected]>
Co-authored-by: KaWaite <[email protected]>
Co-authored-by: rot1024 <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <[email protected]>
  • Loading branch information
7 people authored Jul 8, 2021
1 parent 0310f50 commit 51de778
Show file tree
Hide file tree
Showing 59 changed files with 12,559 additions and 12,207 deletions.
34 changes: 17 additions & 17 deletions src/components/atoms/AdditionButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ export interface Props {
const AdditionButton: React.FC<Props> = ({ className, children, disabled, onClick }) => {
const referenceElement = useRef<HTMLDivElement>(null);
const popperElement = useRef<HTMLDivElement>(null);
const { styles, attributes, update: updatePopper } = usePopper(
referenceElement.current,
popperElement.current,
{
placement: "bottom",
strategy: "fixed",
modifiers: [
{
name: "eventListeners",
enabled: false,
options: {
scroll: false,
resize: false,
},
const {
styles,
attributes,
update: updatePopper,
} = usePopper(referenceElement.current, popperElement.current, {
placement: "bottom",
strategy: "fixed",
modifiers: [
{
name: "eventListeners",
enabled: false,
options: {
scroll: false,
resize: false,
},
],
},
);
},
],
});

const handleClick = useCallback(() => {
if (disabled) return;
Expand Down
4 changes: 4 additions & 0 deletions src/components/atoms/Icon/Icons/fieldClear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/components/atoms/Icon/Icons/fieldLinked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/components/atoms/Icon/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ import NewWorkspace from "./Icons/newWorkspace.svg";
import Preview from "./Icons/preview.svg";
import Install from "./Icons/install.svg";
import CopyCode from "./Icons/copyCode.svg";
import FieldClear from "./Icons/fieldClear.svg";
import FieldLinked from "./Icons/fieldLinked.svg";

// Misc
import Logo from "./Icons/reearthLogo.svg";
Expand Down Expand Up @@ -197,6 +199,8 @@ export default {
newWorkspace: NewWorkspace,
preview: Preview,
copyCode: CopyCode,
fieldLinked: FieldLinked,
fieldClear: FieldClear,
map: MapIcon,
noProjects: NoProjects,
topPage: TopPage,
Expand Down
34 changes: 17 additions & 17 deletions src/components/atoms/InsertionBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ const InsertionBar: React.FC<Props> = ({
}) => {
const referenceElement = useRef<HTMLDivElement>(null);
const popperElement = useRef<HTMLDivElement>(null);
const { styles, attributes, update: updatePopper } = usePopper(
referenceElement.current,
popperElement.current,
{
placement: "bottom",
strategy: "fixed",
modifiers: [
{
name: "eventListeners",
enabled: false,
options: {
scroll: false,
resize: false,
},
const {
styles,
attributes,
update: updatePopper,
} = usePopper(referenceElement.current, popperElement.current, {
placement: "bottom",
strategy: "fixed",
modifiers: [
{
name: "eventListeners",
enabled: false,
options: {
scroll: false,
resize: false,
},
],
},
);
},
],
});

const handleClick = useCallback(() => {
if (mode !== "visible") return;
Expand Down
7 changes: 4 additions & 3 deletions src/components/atoms/Markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ const Markdown: React.FC<Props> = ({
onClick,
onDoubleClick,
}) => {
const dark = useMemo(() => (backgroundColor ? isDark(backgroundColor) : false), [
backgroundColor,
]);
const dark = useMemo(
() => (backgroundColor ? isDark(backgroundColor) : false),
[backgroundColor],
);

return (
<Wrapper
Expand Down
1 change: 0 additions & 1 deletion src/components/atoms/PropertyGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const PropertyTitle = styled.div`
background-color: ${props => props.theme.properties.bg};
padding: 8px 16px;
text-align: left;
cursor: pointer;
user-select: none;
display: flex;
align-items: center;
Expand Down
68 changes: 36 additions & 32 deletions src/components/atoms/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React, { useState, useRef, useCallback, useLayoutEffect } from "react";
import { useClickAway } from "react-use";
import { usePopper } from "react-popper";
import { useMergeRefs } from "use-callback-ref";
import { useIntl } from "react-intl";

import { styled, css, useTheme, metrics } from "@reearth/theme";
import { metricsSizes } from "@reearth/theme/metrics";
import colors from "@reearth/theme/colors";
import Icon from "@reearth/components/atoms/Icon";
import Text from "@reearth/components/atoms/Text";

Expand All @@ -26,7 +27,9 @@ type OptionElement<Value extends string | number> = React.ReactElement<OptionPro
export type Props<Value extends string | number> = {
className?: string;
value?: Value;
placeholder?: string;
inactive?: boolean;
color?: string;
fullWidth?: boolean;
onChange?: (value: Value) => void;
children?: OptionElement<Value>[];
Expand All @@ -41,49 +44,52 @@ const Select = <Value extends string | number>(
{
className,
value: selectedValue,
placeholder,
inactive = false,
color,
fullWidth = false,
onChange,
children,
}: Props<Value>,
ref: React.Ref<HTMLDivElement>,
) => {
const intl = useIntl();
const [open, setOpen] = useState(false);
const [focusedValue, setFocusedValue] = useState(selectedValue);

const wrapperRef = useRef<HTMLDivElement>(null);
const listRef = useRef<HTMLUListElement>(null);
const mergedRef = useMergeRefs(ref ? [ref, wrapperRef] : [wrapperRef]);
const { styles, attributes, update: updatePopper } = usePopper(
wrapperRef.current,
listRef.current,
{
placement: "bottom",
modifiers: [
{
name: "flip",
enabled: true,
options: {
fallbackPlacements: ["top"],
},
const {
styles,
attributes,
update: updatePopper,
} = usePopper(wrapperRef.current, listRef.current, {
placement: "bottom",
modifiers: [
{
name: "flip",
enabled: true,
options: {
fallbackPlacements: ["top"],
},
{
name: "offset",
options: {
offset: [0, 4],
},
},
{
name: "offset",
options: {
offset: [0, 4],
},
{
name: "eventListeners",
enabled: !open,
options: {
scroll: false,
resize: false,
},
},
{
name: "eventListeners",
enabled: !open,
options: {
scroll: false,
resize: false,
},
],
},
);
},
],
});

const isValidElement = (object: {} | null | undefined): object is OptionElement<Value> =>
React.isValidElement(object);
Expand Down Expand Up @@ -219,8 +225,8 @@ const Select = <Value extends string | number>(
<Selected
inactive={inactive}
size="xs"
color={inactive ? "" : theme.properties.contentsText}>
{selectedLabel}
color={!selectedValue ? theme.colors.text.weak : color}>
{selectedLabel || placeholder || intl.formatMessage({ defaultMessage: "not set" })}
</Selected>
<StyledDownArrow icon="arrowSelect" />
</SelectWrapper>
Expand Down Expand Up @@ -277,8 +283,6 @@ const SelectWrapper = styled.div`
const Selected = styled(Text)<{ inactive: boolean }>`
flex: 1;
padding: 3px;
color: ${({ inactive, theme }) =>
inactive ? colors.outline.main : theme.properties.contentsText};
`;

const OptionList = styled.ul<{ fullWidth: boolean; open: boolean }>`
Expand Down
8 changes: 4 additions & 4 deletions src/components/atoms/SelectBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ const SelectField = <Value extends string | number = string>({
value={selected}
inactive={disabled}
onChange={onChange}
fullWidth>
fullWidth
color={color}>
{items.map(({ key, label, icon }) => (
<Option key={key} textColor={color} value={key} label={label}>
<Option key={key} value={key} label={label}>
<OptionCheck size="xs">{key === selected && <Icon icon="check" size={12} />}</OptionCheck>
{hasIcon && <OptionIcon size="xs">{icon && <Icon icon={icon} />}</OptionIcon>}
{label}
Expand Down Expand Up @@ -67,14 +68,13 @@ const OptionIcon = styled(Text)`

const Option = styled.li<{
focused?: boolean;
textColor?: string;
label?: string;
}>`
display: flex;
list-style: none;
padding: 6px;
font-size: ${fonts.sizes["2xs"]}px;
color: ${({ textColor, theme }) => textColor || theme.main.text};
color: ${({ theme }) => theme.main.text};
background: ${({ focused, theme }) => (focused ? "transparent" : theme.properties.bg)};
cursor: pointer;
`;
Expand Down
24 changes: 2 additions & 22 deletions src/components/atoms/SelectOption/index.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
import { styled } from "@reearth/theme";
import colors from "@reearth/theme/colors";
import fonts from "@reearth/theme/fonts";

export type Props = {
label: string;
linked?: boolean;
overridden?: boolean;
inactive?: boolean;
focused?: boolean;
selected?: boolean;
};

const Option = styled.li<Props>`
display: flex;
list-style: none;
padding: 6px;
font-size: ${fonts.sizes.xs}px;
color: ${({ linked, overridden, selected, inactive, theme }) =>
selected && linked && overridden
? colors.primary.main
: selected && linked
? colors.primary.main
: selected && overridden
? colors.danger.main
: selected
? theme.properties.contentsText
: linked && overridden
? colors.danger.main
: overridden
? colors.primary.main
: inactive
? colors.outline.main
: theme.properties.contentsText};
background: ${({ focused, theme }) => (focused ? theme.colors.bg[4] : theme.colors.bg[2])};
color: ${({ theme }) => theme.properties.contentsText};
background: ${({ focused }) => (focused ? "#222222" : "transparent")};
cursor: pointer;
`;

Expand Down
13 changes: 7 additions & 6 deletions src/components/molecules/Common/Cesium/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ export default ({
}
}, [cameraState, onCameraChange]);

const [imageryLayers, setImageryLayers] = useState<
[string, ImageryProvider, number | undefined, number | undefined][]
>();
const [imageryLayers, setImageryLayers] =
useState<[string, ImageryProvider, number | undefined, number | undefined][]>();

useDeepCompareEffect(() => {
const newTiles = (property?.tiles?.length ? property.tiles : undefined)
Expand Down Expand Up @@ -226,9 +225,11 @@ const getCamera = (viewer: CesiumViewer) => {
if (!(camera.frustum instanceof PerspectiveFrustum)) return;

const ellipsoid = viewer.scene.globe.ellipsoid;
const { latitude, longitude, height: altitude } = ellipsoid.cartesianToCartographic(
camera.position,
);
const {
latitude,
longitude,
height: altitude,
} = ellipsoid.cartesianToCartographic(camera.position);
const lat = CesiumMath.toDegrees(latitude);
const lng = CesiumMath.toDegrees(longitude);
const { heading, pitch, roll } = camera;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ const Ellipsoid: PrimitiveComponent<Property, PluginProperty> = ({
return new Cartesian3(radius, radius, radius);
}, [radius]);

const material = useMemo(() => toColor(property?.default?.fillColor), [
property?.default?.fillColor,
]);
const material = useMemo(
() => toColor(property?.default?.fillColor),
[property?.default?.fillColor],
);

return !isVisible ? null : (
<Entity id={id} onClick={onClick} position={position}>
Expand Down
Loading

0 comments on commit 51de778

Please sign in to comment.