@roadlittledawn/docs-design-system-react 0.12.0 → 0.12.1
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/USAGE.md
CHANGED
|
@@ -134,6 +134,7 @@ import { Card } from "@roadlittledawn/docs-design-system-react";
|
|
|
134
134
|
| `href` | `string` | — | Optional link URL. When provided, the entire card becomes clickable |
|
|
135
135
|
| `icon` | `ReactNode` | — | Optional icon to display. Pass a rendered icon component. In MDX, the consuming site's component map resolves string names to rendered components before passing here. |
|
|
136
136
|
| `iconPlacement` | `"left" \| "top-left" \| "top-center"` | `"top-left"` | Where to place the icon: vertically centered on the left, above content flush left, or above content centered |
|
|
137
|
+
| `iconSize` | `string` | — | Override the icon container size (width and height). Accepts any valid CSS length (e.g. `"2rem"`, `"48px"`). Defaults to `--dds-card-icon-size` (`1.5rem`). |
|
|
137
138
|
| `showArrow` | `boolean` | `false` | Show an animated arrow in the lower-right corner to signal the card is navigable. Best used with `href`. |
|
|
138
139
|
| `children` | `ReactNode` | — | Card content |
|
|
139
140
|
| `className` | `string` | `""` | Additional CSS classes |
|
|
@@ -161,6 +162,11 @@ import { Card } from "@roadlittledawn/docs-design-system-react";
|
|
|
161
162
|
Read guides, tutorials, and API references.
|
|
162
163
|
</Card>
|
|
163
164
|
|
|
165
|
+
{/* Card with custom icon size (48px container) */}
|
|
166
|
+
<Card title="Documentation" icon={<YourIcon />} iconPlacement="top-left" iconSize="3rem">
|
|
167
|
+
Icon container overridden to 48px × 48px.
|
|
168
|
+
</Card>
|
|
169
|
+
|
|
164
170
|
{/* Colored background */}
|
|
165
171
|
<Card title="New Feature" titleColor="blue" backgroundColor="blue">
|
|
166
172
|
Check out our latest component additions.
|
|
@@ -28,6 +28,11 @@ export interface CardProps {
|
|
|
28
28
|
* @default 'top-left'
|
|
29
29
|
*/
|
|
30
30
|
iconPlacement?: "left" | "top-left" | "top-center";
|
|
31
|
+
/**
|
|
32
|
+
* Override the icon container size (width and height). Accepts any valid CSS length value (e.g. `"2rem"`, `"48px"`).
|
|
33
|
+
* Defaults to the `--dds-card-icon-size` token (`1.5rem`).
|
|
34
|
+
*/
|
|
35
|
+
iconSize?: string;
|
|
31
36
|
/**
|
|
32
37
|
* Show an animated arrow in the lower-right corner to signal the card is navigable.
|
|
33
38
|
* Best used together with `href`. The arrow animates with a springy motion on hover.
|
|
@@ -39,4 +44,4 @@ export interface CardProps {
|
|
|
39
44
|
/** Additional CSS classes */
|
|
40
45
|
className?: string;
|
|
41
46
|
}
|
|
42
|
-
export declare function Card({ title, titleColor, backgroundColor, href, icon, iconPlacement, showArrow, children, className, }: CardProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export declare function Card({ title, titleColor, backgroundColor, href, icon, iconPlacement, iconSize, showArrow, children, className, }: CardProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/components/Card.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
13
|
export function Card(_a) {
|
|
3
|
-
var title = _a.title, _b = _a.titleColor, titleColor = _b === void 0 ? "gray" : _b, _c = _a.backgroundColor, backgroundColor = _c === void 0 ? "white" : _c, href = _a.href, icon = _a.icon, _d = _a.iconPlacement, iconPlacement = _d === void 0 ? "top-left" : _d, _e = _a.showArrow, showArrow = _e === void 0 ? false : _e, children = _a.children, _f = _a.className, className = _f === void 0 ? "" : _f;
|
|
14
|
+
var title = _a.title, _b = _a.titleColor, titleColor = _b === void 0 ? "gray" : _b, _c = _a.backgroundColor, backgroundColor = _c === void 0 ? "white" : _c, href = _a.href, icon = _a.icon, _d = _a.iconPlacement, iconPlacement = _d === void 0 ? "top-left" : _d, iconSize = _a.iconSize, _e = _a.showArrow, showArrow = _e === void 0 ? false : _e, children = _a.children, _f = _a.className, className = _f === void 0 ? "" : _f;
|
|
4
15
|
var cardClasses = [
|
|
5
16
|
"dds-card",
|
|
6
17
|
"dds-card-bg-".concat(backgroundColor),
|
|
@@ -19,7 +30,7 @@ export function Card(_a) {
|
|
|
19
30
|
iconPlacement === "top-center" ? "dds-card-icon-top-center" : "",
|
|
20
31
|
]
|
|
21
32
|
.filter(Boolean)
|
|
22
|
-
.join(" "), "aria-hidden": "true", children: icon })) : null;
|
|
33
|
+
.join(" "), style: __assign({}, (iconSize && { width: iconSize, height: iconSize })), "aria-hidden": "true", children: icon })) : null;
|
|
23
34
|
var arrowEl = showArrow ? (_jsx("span", { className: "dds-card-arrow", "aria-hidden": "true", children: _jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M2 8H14M10 4L14 8L10 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) })) : null;
|
|
24
35
|
var bodyContent = icon && iconPlacement === "left" ? (_jsxs("div", { className: "dds-card-icon-row", children: [iconEl, _jsxs("div", { className: "dds-card-icon-content", children: [title && _jsx("h3", { className: titleClasses, children: title }), _jsx("div", { className: textClasses, children: children })] })] })) : (_jsxs(_Fragment, { children: [iconEl, title && _jsx("h3", { className: titleClasses, children: title }), _jsx("div", { className: textClasses, children: children })] }));
|
|
25
36
|
var content = (_jsxs("div", { className: cardClasses, children: [bodyContent, arrowEl] }));
|
|
@@ -46,6 +46,11 @@ export declare const NoTitle: Story;
|
|
|
46
46
|
* All icon placement variants side by side.
|
|
47
47
|
*/
|
|
48
48
|
export declare const IconPlacements: Story;
|
|
49
|
+
/**
|
|
50
|
+
* Cards with a custom icon size using the `iconSize` prop.
|
|
51
|
+
* Use any valid CSS length value (e.g. `"2rem"`, `"48px"`).
|
|
52
|
+
*/
|
|
53
|
+
export declare const WithCustomIconSize: Story;
|
|
49
54
|
/**
|
|
50
55
|
* All title color variants.
|
|
51
56
|
*/
|
|
@@ -38,6 +38,10 @@ var meta = {
|
|
|
38
38
|
description: 'Placement of the icon within the card.',
|
|
39
39
|
table: { defaultValue: { summary: "'top-left'" } },
|
|
40
40
|
},
|
|
41
|
+
iconSize: {
|
|
42
|
+
control: 'text',
|
|
43
|
+
description: 'Override the icon container size (width and height, e.g. "2rem", "48px"). Defaults to the --dds-card-icon-size token (1.5rem).',
|
|
44
|
+
},
|
|
41
45
|
showArrow: {
|
|
42
46
|
control: 'boolean',
|
|
43
47
|
description: 'Show an animated arrow in the lower-right corner to signal the card is navigable.',
|
|
@@ -235,6 +239,20 @@ export var IconPlacements = {
|
|
|
235
239
|
},
|
|
236
240
|
render: function () { return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '1rem' }, children: [_jsx(Card, { title: "Icon Left", icon: _jsx(DemoIcon, {}), iconPlacement: "left", children: _jsx("span", { style: { color: 'var(--dds-card-text-gray)' }, children: "Icon is centered vertically beside the content." }) }), _jsx(Card, { title: "Icon Top Left", icon: _jsx(DemoIcon, {}), iconPlacement: "top-left", children: _jsx("span", { style: { color: 'var(--dds-card-text-gray)' }, children: "Icon sits above the title, flush left." }) }), _jsx(Card, { title: "Icon Top Center", icon: _jsx(DemoIcon, {}), iconPlacement: "top-center", children: _jsx("span", { style: { color: 'var(--dds-card-text-gray)' }, children: "Icon sits above the title, horizontally centered." }) })] })); },
|
|
237
241
|
};
|
|
242
|
+
/**
|
|
243
|
+
* Cards with a custom icon size using the `iconSize` prop.
|
|
244
|
+
* Use any valid CSS length value (e.g. `"2rem"`, `"48px"`).
|
|
245
|
+
*/
|
|
246
|
+
export var WithCustomIconSize = {
|
|
247
|
+
parameters: {
|
|
248
|
+
docs: {
|
|
249
|
+
source: {
|
|
250
|
+
code: "{/* 48px icon container */}\n<Card title=\"Large Icon\" icon={<YourIcon />} iconPlacement=\"top-left\" iconSize=\"3rem\">\n Icon container is 48px \u00D7 48px (3rem).\n</Card>\n\n{/* 16px icon container */}\n<Card title=\"Small Icon\" icon={<YourIcon />} iconPlacement=\"left\" iconSize=\"1rem\">\n Icon container is 16px \u00D7 16px (1rem).\n</Card>",
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
render: function () { return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '1rem' }, children: [_jsx(Card, { title: "Large Icon", icon: _jsx(DemoIcon, {}), iconPlacement: "top-left", iconSize: "3rem", children: _jsx("span", { style: { color: 'var(--dds-card-text-gray)' }, children: "Icon container is 48px \u00D7 48px (3rem)." }) }), _jsx(Card, { title: "Small Icon", icon: _jsx(DemoIcon, {}), iconPlacement: "left", iconSize: "1rem", children: _jsx("span", { style: { color: 'var(--dds-card-text-gray)' }, children: "Icon container is 16px \u00D7 16px (1rem)." }) })] })); },
|
|
255
|
+
};
|
|
238
256
|
/**
|
|
239
257
|
* All title color variants.
|
|
240
258
|
*/
|