-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
react|docs: creates
Switch
component and story
- Loading branch information
1 parent
35ab166
commit 34d01c1
Showing
8 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Switch } from '@wolves-league-ui/react'; | ||
|
||
const meta: Meta<typeof Switch> = { | ||
component: Switch, | ||
title: 'Form/Switch', | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
id: { control: 'text' }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Switch>; | ||
|
||
export const Default: Story = { | ||
render: (args) => ( | ||
<div className="flex items-center gap-4"> | ||
<label htmlFor="switch-id" className="text-gray-100"> | ||
Label | ||
</label> | ||
<Switch {...args} /> | ||
</div> | ||
), | ||
args: { | ||
id: 'switch-id', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as SwitchPrimitive from '@radix-ui/react-switch'; | ||
|
||
export const Switch = ({ id }: { id?: string }) => ( | ||
<SwitchPrimitive.Root | ||
id={id} | ||
className="w-10 h-6 bg-gray-900 rounded-full relative shadow-md border border-gray-700 focus:shadow-sm data-[state=checked]:border-wl-700 outline-none cursor-default" | ||
> | ||
<SwitchPrimitive.Thumb className="block w-5 h-5 bg-gray-100 data-[state=checked]:bg-wl-700 rounded-full shadow-md transition-transform duration-100 translate-x-[0.063rem] will-change-transform data-[state=checked]:translate-x-[17px]" /> | ||
</SwitchPrimitive.Root> | ||
); | ||
Switch.displayName = 'Switch'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import '../index.css'; | ||
// Form | ||
export * from './components/Button'; | ||
export * from './components/Checkbox'; | ||
export * from './components/Switch'; | ||
// Overlay | ||
export * from './components/Tooltip'; | ||
export * from './components/Dialog'; | ||
export * from './components/Checkbox'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.