Skip to content

Commit

Permalink
Merge pull request #500 from pixiv/chore/storybook-Switch
Browse files Browse the repository at this point in the history
chore: switch story
  • Loading branch information
toshusai authored Apr 5, 2024
2 parents dc3642b + 271a6f7 commit 69ebed2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storybook Tests Switch Basic 1`] = `
exports[`Storybook Tests Switch Checked 1`] = `
.c0 {
display: inline-grid;
grid-template-columns: auto 1fr;
Expand Down Expand Up @@ -118,8 +118,8 @@ exports[`Storybook Tests Switch Basic 1`] = `
className="c0"
>
<input
aria-label="label"
checked={false}
aria-label="checked"
checked={true}
className="c1"
disabled={false}
name="name"
Expand All @@ -144,7 +144,7 @@ exports[`Storybook Tests Switch Basic 1`] = `
</div>
`;

exports[`Storybook Tests Switch Checked 1`] = `
exports[`Storybook Tests Switch Default 1`] = `
.c0 {
display: inline-grid;
grid-template-columns: auto 1fr;
Expand Down Expand Up @@ -262,8 +262,7 @@ exports[`Storybook Tests Switch Checked 1`] = `
className="c0"
>
<input
aria-label="label"
checked={true}
checked={false}
className="c1"
disabled={false}
name="name"
Expand Down Expand Up @@ -417,7 +416,7 @@ exports[`Storybook Tests Switch Disabled 1`] = `
checked={false}
className="c1"
disabled={true}
name="name"
name="disabled"
onChange={[Function]}
onClick={[Function]}
onDragStart={[Function]}
Expand All @@ -444,7 +443,7 @@ exports[`Storybook Tests Switch Disabled 1`] = `
</div>
`;

exports[`Storybook Tests Switch Labelled 1`] = `
exports[`Storybook Tests Switch Label 1`] = `
.c0 {
display: inline-grid;
grid-template-columns: auto 1fr;
Expand Down Expand Up @@ -572,7 +571,7 @@ exports[`Storybook Tests Switch Labelled 1`] = `
checked={false}
className="c1"
disabled={false}
name="name"
name="label"
onChange={[Function]}
onClick={[Function]}
onDragStart={[Function]}
Expand Down
28 changes: 10 additions & 18 deletions packages/react/src/components/Switch/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ import { Meta, StoryObj } from '@storybook/react'
export default {
title: 'Switch',
component: Switch,
args: {
name: 'name',
label: 'label',
},
parameters: {
layout: 'centered',
},
} as Meta<typeof Switch>

export const Basic: StoryObj<typeof Switch> = {
export const Default: StoryObj<typeof Switch> = {
render: function Render(args) {
const [checked, setChecked] = useState(false)
return (
Expand All @@ -33,33 +29,29 @@ export const Basic: StoryObj<typeof Switch> = {
}

export const Checked: StoryObj<typeof Switch> = {
render: function Render(args) {
render: function Render() {
const [checked, setChecked] = useState(true)
return (
<div>
<Switch
{...args}
name="name"
label="checked"
onChange={(v) => {
setChecked(v)
}}
checked={args.checked ?? checked}
checked={checked}
/>
</div>
)
},
}

export const Labelled: StoryObj<typeof Switch> = {
render: function Render(args) {
export const Label: StoryObj<typeof Switch> = {
render: function Render() {
const [checked, setChecked] = useState(false)
return (
<div>
<Switch
{...args}
checked={args.checked ?? checked}
onChange={setChecked}
>
<Switch name="label" checked={checked} onChange={setChecked}>
Label
</Switch>
</div>
Expand All @@ -68,13 +60,13 @@ export const Labelled: StoryObj<typeof Switch> = {
}

export const Disabled: StoryObj<typeof Switch> = {
render: function Render(args) {
render: function Render() {
const [checked, setChecked] = useState(false)
return (
<div>
<Switch
{...args}
checked={args.checked ?? checked}
name="disabled"
checked={checked}
onChange={setChecked}
disabled
>
Expand Down

0 comments on commit 69ebed2

Please sign in to comment.