Skip to content

Commit e37601f

Browse files
committed
docs: Make component card heights match
1 parent 39e6ade commit e37601f

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

packages/dev/s2-docs/src/ComponentCardView.tsx

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,36 @@ const componentIllustrations: Record<string, React.ComponentType | undefined> =
160160
'usePress': usePressSvg
161161
};
162162

163-
const illustrationStyles = style({
163+
// Overrides for specific illustrations so they fit within the cards.
164+
const propOverrides = {
165+
DateField: {
166+
viewBox: '0 -56 276 276'
167+
},
168+
TimeField: {
169+
viewBox: '0 -56 276 276'
170+
},
171+
DatePicker: {
172+
style: {alignSelf: 'end'}
173+
},
174+
DateRangePicker: {
175+
style: {alignSelf: 'end'}
176+
},
177+
DropZone: {
178+
viewBox: '0 0 290 220'
179+
}
180+
};
181+
182+
const illustrationContainer = style({
164183
width: 'full',
165184
aspectRatio: '3/2',
166-
objectFit: 'cover',
185+
backgroundColor: '--anatomy-gray-100',
186+
display: 'flex',
187+
alignItems: 'center',
188+
justifyContent: 'center'
189+
});
190+
191+
const illustrationStyles = style({
192+
width: 'calc(100% - 16px)',
167193
userSelect: 'none',
168194
pointerEvents: 'none'
169195
});
@@ -183,13 +209,21 @@ export function ComponentCardView({items, ariaLabel = 'Items', size = 'S', onAct
183209
<Collection items={items}>
184210
{(item) => {
185211
let IllustrationComponent = componentIllustrations[item.name] || ComingSoonSvg;
212+
let overrides = propOverrides[item.name] || {};
186213
return (
187214
<Card key={item.id} id={item.id} href={item.href} size={size} textValue={item.name}>
188215
<CardPreview>
189-
<IllustrationComponent
190-
aria-hidden="true"
191-
// @ts-ignore
192-
className={illustrationStyles} />
216+
<div className={illustrationContainer}>
217+
<IllustrationComponent
218+
{...overrides}
219+
aria-hidden="true"
220+
// @ts-ignore
221+
className={illustrationStyles}
222+
style={{
223+
...overrides.style,
224+
maxHeight: 'calc(100% - 16px)'
225+
}} />
226+
</div>
193227
</CardPreview>
194228
<Content>
195229
<Text slot="title">{item.name}</Text>

0 commit comments

Comments
 (0)