-
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.
- Loading branch information
1 parent
9f96337
commit 8095646
Showing
4 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import Switch from './Switch'; | ||
|
||
const meta: Meta<typeof Switch> = { | ||
component: Switch, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Switch>; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
checked: false, | ||
}, | ||
render: (args) => <Switch checked={args.checked} />, | ||
}; |
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,42 @@ | ||
import React from 'react'; | ||
import { | ||
Switch as MuiSwitch, | ||
SwitchProps as MuiSwitchProps, | ||
styled, | ||
} from '@mui/material'; | ||
|
||
const SwitchComponent = styled(MuiSwitch)` | ||
&.MuiSwitch-root { | ||
width: 40px; | ||
padding: 11px 2px; | ||
} | ||
& .MuiSwitch-switchBase { | ||
top: 8px; | ||
padding: 6.5px; | ||
&.Mui-checked { | ||
transform: translateX(16px); | ||
& + .MuiSwitch-track { | ||
opacity: 1; | ||
} | ||
& .MuiSwitch-thumb { | ||
background-color: #fff; | ||
} | ||
} | ||
} | ||
& .MuiSwitch-track { | ||
width: 38px; | ||
height: 20px; | ||
border-radius: 10px; | ||
} | ||
& .MuiSwitch-thumb { | ||
width: 12px; | ||
height: 12px; | ||
border-radius: 6; | ||
} | ||
`; | ||
|
||
const Switch: React.FC<MuiSwitchProps> = (props) => { | ||
return <SwitchComponent {...props} />; | ||
}; | ||
|
||
export default 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './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