@czi-sds/mcp 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/data/component-docs/Accordion.md +291 -0
- package/data/component-docs/Autocomplete.md +525 -0
- package/data/component-docs/Banner.md +231 -0
- package/data/component-docs/Button.md +224 -0
- package/data/component-docs/ButtonDropdown.md +256 -0
- package/data/component-docs/ButtonGroup.md +320 -0
- package/data/component-docs/ButtonToggle.md +397 -0
- package/data/component-docs/Callout.md +268 -0
- package/data/component-docs/CellBasic.md +122 -0
- package/data/component-docs/CellComponent.md +63 -0
- package/data/component-docs/CellHeader.md +128 -0
- package/data/component-docs/ComplexFilter.md +294 -0
- package/data/component-docs/ContentCard.md +406 -0
- package/data/component-docs/Dialog.md +651 -0
- package/data/component-docs/Dropdown.md +155 -0
- package/data/component-docs/DropdownMenu.md +949 -0
- package/data/component-docs/HeatmapChart.md +782 -0
- package/data/component-docs/Hero.md +363 -0
- package/data/component-docs/Icon.md +283 -0
- package/data/component-docs/InputCheckbox.md +205 -0
- package/data/component-docs/InputDropdown.md +482 -0
- package/data/component-docs/InputRadio.md +173 -0
- package/data/component-docs/InputSearch.md +81 -0
- package/data/component-docs/InputSlider.md +189 -0
- package/data/component-docs/InputText.md +110 -0
- package/data/component-docs/InputToggle.md +141 -0
- package/data/component-docs/IntentMessage.md +293 -0
- package/data/component-docs/Legend.md +442 -0
- package/data/component-docs/Link.md +23 -0
- package/data/component-docs/List.md +300 -0
- package/data/component-docs/LoadingIndicator.md +198 -0
- package/data/component-docs/Menu.md +298 -0
- package/data/component-docs/MenuItem.md +100 -0
- package/data/component-docs/NavigationFooter.md +165 -0
- package/data/component-docs/NavigationHeader.md +500 -0
- package/data/component-docs/NavigationJumpTo.md +414 -0
- package/data/component-docs/Notification.md +288 -0
- package/data/component-docs/Pagination.md +67 -0
- package/data/component-docs/Panel.md +636 -0
- package/data/component-docs/Popover.md +448 -0
- package/data/component-docs/PreComposedTable.md +2947 -0
- package/data/component-docs/SegmentedControl.md +396 -0
- package/data/component-docs/StackedBarChart.md +475 -0
- package/data/component-docs/Table.md +2000 -0
- package/data/component-docs/TableHeader.md +53 -0
- package/data/component-docs/TableRow.md +74 -0
- package/data/component-docs/Tabs.md +455 -0
- package/data/component-docs/Tag.md +647 -0
- package/data/component-docs/TagFilter.md +131 -0
- package/data/component-docs/Tooltip.md +561 -0
- package/data/component-docs/TooltipCondensed.md +203 -0
- package/data/component-docs/TooltipTable.md +145 -0
- package/data/component-docs/index.json +262 -0
- package/data/component-list.json +2 -5
- package/data/component-props/Accordion.json +31 -11
- package/data/component-props/Alert.json +3 -3
- package/data/component-props/Autocomplete.json +150 -15
- package/data/component-props/Banner.json +31 -17
- package/data/component-props/Button.json +45 -20
- package/data/component-props/ButtonDropdown.json +36 -17
- package/data/component-props/ButtonDropdownLegacy.json +11 -11
- package/data/component-props/ButtonGroup.json +32 -11
- package/data/component-props/ButtonIcon.json +10 -10
- package/data/component-props/ButtonLegacy.json +19 -19
- package/data/component-props/ButtonToggle.json +32 -19
- package/data/component-props/ButtonToggleLegacy.json +11 -11
- package/data/component-props/Callout.json +58 -17
- package/data/component-props/CellBasic.json +94 -41
- package/data/component-props/CellComponent.json +23 -7
- package/data/component-props/CellHeader.json +62 -19
- package/data/component-props/ComplexFilter.json +52 -21
- package/data/component-props/ContentCard.json +70 -47
- package/data/component-props/Dialog.json +47 -14
- package/data/component-props/Dropdown.json +67 -31
- package/data/component-props/DropdownMenu.json +128 -23
- package/data/component-props/HeatmapChart.json +88 -12
- package/data/component-props/Hero.json +80 -39
- package/data/component-props/Icon.json +20 -9
- package/data/component-props/InputCheckbox.json +36 -14
- package/data/component-props/InputDropdown.json +75 -27
- package/data/component-props/InputRadio.json +31 -13
- package/data/component-props/InputSearch.json +41 -18
- package/data/component-props/InputSlider.json +46 -19
- package/data/component-props/InputText.json +26 -19
- package/data/component-props/InputToggle.json +26 -9
- package/data/component-props/IntentMessage.json +38 -9
- package/data/component-props/Link.json +13 -7
- package/data/component-props/LoadingIndicator.json +11 -3
- package/data/component-props/MenuItem.json +38 -19
- package/data/component-props/MenuSelect.json +8 -8
- package/data/component-props/NavigationFooter.json +49 -19
- package/data/component-props/NavigationHeader.json +150 -37
- package/data/component-props/NavigationJumpTo.json +33 -7
- package/data/component-props/Notification.json +39 -21
- package/data/component-props/Pagination.json +39 -11
- package/data/component-props/Panel.json +62 -9
- package/data/component-props/Popover.json +80 -7
- package/data/component-props/PreComposedTable.json +99 -27
- package/data/component-props/SegmentedControl.json +42 -3
- package/data/component-props/StackedBarChart.json +116 -42
- package/data/component-props/TableRow.json +38 -19
- package/data/component-props/Tabs.json +66 -9
- package/data/component-props/Tag.json +34 -17
- package/data/component-props/TagFilter.json +10 -3
- package/data/component-props/Tooltip.json +49 -18
- package/data/component-props/TooltipCondensed.json +18 -9
- package/data/component-props/TooltipTable.json +17 -7
- package/data/resources/{zeroheight-rules.md → documentation-rules.md} +43 -30
- package/data/resources/figma-rules.md +2 -2
- package/dist/stdio.js +483 -780
- package/package.json +12 -8
- package/data/component-props/ButtonDropdownV2.json +0 -34
- package/data/component-props/ButtonNew.json +0 -47
- package/data/component-props/ButtonToggleV2.json +0 -44
- package/data/component-props/ButtonV2.json +0 -43
- package/data/zeroheight-cache.json +0 -10259
- package/data/zeroheight-exports/Accordion.md +0 -774
- package/data/zeroheight-exports/Banner.md +0 -691
- package/data/zeroheight-exports/Borders.md +0 -117
- package/data/zeroheight-exports/Buttons.md +0 -1854
- package/data/zeroheight-exports/Callout.md +0 -931
- package/data/zeroheight-exports/Colors.md +0 -1755
- package/data/zeroheight-exports/Content-Card.md +0 -309
- package/data/zeroheight-exports/Contributing-to-SDS.md +0 -98
- package/data/zeroheight-exports/Control-Inputs.md +0 -2818
- package/data/zeroheight-exports/Corners.md +0 -104
- package/data/zeroheight-exports/Cover-page.md +0 -3
- package/data/zeroheight-exports/Dialog.md +0 -1367
- package/data/zeroheight-exports/Downloads.md +0 -236
- package/data/zeroheight-exports/Drop-Shadows.md +0 -79
- package/data/zeroheight-exports/Dropdown-Input.md +0 -1776
- package/data/zeroheight-exports/Dropdown-Menus.md +0 -913
- package/data/zeroheight-exports/Element-Status-Tracker.md +0 -267
- package/data/zeroheight-exports/Field-Inputs.md +0 -1405
- package/data/zeroheight-exports/Filters.md +0 -1111
- package/data/zeroheight-exports/Getting-Started.md +0 -1157
- package/data/zeroheight-exports/Hero.md +0 -414
- package/data/zeroheight-exports/Icons.md +0 -2067
- package/data/zeroheight-exports/Intent.md +0 -86
- package/data/zeroheight-exports/Introduction-to-Bases.md +0 -35
- package/data/zeroheight-exports/Introduction-to-Cells.md +0 -35
- package/data/zeroheight-exports/Introduction-to-DNA.md +0 -35
- package/data/zeroheight-exports/Introduction-to-Genes.md +0 -35
- package/data/zeroheight-exports/Introduction.md +0 -115
- package/data/zeroheight-exports/Link.md +0 -432
- package/data/zeroheight-exports/Lists.md +0 -986
- package/data/zeroheight-exports/Loading-Indicator.md +0 -41
- package/data/zeroheight-exports/Navigation.md +0 -1190
- package/data/zeroheight-exports/Notification.md +0 -1038
- package/data/zeroheight-exports/Panel.md +0 -1030
- package/data/zeroheight-exports/README.md +0 -122
- package/data/zeroheight-exports/Responsive-Design.md +0 -330
- package/data/zeroheight-exports/Search-Input.md +0 -91
- package/data/zeroheight-exports/Search.md +0 -822
- package/data/zeroheight-exports/Segmented-Control.md +0 -609
- package/data/zeroheight-exports/Spacing.md +0 -297
- package/data/zeroheight-exports/Table.md +0 -5345
- package/data/zeroheight-exports/Tabs.md +0 -1324
- package/data/zeroheight-exports/Tags.md +0 -1545
- package/data/zeroheight-exports/Text-Link.md +0 -268
- package/data/zeroheight-exports/Theming.md +0 -362
- package/data/zeroheight-exports/Tooltips.md +0 -2015
- package/data/zeroheight-exports/Typography.md +0 -800
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
# Content Card
|
|
2
|
+
|
|
3
|
+
## Source Code
|
|
4
|
+
|
|
5
|
+
The component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/tree/main/packages/components/src/core/ContentCard).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import {
|
|
13
|
+
ContentCard,
|
|
14
|
+
ContentCardActions,
|
|
15
|
+
ContentCardBody,
|
|
16
|
+
} from "@czi-sds/components";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Code examples
|
|
20
|
+
|
|
21
|
+
### **Default Content Card**
|
|
22
|
+
|
|
23
|
+
This example has the minimum props needed for the ContentCard component. `visualElementType` is the only required prop, and it must be set even when the card has no visual.
|
|
24
|
+
|
|
25
|
+
**Example: DefaultContentCard**
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
// Most minimal ContentCard: visualElementType is the only required prop
|
|
29
|
+
|
|
30
|
+
import { ContentCard, ContentCardBody } from "@czi-sds/components";
|
|
31
|
+
|
|
32
|
+
function App() {
|
|
33
|
+
return (
|
|
34
|
+
<div className="app">
|
|
35
|
+
<ContentCard
|
|
36
|
+
visualElementType="none"
|
|
37
|
+
titleText="Content Card title"
|
|
38
|
+
subtitleText="A subtitle that sits under the title"
|
|
39
|
+
>
|
|
40
|
+
<ContentCardBody>
|
|
41
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus
|
|
42
|
+
facilisis tortor et pellentesque pulvinar. Ut at convallis ipsum.
|
|
43
|
+
</ContentCardBody>
|
|
44
|
+
</ContentCard>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default App;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Text slots
|
|
53
|
+
|
|
54
|
+
This example shows the four text props and the order they render in, with body copy passed as children.
|
|
55
|
+
|
|
56
|
+
**Example: ContentCardTextSlots**
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
// The four text slots, in the order they are rendered
|
|
60
|
+
|
|
61
|
+
import { ContentCard, ContentCardBody } from "@czi-sds/components";
|
|
62
|
+
|
|
63
|
+
function App() {
|
|
64
|
+
return (
|
|
65
|
+
<div className="app">
|
|
66
|
+
<ContentCard
|
|
67
|
+
visualElementType="none"
|
|
68
|
+
overlineText="Overline"
|
|
69
|
+
titleText="Content Card title"
|
|
70
|
+
subtitleText="Subtitle"
|
|
71
|
+
metadataText="Metadata, such as a date or an author"
|
|
72
|
+
>
|
|
73
|
+
<ContentCardBody>
|
|
74
|
+
Anything passed as children renders below the text slots. Wrap plain
|
|
75
|
+
copy in ContentCardBody so it picks up the card's body styling.
|
|
76
|
+
</ContentCardBody>
|
|
77
|
+
</ContentCard>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default App;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Content Card with an image
|
|
86
|
+
|
|
87
|
+
This example shows an image card in both image positions. The `image` prop takes either a URL string or a CardMedia element, `imageSize` sets the width of the image area, and `imagePadding` insets the image instead of letting it meet the card border.
|
|
88
|
+
|
|
89
|
+
**Example: ContentCardWithAnImage**
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { ContentCard, ContentCardBody } from "@czi-sds/components";
|
|
93
|
+
|
|
94
|
+
// Inline placeholder so the example does not depend on a remote image
|
|
95
|
+
const IMAGE =
|
|
96
|
+
"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><rect width='300' height='300' fill='rgb(207,212,220)'/></svg>";
|
|
97
|
+
|
|
98
|
+
function App() {
|
|
99
|
+
return (
|
|
100
|
+
<div
|
|
101
|
+
className="app"
|
|
102
|
+
style={{ display: "flex", flexDirection: "column", gap: "32px" }}
|
|
103
|
+
>
|
|
104
|
+
<ContentCard
|
|
105
|
+
visualElementType="image"
|
|
106
|
+
image={IMAGE}
|
|
107
|
+
imageSize={200}
|
|
108
|
+
titleText="Image on the left"
|
|
109
|
+
subtitleText="The default image position"
|
|
110
|
+
>
|
|
111
|
+
<ContentCardBody>
|
|
112
|
+
Pass image either a URL string or a CardMedia element. imageSize sets
|
|
113
|
+
the width of the image area in pixels.
|
|
114
|
+
</ContentCardBody>
|
|
115
|
+
</ContentCard>
|
|
116
|
+
|
|
117
|
+
<ContentCard
|
|
118
|
+
visualElementType="image"
|
|
119
|
+
image={IMAGE}
|
|
120
|
+
imageSize={200}
|
|
121
|
+
imagePosition="right"
|
|
122
|
+
imagePadding
|
|
123
|
+
titleText="Image on the right, with padding"
|
|
124
|
+
subtitleText="imagePosition and imagePadding"
|
|
125
|
+
>
|
|
126
|
+
<ContentCardBody>
|
|
127
|
+
imagePadding insets the image from the edge of the card instead of
|
|
128
|
+
letting it bleed to the border.
|
|
129
|
+
</ContentCardBody>
|
|
130
|
+
</ContentCard>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export default App;
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Content Card with an icon
|
|
139
|
+
|
|
140
|
+
This example swaps the image for an icon. The `image` and `icon` props are mutually exclusive, and which one is available follows `visualElementType`.
|
|
141
|
+
|
|
142
|
+
**Example: ContentCardWithAnIcon**
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import { ContentCard, ContentCardBody, Icon } from "@czi-sds/components";
|
|
146
|
+
|
|
147
|
+
function App() {
|
|
148
|
+
return (
|
|
149
|
+
<div className="app">
|
|
150
|
+
<ContentCard
|
|
151
|
+
visualElementType="icon"
|
|
152
|
+
icon={<Icon sdsIcon="Compass" sdsSize="xl" />}
|
|
153
|
+
titleText="Icon instead of an image"
|
|
154
|
+
subtitleText="The icon sits to the left of the content"
|
|
155
|
+
>
|
|
156
|
+
<ContentCardBody>
|
|
157
|
+
Set visualElementType to icon and pass any Icon element. The icon and
|
|
158
|
+
image props are mutually exclusive.
|
|
159
|
+
</ContentCardBody>
|
|
160
|
+
</ContentCard>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export default App;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Narrow Content Card
|
|
169
|
+
|
|
170
|
+
This example shows the narrow layout, which stacks the visual above the content and suits card grids. A wide card also switches to this layout on its own once it is rendered below roughly 595px.
|
|
171
|
+
|
|
172
|
+
**Example: NarrowContentCard**
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
// Narrow cards stack the visual above the content, which suits card grids
|
|
176
|
+
|
|
177
|
+
import { ContentCard, ContentCardBody } from "@czi-sds/components";
|
|
178
|
+
|
|
179
|
+
const IMAGE =
|
|
180
|
+
"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><rect width='300' height='300' fill='rgb(207,212,220)'/></svg>";
|
|
181
|
+
|
|
182
|
+
function App() {
|
|
183
|
+
return (
|
|
184
|
+
<div className="app" style={{ display: "flex", gap: "32px" }}>
|
|
185
|
+
<ContentCard
|
|
186
|
+
sdsType="narrow"
|
|
187
|
+
visualElementType="image"
|
|
188
|
+
image={IMAGE}
|
|
189
|
+
imageSize={140}
|
|
190
|
+
titleText="First card"
|
|
191
|
+
subtitleText="Subtitle"
|
|
192
|
+
style={{ width: "260px" }}
|
|
193
|
+
>
|
|
194
|
+
<ContentCardBody>
|
|
195
|
+
A card also switches to the narrow layout on its own once it is
|
|
196
|
+
rendered below roughly 595px wide.
|
|
197
|
+
</ContentCardBody>
|
|
198
|
+
</ContentCard>
|
|
199
|
+
|
|
200
|
+
<ContentCard
|
|
201
|
+
sdsType="narrow"
|
|
202
|
+
visualElementType="image"
|
|
203
|
+
image={IMAGE}
|
|
204
|
+
imageSize={140}
|
|
205
|
+
titleText="Second card"
|
|
206
|
+
subtitleText="Subtitle"
|
|
207
|
+
style={{ width: "260px" }}
|
|
208
|
+
>
|
|
209
|
+
<ContentCardBody>
|
|
210
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus
|
|
211
|
+
facilisis tortor et pellentesque pulvinar.
|
|
212
|
+
</ContentCardBody>
|
|
213
|
+
</ContentCard>
|
|
214
|
+
</div>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export default App;
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Content Card with actions
|
|
222
|
+
|
|
223
|
+
This example adds a button row through ContentCardActions, which accepts SDS Button elements only. Alignment comes from `buttonsPosition` on the card.
|
|
224
|
+
|
|
225
|
+
**Example: ContentCardWithActions**
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
// ContentCardActions only accepts SDS Button elements
|
|
229
|
+
|
|
230
|
+
import {
|
|
231
|
+
Button,
|
|
232
|
+
ContentCard,
|
|
233
|
+
ContentCardActions,
|
|
234
|
+
ContentCardBody,
|
|
235
|
+
} from "@czi-sds/components";
|
|
236
|
+
|
|
237
|
+
function App() {
|
|
238
|
+
return (
|
|
239
|
+
<div className="app">
|
|
240
|
+
<ContentCard
|
|
241
|
+
visualElementType="none"
|
|
242
|
+
buttonsPosition="right"
|
|
243
|
+
titleText="Card with actions"
|
|
244
|
+
subtitleText="buttonsPosition aligns the button row"
|
|
245
|
+
>
|
|
246
|
+
<ContentCardBody>
|
|
247
|
+
Buttons belong in ContentCardActions, which the card positions for
|
|
248
|
+
you. Anything that is not an SDS Button is dropped with a warning.
|
|
249
|
+
</ContentCardBody>
|
|
250
|
+
|
|
251
|
+
<ContentCardActions>
|
|
252
|
+
<Button sdsStyle="minimal" sdsType="primary">
|
|
253
|
+
Secondary action
|
|
254
|
+
</Button>
|
|
255
|
+
<Button sdsStyle="solid" sdsType="primary">
|
|
256
|
+
Primary action
|
|
257
|
+
</Button>
|
|
258
|
+
</ContentCardActions>
|
|
259
|
+
</ContentCard>
|
|
260
|
+
</div>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export default App;
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Clickable Content Card
|
|
268
|
+
|
|
269
|
+
This example makes the whole card a single click target. `clickableCardProps` is forwarded to the wrapper, so the card can act as a link, and only the first button in ContentCardActions survives, since a button cannot be nested inside another button.
|
|
270
|
+
|
|
271
|
+
**Example: ClickableContentCard**
|
|
272
|
+
|
|
273
|
+
```tsx
|
|
274
|
+
// A clickable card is a single button, so it holds at most one action button
|
|
275
|
+
|
|
276
|
+
import {
|
|
277
|
+
Button,
|
|
278
|
+
ContentCard,
|
|
279
|
+
ContentCardActions,
|
|
280
|
+
ContentCardBody,
|
|
281
|
+
Icon,
|
|
282
|
+
} from "@czi-sds/components";
|
|
283
|
+
|
|
284
|
+
function App() {
|
|
285
|
+
return (
|
|
286
|
+
<div className="app">
|
|
287
|
+
<ContentCard
|
|
288
|
+
visualElementType="none"
|
|
289
|
+
clickableCard
|
|
290
|
+
clickableCardProps={{
|
|
291
|
+
href: "https://sds.czi.design",
|
|
292
|
+
target: "_blank",
|
|
293
|
+
}}
|
|
294
|
+
titleText="The whole card is clickable"
|
|
295
|
+
subtitleText="clickableCard also forces boundingBox on"
|
|
296
|
+
>
|
|
297
|
+
<ContentCardBody>
|
|
298
|
+
clickableCardProps is forwarded to the wrapper, so the card can behave
|
|
299
|
+
as a link. Only the first button in ContentCardActions is kept, since
|
|
300
|
+
a button cannot be nested inside another button.
|
|
301
|
+
</ContentCardBody>
|
|
302
|
+
|
|
303
|
+
<ContentCardActions>
|
|
304
|
+
<Button
|
|
305
|
+
sdsStyle="minimal"
|
|
306
|
+
sdsType="primary"
|
|
307
|
+
endIcon={<Icon sdsIcon="ChevronRight" sdsSize="xs" />}
|
|
308
|
+
>
|
|
309
|
+
Learn more
|
|
310
|
+
</Button>
|
|
311
|
+
</ContentCardActions>
|
|
312
|
+
</ContentCard>
|
|
313
|
+
</div>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export default App;
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Bounding box and decorative border
|
|
321
|
+
|
|
322
|
+
This example shows the two framing options: the accent bar added by `decorativeBorder`, and a card with `boundingBox` turned off so it sits directly on the page.
|
|
323
|
+
|
|
324
|
+
**Example: ContentCardBoundingBox**
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
import { ContentCard, ContentCardBody } from "@czi-sds/components";
|
|
328
|
+
|
|
329
|
+
function App() {
|
|
330
|
+
return (
|
|
331
|
+
<div
|
|
332
|
+
className="app"
|
|
333
|
+
style={{ display: "flex", flexDirection: "column", gap: "32px" }}
|
|
334
|
+
>
|
|
335
|
+
<ContentCard
|
|
336
|
+
visualElementType="none"
|
|
337
|
+
decorativeBorder
|
|
338
|
+
titleText="Decorative border"
|
|
339
|
+
subtitleText="An accent bar on the leading edge"
|
|
340
|
+
>
|
|
341
|
+
<ContentCardBody>
|
|
342
|
+
decorativeBorder draws an accent bar down the left edge of a wide card
|
|
343
|
+
and across the top of a narrow one. It needs boundingBox to be on.
|
|
344
|
+
</ContentCardBody>
|
|
345
|
+
</ContentCard>
|
|
346
|
+
|
|
347
|
+
<ContentCard
|
|
348
|
+
visualElementType="none"
|
|
349
|
+
boundingBox={false}
|
|
350
|
+
titleText="No bounding box"
|
|
351
|
+
subtitleText="The card sits directly on the page"
|
|
352
|
+
>
|
|
353
|
+
<ContentCardBody>
|
|
354
|
+
Turning boundingBox off removes the border, background, and padding,
|
|
355
|
+
which suits cards that are already inside a bounded surface.
|
|
356
|
+
</ContentCardBody>
|
|
357
|
+
</ContentCard>
|
|
358
|
+
</div>
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export default App;
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Anatomy
|
|
366
|
+
|
|
367
|
+
A ContentCard takes its text through props rather than through composition: `overlineText`, `titleText`, `subtitleText`, and `metadataText` are rendered in that order, each with its own styling. Children are for everything below that text block.
|
|
368
|
+
|
|
369
|
+
Alongside the card itself, the package exports the pieces used to fill those children:
|
|
370
|
+
|
|
371
|
+
- `ContentCardBody`: wraps body copy so it picks up the card's body styling.
|
|
372
|
+
|
|
373
|
+
- `ContentCardActions`: holds the card's buttons. It accepts SDS Button elements only, and anything else is dropped with a warning. The card injects `buttonsPosition` into it, so alignment is set on the card rather than here.
|
|
374
|
+
|
|
375
|
+
- `ContentCardMedia`: MUI's CardMedia, re-exported for building an image element by hand instead of passing a URL to the `image` prop.
|
|
376
|
+
|
|
377
|
+
- `ContentCardOverline`, `ContentCardTitle`, `ContentCardSubtitle`, `ContentCardMetadata`: the styled text elements the card uses internally, exported for reuse in custom layouts. Prefer the matching props for ordinary cards.
|
|
378
|
+
|
|
379
|
+
## MUI Documentation
|
|
380
|
+
|
|
381
|
+
Documentation for the underlying MUI Card component can be found [here](https://mui.com/material-ui/react-card/).
|
|
382
|
+
|
|
383
|
+
## Props
|
|
384
|
+
|
|
385
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
386
|
+
|
|
387
|
+
| Name | Type | Default | Description |
|
|
388
|
+
| -------------------- | -------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
389
|
+
| `visualElementType` | `"image" \| "icon" \| "none"` | `"none"` | **Required.** Specifies what type of visual element to render on the card: an image, an icon, or none. It also narrows which visual props are accepted, so image props are only available on an image card and icon on an icon card. |
|
|
390
|
+
| `boundingBox` | `boolean` | `true` | If `true`, wraps content and visuals inside a bounded layout with background and padding. It is forced on when `clickableCard` is `true`. |
|
|
391
|
+
| `buttonsPosition` | `"left" \|"right"` | `"left"` | Determines the alignment of buttons in the ContentCardActions component. |
|
|
392
|
+
| `classes` | `object` | - | Custom class names for different card sub-sections (e.g., `cardPaper`, `cardTitle`, `cardActions`, etc.). Could be used to style the component with TailwindCss. Full list of available class names are:`cardPaper`, `cardContent`, `cardHeader`, `cardMedia`, `cardOverline`, `cardTitle`, `cardSubtitle`, `cardMetadata`, `cardActions`, `clickableCardButton` |
|
|
393
|
+
| `decorativeBorder` | `boolean` | `false` | If `true`, draws an accent bar along the leading edge of the card: down the left side of a wide card, across the top of a narrow one. It requires `boundingBox`, and on an image card it only appears when the image is on the right, or on the left with `imagePadding`. |
|
|
394
|
+
| `children` | `ReactNode` | - | The content to be displayed inside the card body, including custom components and ContentCardActions. |
|
|
395
|
+
| `clickableCard` | `boolean` | `false` | If `true`, wraps the card with an action area and makes it clickable. Because the card then is a button, ContentCardActions keeps only its first button and renders it as a `div`. |
|
|
396
|
+
| `clickableCardProps` | `Partial<ButtonProps & { target?: string }>` | - | Props forwarded to the clickable card wrapper when `clickableCard` is `true`, including `href` and `target` to make the whole card a link. |
|
|
397
|
+
| `icon` | `ReactNode` | - | The icon displayed in the card when `visualElementType` is `"icon"`. |
|
|
398
|
+
| `image` | `ReactNode` | - | The image displayed in the card when `visualElementType` is `"image"`. |
|
|
399
|
+
| `imagePadding` | `boolean` | `false` | If `true`, applies padding around the image inside the card. |
|
|
400
|
+
| `imagePosition` | `"left" \| "right"` | `"left"` | Position of the image in the card layout (`"left"` or `"right"`). |
|
|
401
|
+
| `imageSize` | `number` | `300` | Width of the image area in pixels when `visualElementType` is `"image"`. |
|
|
402
|
+
| `metadataText` | `ReactNode` | - | Optional metadata text, usually used for extra context like date or author. |
|
|
403
|
+
| `overlineText` | `ReactNode` | - | A small overline text displayed above the title. |
|
|
404
|
+
| `sdsType` | `"wide" \| "narrow"` | `"wide"` | Determines the card layout style. `"wide"` shows the image and content side by side, `"narrow"` stacks them vertically. The card watches its own width and switches to narrow on its own once it drops below roughly 595px, so this prop sets the layout it uses when there is room. |
|
|
405
|
+
| `subtitleText` | `ReactNode` | - | Optional subtitle text displayed below the title. |
|
|
406
|
+
| `titleText` | `ReactNode` | - | The main title text of the card. |
|