Skip to content

Commit d65c45a

Browse files
committed
change story
1 parent 2adb831 commit d65c45a

File tree

1 file changed

+104
-12
lines changed

1 file changed

+104
-12
lines changed

docs/stories/ImageFrame.stories.tsx

Lines changed: 104 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,119 @@ export default meta;
1616

1717
type Story = StoryObj<typeof meta>;
1818

19-
const IMAGE_SRC = "https://images.unsplash.com/photo-1535025183041-0991a977e25b?w=400&dpr=2&q=80";
19+
type ImageFrameCase = {
20+
caseLabel: string;
21+
src: string;
22+
width: string;
23+
ratio: number;
24+
height?: string;
25+
};
2026

21-
const conditionMap = {
22-
sizing: {
23-
w200_defaultRatio: { width: "200px" },
24-
w200_r1: { width: "200px", ratio: 1 },
25-
w200_r4_3: { width: "200px", ratio: 4 / 3 },
26-
w200_r16_9: { width: "200px", ratio: 16 / 9 },
27-
w200_h150_r4_3: { width: "200px", height: "150px", ratio: 4 / 3 },
28-
w200_h200_r4_3: { width: "200px", height: "200px", ratio: 4 / 3 },
27+
type ImageFrameCaseProps = ImageFrameCase & {
28+
rounded?: boolean;
29+
stroke?: boolean;
30+
};
31+
32+
const IMAGE_CASES: ImageFrameCase[] = [
33+
{
34+
caseLabel: "ratio=1, width=96",
35+
src: "https://placehold.co/320x180/ff7a00/ffffff?text=16:9",
36+
width: "96px",
37+
ratio: 1,
38+
},
39+
{
40+
caseLabel: "ratio=4/3, width=120",
41+
src: "https://placehold.co/180x320/4c6fff/ffffff?text=9:16",
42+
width: "120px",
43+
ratio: 4 / 3,
44+
},
45+
{
46+
caseLabel: "ratio=16/9, width=160",
47+
src: "https://placehold.co/240x240/00b894/ffffff?text=1:1",
48+
width: "160px",
49+
ratio: 16 / 9,
50+
},
51+
{
52+
caseLabel: "ratio=4/3, width=160, height=120",
53+
src: "https://placehold.co/320x180/ffb300/ffffff?text=16:9",
54+
width: "160px",
55+
height: "120px",
56+
ratio: 4 / 3,
57+
},
58+
{
59+
caseLabel: "ratio=1, width=120, height=80",
60+
src: "https://placehold.co/320x180/8e44ad/ffffff?text=16:9",
61+
width: "120px",
62+
height: "80px",
63+
ratio: 1,
2964
},
65+
{
66+
caseLabel: "ratio=3/4, width=120",
67+
src: "https://placehold.co/180x320/2d3436/ffffff?text=9:16",
68+
width: "120px",
69+
ratio: 3 / 4,
70+
},
71+
];
72+
73+
const conditionMap = {
74+
caseLabel: IMAGE_CASES.reduce(
75+
(acc, item) => {
76+
acc[item.caseLabel] = {
77+
src: item.src,
78+
width: item.width,
79+
height: item.height,
80+
ratio: item.ratio,
81+
};
82+
83+
return acc;
84+
},
85+
{} as Record<string, Omit<ImageFrameCase, "caseLabel">>,
86+
),
87+
};
88+
89+
const ImageFrameCase = ({
90+
caseLabel,
91+
src,
92+
width,
93+
height,
94+
ratio,
95+
rounded,
96+
stroke,
97+
}: ImageFrameCaseProps) => {
98+
return (
99+
<div style={{ display: "flex", alignItems: "center", gap: "12px" }}>
100+
<ImageFrame
101+
src={src}
102+
alt={caseLabel}
103+
ratio={ratio}
104+
width={width}
105+
height={height}
106+
rounded={rounded}
107+
stroke={stroke}
108+
/>
109+
<div style={{ display: "flex", flexDirection: "column", gap: "4px" }}>
110+
<span style={{ fontSize: "12px", color: "var(--seed-color-fg-placeholder)" }}>
111+
{caseLabel}
112+
</span>
113+
<code style={{ fontSize: "12px", fontFamily: "Courier", wordBreak: "break-all" }}>
114+
src: {src}
115+
</code>
116+
<code style={{ fontSize: "12px", fontFamily: "Courier" }}>width: {width}</code>
117+
<code style={{ fontSize: "12px", fontFamily: "Courier" }}>ratio: {ratio}</code>
118+
<code style={{ fontSize: "12px", fontFamily: "Courier" }}>height: {height ?? "-"}</code>
119+
</div>
120+
</div>
121+
);
30122
};
31123

32124
const CommonStoryTemplate: Story = {
33125
args: {
34-
src: IMAGE_SRC,
35-
alt: "Landscape photograph by Tobias Tullius",
126+
src: "https://placehold.co/1x1/000000/ffffff",
127+
alt: "ImageFrame placeholder",
36128
},
37129
render: (args) => (
38130
<VariantTable
39-
Component={meta.component}
131+
Component={ImageFrameCase}
40132
variantMap={imageFrameVariantMap}
41133
conditionMap={conditionMap}
42134
{...args}

0 commit comments

Comments
 (0)