@roadlittledawn/docs-design-system-react 0.7.0 → 0.8.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/dist/components/Grid.d.ts +90 -0
- package/dist/components/Grid.js +95 -0
- package/dist/components/Grid.stories.d.ts +69 -0
- package/dist/components/Grid.stories.js +259 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/styles.css +116 -0
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** Breakpoint at which columns stack vertically */
|
|
3
|
+
type StackAt = 'sm' | 'md' | 'lg' | 'never';
|
|
4
|
+
/** Vertical alignment of column content */
|
|
5
|
+
type AlignItems = 'start' | 'center' | 'end' | 'stretch';
|
|
6
|
+
/** Configuration for a border or divider line */
|
|
7
|
+
export interface BorderConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Line thickness in pixels
|
|
10
|
+
* @default 1
|
|
11
|
+
*/
|
|
12
|
+
thickness?: number;
|
|
13
|
+
/** Line color (defaults to the `--dds-grid-divider-color` token) */
|
|
14
|
+
color?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface GridProps {
|
|
17
|
+
/**
|
|
18
|
+
* Number of equal columns, or an array of fractional widths
|
|
19
|
+
* (e.g. `[1, 2]` for a 1/3 + 2/3 split).
|
|
20
|
+
* @default 2
|
|
21
|
+
*/
|
|
22
|
+
columns?: number | number[];
|
|
23
|
+
/**
|
|
24
|
+
* Space between columns. Use `'sm'`, `'md'`, or `'lg'` for design-token sizes,
|
|
25
|
+
* or any valid CSS length string (e.g. `'16px'`, `'1.5rem'`, `'2em'`).
|
|
26
|
+
* @default 'md'
|
|
27
|
+
*/
|
|
28
|
+
gap?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Viewport breakpoint at which columns collapse to a single vertical stack.
|
|
31
|
+
* @default 'md'
|
|
32
|
+
*/
|
|
33
|
+
stackAt?: StackAt;
|
|
34
|
+
/**
|
|
35
|
+
* Vertical dividing line drawn between columns.
|
|
36
|
+
* Converts to a horizontal rule when the layout stacks.
|
|
37
|
+
*/
|
|
38
|
+
columnDivider?: BorderConfig;
|
|
39
|
+
/** Horizontal rule rendered above the grid. */
|
|
40
|
+
topBorder?: BorderConfig;
|
|
41
|
+
/** Horizontal rule rendered below the grid. */
|
|
42
|
+
bottomBorder?: BorderConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Vertical alignment of content within each column.
|
|
45
|
+
* @default 'stretch'
|
|
46
|
+
*/
|
|
47
|
+
align?: AlignItems;
|
|
48
|
+
/** Background color applied to the grid container. */
|
|
49
|
+
backgroundColor?: string;
|
|
50
|
+
/** Additional CSS classes applied to the grid wrapper. */
|
|
51
|
+
className?: string;
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
export interface ColumnProps {
|
|
55
|
+
/**
|
|
56
|
+
* How many grid columns this item should span.
|
|
57
|
+
* @default 1
|
|
58
|
+
*/
|
|
59
|
+
span?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Makes the column content sticky (`position: sticky; top: …`) while adjacent columns scroll.
|
|
62
|
+
* Useful for tutorial-style layouts with a persistent code panel.
|
|
63
|
+
* Automatically disabled when the grid stacks on mobile.
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
sticky?: boolean;
|
|
67
|
+
/** Background color applied to the column. */
|
|
68
|
+
backgroundColor?: string;
|
|
69
|
+
/** Additional CSS classes applied to the column wrapper. */
|
|
70
|
+
className?: string;
|
|
71
|
+
children: ReactNode;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Multi-column layout container for documentation pages.
|
|
75
|
+
* Supports equal and fractional column splits, configurable responsive stacking,
|
|
76
|
+
* optional column dividers, top/bottom borders, and background colours.
|
|
77
|
+
*
|
|
78
|
+
* Pair with `<Column>` children to control individual column behaviour.
|
|
79
|
+
*/
|
|
80
|
+
export declare function Grid({ columns, gap, stackAt, columnDivider, topBorder, bottomBorder, align, backgroundColor, className, children, }: GridProps): import("react/jsx-runtime").JSX.Element;
|
|
81
|
+
/**
|
|
82
|
+
* An individual column within a `<Grid>`.
|
|
83
|
+
*
|
|
84
|
+
* Use the `span` prop to make a column occupy more than one grid track, and
|
|
85
|
+
* `sticky` to keep the column content pinned while adjacent content scrolls.
|
|
86
|
+
* The column element itself always stretches to the full row height so that
|
|
87
|
+
* column dividers cover the entire row regardless of which column is taller.
|
|
88
|
+
*/
|
|
89
|
+
export declare function Column({ span, sticky, backgroundColor, className, children, }: ColumnProps): import("react/jsx-runtime").JSX.Element;
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
var GAP_TOKEN_MAP = {
|
|
14
|
+
sm: 'var(--dds-grid-gap-sm)',
|
|
15
|
+
md: 'var(--dds-grid-gap-md)',
|
|
16
|
+
lg: 'var(--dds-grid-gap-lg)',
|
|
17
|
+
};
|
|
18
|
+
var ALIGN_MAP = {
|
|
19
|
+
start: 'start',
|
|
20
|
+
center: 'center',
|
|
21
|
+
end: 'end',
|
|
22
|
+
stretch: 'stretch',
|
|
23
|
+
};
|
|
24
|
+
function resolveGap(gap) {
|
|
25
|
+
if (gap in GAP_TOKEN_MAP)
|
|
26
|
+
return GAP_TOKEN_MAP[gap];
|
|
27
|
+
return gap; // custom CSS length string, e.g. '16px', '1.5rem', '2em'
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Multi-column layout container for documentation pages.
|
|
31
|
+
* Supports equal and fractional column splits, configurable responsive stacking,
|
|
32
|
+
* optional column dividers, top/bottom borders, and background colours.
|
|
33
|
+
*
|
|
34
|
+
* Pair with `<Column>` children to control individual column behaviour.
|
|
35
|
+
*/
|
|
36
|
+
export function Grid(_a) {
|
|
37
|
+
var _b, _c, _d, _e, _f, _g;
|
|
38
|
+
var _h = _a.columns, columns = _h === void 0 ? 2 : _h, _j = _a.gap, gap = _j === void 0 ? 'md' : _j, _k = _a.stackAt, stackAt = _k === void 0 ? 'md' : _k, columnDivider = _a.columnDivider, topBorder = _a.topBorder, bottomBorder = _a.bottomBorder, _l = _a.align, align = _l === void 0 ? 'stretch' : _l, backgroundColor = _a.backgroundColor, _m = _a.className, className = _m === void 0 ? '' : _m, children = _a.children;
|
|
39
|
+
var columnTemplate = Array.isArray(columns)
|
|
40
|
+
? columns.map(function (n) { return "".concat(n, "fr"); }).join(' ')
|
|
41
|
+
: "repeat(".concat(columns, ", 1fr)");
|
|
42
|
+
var style = __assign(__assign(__assign(__assign({ '--dds-grid-template-columns': columnTemplate, '--dds-grid-gap': resolveGap(gap), '--dds-grid-align': ALIGN_MAP[align] }, (backgroundColor ? { backgroundColor: backgroundColor } : {})), (topBorder
|
|
43
|
+
? {
|
|
44
|
+
'--dds-grid-top-border-thickness': "".concat((_b = topBorder.thickness) !== null && _b !== void 0 ? _b : 1, "px"),
|
|
45
|
+
'--dds-grid-top-border-color': (_c = topBorder.color) !== null && _c !== void 0 ? _c : 'var(--dds-grid-divider-color)',
|
|
46
|
+
}
|
|
47
|
+
: {})), (bottomBorder
|
|
48
|
+
? {
|
|
49
|
+
'--dds-grid-bottom-border-thickness': "".concat((_d = bottomBorder.thickness) !== null && _d !== void 0 ? _d : 1, "px"),
|
|
50
|
+
'--dds-grid-bottom-border-color': (_e = bottomBorder.color) !== null && _e !== void 0 ? _e : 'var(--dds-grid-divider-color)',
|
|
51
|
+
}
|
|
52
|
+
: {})), (columnDivider
|
|
53
|
+
? {
|
|
54
|
+
'--dds-grid-column-divider-thickness': "".concat((_f = columnDivider.thickness) !== null && _f !== void 0 ? _f : 1, "px"),
|
|
55
|
+
'--dds-grid-column-divider-color': (_g = columnDivider.color) !== null && _g !== void 0 ? _g : 'var(--dds-grid-divider-color)',
|
|
56
|
+
}
|
|
57
|
+
: {}));
|
|
58
|
+
var classNames = [
|
|
59
|
+
'dds-grid',
|
|
60
|
+
"dds-grid-stack-".concat(stackAt),
|
|
61
|
+
topBorder ? 'dds-grid-has-top-border' : '',
|
|
62
|
+
bottomBorder ? 'dds-grid-has-bottom-border' : '',
|
|
63
|
+
columnDivider ? 'dds-grid-has-column-divider' : '',
|
|
64
|
+
className,
|
|
65
|
+
]
|
|
66
|
+
.filter(Boolean)
|
|
67
|
+
.join(' ');
|
|
68
|
+
return (_jsx("div", { className: classNames, style: style, children: children }));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* An individual column within a `<Grid>`.
|
|
72
|
+
*
|
|
73
|
+
* Use the `span` prop to make a column occupy more than one grid track, and
|
|
74
|
+
* `sticky` to keep the column content pinned while adjacent content scrolls.
|
|
75
|
+
* The column element itself always stretches to the full row height so that
|
|
76
|
+
* column dividers cover the entire row regardless of which column is taller.
|
|
77
|
+
*/
|
|
78
|
+
export function Column(_a) {
|
|
79
|
+
var span = _a.span, _b = _a.sticky, sticky = _b === void 0 ? false : _b, backgroundColor = _a.backgroundColor, _c = _a.className, className = _c === void 0 ? '' : _c, children = _a.children;
|
|
80
|
+
var style = {};
|
|
81
|
+
if (span && span > 1) {
|
|
82
|
+
style.gridColumn = "span ".concat(span);
|
|
83
|
+
}
|
|
84
|
+
if (backgroundColor) {
|
|
85
|
+
style.backgroundColor = backgroundColor;
|
|
86
|
+
}
|
|
87
|
+
var classNames = [
|
|
88
|
+
'dds-grid-column',
|
|
89
|
+
sticky ? 'dds-grid-column-sticky' : '',
|
|
90
|
+
className,
|
|
91
|
+
]
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.join(' ');
|
|
94
|
+
return (_jsx("div", { className: classNames, style: style, children: sticky ? (_jsx("div", { className: "dds-grid-column-sticky-inner", children: children })) : (children) }));
|
|
95
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Grid } from './Grid';
|
|
3
|
+
/**
|
|
4
|
+
* `Grid` and `Column` provide a flexible multi-column layout for documentation pages.
|
|
5
|
+
* Common patterns include side-by-side comparisons, image + annotation, and
|
|
6
|
+
* tutorial-style instruction / code pairings.
|
|
7
|
+
*/
|
|
8
|
+
declare const meta: Meta<typeof Grid>;
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof Grid>;
|
|
11
|
+
/**
|
|
12
|
+
* Fully interactive default story — all controls in the prop table affect this
|
|
13
|
+
* live preview. Adjust `columns`, `gap`, `stackAt`, `align`, `columnDivider`,
|
|
14
|
+
* `topBorder`, `bottomBorder`, and `backgroundColor` via the Controls panel.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Default: Story;
|
|
17
|
+
/**
|
|
18
|
+
* Two equal columns — the default layout. Columns stack vertically at the `md`
|
|
19
|
+
* breakpoint (768 px) by default.
|
|
20
|
+
*/
|
|
21
|
+
export declare const TwoEqualColumns: Story;
|
|
22
|
+
/**
|
|
23
|
+
* Three equal columns, with a top and bottom border to create a contained
|
|
24
|
+
* "feature grid" panel. Useful for listing icons with short descriptions.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ThreeColumnFeatureGrid: Story;
|
|
27
|
+
/**
|
|
28
|
+
* Asymmetric 1/3 + 2/3 split — pass an array of fractional weights.
|
|
29
|
+
* A common pattern for a narrow label / sidebar alongside wide content.
|
|
30
|
+
*/
|
|
31
|
+
export declare const AsymmetricSplit: Story;
|
|
32
|
+
/**
|
|
33
|
+
* Image + annotation layout. `align="center"` vertically centres the shorter
|
|
34
|
+
* column when image and text have different heights.
|
|
35
|
+
*/
|
|
36
|
+
export declare const ImageAndText: Story;
|
|
37
|
+
/**
|
|
38
|
+
* Tutorial layout — prose instructions on the left, sticky code panel on the
|
|
39
|
+
* right. The code panel stays in view while the user scrolls through the steps.
|
|
40
|
+
* The column divider runs the full height of the row regardless of which column
|
|
41
|
+
* is taller. The `sticky` prop is automatically disabled when the grid stacks.
|
|
42
|
+
*/
|
|
43
|
+
export declare const TutorialWithStickyCode: Story;
|
|
44
|
+
/**
|
|
45
|
+
* Column dividers — a vertical line between columns that converts to a
|
|
46
|
+
* horizontal rule at the stacking breakpoint.
|
|
47
|
+
*/
|
|
48
|
+
export declare const WithColumnDivider: Story;
|
|
49
|
+
/**
|
|
50
|
+
* Background colors — apply a background to the entire grid and / or to
|
|
51
|
+
* individual columns using the `backgroundColor` prop.
|
|
52
|
+
*/
|
|
53
|
+
export declare const BackgroundColors: Story;
|
|
54
|
+
/**
|
|
55
|
+
* Large gap between columns — useful when columns contain rich content
|
|
56
|
+
* that needs extra breathing room.
|
|
57
|
+
*/
|
|
58
|
+
export declare const LargeGap: Story;
|
|
59
|
+
/**
|
|
60
|
+
* Custom gap — pass any CSS length string such as `'1.5rem'` or `'40px'`
|
|
61
|
+
* for fine-grained control beyond the named size tokens.
|
|
62
|
+
*/
|
|
63
|
+
export declare const CustomGap: Story;
|
|
64
|
+
/**
|
|
65
|
+
* Span — a column set to `span={2}` occupies two grid tracks.
|
|
66
|
+
* Useful for full-width content (e.g. a summary row) inside an otherwise
|
|
67
|
+
* multi-column grid.
|
|
68
|
+
*/
|
|
69
|
+
export declare const ColumnSpan: Story;
|
|
@@ -0,0 +1,259 @@
|
|
|
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
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Grid } from './Grid';
|
|
14
|
+
import { Column } from './Grid';
|
|
15
|
+
import { CodeBlock } from './CodeBlock';
|
|
16
|
+
/**
|
|
17
|
+
* `Grid` and `Column` provide a flexible multi-column layout for documentation pages.
|
|
18
|
+
* Common patterns include side-by-side comparisons, image + annotation, and
|
|
19
|
+
* tutorial-style instruction / code pairings.
|
|
20
|
+
*/
|
|
21
|
+
var meta = {
|
|
22
|
+
title: 'Components/Grid',
|
|
23
|
+
component: Grid,
|
|
24
|
+
tags: ['autodocs'],
|
|
25
|
+
argTypes: {
|
|
26
|
+
columns: {
|
|
27
|
+
control: { type: 'object' },
|
|
28
|
+
description: 'Number of equal columns, or an array of fractional weights for asymmetric splits (e.g. `[1, 2]` → 1/3 + 2/3). Enter a number or a JSON array in the control.',
|
|
29
|
+
table: { defaultValue: { summary: '2' } },
|
|
30
|
+
},
|
|
31
|
+
gap: {
|
|
32
|
+
control: { type: 'select' },
|
|
33
|
+
options: ['sm', 'md', 'lg', '0.5rem', '1rem', '1.5rem', '2rem', '3rem', '8px', '16px', '24px', '32px'],
|
|
34
|
+
description: "Space between columns. Use `'sm'`, `'md'`, or `'lg'` for design-token sizes, or any CSS length string (e.g. `'16px'`, `'1.5rem'`).",
|
|
35
|
+
table: { defaultValue: { summary: "'md'" } },
|
|
36
|
+
},
|
|
37
|
+
stackAt: {
|
|
38
|
+
control: { type: 'select' },
|
|
39
|
+
options: ['sm', 'md', 'lg', 'never'],
|
|
40
|
+
description: 'Breakpoint at which columns collapse to a single vertical stack.',
|
|
41
|
+
table: { defaultValue: { summary: "'md'" } },
|
|
42
|
+
},
|
|
43
|
+
align: {
|
|
44
|
+
control: { type: 'select' },
|
|
45
|
+
options: ['start', 'center', 'end', 'stretch'],
|
|
46
|
+
description: 'Vertical alignment of content within each column.',
|
|
47
|
+
table: { defaultValue: { summary: "'stretch'" } },
|
|
48
|
+
},
|
|
49
|
+
columnDivider: {
|
|
50
|
+
control: { type: 'object' },
|
|
51
|
+
description: 'Vertical line between columns (`{ thickness?: number; color?: string }`). Converts to a horizontal rule when stacked.',
|
|
52
|
+
},
|
|
53
|
+
topBorder: {
|
|
54
|
+
control: { type: 'object' },
|
|
55
|
+
description: 'Horizontal rule above the grid (`{ thickness?: number; color?: string }`).',
|
|
56
|
+
},
|
|
57
|
+
bottomBorder: {
|
|
58
|
+
control: { type: 'object' },
|
|
59
|
+
description: 'Horizontal rule below the grid (`{ thickness?: number; color?: string }`).',
|
|
60
|
+
},
|
|
61
|
+
backgroundColor: {
|
|
62
|
+
control: 'color',
|
|
63
|
+
description: 'Background color for the entire grid container.',
|
|
64
|
+
},
|
|
65
|
+
className: {
|
|
66
|
+
control: 'text',
|
|
67
|
+
description: 'Additional CSS classes applied to the grid wrapper.',
|
|
68
|
+
table: { defaultValue: { summary: '""' } },
|
|
69
|
+
},
|
|
70
|
+
children: {
|
|
71
|
+
control: false,
|
|
72
|
+
description: 'Grid content — typically `Column` components.',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
parameters: {
|
|
76
|
+
docs: {
|
|
77
|
+
description: {
|
|
78
|
+
component: "\nLayout primitive for multi-column documentation content.\n\n## When to Use\n\n- **Image + annotation** \u2014 screenshot or diagram on one side, feature callouts on the other\n- **Tutorial / live demo** \u2014 prose instructions on one side, sticky code panel on the other\n- **Side-by-side comparison** \u2014 before/after, two approaches, or option A vs option B\n- **Feature grid** \u2014 icon + short description repeated across columns\n\n## When Not to Use\n\n- For card-style repeating items of the same type \u2014 use `CardGrid` instead\n- For a single column of content \u2014 use standard block-level markup\n\n## Accessibility\n\n- Rendered as a semantic `<div>`; no implicit ARIA role (not a data table)\n- Source order should match reading order; avoid visual reordering via CSS `order`\n- Column dividers are decorative and carry no meaning for assistive technology\n ",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
export default meta;
|
|
84
|
+
/* -------------------------------------------------------------------------- */
|
|
85
|
+
/* Helpers */
|
|
86
|
+
/* -------------------------------------------------------------------------- */
|
|
87
|
+
var textColor = { color: 'var(--dds-tabs-panel-text)' };
|
|
88
|
+
var subtle = { color: 'var(--dds-tabs-panel-text)', fontFamily: 'sans-serif', margin: 0 };
|
|
89
|
+
function Placeholder(_a) {
|
|
90
|
+
var label = _a.label, _b = _a.height, height = _b === void 0 ? 120 : _b, _c = _a.bg, bg = _c === void 0 ? 'rgba(99,102,241,0.1)' : _c;
|
|
91
|
+
return (_jsx("div", { style: __assign(__assign({ display: 'flex', alignItems: 'center', justifyContent: 'center', height: height, background: bg, borderRadius: 6 }, textColor), { fontFamily: 'sans-serif', fontWeight: 600, fontSize: '0.875rem' }), children: label }));
|
|
92
|
+
}
|
|
93
|
+
/* -------------------------------------------------------------------------- */
|
|
94
|
+
/* Stories */
|
|
95
|
+
/* -------------------------------------------------------------------------- */
|
|
96
|
+
/**
|
|
97
|
+
* Fully interactive default story — all controls in the prop table affect this
|
|
98
|
+
* live preview. Adjust `columns`, `gap`, `stackAt`, `align`, `columnDivider`,
|
|
99
|
+
* `topBorder`, `bottomBorder`, and `backgroundColor` via the Controls panel.
|
|
100
|
+
*/
|
|
101
|
+
export var Default = {
|
|
102
|
+
args: {
|
|
103
|
+
columns: 2,
|
|
104
|
+
gap: 'md',
|
|
105
|
+
stackAt: 'md',
|
|
106
|
+
align: 'stretch',
|
|
107
|
+
},
|
|
108
|
+
render: function (args) { return (_jsxs(Grid, __assign({}, args, { children: [_jsx(Column, { children: _jsx(Placeholder, { label: "Column 1" }) }), _jsx(Column, { children: _jsx(Placeholder, { label: "Column 2" }) })] }))); },
|
|
109
|
+
parameters: {
|
|
110
|
+
docs: {
|
|
111
|
+
source: {
|
|
112
|
+
code: "<Grid columns={2} gap=\"md\">\n <Column>Column 1 content</Column>\n <Column>Column 2 content</Column>\n</Grid>",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Two equal columns — the default layout. Columns stack vertically at the `md`
|
|
119
|
+
* breakpoint (768 px) by default.
|
|
120
|
+
*/
|
|
121
|
+
export var TwoEqualColumns = {
|
|
122
|
+
render: function () { return (_jsxs(Grid, { columns: 2, children: [_jsx(Column, { children: _jsx(Placeholder, { label: "Column 1" }) }), _jsx(Column, { children: _jsx(Placeholder, { label: "Column 2" }) })] })); },
|
|
123
|
+
parameters: {
|
|
124
|
+
docs: {
|
|
125
|
+
source: {
|
|
126
|
+
code: "<Grid columns={2}>\n <Column>Column 1 content</Column>\n <Column>Column 2 content</Column>\n</Grid>",
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Three equal columns, with a top and bottom border to create a contained
|
|
133
|
+
* "feature grid" panel. Useful for listing icons with short descriptions.
|
|
134
|
+
*/
|
|
135
|
+
export var ThreeColumnFeatureGrid = {
|
|
136
|
+
render: function () { return (_jsxs(Grid, { columns: 3, gap: "md", topBorder: { color: 'var(--dds-grid-divider-color)' }, bottomBorder: { color: 'var(--dds-grid-divider-color)' }, children: [_jsx(Column, { children: _jsxs("p", { style: subtle, children: [_jsx("strong", { children: "Feature A" }), _jsx("br", {}), "Short description of the feature."] }) }), _jsx(Column, { children: _jsxs("p", { style: subtle, children: [_jsx("strong", { children: "Feature B" }), _jsx("br", {}), "Short description of the feature."] }) }), _jsx(Column, { children: _jsxs("p", { style: subtle, children: [_jsx("strong", { children: "Feature C" }), _jsx("br", {}), "Short description of the feature."] }) })] })); },
|
|
137
|
+
parameters: {
|
|
138
|
+
docs: {
|
|
139
|
+
source: {
|
|
140
|
+
code: "<Grid\n columns={3}\n gap=\"md\"\n topBorder={{ color: '#ccc' }}\n bottomBorder={{ color: '#ccc' }}\n>\n <Column><strong>Feature A</strong> \u2014 Short description.</Column>\n <Column><strong>Feature B</strong> \u2014 Short description.</Column>\n <Column><strong>Feature C</strong> \u2014 Short description.</Column>\n</Grid>",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Asymmetric 1/3 + 2/3 split — pass an array of fractional weights.
|
|
147
|
+
* A common pattern for a narrow label / sidebar alongside wide content.
|
|
148
|
+
*/
|
|
149
|
+
export var AsymmetricSplit = {
|
|
150
|
+
render: function () { return (_jsxs(Grid, { columns: [1, 2], children: [_jsx(Column, { children: _jsx(Placeholder, { label: "1 / 3", height: 160, bg: "rgba(16,185,129,0.1)" }) }), _jsx(Column, { children: _jsx(Placeholder, { label: "2 / 3", height: 160, bg: "rgba(99,102,241,0.1)" }) })] })); },
|
|
151
|
+
parameters: {
|
|
152
|
+
docs: {
|
|
153
|
+
source: {
|
|
154
|
+
code: "<Grid columns={[1, 2]}>\n <Column>Narrow (1/3)</Column>\n <Column>Wide (2/3)</Column>\n</Grid>",
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Image + annotation layout. `align="center"` vertically centres the shorter
|
|
161
|
+
* column when image and text have different heights.
|
|
162
|
+
*/
|
|
163
|
+
export var ImageAndText = {
|
|
164
|
+
render: function () { return (_jsxs(Grid, { columns: [1, 2], align: "center", columnDivider: { color: 'var(--dds-grid-divider-color)' }, children: [_jsx(Column, { children: _jsx(Placeholder, { label: "Diagram / Screenshot", height: 200, bg: "rgba(234,179,8,0.1)" }) }), _jsxs(Column, { children: [_jsx("p", { style: __assign(__assign({}, subtle), { marginBottom: '0.5rem' }), children: _jsx("strong", { children: "What you're looking at" }) }), _jsxs("p", { style: subtle, children: ["This panel describes the key elements of the diagram on the left. Use ", _jsx("code", { children: "align=\"center\"" }), " so short text stays vertically centred next to a taller image."] })] })] })); },
|
|
165
|
+
parameters: {
|
|
166
|
+
docs: {
|
|
167
|
+
source: {
|
|
168
|
+
code: "<Grid columns={[1, 2]} align=\"center\" columnDivider={{ color: '#ddd' }}>\n <Column>\n <img src=\"/diagram.png\" alt=\"Architecture diagram\" />\n </Column>\n <Column>\n <h3>What you're looking at</h3>\n <p>Description of the diagram elements...</p>\n </Column>\n</Grid>",
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Tutorial layout — prose instructions on the left, sticky code panel on the
|
|
175
|
+
* right. The code panel stays in view while the user scrolls through the steps.
|
|
176
|
+
* The column divider runs the full height of the row regardless of which column
|
|
177
|
+
* is taller. The `sticky` prop is automatically disabled when the grid stacks.
|
|
178
|
+
*/
|
|
179
|
+
export var TutorialWithStickyCode = {
|
|
180
|
+
render: function () { return (_jsxs(Grid, { columns: 2, stackAt: "lg", gap: "lg", columnDivider: { thickness: 2, color: 'var(--dds-grid-divider-color)' }, children: [_jsxs(Column, { children: [_jsx("p", { style: __assign(__assign({}, subtle), { marginBottom: '1rem' }), children: _jsx("strong", { children: "Step 1 \u2014 Install dependencies" }) }), _jsx("p", { style: __assign(__assign({}, subtle), { marginBottom: '1rem' }), children: "Run the installer and follow the prompts. This sets up the project scaffold and pulls in all required packages." }), _jsx("p", { style: __assign(__assign({}, subtle), { marginBottom: '1rem' }), children: _jsx("strong", { children: "Step 2 \u2014 Configure your project" }) }), _jsxs("p", { style: __assign(__assign({}, subtle), { marginBottom: '1rem' }), children: ["Open ", _jsx("code", { children: "config.ts" }), " and update the values for your environment. Refer to the code panel on the right for a complete example."] }), _jsx("p", { style: __assign(__assign({}, subtle), { marginBottom: '1rem' }), children: _jsx("strong", { children: "Step 3 \u2014 Start the dev server" }) }), _jsx("p", { style: subtle, children: "Run the dev command. The server watches for file changes and hot-reloads automatically." })] }), _jsx(Column, { sticky: true, children: _jsx(CodeBlock, { language: "bash", code: "npm install\n\nnpm run dev" }) })] })); },
|
|
181
|
+
parameters: {
|
|
182
|
+
docs: {
|
|
183
|
+
source: {
|
|
184
|
+
code: "<Grid columns={2} stackAt=\"lg\" gap=\"lg\" columnDivider={{ thickness: 2 }}>\n <Column>\n {/* Step-by-step instructions */}\n <p><strong>Step 1 \u2014 Install dependencies</strong></p>\n <p>Run the installer and follow the prompts.</p>\n {/* \u2026 more steps \u2026 */}\n </Column>\n <Column sticky>\n <CodeBlock language=\"bash\" code=\"npm install\\n\\nnpm run dev\" />\n </Column>\n</Grid>",
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Column dividers — a vertical line between columns that converts to a
|
|
191
|
+
* horizontal rule at the stacking breakpoint.
|
|
192
|
+
*/
|
|
193
|
+
export var WithColumnDivider = {
|
|
194
|
+
render: function () { return (_jsxs(Grid, { columns: 3, columnDivider: { thickness: 1, color: 'var(--dds-grid-divider-color)' }, children: [_jsxs(Column, { children: [_jsx("p", { style: subtle, children: _jsx("strong", { children: "Option A" }) }), _jsx("p", { style: subtle, children: "Description of the first approach." })] }), _jsxs(Column, { children: [_jsx("p", { style: subtle, children: _jsx("strong", { children: "Option B" }) }), _jsx("p", { style: subtle, children: "Description of the second approach." })] }), _jsxs(Column, { children: [_jsx("p", { style: subtle, children: _jsx("strong", { children: "Option C" }) }), _jsx("p", { style: subtle, children: "Description of the third approach." })] })] })); },
|
|
195
|
+
parameters: {
|
|
196
|
+
docs: {
|
|
197
|
+
source: {
|
|
198
|
+
code: "<Grid columns={3} columnDivider={{ thickness: 1, color: '#e0e0e0' }}>\n <Column>\n <strong>Option A</strong>\n <p>Description of the first approach.</p>\n </Column>\n <Column>\n <strong>Option B</strong>\n <p>Description of the second approach.</p>\n </Column>\n <Column>\n <strong>Option C</strong>\n <p>Description of the third approach.</p>\n </Column>\n</Grid>",
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Background colors — apply a background to the entire grid and / or to
|
|
205
|
+
* individual columns using the `backgroundColor` prop.
|
|
206
|
+
*/
|
|
207
|
+
export var BackgroundColors = {
|
|
208
|
+
render: function () { return (_jsxs(Grid, { columns: 2, gap: "lg", backgroundColor: "rgba(99,102,241,0.04)", children: [_jsxs(Column, { backgroundColor: "rgba(16,185,129,0.08)", children: [_jsx("p", { style: subtle, children: _jsx("strong", { children: "Column with background" }) }), _jsx("p", { style: subtle, children: "Each column can have its own background color." })] }), _jsxs(Column, { backgroundColor: "rgba(234,179,8,0.08)", children: [_jsx("p", { style: subtle, children: _jsx("strong", { children: "Another column background" }) }), _jsxs("p", { style: subtle, children: ["The grid container also has a light background applied via", ' ', _jsx("code", { children: "backgroundColor" }), " on the ", _jsx("code", { children: "Grid" }), "."] })] })] })); },
|
|
209
|
+
parameters: {
|
|
210
|
+
docs: {
|
|
211
|
+
source: {
|
|
212
|
+
code: "<Grid columns={2} gap=\"lg\" backgroundColor=\"rgba(99,102,241,0.04)\">\n <Column backgroundColor=\"rgba(16,185,129,0.08)\">\n <strong>Column with background</strong>\n <p>Each column can have its own background color.</p>\n </Column>\n <Column backgroundColor=\"rgba(234,179,8,0.08)\">\n <strong>Another column background</strong>\n <p>Set on both the Grid container and individual Columns.</p>\n </Column>\n</Grid>",
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Large gap between columns — useful when columns contain rich content
|
|
219
|
+
* that needs extra breathing room.
|
|
220
|
+
*/
|
|
221
|
+
export var LargeGap = {
|
|
222
|
+
render: function () { return (_jsxs(Grid, { columns: 2, gap: "lg", children: [_jsx(Column, { children: _jsx(Placeholder, { label: "Column 1", height: 140 }) }), _jsx(Column, { children: _jsx(Placeholder, { label: "Column 2", height: 140 }) })] })); },
|
|
223
|
+
parameters: {
|
|
224
|
+
docs: {
|
|
225
|
+
source: {
|
|
226
|
+
code: "<Grid columns={2} gap=\"lg\">\n <Column>Column 1 content</Column>\n <Column>Column 2 content</Column>\n</Grid>",
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Custom gap — pass any CSS length string such as `'1.5rem'` or `'40px'`
|
|
233
|
+
* for fine-grained control beyond the named size tokens.
|
|
234
|
+
*/
|
|
235
|
+
export var CustomGap = {
|
|
236
|
+
render: function () { return (_jsxs(Grid, { columns: 2, gap: "3rem", children: [_jsx(Column, { children: _jsx(Placeholder, { label: "Column 1", height: 140 }) }), _jsx(Column, { children: _jsx(Placeholder, { label: "Column 2", height: 140 }) })] })); },
|
|
237
|
+
parameters: {
|
|
238
|
+
docs: {
|
|
239
|
+
source: {
|
|
240
|
+
code: "<Grid columns={2} gap=\"3rem\">\n <Column>Column 1 content</Column>\n <Column>Column 2 content</Column>\n</Grid>",
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Span — a column set to `span={2}` occupies two grid tracks.
|
|
247
|
+
* Useful for full-width content (e.g. a summary row) inside an otherwise
|
|
248
|
+
* multi-column grid.
|
|
249
|
+
*/
|
|
250
|
+
export var ColumnSpan = {
|
|
251
|
+
render: function () { return (_jsxs(Grid, { columns: 3, gap: "md", children: [_jsx(Column, { children: _jsx(Placeholder, { label: "Col 1" }) }), _jsx(Column, { children: _jsx(Placeholder, { label: "Col 2" }) }), _jsx(Column, { children: _jsx(Placeholder, { label: "Col 3" }) }), _jsx(Column, { span: 3, children: _jsx(Placeholder, { label: "Spans all 3 columns", height: 60, bg: "rgba(239,68,68,0.1)" }) })] })); },
|
|
252
|
+
parameters: {
|
|
253
|
+
docs: {
|
|
254
|
+
source: {
|
|
255
|
+
code: "<Grid columns={3} gap=\"md\">\n <Column>Col 1</Column>\n <Column>Col 2</Column>\n <Column>Col 3</Column>\n <Column span={3}>Spans all 3 columns</Column>\n</Grid>",
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/styles.css
CHANGED
|
@@ -258,6 +258,13 @@
|
|
|
258
258
|
--dds-list-badge-shadow: inset 0 0 0 1px #bfc2c7;
|
|
259
259
|
--dds-list-connector-line: #eceef2; /* gray-200 */
|
|
260
260
|
--dds-list-text: #374151; /* gray-700 */
|
|
261
|
+
|
|
262
|
+
/* Grid */
|
|
263
|
+
--dds-grid-gap-sm: 1rem; /* gap-4 */
|
|
264
|
+
--dds-grid-gap-md: 1.5rem; /* gap-6 */
|
|
265
|
+
--dds-grid-gap-lg: 2.5rem; /* gap-10 */
|
|
266
|
+
--dds-grid-divider-color: #e5e7eb; /* gray-200 */
|
|
267
|
+
--dds-grid-sticky-top: 1rem;
|
|
261
268
|
}
|
|
262
269
|
/* ==========================================================================
|
|
263
270
|
Dark Mode Tokens
|
|
@@ -419,6 +426,9 @@
|
|
|
419
426
|
--dds-list-badge-shadow: inset 0 0 0 1px #353a42;
|
|
420
427
|
--dds-list-connector-line: #353a42; /* gray-600 */
|
|
421
428
|
--dds-list-text: #e5e7eb; /* gray-200 */
|
|
429
|
+
|
|
430
|
+
/* Grid */
|
|
431
|
+
--dds-grid-divider-color: #4b5563; /* gray-600 */
|
|
422
432
|
}
|
|
423
433
|
/* Auto dark mode — follows OS preference, opt-out with .dds-light */
|
|
424
434
|
@media (prefers-color-scheme: dark) {
|
|
@@ -575,6 +585,9 @@
|
|
|
575
585
|
--dds-list-badge-shadow: inset 0 0 0 1px #353a42;
|
|
576
586
|
--dds-list-connector-line: #353a42; /* gray-600 */
|
|
577
587
|
--dds-list-text: #e5e7eb; /* gray-200 */
|
|
588
|
+
|
|
589
|
+
/* Grid */
|
|
590
|
+
--dds-grid-divider-color: #4b5563; /* gray-600 */
|
|
578
591
|
}
|
|
579
592
|
}
|
|
580
593
|
/* Explicit dark mode via data attribute (overrides OS preference) */
|
|
@@ -1832,4 +1845,107 @@ a.no-text-decoration {
|
|
|
1832
1845
|
}
|
|
1833
1846
|
}
|
|
1834
1847
|
}
|
|
1848
|
+
/* =============================================================================
|
|
1849
|
+
Grid — multi-column layout component
|
|
1850
|
+
============================================================================= */
|
|
1851
|
+
/* Base grid container */
|
|
1852
|
+
.dds-grid {
|
|
1853
|
+
display: grid;
|
|
1854
|
+
grid-template-columns: var(--dds-grid-template-columns, repeat(2, 1fr));
|
|
1855
|
+
gap: var(--dds-grid-gap, var(--dds-grid-gap-md));
|
|
1856
|
+
align-items: var(--dds-grid-align, stretch);
|
|
1857
|
+
}
|
|
1858
|
+
/* Optional top border */
|
|
1859
|
+
.dds-grid-has-top-border {
|
|
1860
|
+
border-top: var(--dds-grid-top-border-thickness, 1px) solid
|
|
1861
|
+
var(--dds-grid-top-border-color, var(--dds-grid-divider-color));
|
|
1862
|
+
padding-top: var(--dds-grid-gap, var(--dds-grid-gap-md));
|
|
1863
|
+
}
|
|
1864
|
+
/* Optional bottom border */
|
|
1865
|
+
.dds-grid-has-bottom-border {
|
|
1866
|
+
border-bottom: var(--dds-grid-bottom-border-thickness, 1px) solid
|
|
1867
|
+
var(--dds-grid-bottom-border-color, var(--dds-grid-divider-color));
|
|
1868
|
+
padding-bottom: var(--dds-grid-gap, var(--dds-grid-gap-md));
|
|
1869
|
+
}
|
|
1870
|
+
/* Column divider — vertical line between columns */
|
|
1871
|
+
.dds-grid-has-column-divider .dds-grid-column + .dds-grid-column {
|
|
1872
|
+
border-left: var(--dds-grid-column-divider-thickness, 1px) solid
|
|
1873
|
+
var(--dds-grid-column-divider-color, var(--dds-grid-divider-color));
|
|
1874
|
+
padding-left: var(--dds-grid-gap, var(--dds-grid-gap-md));
|
|
1875
|
+
}
|
|
1876
|
+
/* Individual column */
|
|
1877
|
+
.dds-grid-column {
|
|
1878
|
+
/* Prevent grid cells from overflowing (e.g. wide code blocks) */
|
|
1879
|
+
min-width: 0;
|
|
1880
|
+
}
|
|
1881
|
+
/* Sticky column — column div stretches to full row height so that border-left
|
|
1882
|
+
covers the entire row. The CONTENT inside is what scrolls sticky, via the
|
|
1883
|
+
inner wrapper. */
|
|
1884
|
+
.dds-grid-column-sticky {
|
|
1885
|
+
/* No align-self override — stretches naturally to row height */
|
|
1886
|
+
}
|
|
1887
|
+
/* Inner wrapper that provides the actual sticky scroll behaviour */
|
|
1888
|
+
.dds-grid-column-sticky-inner {
|
|
1889
|
+
position: sticky;
|
|
1890
|
+
top: var(--dds-grid-sticky-top, 1rem);
|
|
1891
|
+
}
|
|
1892
|
+
/* =============================================================================
|
|
1893
|
+
Responsive stacking — columns collapse to a single vertical track
|
|
1894
|
+
============================================================================= */
|
|
1895
|
+
/* Stack at sm breakpoint (≤ 640 px) */
|
|
1896
|
+
@media (max-width: 640px) {
|
|
1897
|
+
.dds-grid-stack-sm {
|
|
1898
|
+
grid-template-columns: 1fr;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
/* Column divider becomes a horizontal rule when stacked */
|
|
1902
|
+
.dds-grid-stack-sm.dds-grid-has-column-divider .dds-grid-column + .dds-grid-column {
|
|
1903
|
+
border-left: none;
|
|
1904
|
+
padding-left: 0;
|
|
1905
|
+
border-top: var(--dds-grid-column-divider-thickness, 1px) solid
|
|
1906
|
+
var(--dds-grid-column-divider-color, var(--dds-grid-divider-color));
|
|
1907
|
+
padding-top: var(--dds-grid-gap, var(--dds-grid-gap-md));
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
/* Sticky inner wrapper no-ops when stacked */
|
|
1911
|
+
.dds-grid-stack-sm .dds-grid-column-sticky-inner {
|
|
1912
|
+
position: static;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
/* Stack at md breakpoint (≤ 768 px) */
|
|
1916
|
+
@media (max-width: 768px) {
|
|
1917
|
+
.dds-grid-stack-md {
|
|
1918
|
+
grid-template-columns: 1fr;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
.dds-grid-stack-md.dds-grid-has-column-divider .dds-grid-column + .dds-grid-column {
|
|
1922
|
+
border-left: none;
|
|
1923
|
+
padding-left: 0;
|
|
1924
|
+
border-top: var(--dds-grid-column-divider-thickness, 1px) solid
|
|
1925
|
+
var(--dds-grid-column-divider-color, var(--dds-grid-divider-color));
|
|
1926
|
+
padding-top: var(--dds-grid-gap, var(--dds-grid-gap-md));
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
.dds-grid-stack-md .dds-grid-column-sticky-inner {
|
|
1930
|
+
position: static;
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
/* Stack at lg breakpoint (≤ 1024 px) */
|
|
1934
|
+
@media (max-width: 1024px) {
|
|
1935
|
+
.dds-grid-stack-lg {
|
|
1936
|
+
grid-template-columns: 1fr;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
.dds-grid-stack-lg.dds-grid-has-column-divider .dds-grid-column + .dds-grid-column {
|
|
1940
|
+
border-left: none;
|
|
1941
|
+
padding-left: 0;
|
|
1942
|
+
border-top: var(--dds-grid-column-divider-thickness, 1px) solid
|
|
1943
|
+
var(--dds-grid-column-divider-color, var(--dds-grid-divider-color));
|
|
1944
|
+
padding-top: var(--dds-grid-gap, var(--dds-grid-gap-md));
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
.dds-grid-stack-lg .dds-grid-column-sticky-inner {
|
|
1948
|
+
position: static;
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1835
1951
|
|