@roadlittledawn/docs-design-system-react 0.12.0 → 0.12.2
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 +20 -4
- package/dist/components/Card.d.ts +6 -1
- package/dist/components/Card.js +13 -2
- package/dist/components/Card.stories.d.ts +5 -0
- package/dist/components/Card.stories.js +18 -0
- package/dist/components/List.d.ts +1 -1
- package/dist/components/List.js +7 -3
- package/dist/styles.css +32 -15
- package/package.json +1 -1
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.
|
|
@@ -523,10 +529,20 @@ import { List } from "@roadlittledawn/docs-design-system-react";
|
|
|
523
529
|
|
|
524
530
|
### List.Item Props
|
|
525
531
|
|
|
526
|
-
| Prop
|
|
527
|
-
|
|
|
528
|
-
| `children`
|
|
529
|
-
| `className`
|
|
532
|
+
| Prop | Type | Default | Description |
|
|
533
|
+
| ------------ | ----------- | ------- | --------------------------------------------------------------------------- |
|
|
534
|
+
| `children` | `ReactNode` | — | List item content |
|
|
535
|
+
| `className` | `string` | `""` | Additional CSS classes |
|
|
536
|
+
| `bulletIcon` | `ReactNode` | — | Custom bullet icon for this item. Overrides the parent `List`'s `bulletIcon` |
|
|
537
|
+
|
|
538
|
+
### CSS classes
|
|
539
|
+
|
|
540
|
+
| Class | Element | Notes |
|
|
541
|
+
| ----- | ------- | ----- |
|
|
542
|
+
| `dds-list` | `<ol>` / `<ul>` | Root list element |
|
|
543
|
+
| `dds-list-item` | `<li>` | Each list item |
|
|
544
|
+
| `dds-list-item-content` | `<div>` | Wraps item children; target for content-level overrides |
|
|
545
|
+
| `dds-list-item-icon` | `<span>` | Wrapper for custom `bulletIcon` SVG/node |
|
|
530
546
|
|
|
531
547
|
### Examples
|
|
532
548
|
|
|
@@ -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
|
*/
|
|
@@ -16,7 +16,7 @@ export interface ListItemProps {
|
|
|
16
16
|
children: ReactNode;
|
|
17
17
|
/** Additional CSS classes */
|
|
18
18
|
className?: string;
|
|
19
|
-
/**
|
|
19
|
+
/** Custom bullet icon (React node, e.g., SVG) for this item. Overrides the parent List's bulletIcon */
|
|
20
20
|
bulletIcon?: ReactNode;
|
|
21
21
|
}
|
|
22
22
|
export declare function ListItem({ children, className, bulletIcon }: ListItemProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/components/List.js
CHANGED
|
@@ -15,12 +15,16 @@ function ListImpl(_a) {
|
|
|
15
15
|
var children = _a.children, _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.ordered, ordered = _c === void 0 ? true : _c, bullet = _a.bullet, bulletIcon = _a.bulletIcon;
|
|
16
16
|
var listClasses = ["dds-list", className].filter(Boolean).join(" ");
|
|
17
17
|
var Element = ordered ? "ol" : "ul";
|
|
18
|
-
return (_jsx(Element, { className: listClasses, "data-ordered": ordered,
|
|
18
|
+
return (_jsx(Element, { className: listClasses, "data-ordered": ordered, style: bullet && !bulletIcon
|
|
19
19
|
? { "--dds-list-bullet": JSON.stringify(bullet) }
|
|
20
20
|
: undefined, children: bulletIcon && !ordered
|
|
21
21
|
? React.Children.map(children, function (child) {
|
|
22
|
+
var _a;
|
|
22
23
|
if (React.isValidElement(child) && child.type === ListItem) {
|
|
23
|
-
|
|
24
|
+
var childProps = child.props;
|
|
25
|
+
return React.cloneElement(child, __assign(__assign({}, childProps), {
|
|
26
|
+
// Child's own bulletIcon takes precedence over the parent's
|
|
27
|
+
bulletIcon: (_a = childProps.bulletIcon) !== null && _a !== void 0 ? _a : bulletIcon }));
|
|
24
28
|
}
|
|
25
29
|
return child;
|
|
26
30
|
})
|
|
@@ -29,7 +33,7 @@ function ListImpl(_a) {
|
|
|
29
33
|
export function ListItem(_a) {
|
|
30
34
|
var children = _a.children, _b = _a.className, className = _b === void 0 ? "" : _b, bulletIcon = _a.bulletIcon;
|
|
31
35
|
var itemClasses = ["dds-list-item", className].filter(Boolean).join(" ");
|
|
32
|
-
return (_jsxs("li", { className: itemClasses, children: [bulletIcon && (_jsx("span", { className: "dds-list-item-icon", "aria-hidden": "true", children: bulletIcon })), children] }));
|
|
36
|
+
return (_jsxs("li", { className: itemClasses, "data-has-icon": bulletIcon ? "true" : undefined, children: [bulletIcon && (_jsx("span", { className: "dds-list-item-icon", "aria-hidden": "true", children: bulletIcon })), _jsx("div", { className: "dds-list-item-content", children: children })] }));
|
|
33
37
|
}
|
|
34
38
|
export var List = Object.assign(ListImpl, {
|
|
35
39
|
Item: ListItem,
|
package/dist/styles.css
CHANGED
|
@@ -1745,7 +1745,9 @@ a.no-text-decoration {
|
|
|
1745
1745
|
.dds-list-item {
|
|
1746
1746
|
counter-increment: list-counter;
|
|
1747
1747
|
position: relative;
|
|
1748
|
-
|
|
1748
|
+
display: flex;
|
|
1749
|
+
align-items: flex-start;
|
|
1750
|
+
gap: 1rem;
|
|
1749
1751
|
margin-bottom: var(--dds-list-item-margin-bottom, 1.5rem);
|
|
1750
1752
|
min-height: var(--dds-list-badge-size);
|
|
1751
1753
|
}
|
|
@@ -1767,13 +1769,10 @@ a.no-text-decoration {
|
|
|
1767
1769
|
/* Ordered list badges */
|
|
1768
1770
|
.dds-list[data-ordered="true"] .dds-list-item::before {
|
|
1769
1771
|
content: counter(list-counter);
|
|
1770
|
-
|
|
1771
|
-
left: 0;
|
|
1772
|
-
top: 0;
|
|
1772
|
+
flex-shrink: 0;
|
|
1773
1773
|
width: var(--dds-list-badge-size, 2.5rem);
|
|
1774
1774
|
height: var(--dds-list-badge-size, 2.5rem);
|
|
1775
1775
|
line-height: var(--dds-line-height-relaxed);
|
|
1776
|
-
inset-inline-start: 0;
|
|
1777
1776
|
display: flex;
|
|
1778
1777
|
align-items: center;
|
|
1779
1778
|
justify-content: center;
|
|
@@ -1787,27 +1786,24 @@ a.no-text-decoration {
|
|
|
1787
1786
|
/* Unordered list bullets */
|
|
1788
1787
|
.dds-list[data-ordered="false"] .dds-list-item::before {
|
|
1789
1788
|
content: var(--dds-list-bullet, "•");
|
|
1790
|
-
|
|
1791
|
-
left: 0;
|
|
1792
|
-
top: 0;
|
|
1789
|
+
flex-shrink: 0;
|
|
1793
1790
|
width: var(--dds-list-badge-size, 2.5rem);
|
|
1794
1791
|
height: var(--dds-list-badge-size, 2.5rem);
|
|
1795
|
-
inset-inline-start: 0;
|
|
1796
1792
|
display: flex;
|
|
1793
|
+
transform: translateY(var(--dds-list-bullet-offset, -0.1em));
|
|
1797
1794
|
align-items: center;
|
|
1798
1795
|
justify-content: center;
|
|
1799
|
-
font-size: var(--dds-list-bullet-size, 1.
|
|
1796
|
+
font-size: var(--dds-list-bullet-size, 1.25rem);
|
|
1800
1797
|
color: var(--dds-list-badge-text);
|
|
1801
1798
|
}
|
|
1802
|
-
/* Hide ::before when
|
|
1803
|
-
|
|
1799
|
+
/* Hide ::before when item has a custom icon.
|
|
1800
|
+
Specificity matches the show rules above (0-3-1) and comes after, so it wins. */
|
|
1801
|
+
.dds-list .dds-list-item[data-has-icon="true"]::before {
|
|
1804
1802
|
display: none;
|
|
1805
1803
|
}
|
|
1806
1804
|
/* Custom icon bullet */
|
|
1807
1805
|
.dds-list-item-icon {
|
|
1808
|
-
|
|
1809
|
-
left: 0;
|
|
1810
|
-
top: 0;
|
|
1806
|
+
flex-shrink: 0;
|
|
1811
1807
|
width: var(--dds-list-badge-size, 2.5rem);
|
|
1812
1808
|
height: var(--dds-list-badge-size, 2.5rem);
|
|
1813
1809
|
display: flex;
|
|
@@ -1819,6 +1815,27 @@ a.no-text-decoration {
|
|
|
1819
1815
|
width: 1.25rem;
|
|
1820
1816
|
height: 1.25rem;
|
|
1821
1817
|
}
|
|
1818
|
+
/* Content wrapper — flex child that fills remaining space */
|
|
1819
|
+
.dds-list-item-content {
|
|
1820
|
+
flex: 1;
|
|
1821
|
+
min-width: 0;
|
|
1822
|
+
}
|
|
1823
|
+
/* Neutralize consuming-site typography margins that would misalign the badge.
|
|
1824
|
+
The list item's own margin/padding controls spacing — not the children's. */
|
|
1825
|
+
.dds-list-item-content > :first-child {
|
|
1826
|
+
margin-top: 0;
|
|
1827
|
+
}
|
|
1828
|
+
.dds-list-item-content > :last-child {
|
|
1829
|
+
margin-bottom: 0;
|
|
1830
|
+
}
|
|
1831
|
+
/* For unordered lists, vertically center the content within the li so the first
|
|
1832
|
+
text line's center aligns with the bullet/icon center.
|
|
1833
|
+
margin-block: auto distributes remaining space evenly above and below the
|
|
1834
|
+
content span, so its midpoint always lands at badge-size/2 — the same as the
|
|
1835
|
+
bullet center — regardless of font-size or line-height. */
|
|
1836
|
+
.dds-list[data-ordered="false"] .dds-list-item-content {
|
|
1837
|
+
margin-block: auto;
|
|
1838
|
+
}
|
|
1822
1839
|
/* ==========================================================================
|
|
1823
1840
|
Popover Component
|
|
1824
1841
|
Uses the native Popover API for top-layer rendering.
|