Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): layer style node system #1143

Merged
merged 28 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bc119ba
inital node implemention
mkumbobeaty Sep 11, 2024
c92069e
Merge branch 'main' of github.com:reearth/reearth-visualizer into fea…
mkumbobeaty Sep 11, 2024
547c310
implement the nodes and improve interface tab
mkumbobeaty Sep 11, 2024
3dc1a85
improve node feature
mkumbobeaty Sep 12, 2024
0247a68
implement polyline nodes
mkumbobeaty Sep 12, 2024
bb69fea
improve folders
mkumbobeaty Sep 12, 2024
9b387b1
add all sub-tab menu
mkumbobeaty Sep 16, 2024
677be7a
Merge branch 'main' of github.com:reearth/reearth-visualizer into fea…
mkumbobeaty Sep 17, 2024
d81de96
update conditional
mkumbobeaty Sep 17, 2024
b26b952
fix current interface tab
mkumbobeaty Sep 17, 2024
5820542
remove height
mkumbobeaty Sep 17, 2024
a61821d
Merge branch 'main' of github.com:reearth/reearth-visualizer into fea…
mkumbobeaty Sep 17, 2024
ab6ad38
refactor node
mkumbobeaty Sep 18, 2024
00fc6f9
improve conditionas
mkumbobeaty Sep 20, 2024
dfc7544
update tabs in node system
mkumbobeaty Sep 20, 2024
ead4156
refactor node system
mkumbobeaty Sep 23, 2024
ba23a9a
Merge branch 'main' of github.com:reearth/reearth-visualizer into fea…
mkumbobeaty Sep 23, 2024
3568cfe
rename node
mkumbobeaty Sep 24, 2024
82f6a3a
improve code quality
mkumbobeaty Sep 24, 2024
ee46bd1
fix scroll
mkumbobeaty Sep 24, 2024
a456ca2
fix undefined
mkumbobeaty Sep 24, 2024
f3d7ced
improve scroll bar
mkumbobeaty Sep 25, 2024
7cc049d
refactor: re-structure the components & logic
airslice Sep 27, 2024
0cab430
refactor: rename & update i18n
airslice Sep 27, 2024
a95a93a
Merge branch 'main' into feat/new-layer-style-node-system
airslice Sep 27, 2024
349800e
refactor: disable used node & fix typo
airslice Sep 27, 2024
04ace18
fix: condition property & wrap color
airslice Sep 30, 2024
fe80dd1
Merge branch 'main' into feat/new-layer-style-node-system
airslice Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { CodeInput } from "@reearth/beta/lib/reearth-ui";
import { LayerStyle } from "@reearth/services/api/layerStyleApi/utils";
import { styled } from "@reearth/services/theme";
import { SetStateAction } from "jotai";
import { Dispatch, FC, useCallback, useEffect, useState } from "react";

import NoStyleMessage from "../NoStyleMessage";

type CodeProps = {
layerStyle: LayerStyle | undefined;
setLayerStyle: Dispatch<SetStateAction<LayerStyle | undefined>>;
};

const StyleCode: FC<CodeProps> = ({ layerStyle, setLayerStyle }) => {
const [styleCode, setStyleCode] = useState<string | undefined>("");

useEffect(() => {
setStyleCode(JSON.stringify(layerStyle?.value, null, 2));
}, [layerStyle]);

const handleStyleCodeChange = useCallback(
(newStyleCode?: string) => {
try {
const parsedStyle = JSON.parse(newStyleCode || "");
setLayerStyle((prev) => {
if (!prev?.id) return prev;
return {
...prev,
value: parsedStyle
};
});
} catch (_error) {
// Do nothing
}

setStyleCode(newStyleCode);
},
[setLayerStyle]
);

return layerStyle?.id ? (
<CodeWrapper>
<CodeInput
value={styleCode}
onChange={handleStyleCodeChange}
language="json"
showLines={false}
/>
</CodeWrapper>
) : (
<NoStyleMessage />
);
};

export default StyleCode;

const CodeWrapper = styled("div")(({ theme }) => ({
padding: theme.spacing.small,
height: "100%"
}));
Loading
Loading