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

feat: support dataset schema preview and create layer group from selected primitive type #74

Merged
merged 45 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d8477c5
select dataset and global state
HideBa Aug 6, 2021
c676a8f
Merge branch 'main' into refine-dataset-import
HideBa Sep 7, 2021
ef07a68
Merge branch 'main' into refine-dataset-import
HideBa Sep 7, 2021
b2aeb59
fix merge mistake
HideBa Sep 7, 2021
4e70a83
fix storybook
HideBa Sep 8, 2021
774ec39
Merge branch 'fix-storybook' into refine-dataset-import
HideBa Sep 8, 2021
92705a5
refactor tab card
HideBa Sep 8, 2021
379f700
add dataset tab on right pane
HideBa Sep 8, 2021
917260d
wip: dev table component
HideBa Sep 8, 2021
17c12a1
impl outline of datasset pane
HideBa Sep 9, 2021
7511ac5
Merge branch 'main' of github.com:reearth/reearth-web into refine-dat…
HideBa Sep 9, 2021
5a5d650
impl dataset fetch
HideBa Sep 10, 2021
aed7c00
Merge branch 'main' into refine-dataset-import
HideBa Sep 14, 2021
87c5eef
wip: impl dataset list
HideBa Sep 17, 2021
0a93db2
Merge branch 'main' into refine-dataset-import
HideBa Oct 20, 2021
ac96ea6
Merge remote-tracking branch 'origin/main' into refine-dataset-import
HideBa Oct 27, 2021
fa2f32e
convert raw dataset to structed one
HideBa Oct 28, 2021
bda1e43
Merge branch 'main' into refine-dataset-import
HideBa Nov 2, 2021
a5e1164
Co-authored-by: rot1024 <aayhrot@gmail.com>
HideBa Nov 2, 2021
7f69b74
add text color on table
HideBa Nov 4, 2021
76e2bd4
wip: show primitive types
HideBa Nov 4, 2021
de72123
show layer type
HideBa Nov 4, 2021
1b38f2d
wip: create layer group from selected extensionId
HideBa Nov 8, 2021
1346010
create layer group from selected primitive type
HideBa Nov 9, 2021
c839c4a
add icon
HideBa Nov 9, 2021
7aa7d2c
delete old code
HideBa Nov 9, 2021
fd79204
Merge branch 'main' of github.com:reearth/reearth-web into refine-dat…
HideBa Nov 9, 2021
b0e97f4
gen i18n
HideBa Nov 9, 2021
43b66a4
fix tab statement
HideBa Nov 9, 2021
4f01d4e
fix dnd
HideBa Nov 10, 2021
62d727e
fix unexpected changes
HideBa Nov 10, 2021
85a89ac
fix type error
rot1024 Nov 10, 2021
9006a19
fix type error
rot1024 Nov 10, 2021
b71b4ef
delete console
HideBa Nov 10, 2021
1be664a
fig gql gen
HideBa Nov 10, 2021
088e0de
fix lint error
HideBa Nov 11, 2021
4ce3c42
fix value for lat lng
HideBa Nov 11, 2021
12351ed
Merge branch 'main' into refine-dataset-import
HideBa Nov 11, 2021
e7a1241
fix import
HideBa Nov 11, 2021
d3c28e3
Merge branch 'refine-dataset-import' of github.com:reearth/reearth-we…
HideBa Nov 11, 2021
6f4857f
add message
HideBa Nov 11, 2021
fcb9077
add message
HideBa Nov 11, 2021
3db437b
Merge branches 'refine-dataset-import' and 'main' of github.com:reear…
HideBa Nov 12, 2021
6eea4e7
exclude primitives
HideBa Nov 12, 2021
55c0462
fix type error
HideBa Nov 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/atoms/Icon/Icons/update.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/components/atoms/Icon/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import File from "./Icons/fileIcon.svg";
import PcIcon from "./Icons/pcIcon.svg";
import GoogleDriveIcon from "./Icons/googleDriveIcon.svg";
import SheetFileIcon from "./Icons/sheet-file.svg";
import Update from "./Icons/update.svg";

// Asset
import AssetGrid from "./Icons/assetGrid.svg";
Expand Down Expand Up @@ -148,6 +149,7 @@ export default {
dataset: Dataset,
datasetAdd: DatasetAdd,
file: File,
update: Update,
googleDrive: GoogleDriveIcon,
sheetFile: SheetFileIcon,
computer: PcIcon,
Expand Down
20 changes: 20 additions & 0 deletions src/components/atoms/TabCard/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";

import { Meta, Story } from "@storybook/react";
import TabCard, { Props } from ".";

export default {
title: "atoms/TabCard",
component: TabCard,
} as Meta;

const SampleBody = () => <div>Hello</div>;

export const Default: Story<Props> = args => (
<TabCard {...args}>
<SampleBody />
</TabCard>
);
Default.args = {
name: "Property",
};
40 changes: 40 additions & 0 deletions src/components/atoms/TabCard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from "react";

import { styled, useTheme } from "@reearth/theme";
import Text from "@reearth/components/atoms/Text";
import Flex from "../Flex";
import Box from "../Box";

export type Props = {
className?: string;
name?: string;
children?: React.ReactNode;
};

const TabCard: React.FC<Props> = ({ className, name, children }) => {
const theme = useTheme();
return (
<Box mb="l" className={className}>
<Flex direction="column" align="flex-start">
<Box bg={theme.properties.bg} pt="s" pb="s" pr="l" pl="l">
<Text
size="xs"
color={theme.main.strongText}
weight="normal"
otherProperties={{ flex: "auto" }}>
{name}
</Text>
</Box>
<Body>{children}</Body>
</Flex>
</Box>
);
};

const Body = styled.div`
width: calc(100% - 32px);
background-color: ${props => props.theme.properties.bg};
padding: 16px;
`;

export default TabCard;
57 changes: 57 additions & 0 deletions src/components/atoms/Table/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from "react";

import { Meta, Story } from "@storybook/react";
import Table, { Props } from ".";

export default {
title: "atoms/Table",
component: Table,
} as Meta;

const headers = ["title", "lat", "lng", "size", "color", "text"];
type Rows = typeof headers[number];
type Item = { [k in Rows]: string | number };
const data: Item[] = [
{
title: "Japan",
lat: 35.03,
lng: 135.71,
size: 10,
color: "#3d86fa",
text: "short text",
},
{
title: "America",
lat: 50.1,
lng: 170.71,
size: 40,
color: "#ffffff",
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
},
];

export const Default: Story<Props<Item>> = args => <Table {...args} />;

export const Scroll: Story<Props<Item>> = args => <Table {...args} />;
export const Auto: Story<Props<Item>> = args => <Table {...args} />;

Default.args = {
headers,
items: data,
scroll: false,
};

Scroll.args = {
headers,
items: data,
layout: "fixed",
columnWidth: "100px",
width: "400px",
};

Auto.args = {
headers,
items: data,
layout: "auto",
scroll: false,
};
115 changes: 115 additions & 0 deletions src/components/atoms/Table/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import React from "react";

import theme, { fonts, styled } from "@reearth/theme";
import { TypographySize } from "@reearth/theme/fonts";

export type Props<T> = {
className?: string;
headers?: (keyof T)[];
items?: T[];
bg?: string;
borderColor?: string;
textColor?: string;
textSize?: TypographySize;
layout?: "auto" | "fixed";
textAlign?: "left" | "center" | "right";
width?: string;
columnWidth?: string;
columnHeight?: string;
scroll?: boolean;
multiLine?: boolean;
};

export default function Table<T>({
className,
width,
headers,
items,
bg,
borderColor,
textColor,
textSize = "s",
layout = "auto",
textAlign = "left",
columnWidth,
columnHeight,
scroll = true,
multiLine = false,
}: Props<T>): JSX.Element | null {
return (
<StyledTable
bg={bg}
borderColor={borderColor}
textColor={textColor}
textSize={fonts.sizes[textSize]}
layout={layout}
className={className}
textAlign={textAlign}
multiLine={multiLine}
width={width}
columnWidth={columnWidth}
columnHeight={columnHeight}
scroll={scroll}>
<thead>
<tr>
{headers?.map((h, i) => (
<StyledTh key={i} width={columnWidth}>
{h}
</StyledTh>
))}
</tr>
</thead>
<tbody>
{items?.map((item, i) => {
return (
<tr key={i}>
{headers?.map((h, i) => {
return <StyledTd key={i}>{item[h]}</StyledTd>;
})}
</tr>
);
})}
</tbody>
</StyledTable>
);
}

const StyledTable = styled.table<{
bg?: string;
borderColor?: string;
textColor?: string;
textSize?: number;
layout?: "auto" | "fixed";
textAlign?: "left" | "center" | "right";
multiLine?: boolean;
columnWidth?: string;
columnHeight?: string;
scroll?: boolean;
width?: string;
}>`
table-layout: ${({ layout }) => layout};
text-align: ${({ textAlign }) => textAlign};
white-space: ${({ multiLine }) => (multiLine ? "normal" : "nowrap")};
background: ${({ bg, theme }) => (bg ? bg : theme.main.bg)};
border-color: ${({ borderColor, theme }) => (borderColor ? borderColor : theme.main.lighterBg)};
color: ${({ textColor }) => (textColor ? textColor : theme.main.text)};
font-size: ${({ textSize }) => `${textSize}px`};
width: ${({ width }) => (width ? width : "100%")};
height: ${({ columnHeight }) => columnHeight};
overflow: ${({ scroll }) => (scroll ? "scroll" : "hidden")};
display: block;
`;

const StyledTh = styled.th<{ width?: string }>`
padding: ${({ theme }) => theme.metrics.s}px;
font-weight: ${fonts.weight.normal};
width: ${({ width }) => width};
overflow: hidden;
text-overflow: ellipsis;
`;

const StyledTd = styled.td`
padding: ${({ theme }) => theme.metrics.s}px;
overflow: hidden;
text-overflow: ellipsis;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, { useCallback, useState } from "react";
import { useIntl } from "react-intl";

import Button from "@reearth/components/atoms/Button";
import Flex from "@reearth/components/atoms/Flex";
import SelectField from "@reearth/components/atoms/SelectBox";
import Text from "@reearth/components/atoms/Text";
import { styled } from "@reearth/theme";

export type PrimitiveItem = { name: string; extensionId: string; icon: string; pluginId: string };

export type Props = {
primitiveItems?: PrimitiveItem[];
onCreateLayerGroup?: (pluginId: string, extensionId: string) => void;
};

const DatasetPropertyItem: React.FC<Props> = ({ primitiveItems, onCreateLayerGroup }) => {
const intl = useIntl();
const [selectedPrimitiveType, selectPrimitiveType] = useState("");

const handlePrimitiveTypeChange = (type: string) => {
if (primitiveItems?.map(p => p.extensionId).includes(type)) {
selectPrimitiveType(type);
}
};

const handleSubmit = useCallback(() => {
const item = primitiveItems?.find(p => p.extensionId === selectedPrimitiveType);
if (!item) return;
onCreateLayerGroup?.(item?.pluginId, item?.extensionId);
}, [onCreateLayerGroup, primitiveItems, selectedPrimitiveType]);

const convertPrimitiveItemToDatasetPropertyItem = (
items?: PrimitiveItem[],
): { key: string; label: string; icon: string }[] => {
return items?.map(i => ({ key: i.extensionId, label: i.name, icon: i.icon })) || [];
};
return (
<Flex direction="column">
<Flex>
<Flex flex={1}>
<Text size="xs">{intl.formatMessage({ defaultMessage: "Layer style" })}</Text>
</Flex>
<Flex flex={2}>
<SelectField
items={convertPrimitiveItemToDatasetPropertyItem(primitiveItems)}
selected={selectedPrimitiveType}
onChange={handlePrimitiveTypeChange}
/>
</Flex>
</Flex>
<StyledButton
type="button"
text={intl.formatMessage({ defaultMessage: "import" })}
buttonType="primary"
disabled={!selectedPrimitiveType}
onClick={handleSubmit}
/>
</Flex>
);
};

const StyledButton = styled(Button)`
width: 80px;
margin-left: auto;
`;

export default DatasetPropertyItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";

import { Meta, Story } from "@storybook/react";
import DatasetInfoPane, { Props } from ".";

export default {
title: "molecules/EarthEditor/DatasetInfoPane",
component: DatasetInfoPane,
} as Meta;

export const Default: Story<Props> = args => {
return <DatasetInfoPane {...args} />;
};

Default.args = {};