Skip to content

Commit

Permalink
Merge branch 'main' into update/cesium
Browse files Browse the repository at this point in the history
  • Loading branch information
keiya01 authored Apr 9, 2024
2 parents 00b08f3 + 232a446 commit f36f321
Show file tree
Hide file tree
Showing 41 changed files with 1,116 additions and 257 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/_upload_cesium_token_txt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Upload Cesium Ion token
on:
workflow_call:
inputs:
gcs_dst:
type: string
required: true
secrets:
credentials_json:
required: true
jobs:
upload:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.credentials_json }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Upload Ion token
id: ion_token
run: |
cesium_ion_token_txt_path="/tmp/cesium_ion_token.txt"
curl https://raw.githubusercontent.com/CesiumGS/cesium/main/packages/engine/Source/Core/Ion.js > /tmp/Ion.js
cat /tmp/Ion.js | node -e "console.log(require('fs').readFileSync(process.stdin.fd).toString().match(/const defaultAccessToken =(\n| ).*\"(.*)\";/)[2])" | tr -d '\n' >> ${cesium_ion_token_txt_path}
token_length=$(cat ${cesium_ion_token_txt_path} | wc -c)
if [ $token_length -ne 177 ]; then
echo "Token length is invalid. TokenLength: ${token_length}"
exit 1
fi
gsutil cp ${cesium_ion_token_txt_path} ${{ inputs.gcs_dst }}/cesium_ion_token.txt
14 changes: 14 additions & 0 deletions .github/workflows/update_esium_ion_token_nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Update Cesium Ion token Nightly

# Every 2nd day of the month at 02:00 JST.
on:
workflow_dispatch:
schedule:
- cron: '0 17 1 * *'
jobs:
upload:
uses: ./.github/workflows/_upload_cesium_token_txt.yml
with:
gcs_dst: gs://test.reearth.dev
secrets:
credentials_json: ${{ secrets.GCP_SA_KEY }}
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/paulmach/go.geojson v1.4.0
github.com/pkg/errors v0.9.1
github.com/ravilushqa/otelgqlgen v0.15.0
github.com/reearth/reearthx v0.0.0-20240308140749-72a08570c19b
github.com/reearth/reearthx v0.0.0-20240403021819-5cbc45bf18eb
github.com/samber/lo v1.39.0
github.com/spf13/afero v1.11.0
github.com/square/mongo-lock v0.0.0-20201208161834-4db518ed7fb2
Expand Down
4 changes: 2 additions & 2 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/ravilushqa/otelgqlgen v0.15.0 h1:U85nrlweMXTGaMChUViYM39/MXBZVeVVlpuHq+6eECQ=
github.com/ravilushqa/otelgqlgen v0.15.0/go.mod h1:o+1Eju0VySmgq2BP8Vupz2YrN21Bj7D7imBqu3m2uB8=
github.com/reearth/reearthx v0.0.0-20240308140749-72a08570c19b h1:wfTQ4SazfN9hYe13PqwnwB/E3Tw9+f99Y97iQRqOjso=
github.com/reearth/reearthx v0.0.0-20240308140749-72a08570c19b/go.mod h1:d1WXkdCVzSoc8pl3vW9/9yKfk4fdoZQZhX8Ot8jqgnc=
github.com/reearth/reearthx v0.0.0-20240403021819-5cbc45bf18eb h1:K0azcAIwDhuyZw60ib69g/wgNVy0FgLhl2XUWtr4Y5A=
github.com/reearth/reearthx v0.0.0-20240403021819-5cbc45bf18eb/go.mod h1:d1WXkdCVzSoc8pl3vW9/9yKfk4fdoZQZhX8Ot8jqgnc=
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down
4 changes: 2 additions & 2 deletions web/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@apollo/client";
import { ThemeProvider } from "@emotion/react";
import { withThemeFromJSXProvider } from "@storybook/addon-styling";
import type { Preview } from "@storybook/react";
import type { Preview, ReactRenderer } from "@storybook/react";
import React from "react";

import classicDarkTheme from "../src/classic/theme/reearthTheme/darkTheme"; // temp classic imports
Expand Down Expand Up @@ -46,7 +46,7 @@ const preview: Preview = {
},
},
decorators: [
withThemeFromJSXProvider({
withThemeFromJSXProvider<ReactRenderer>({
themes: {
light: {
classic: classicLightTheme,
Expand Down
35 changes: 35 additions & 0 deletions web/src/beta/components/FloatedPanel/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { css } from "@emotion/react";
import { Meta, Story } from "@storybook/react";

import FloatedPanel, { Props } from ".";

const meta: Meta<Props> = {
component: FloatedPanel,
};

export default meta;

const Template: Story<Props> = args => <FloatedPanel {...args} />;

export const Default = Template.bind({});
Default.args = {
visible: true,
children: "This is the content of the floated panel",
};

export const Hidden = Template.bind({});
Hidden.args = {
visible: false,
children: "This is the content of the floated panel",
};

export const CustomStyles = Template.bind({});
CustomStyles.args = {
visible: true,
children: "This is the content of the floated panel",
styles: css`
background-color: lightblue;
color: white;
padding: 10px;
`,
};
33 changes: 29 additions & 4 deletions web/src/beta/components/InsertionBar/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
import { Meta, StoryObj } from "@storybook/react";

import InsertionBar from ".";
import InsertionBar, { Props } from ".";

export default {
const meta: Meta<Props> = {
component: InsertionBar,
} as Meta;
};

export default meta;

type Story = StoryObj<typeof InsertionBar>;

export const Default: Story = {};
export const Default: Story = {
args: {
pos: "bottom",
mode: "visible",
onButtonClick: () => console.log("Button clicked"),
children: "Insertion bar content",
},
};

export const Hidden: Story = {
args: {
pos: "top",
mode: "hidden",
children: "Insertion bar content",
},
};

export const Dragging: Story = {
args: {
pos: "bottom",
mode: "dragging",
children: "Insertion bar content",
},
};
13 changes: 10 additions & 3 deletions web/src/beta/components/SidePanelSectionField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const SidePanelSectionField: React.FC<{
gap?: number;
children?: ReactNode;
storageKey?: string;
}> = ({ className, title, startCollapsed, gap, children, storageKey }) => {
border?: string;
}> = ({ className, title, startCollapsed, gap, children, storageKey, border }) => {
const theme = useTheme();
const [opened, setOpened] = useState<boolean>(() => {
const storedValue = localStorage.getItem(storageKey || "");
Expand All @@ -33,7 +34,12 @@ const SidePanelSectionField: React.FC<{
<ArrowIcon icon="arrowToggle" size={12} color={theme.content.main} opened={opened} />
</Header>
)}
{opened && children && <Content gap={gap}>{children}</Content>}

{opened && children && (
<Content gap={gap} border={border}>
{children}
</Content>
)}
</Field>
);
};
Expand All @@ -57,11 +63,12 @@ const ArrowIcon = styled(Icon)<{ opened?: boolean }>`
transition: all 0.2s;
`;

const Content = styled.div<{ gap?: number }>`
const Content = styled.div<{ gap?: number; border?: string }>`
padding: 8px;
display: flex;
flex-direction: column;
gap: ${({ gap }) => (gap ?? 16) + "px"} 16px;
border-top: ${({ border, theme }) => (border ? `1px solid ${theme.outline.weak}` : "none")};
`;

export default SidePanelSectionField;
14 changes: 12 additions & 2 deletions web/src/beta/components/Slide/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@ const Page = styled.div`
background-color: ${({ color }) => color};
`;

interface DefaultProps {
pos: number;
setPos: React.Dispatch<React.SetStateAction<number>>;
}

export default {
component: Slide,
decorators: [
Story => {
const [pos, setPos] = useState(0);
return <Story pos={pos} setPos={setPos} />;
},
],
} as Meta;

export const Default = () => {
const [pos, setPos] = useState(0);
export const Default = ({ pos, setPos }: DefaultProps) => {
return (
<Wrapper>
<Slide pos={pos}>
Expand Down
15 changes: 12 additions & 3 deletions web/src/beta/components/TabMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@ export type TabObject = {
export type Props = {
tabs: TabObject[];
selectedTab: string;
scrollable?: boolean;
onSelectedTabChange: (tab: string) => void;
menuAlignment?: menuAlignment;
};

const TabMenu: FC<Props> = ({ tabs, selectedTab, onSelectedTabChange, menuAlignment }) => {
const TabMenu: FC<Props> = ({
tabs,
selectedTab,
scrollable,
onSelectedTabChange,
menuAlignment,
}) => {
const selectedTabItem = useMemo(() => {
return tabs.find(({ id }) => id === selectedTab);
}, [selectedTab, tabs]);
Expand All @@ -40,7 +47,7 @@ const TabMenu: FC<Props> = ({ tabs, selectedTab, onSelectedTabChange, menuAlignm
</TabIconWrapper>
))}
</Tabs>
<MainArea>
<MainArea scrollable={scrollable}>
{selectedTabItem?.name && !menuAlignment && (
<Header>
<Text size="body">{selectedTabItem.name}</Text>
Expand Down Expand Up @@ -91,8 +98,10 @@ const Header = styled.div`
border-bottom: 1px solid ${({ theme }) => theme.outline.weak};
`;

const MainArea = styled.div`
const MainArea = styled.div<{ scrollable?: boolean }>`
display: block;
height: auto;
overflow-y: ${({ scrollable }) => (scrollable ? "auto" : "unset")};
`;

const Content = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion web/src/beta/components/fields/SelectField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const InputWrapper = styled.div<{ disabled: boolean }>`
`;

const Select = styled.div<{ open: boolean; selected: boolean }>`
padding: 9px 8px;
padding: 8px;
/* The width + placement of the arrow icon */
padding-right: 22px;
border-radius: 4px;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React, { useCallback, useState } from "react";

import TextInput from "@reearth/beta/components/fields/common/TextInput";
import { styled } from "@reearth/services/theme";

import { PropertyProps, dataTypes } from "..";
import {
DeleteButton,
HandleIcon,
PropertyField,
PropertyFieldContanier,
SelectWrapper,
StyledText,
} from "../../utils";

type Props = {
property: PropertyProps;
onKeyChange: (newValue?: string) => void;
onValueChange: (newValue?: string) => void;
onRemovePropertyItem: () => void;
};

const PropertyItem: React.FC<Props> = ({
property,
onKeyChange,
onValueChange,
onRemovePropertyItem,
}) => {
const [propertyName, setPropertyName] = useState<string>(property.key);
const [dataType, setDataType] = useState<string>(property.value);
const [isEditName, setIsEditName] = useState(false);
const [isEditType, setIsEditType] = useState(false);

const handleKeyChange = useCallback(
(newValue: string) => {
setPropertyName(newValue);
onKeyChange(newValue);
if (isEditName) setIsEditName(value => !value);
},
[isEditName, onKeyChange],
);

const handleValueChange = useCallback(
(newValue: string) => {
setDataType(newValue);
onValueChange(newValue);
if (isEditType) setIsEditType(value => !value);
},
[isEditType, onValueChange],
);

const handleDoubleClick = useCallback((field: string) => {
if (field === "name") {
setIsEditName(true);
} else if (field === "type") {
setIsEditType(true);
}
}, []);

const handleOnBlur = useCallback(() => {
setIsEditName(false);
}, []);

return (
<PropertyFieldContanier>
<PropertyField>
<HandleIcon icon="dndHandle" size={24} />
{propertyName.trim() === "" || isEditName ? (
<StyledTextInput value={propertyName} onChange={handleKeyChange} onBlur={handleOnBlur} />
) : (
<StyledText onDoubleClick={() => handleDoubleClick("name")} size="footnote">
{propertyName}
</StyledText>
)}
</PropertyField>
<PropertyField
style={{
justifyContent: "space-between",
}}>
{dataType.trim() === "" || isEditType ? (
<StyledSelect
value={dataType}
options={dataTypes.map(v => ({ key: v, label: v }))}
attachToRoot
onChange={handleValueChange}
/>
) : (
<StyledText onDoubleClick={() => handleDoubleClick("type")} size="footnote">
{dataType}
</StyledText>
)}

<DeleteButton icon="trash" size={16} onClick={onRemovePropertyItem} />
</PropertyField>
</PropertyFieldContanier>
);
};

export default PropertyItem;

const StyledSelect = styled(SelectWrapper)`
margin-top: 0;
padding: 8px 0;
`;

const StyledTextInput = styled(TextInput)`
width: 100%;
&:focus {
border: 1px solid ${({ theme }) => theme.select.strong};
}
`;
Loading

0 comments on commit f36f321

Please sign in to comment.