diff --git a/web/src/beta/components/SubTabButtonList/index.stories.tsx b/web/src/beta/components/SubTabButtonList/index.stories.tsx new file mode 100644 index 0000000000..2a0aef0aad --- /dev/null +++ b/web/src/beta/components/SubTabButtonList/index.stories.tsx @@ -0,0 +1,21 @@ +import { Meta, StoryObj } from "@storybook/react"; + +import SubTabButtonList from "."; + +const meta: Meta = { + component: SubTabButtonList, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + args: { + items: [ + { id: "1", name: "GIS", active: true }, + { id: "2", name: "Story", active: false }, + { id: "3", name: "Web AR", active: false }, + ], + }, +}; diff --git a/web/src/beta/components/SubTabButtonList/index.tsx b/web/src/beta/components/SubTabButtonList/index.tsx new file mode 100644 index 0000000000..5bc6646f0a --- /dev/null +++ b/web/src/beta/components/SubTabButtonList/index.tsx @@ -0,0 +1,41 @@ +import Text from "@reearth/beta/components/Text"; +import { SwitchField } from "@reearth/beta/hooks/useManageSwitchState/hooks"; +import { styled, useTheme } from "@reearth/services/theme"; + +type CustomField = { + name: string; +}; +type SwitchCustomField = SwitchField; + +export type Props = { + items: SwitchCustomField[]; + onChange?: (id: string) => void; +}; +const SubTabButtonList: React.FC = ({ items, onChange }) => { + const theme = useTheme(); + return ( + <> + {items.map((item, index) => ( + onChange?.(item.id)}> + + {item.name} + + + ))} + + ); +}; + +const SubTabButton = styled.button<{ disabled: boolean }>` + background: ${({ disabled, theme }) => (disabled ? theme.general.select : "inherit")}; + padding: 8px; + height: 32px; + border-radius: 4px 4px 0px 0px; + transition: all 0.5s; + :hover { + background: ${({ theme }) => theme.general.select}; + } + text-align: center; +`; + +export default SubTabButtonList; diff --git a/web/src/beta/hooks/useManageSwitchState/hooks.tsx b/web/src/beta/hooks/useManageSwitchState/hooks.tsx index 70157371fc..2bca5b3a25 100644 --- a/web/src/beta/hooks/useManageSwitchState/hooks.tsx +++ b/web/src/beta/hooks/useManageSwitchState/hooks.tsx @@ -1,6 +1,6 @@ import { useState, useCallback } from "react"; -type SwitchField = { +export type SwitchField = { id: string; active?: boolean; } & T;