-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathindex.story.tsx
More file actions
219 lines (208 loc) · 4.84 KB
/
index.story.tsx
File metadata and controls
219 lines (208 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import type { Meta, StoryObj } from '@storybook/react-vite';
import * as Card from '../index';
/**
* Temporary text component for story examples. This will be replaced by an
* official DS `<Text />` component once it's available.
*/
function Text( { children }: { children: React.ReactNode } ) {
return (
<p
style={ {
margin: 0,
fontFamily: 'var(--wpds-typography-font-family-body)',
fontSize: 'var(--wpds-typography-font-size-md)',
fontWeight: 'var(--wpds-typography-font-weight-regular)',
lineHeight: 'var(--wpds-typography-line-height-sm)',
textWrap: 'pretty',
color: 'var(--wpds-color-fg-content-neutral-weak)',
} }
>
{ children }
</p>
);
}
const meta: Meta< typeof Card.Root > = {
tags: [ 'manifest' ],
title: 'Design System/Components/Card',
component: Card.Root,
subcomponents: {
'Card.Header': Card.Header,
'Card.Content': Card.Content,
'Card.FullBleed': Card.FullBleed,
'Card.Title': Card.Title,
},
};
export default meta;
type Story = StoryObj< typeof Card.Root >;
export const Default: Story = {
args: {
children: (
<>
<Card.Header>
<Card.Title>Card title</Card.Title>
</Card.Header>
<Card.Content>
<Text>
This is the main content area. It can contain any
elements. This is the main content area. It can contain
any elements. This is the main content area. It can
contain any elements. This is the main content area. It
can contain any elements. This is the main content area.
It can contain any elements. This is the main content
area. It can contain any elements.
</Text>
<Text>
This is the main content area. It can contain any
elements.
</Text>
</Card.Content>
</>
),
},
};
/**
* `Card.FullBleed` breaks out of the card's padding to span
* edge-to-edge. Useful for images, dividers, or embedded content.
*/
export const WithFullBleed: Story = {
args: {
children: (
<>
<Card.Header>
<Card.Title>Featured image</Card.Title>
</Card.Header>
<Card.Content>
<Card.FullBleed>
<div
style={ {
height: 160,
background:
'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
} }
/>
</Card.FullBleed>
<Text>Content below the full-bleed area.</Text>
</Card.Content>
</>
),
},
};
/**
* A minimal card with only a header.
*/
export const HeaderOnly: Story = {
args: {
children: (
<Card.Header>
<Card.Title>Simple card</Card.Title>
</Card.Header>
),
},
};
/**
* An image placed directly inside `Card.Root` (before `Card.Header` and
* `Card.Content`) naturally touches all four card edges. The card's
* `overflow: clip` and `border-radius` clip it to the rounded corners, and
* the header and content below retain their normal padding.
*/
export const HeroImageWithHeaderAndContent: Story = {
args: {
children: (
<>
<div
style={ {
height: 180,
background:
'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
} }
/>
<Card.Header>
<Card.Title>Hero image card</Card.Title>
</Card.Header>
<Card.Content>
<Text>Card body text below the hero image and title.</Text>
</Card.Content>
</>
),
},
};
/**
* Hero image followed only by a `Card.Header`. No content section below.
*/
export const HeroImageWithHeader: Story = {
args: {
children: (
<>
<div
style={ {
height: 180,
background:
'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
} }
/>
<Card.Header>
<Card.Title>Hero image card</Card.Title>
</Card.Header>
</>
),
},
};
/**
* Hero image followed only by a `Card.Content` body. No header section.
*/
export const HeroImageWithContent: Story = {
args: {
children: (
<>
<div
style={ {
height: 180,
background:
'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
} }
/>
<Card.Content>
<Text>Card body text below the hero image.</Text>
</Card.Content>
</>
),
},
};
/**
* A single image filling the entire card — no header or content sections.
* The image is placed directly inside `Card.Root` and is clipped to the
* card's rounded corners by `overflow: clip`.
*/
export const CoverImage: Story = {
args: {
children: (
<div
style={ {
height: 180,
background:
'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
} }
/>
),
},
};
/**
* Use the `render` prop to change the underlying HTML elements for
* better semantics. Here, `Card.Root` renders as a `<section>` and
* `Card.Title` renders as an `<h2>`.
*/
export const CustomSemantics: Story = {
args: {
render: <section />,
children: (
<>
<Card.Header>
<Card.Title render={ <h2 /> }>Section heading</Card.Title>
</Card.Header>
<Card.Content>
<Text>Semantically meaningful card content.</Text>
</Card.Content>
</>
),
},
};