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

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
HideBa committed Dec 17, 2021
1 parent 1316c9a commit f37b314
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 7 deletions.
9 changes: 8 additions & 1 deletion src/components/atoms/AutoComplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Item<Value extends string | number = string> = {

export type Props<Value extends string | number> = {
className?: string;
placeholder?: string;
items?: Item<Value>[];
fullWidth?: boolean;
creatable?: boolean;
Expand All @@ -23,6 +24,7 @@ export type Props<Value extends string | number> = {

function AutoComplete<Value extends string | number>({
className,
placeholder,
items,
fullWidth = false,
creatable,
Expand Down Expand Up @@ -70,7 +72,12 @@ function AutoComplete<Value extends string | number>({
className={className}
fullWidth={fullWidth}
selectComponent={
<StyledTextBox value={filterText} onChange={handleInputChange} onKeyDown={handleKeyDown} />
<StyledTextBox
value={filterText}
onChange={handleInputChange}
onKeyDown={handleKeyDown}
placeholder={placeholder}
/>
}
onChange={handleSelect}
ref={ref}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useCallback } from "react";
import { useIntl } from "react-intl";

import AutoComplete from "@reearth/components/atoms/AutoComplete";
import Box from "@reearth/components/atoms/Box";
Expand Down Expand Up @@ -37,6 +38,7 @@ const SceneTagPane: React.FC<Props> = ({
onTagGroupDetach,
onTagItemDetach,
}) => {
const intl = useIntl();
const handleTagGroupSelect = useCallback(
(tagGroupLabel: string) => {
const targetTagGroup = allTagGroups?.find(tg => tg.label === tagGroupLabel);
Expand Down Expand Up @@ -64,6 +66,7 @@ const SceneTagPane: React.FC<Props> = ({
</Box>
))}
<AutoComplete
placeholder={intl.formatMessage({ defaultMessage: "Add a tag group" })}
onCreate={onTagGroupAdd}
creatable
items={allTagGroups
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import { useIntl } from "react-intl";

import AutoComplete from "@reearth/components/atoms/AutoComplete";
import Box from "@reearth/components/atoms/Box";
Expand Down Expand Up @@ -33,6 +34,7 @@ const SceneTagPane: React.FC<Props> = ({
onTagItemRemove,
onTagGroupUpdate,
}) => {
const intl = useIntl();
return (
<Wrapper className={className} direction="column">
{allTagGroups?.map(tg => (
Expand All @@ -52,7 +54,11 @@ const SceneTagPane: React.FC<Props> = ({
/>
</Box>
))}
<AutoComplete onCreate={onTagGroupAdd} creatable />
<AutoComplete
onCreate={onTagGroupAdd}
creatable
placeholder={intl.formatMessage({ defaultMessage: "Add a tag group" })}
/>
</Wrapper>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useCallback, useRef, useState, useMemo } from "react";
import { useIntl } from "react-intl";
import { useClickAway } from "react-use";

import AutoComplete from "@reearth/components/atoms/AutoComplete";
Expand Down Expand Up @@ -46,6 +47,7 @@ const TagGroup: React.FC<Props> = ({
onTitleEdit,
}) => {
const theme = useTheme();
const intl = useIntl();
const [editing, setEditing] = useState(false);
const titleRef = useRef(null);
useClickAway(titleRef, () => setEditing(false));
Expand Down Expand Up @@ -123,6 +125,7 @@ const TagGroup: React.FC<Props> = ({
onSelect={handleSelectTag}
creatable
onCreate={onTagAdd}
placeholder={intl.formatMessage({ defaultMessage: "Add a tag" })}
/>
</Wrapper>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/EarthEditor/RightMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import TagPane from "../TagPane";

import useHooks, { Tab } from "./hooks";

const layerMode = ["property", "infobox", "export"];
const layerMode = ["property", "infobox", "tag", "export"];
const widgetMode = ["property"];
const sceneMode = ["property"];
const sceneMode = ["property", "tag"];
export type LayerMode = typeof layerMode[number];
export type WidgetMode = typeof widgetMode[number];
export type SceneMode = typeof sceneMode[number];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default () => {

const layerTagGroups = useMemo(() => {
// TagItems which don't belong to any TagGroup will be in "Default" tag group
const defaultTagGroup: TagGroup = { id: "default", label: DEFAULT_TAG_ID, tags: [] };
const defaultTagGroup: TagGroup = { id: DEFAULT_TAG_ID, label: "Default", tags: [] };
const formattedGroups: TagGroup[] = selectedLayerTags
? selectedLayerTags
?.map(t => {
Expand Down
12 changes: 10 additions & 2 deletions translations/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ src:
'1835798571': Layers
'2793623359': Widgets
'3645414921': Delete
'4117491116': Clusters
PropertyPane:
'3453457092': Create Infobox
'3833270271': Dataset
Expand Down Expand Up @@ -260,6 +261,13 @@ src:
project.
'3869801582': Embed Code
'4062044511': Update your project
TagPane:
LayerTagPane:
'1950319966': Add a tag group
SceneTagPane:
'1950319966': Add a tag group
TagGroup:
'1562483899': Add a tag
Settings:
Account:
AccountSection:
Expand Down Expand Up @@ -490,8 +498,8 @@ src:
'2793623359': Widgets
'3590336714': Export
TagPane:
'1982056879': A tag with the same label already exist. Please input a different label and try again.
'4149491408': 'This tag group still has tags. You must remove all tags in the tag group before you can delete it.'
'1982056879': Same label tag already exist. Please type different label.
'4149491408': 'Tag group has tags, you need to remove all tags under the tag group'
Notification:
'687096634': Warning
'1354606874': Notice
Expand Down
8 changes: 8 additions & 0 deletions translations/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ src:
'1835798571': レイヤー
'2793623359': ウィジェット
'3645414921': 削除
'4117491116': クラスター
PropertyPane:
'3453457092': インフォボックス作成
'3833270271': データセット
Expand Down Expand Up @@ -234,6 +235,13 @@ src:
'3733220817': URLを知っている人もこのプロジェクトを見ることができなくなります。
'3869801582': 埋め込み用コード
'4062044511': プロジェクトを更新する
TagPane:
LayerTagPane:
'1950319966': タググループを追加
SceneTagPane:
'1950319966': タググループを追加
TagGroup:
'1562483899': タグを追加
Settings:
Account:
AccountSection:
Expand Down

0 comments on commit f37b314

Please sign in to comment.