mirror of
https://github.com/penpot/penpot.git
synced 2025-04-13 07:21:40 -05:00
📎 Add storybook helper components and improve current stories
This commit is contained in:
parent
203a39f07c
commit
5309da2eee
5 changed files with 64 additions and 27 deletions
|
@ -17,4 +17,6 @@
|
|||
;; meta / misc
|
||||
:meta #js {:icons icon-list :svgs raw-svg-list}
|
||||
:storybook #js {:StoryGrid sb/story-grid*
|
||||
:StoryGridCell sb/story-grid-cell*
|
||||
:StoryHeader sb/story-header*
|
||||
:StoryWrapper sb/story-wrapper*}})
|
||||
|
|
|
@ -2,7 +2,8 @@ import * as React from "react";
|
|||
import Components from "@target/components";
|
||||
|
||||
const { Icon } = Components;
|
||||
const { StoryWrapper, StoryGrid } = Components.storybook;
|
||||
const { StoryWrapper, StoryGrid, StoryGridCell, StoryHeader } =
|
||||
Components.storybook;
|
||||
const { icons } = Components.meta;
|
||||
|
||||
export default {
|
||||
|
@ -17,23 +18,32 @@ const iconList = Object.entries(icons)
|
|||
export const AllIcons = {
|
||||
render: () => (
|
||||
<StoryWrapper theme="default">
|
||||
<h1>All Icons</h1>
|
||||
<p>Hover on an icon to see its ID</p>
|
||||
<StoryHeader>
|
||||
<h1>All Icons</h1>
|
||||
<p>Hover on an icon to see its ID</p>
|
||||
</StoryHeader>
|
||||
<StoryGrid>
|
||||
{iconList.map((iconId) => (
|
||||
<div title={iconId} key={iconId}>
|
||||
<StoryGridCell
|
||||
title={iconId}
|
||||
key={iconId}
|
||||
style={{ color: "var(--color-accent-primary)" }}
|
||||
>
|
||||
<Icon icon={iconId} />
|
||||
</div>
|
||||
</StoryGridCell>
|
||||
))}
|
||||
</StoryGrid>
|
||||
</StoryWrapper>
|
||||
),
|
||||
parameters: {
|
||||
backgrounds: { disable: true },
|
||||
},
|
||||
};
|
||||
|
||||
export const Default = {
|
||||
render: () => (
|
||||
<StoryWrapper theme="default">
|
||||
<Icon icon="pin" />
|
||||
<Icon icon={icons.Pin} />
|
||||
</StoryWrapper>
|
||||
),
|
||||
};
|
||||
|
@ -41,7 +51,7 @@ export const Default = {
|
|||
export const Small = {
|
||||
render: () => (
|
||||
<StoryWrapper theme="default">
|
||||
<Icon icon="pin" size="s" />
|
||||
<Icon icon={icons.Pin} size="s" />
|
||||
</StoryWrapper>
|
||||
),
|
||||
};
|
||||
|
|
|
@ -2,7 +2,8 @@ import * as React from "react";
|
|||
import Components from "@target/components";
|
||||
|
||||
const { RawSvg } = Components;
|
||||
const { StoryWrapper, StoryGrid } = Components.storybook;
|
||||
const { StoryWrapper, StoryGrid, StoryGridCell, StoryHeader } =
|
||||
Components.storybook;
|
||||
const { svgs } = Components.meta;
|
||||
|
||||
export default {
|
||||
|
@ -16,28 +17,30 @@ const assetList = Object.entries(svgs)
|
|||
|
||||
export const AllAssets = {
|
||||
render: () => (
|
||||
<StoryWrapper theme="default">
|
||||
<h1>All assets</h1>
|
||||
<p>Hover on a asset to see its id.</p>
|
||||
<StoryWrapper theme="light">
|
||||
<StoryHeader>
|
||||
<h1>All assets</h1>
|
||||
<p>Hover on a asset to see its id.</p>
|
||||
</StoryHeader>
|
||||
|
||||
<StoryGrid size="200">
|
||||
{assetList.map(x => (
|
||||
<div key={x} title={x}>
|
||||
<RawSvg asset={x} style={{maxWidth: "100%"}} />
|
||||
</div>
|
||||
{assetList.map((x) => (
|
||||
<StoryGridCell key={x} title={x}>
|
||||
<RawSvg asset={x} style={{ maxWidth: "100%" }} />
|
||||
</StoryGridCell>
|
||||
))}
|
||||
</StoryGrid>
|
||||
</StoryWrapper>
|
||||
),
|
||||
parameters: {
|
||||
backgrounds: { default: "debug" }
|
||||
}
|
||||
}
|
||||
backgrounds: { values: [{ name: "debug", value: "#ccc" }] },
|
||||
},
|
||||
};
|
||||
|
||||
export const Default = {
|
||||
render: () => (
|
||||
<StoryWrapper theme="default">
|
||||
<RawSvg asset="brand-gitlab" width="200" />
|
||||
<RawSvg asset={svgs.BrandGitlab} width="200" />
|
||||
</StoryWrapper>
|
||||
),
|
||||
}
|
||||
};
|
||||
|
|
|
@ -24,6 +24,24 @@
|
|||
|
||||
(mf/defc story-grid*
|
||||
{::mf/props :obj}
|
||||
[{:keys [children size]}]
|
||||
[:article {:class (stl/css :story-grid)
|
||||
:style (when (some? size) #js {"--component-grid-size" (dm/str size "px")})} children])
|
||||
[{:keys [children size style] :rest other}]
|
||||
(let [class (stl/css :story-grid)
|
||||
size (or size 16)
|
||||
style (or style {})
|
||||
style (mf/spread style :--component-grid-size (dm/str size "px"))
|
||||
props (mf/spread-props other {:class class :style style})]
|
||||
[:> "article" props children]))
|
||||
|
||||
(mf/defc story-grid-cell*
|
||||
{::mf/props :obj}
|
||||
[{:keys [children] :rest other}]
|
||||
(let [class (stl/css :story-grid-cell)
|
||||
props (mf/spread-props other {:class class})]
|
||||
[:> "article" props children]))
|
||||
|
||||
(mf/defc story-header*
|
||||
{::mf/props :obj}
|
||||
[{:keys [children] :rest other}]
|
||||
(let [class (stl/css :story-header)
|
||||
props (mf/spread-props other {:class class})]
|
||||
[:> "header" props children]))
|
||||
|
|
|
@ -10,8 +10,12 @@
|
|||
grid-template-columns: repeat(auto-fit, var(--component-grid-size, 16px));
|
||||
gap: 1rem;
|
||||
color: var(--color-foreground-primary);
|
||||
|
||||
& > * {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.story-grid-cell {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.story-header {
|
||||
color: var(--color-foreground-primary);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue