Skip to content

Commit

Permalink
chore(Skeleton): migrate stories from CSF2 to CSF3
Browse files Browse the repository at this point in the history
  • Loading branch information
domihustinova committed Sep 9, 2024
1 parent ff825ef commit ef57ddb
Showing 1 changed file with 89 additions and 104 deletions.
193 changes: 89 additions & 104 deletions packages/orbit-components/src/Skeleton/Skeleton.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import * as React from "react";
import type { Meta, StoryObj } from "@storybook/react";

import defaultTheme from "../defaultTheme";
import RenderInRtl from "../utils/rtl/RenderInRtl";
import { SPACINGS_AFTER } from "../common/consts";

import Skeleton from ".";

export default {
title: "Skeleton",
};

enum PRESETS {
List = "List",
Image = "Image",
Expand All @@ -18,129 +15,117 @@ enum PRESETS {
Text = "Text",
}

export const Default = () => {
return <Skeleton height="150px" width="500px" />;
const meta: Meta<typeof Skeleton> = {
title: "Skeleton",
component: Skeleton,
};

Default.story = {
export default meta;
type Story = StoryObj<typeof Skeleton>;

export const Default: Story = {
render: () => <Skeleton height="150px" width="500px" />,

parameters: {
info: "This is the default configuration of this component. Visit Orbit.Kiwi for more detailed guidelines.",
controls: {
disable: true,
},
},
};

export const Playground = ({
animate,
height,
maxHeight,
rowBorderRadius,
rowHeight,
rowOffset,
rows,
spaceAfter,
viewBox,
width,
title,
color,
}) => {
return (
<Skeleton
animate={animate}
color={color}
height={height}
maxHeight={maxHeight}
title={title}
rowBorderRadius={rowBorderRadius}
rowHeight={rowHeight}
rowOffset={rowOffset}
rows={rows}
spaceAfter={spaceAfter}
viewBox={viewBox}
width={width}
/>
);
};

Playground.story = {
export const Playground: Story = {
parameters: {
info: "You can try all possible configurations of this component. However, check Orbit.Kiwi for more detailed design guidelines.",
},
};

Playground.args = {
animate: true,
height: "",
maxHeight: "",
rowBorderRadius: 3,
rowHeight: 21,
rowOffset: 30,
rows: 10,
spaceAfter: SPACINGS_AFTER.NONE,
viewBox: "",
width: "",
title: "Loading",
color: "",
};
args: {
animate: true,
rowBorderRadius: 3,
rowHeight: 21,
rowOffset: 30,
rows: 10,
title: "Loading",
viewBox: "",
width: "",
height: "",
maxHeight: "",
color: "",
spaceAfter: SPACINGS_AFTER.NONE,
},

Playground.argTypes = {
spaceAfter: {
options: Object.values(SPACINGS_AFTER),
control: {
type: "select",
argTypes: {
spaceAfter: {
options: Object.values(SPACINGS_AFTER),
control: {
type: "select",
},
},
},
color: {
options: Object.keys(defaultTheme.orbit).filter(t => t.startsWith("palette")),
control: {
type: "select",
color: {
options: Object.keys(defaultTheme.orbit).filter(t => t.startsWith("palette")),
control: {
type: "select",
},
},
},
};

export const RTL = () => (
<RenderInRtl>
<Skeleton height="100px" width="500px" viewBox="0 0 500 100">
<rect x="48" y="8" rx="3" ry="3" width="88" height="6" />
<rect x="48" y="26" rx="3" ry="3" width="52" height="6" />
<rect x="0" y="56" rx="3" ry="3" width="410" height="6" />
<rect x="0" y="72" rx="3" ry="3" width="380" height="6" />
<rect x="0" y="88" rx="3" ry="3" width="178" height="6" />
<circle cx="20" cy="20" r="20" />
</Skeleton>
</RenderInRtl>
);

export const Custom = ({ height, viewBox, width }) => {
return (
<Skeleton height={height} width={width} viewBox={viewBox}>
<rect x="48" y="8" rx="3" ry="3" width="88" height="6" />
<rect x="48" y="26" rx="3" ry="3" width="52" height="6" />
<rect x="0" y="56" rx="3" ry="3" width="410" height="6" />
<rect x="0" y="72" rx="3" ry="3" width="380" height="6" />
<rect x="0" y="88" rx="3" ry="3" width="178" height="6" />
<circle cx="20" cy="20" r="20" />
</Skeleton>
);
};
export const RTL: Story = {
render: () => (
<RenderInRtl>
<Skeleton height="100px" width="500px" viewBox="0 0 500 100">
<rect x="48" y="8" rx="3" ry="3" width="88" height="6" />
<rect x="48" y="26" rx="3" ry="3" width="52" height="6" />
<rect x="0" y="56" rx="3" ry="3" width="410" height="6" />
<rect x="0" y="72" rx="3" ry="3" width="380" height="6" />
<rect x="0" y="88" rx="3" ry="3" width="178" height="6" />
<circle cx="20" cy="20" r="20" />
</Skeleton>
</RenderInRtl>
),

Custom.args = {
height: "100px",
viewBox: "0 0 500 100",
width: "500px",
parameters: {
info: "This is a preview of this component in RTL setup.",
controls: {
disable: true,
},
},
};

export const Presets = ({ presets }) => {
return <Skeleton preset={presets} />;
};
export const Custom: Story = {
render: ({ height, viewBox, width }) => {
return (
<Skeleton height={height} width={width} viewBox={viewBox}>
<rect x="48" y="8" rx="3" ry="3" width="88" height="6" />
<rect x="48" y="26" rx="3" ry="3" width="52" height="6" />
<rect x="0" y="56" rx="3" ry="3" width="410" height="6" />
<rect x="0" y="72" rx="3" ry="3" width="380" height="6" />
<rect x="0" y="88" rx="3" ry="3" width="178" height="6" />
<circle cx="20" cy="20" r="20" />
</Skeleton>
);
},

Presets.args = {
preset: PRESETS.List,
args: {
height: "100px",
viewBox: "0 0 500 100",
width: "500px",
},
};

Presets.argTypes = {
preset: {
options: PRESETS,
control: {
type: "select",
export const Presets: Story = {
render: ({ preset }) => <Skeleton preset={preset} />,

args: {
preset: PRESETS.List,
},

argTypes: {
preset: {
options: Object.values(PRESETS),
control: {
type: "select",
},
},
},
};

0 comments on commit ef57ddb

Please sign in to comment.