Revamp RawSvg stories and update prop name

This commit is contained in:
Belén Albeza 2024-07-10 16:30:01 +02:00
parent 7e61acc4da
commit ba36023ae6
5 changed files with 61 additions and 46 deletions

View file

@ -16,17 +16,17 @@ export default {
argTypes: { argTypes: {
id: { id: {
options: iconList, options: iconList,
control: { type: "select" } control: { type: "select" },
}, },
size: { size: {
options: ["m", "s"], options: ["m", "s"],
control: { type: "radio" } control: { type: "radio" },
} },
} },
}; };
export const All = { export const All = {
render: ({size}) => ( render: ({ size }) => (
<StoryWrapper theme="default"> <StoryWrapper theme="default">
<StoryHeader> <StoryHeader>
<h1>All Icons</h1> <h1>All Icons</h1>
@ -55,7 +55,7 @@ export const All = {
}; };
export const Default = { export const Default = {
render: ({id, ...args}) => ( render: ({ id, ...args }) => (
<StoryWrapper theme="default"> <StoryWrapper theme="default">
<Icon id={id} {...args} /> <Icon id={id} {...args} />
</StoryWrapper> </StoryWrapper>
@ -64,12 +64,12 @@ export const Default = {
id: "pin", id: "pin",
}, },
parameters: { parameters: {
controls: { exclude: ["size"] } controls: { exclude: ["size"] },
} },
}; };
export const CustomSize = { export const CustomSize = {
render: ({id, size, ...args}) => ( render: ({ id, size, ...args }) => (
<StoryWrapper theme="default"> <StoryWrapper theme="default">
<Icon id={id} size={size} {...args} /> <Icon id={id} size={size} {...args} />
</StoryWrapper> </StoryWrapper>
@ -77,6 +77,5 @@ export const CustomSize = {
args: { args: {
id: "pin", id: "pin",
size: "m", size: "m",
} },
}; };

View file

@ -32,6 +32,6 @@
(mf/defc raw-svg* (mf/defc raw-svg*
{::mf/props :obj} {::mf/props :obj}
[{:keys [asset] :rest props}] [{:keys [id] :rest props}]
[:> "svg" props [:> "svg" props
[:use {:href (dm/str "#asset-" asset)}]]) [:use {:href (dm/str "#asset-" id)}]])

View file

@ -6,41 +6,51 @@ const { StoryWrapper, StoryGrid, StoryGridCell, StoryHeader } =
Components.storybook; Components.storybook;
const { svgs } = Components.meta; const { svgs } = Components.meta;
export default {
title: "Foundations/RawSvg",
component: Components.RawSvg,
};
const assetList = Object.entries(svgs) const assetList = Object.entries(svgs)
.map(([_, value]) => value) .map(([_, value]) => value)
.sort(); .sort();
export const AllAssets = { export default {
render: () => ( title: "Foundations/Assets/RawSvg",
component: Components.RawSvg,
argTypes: {
id: {
options: assetList,
control: { type: "select" },
},
},
};
export const All = {
render: ({}) => (
<StoryWrapper theme="light"> <StoryWrapper theme="light">
<StoryHeader> <StoryHeader>
<h1>All assets</h1> <h1>All SVG Assets</h1>
<p>Hover on a asset to see its id.</p> <p>Hover on an asset to see its ID.</p>
</StoryHeader> </StoryHeader>
<StoryGrid size="200"> <StoryGrid size="200">
{assetList.map((x) => ( {assetList.map((x) => (
<StoryGridCell key={x} title={x}> <StoryGridCell key={x} title={x}>
<RawSvg asset={x} style={{ maxWidth: "100%" }} /> <RawSvg id={x} style={{ maxWidth: "100%" }} />
</StoryGridCell> </StoryGridCell>
))} ))}
</StoryGrid> </StoryGrid>
</StoryWrapper> </StoryWrapper>
), ),
parameters: { parameters: {
controls: { exclude: ["id"] },
backgrounds: { values: [{ name: "debug", value: "#ccc" }] }, backgrounds: { values: [{ name: "debug", value: "#ccc" }] },
}, },
}; };
export const Default = { export const Default = {
render: () => ( render: ({ id, ...args }) => (
<StoryWrapper theme="default"> <StoryWrapper theme="default">
<RawSvg asset={svgs.BrandGitlab} width="200" /> <RawSvg id={id} {...args} width="200" />
</StoryWrapper> </StoryWrapper>
), ),
args: {
id: "brand-gitlab",
},
}; };

View file

@ -24,13 +24,15 @@ export default {
export const AnyHeading = { export const AnyHeading = {
name: "Heading", name: "Heading",
render: ({level, typography, ...args}) => ( render: ({ level, typography, ...args }) => (
<StoryWrapper theme="default"> <StoryWrapper theme="default">
<Heading level={level} typography={typography} {...args}>Lorem ipsum</Heading> <Heading level={level} typography={typography} {...args}>
Lorem ipsum
</Heading>
</StoryWrapper> </StoryWrapper>
), ),
args: { args: {
level: 1, level: 1,
typography: "display", typography: "display",
} },
}; };

View file

@ -14,29 +14,33 @@ export default {
typography: { typography: {
options: typographyIds, options: typographyIds,
control: { type: "select" }, control: { type: "select" },
} },
} },
}; };
export const Default = { export const Default = {
render: ({typography, ...args}) => ( render: ({ typography, ...args }) => (
<StoryWrapper theme="default"> <StoryWrapper theme="default">
<Text typography={typography} {...args}>Lorem ipsum</Text> <Text typography={typography} {...args}>
</StoryWrapper> Lorem ipsum
), </Text>
args: {
typography: "display"
}
};
export const CustomTag = {
render: ({typography, ...args}) => (
<StoryWrapper theme="default">
<Text typography={typography} {...args}>Lorem ipsum</Text>
</StoryWrapper> </StoryWrapper>
), ),
args: { args: {
typography: "display", typography: "display",
as: "li" },
} };
}
export const CustomTag = {
render: ({ typography, ...args }) => (
<StoryWrapper theme="default">
<Text typography={typography} {...args}>
Lorem ipsum
</Text>
</StoryWrapper>
),
args: {
typography: "display",
as: "li",
},
};