diff --git a/frontend/src/components/v2/Switch/Switch.stories.tsx b/frontend/src/components/v2/Switch/Switch.stories.tsx new file mode 100644 index 0000000000..2f57c64fc6 --- /dev/null +++ b/frontend/src/components/v2/Switch/Switch.stories.tsx @@ -0,0 +1,34 @@ +import type { Meta, StoryObj } from '@storybook/react'; + +import { Switch } from './Switch'; + +const meta: Meta = { + title: 'Components/Switch', + component: Switch, + tags: ['v2'], + argTypes: {} +}; + +export default meta; +type Story = StoryObj; + +// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args +export const Simple: Story = { + args: { + children: 'Dark mode' + } +}; + +export const Disabled: Story = { + args: { + children: 'Dark mode', + isDisabled: true + } +}; + +export const Required: Story = { + args: { + children: 'Dark mode', + isRequired: true + } +}; diff --git a/frontend/src/components/v2/Switch/Switch.tsx b/frontend/src/components/v2/Switch/Switch.tsx new file mode 100644 index 0000000000..f720b6ea64 --- /dev/null +++ b/frontend/src/components/v2/Switch/Switch.tsx @@ -0,0 +1,42 @@ +import { ReactNode } from 'react'; +import * as SwitchPrimitive from '@radix-ui/react-switch'; +import { twMerge } from 'tailwind-merge'; + +export type SwitchProps = Omit & { + children: ReactNode; + id: string; + isChecked?: boolean; + isRequired?: boolean; + isDisabled?: boolean; +}; + +export const Switch = ({ + children, + id, + className, + isChecked, + isDisabled, + isRequired, + ...props +}: SwitchProps): JSX.Element => ( +
+ + + + +
+); diff --git a/frontend/src/components/v2/Switch/index.tsx b/frontend/src/components/v2/Switch/index.tsx new file mode 100644 index 0000000000..c912077ddc --- /dev/null +++ b/frontend/src/components/v2/Switch/index.tsx @@ -0,0 +1,2 @@ +export type { SwitchProps } from './Switch'; +export { Switch } from './Switch'; diff --git a/frontend/src/components/v2/index.tsx b/frontend/src/components/v2/index.tsx index cd8dbf47d9..3b886d3fd9 100644 --- a/frontend/src/components/v2/index.tsx +++ b/frontend/src/components/v2/index.tsx @@ -7,4 +7,5 @@ export * from './Input'; export * from './Menu'; export * from './Modal'; export * from './Select'; +export * from './Switch'; export * from './TextArea';