-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Separator): migrate from CSF2 to CSF3
- Loading branch information
Showing
1 changed file
with
66 additions
and
107 deletions.
There are no files selected for viewing
173 changes: 66 additions & 107 deletions
173
packages/orbit-components/src/Separator/Separator.stories.tsx
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,140 +1,99 @@ | ||
import * as React from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { SPACINGS_AFTER } from "../common/consts"; | ||
import RenderInRtl from "../utils/rtl/RenderInRtl"; | ||
import type { BorderColorClass, SideOffset } from "./types"; | ||
import defaultTheme from "../defaultTheme"; | ||
|
||
import Separator from "."; | ||
|
||
export default { | ||
title: "Separator", | ||
}; | ||
|
||
export const Default = () => <Separator />; | ||
|
||
const kebabCase = (str: string) => str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); | ||
|
||
Default.story = { | ||
parameters: { | ||
info: "This is the default configuration of this component. Visit Orbit.Kiwi for more detailed guidelines.", | ||
}, | ||
}; | ||
|
||
export const Playground = ({ spaceAfter, align, sideOffset, type, color }) => { | ||
return ( | ||
<Separator | ||
color={color} | ||
align={align} | ||
sideOffset={sideOffset} | ||
spaceAfter={spaceAfter} | ||
type={type} | ||
/> | ||
); | ||
}; | ||
const meta: Meta<typeof Separator> = { | ||
title: "Separator", | ||
component: Separator, | ||
|
||
Playground.story = { | ||
parameters: { | ||
info: "You can try all possible configurations of this component. However, check Orbit.Kiwi for more detailed design guidelines.", | ||
info: "Some more info about this component", | ||
}, | ||
}; | ||
|
||
Playground.args = { | ||
spaceAfter: SPACINGS_AFTER.LARGEST, | ||
align: "left", | ||
sideOffset: "none" as SideOffset, | ||
type: "solid", | ||
color: "" as BorderColorClass, | ||
}; | ||
args: { | ||
align: "left", | ||
sideOffset: "none", | ||
type: "solid", | ||
spaceAfter: "none", | ||
}, | ||
|
||
Playground.argTypes = { | ||
spaceAfter: { | ||
options: Object.values(SPACINGS_AFTER), | ||
control: { | ||
type: "select", | ||
argTypes: { | ||
spaceAfter: { | ||
options: Object.values(SPACINGS_AFTER), | ||
control: { | ||
type: "select", | ||
}, | ||
}, | ||
}, | ||
align: { | ||
options: ["left", "right", "center"], | ||
control: { | ||
type: "select", | ||
align: { | ||
options: ["left", "right", "center"], | ||
control: { | ||
type: "select", | ||
}, | ||
}, | ||
}, | ||
sideOffset: { | ||
options: ["none", "small", "medium", "large", "XLarge", "XXLarge"], | ||
control: { | ||
type: "select", | ||
sideOffset: { | ||
options: ["none", "small", "medium", "large", "XLarge", "XXLarge"], | ||
control: { | ||
type: "select", | ||
}, | ||
}, | ||
}, | ||
type: { | ||
options: ["solid", "dashed", "dotted", "double", "none"], | ||
control: { | ||
type: "select", | ||
type: { | ||
options: ["solid", "dashed", "dotted", "double", "none"], | ||
control: { | ||
type: "select", | ||
}, | ||
}, | ||
}, | ||
color: { | ||
options: Object.keys(defaultTheme.orbit) | ||
.filter(t => t.startsWith("palette")) | ||
.map(c => kebabCase(c.replace("palette", "border"))), | ||
control: { | ||
type: "select", | ||
color: { | ||
options: Object.keys(defaultTheme.orbit) | ||
.filter(t => t.startsWith("palette")) | ||
.map(c => kebabCase(c.replace("palette", "border"))), | ||
control: { | ||
type: "select", | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Rtl = args => ( | ||
<RenderInRtl> | ||
<Playground {...args} /> | ||
</RenderInRtl> | ||
); | ||
export default meta; | ||
|
||
Rtl.story = { | ||
name: "RTL", | ||
type Story = StoryObj<typeof Separator>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
align: undefined, | ||
sideOffset: undefined, | ||
type: undefined, | ||
spaceAfter: undefined, | ||
}, | ||
|
||
parameters: { | ||
info: "This is a preview of this component in RTL setup.", | ||
info: "This is the default configuration of this component. Visit Orbit.Kiwi for more detailed guidelines.", | ||
controls: { | ||
disable: true, | ||
}, | ||
}, | ||
}; | ||
|
||
Rtl.args = { | ||
spaceAfter: SPACINGS_AFTER.LARGEST, | ||
align: "left", | ||
sideOffset: "none" as SideOffset, | ||
type: "solid", | ||
color: "" as BorderColorClass, | ||
export const Playground: Story = { | ||
parameters: { | ||
info: "You can try all possible configurations of this component. However, check Orbit.Kiwi for more detailed design guidelines.", | ||
}, | ||
}; | ||
|
||
Rtl.argTypes = { | ||
spaceAfter: { | ||
options: Object.values(SPACINGS_AFTER), | ||
control: { | ||
type: "select", | ||
}, | ||
}, | ||
align: { | ||
options: ["left", "right", "center"], | ||
control: { | ||
type: "select", | ||
}, | ||
}, | ||
sideOffset: { | ||
options: ["none", "small", "medium", "large", "XLarge", "XXLarge"], | ||
control: { | ||
type: "select", | ||
}, | ||
}, | ||
type: { | ||
options: ["solid", "dashed", "dotted", "double", "none"], | ||
control: { | ||
type: "select", | ||
}, | ||
}, | ||
color: { | ||
options: Object.keys(defaultTheme.orbit) | ||
.filter(t => t.startsWith("palette")) | ||
.map(c => kebabCase(c.replace("palette", "border"))), | ||
control: { | ||
type: "select", | ||
}, | ||
export const Rtl: Story = { | ||
render: args => ( | ||
<RenderInRtl> | ||
<Separator {...args} /> | ||
</RenderInRtl> | ||
), | ||
|
||
parameters: { | ||
info: "This is a preview of this component in RTL setup. Check Orbit.Kiwi for more detailed guidelines.", | ||
}, | ||
}; |