doom-design-system 0.4.1 → 0.4.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.
|
@@ -13,33 +13,114 @@ declare const SPACING_MAP: {
|
|
|
13
13
|
readonly 16: "4rem";
|
|
14
14
|
};
|
|
15
15
|
export type Spacing = keyof typeof SPACING_MAP;
|
|
16
|
-
interface LayoutProps extends React.HTMLAttributes<HTMLElement> {
|
|
16
|
+
export interface LayoutProps extends React.HTMLAttributes<HTMLElement> {
|
|
17
|
+
/** The content to be rendered inside the layout container. */
|
|
17
18
|
children?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* The HTML element or React component to render as the root node.
|
|
21
|
+
* @default "div"
|
|
22
|
+
*/
|
|
18
23
|
as?: ElementType;
|
|
19
24
|
}
|
|
20
25
|
export interface GridProps extends LayoutProps {
|
|
26
|
+
/**
|
|
27
|
+
* Defines the columns of the grid.
|
|
28
|
+
* Accepts a number (e.g., `3` for 3 equal columns) or a CSS string (e.g., `"1fr 2fr"`).
|
|
29
|
+
* @default "1fr"
|
|
30
|
+
*/
|
|
21
31
|
columns?: string | number;
|
|
32
|
+
/**
|
|
33
|
+
* Spacing between grid items.
|
|
34
|
+
* Maps to the design system spacing tokens (e.g., `4` = 1rem).
|
|
35
|
+
* @default 4
|
|
36
|
+
*/
|
|
22
37
|
gap?: Spacing;
|
|
23
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* A CSS Grid container for creating two-dimensional layouts.
|
|
41
|
+
* Use this when you need precise control over columns and rows, or complex grid placements.
|
|
42
|
+
*/
|
|
24
43
|
export declare function Grid({ children, columns, gap, className, style, as: Component, ...props }: GridProps): import("react/jsx-runtime").JSX.Element;
|
|
25
44
|
export interface FlexProps extends LayoutProps {
|
|
45
|
+
/**
|
|
46
|
+
* The direction in which flex items are placed in the flex container.
|
|
47
|
+
* @default "row"
|
|
48
|
+
*/
|
|
26
49
|
direction?: "row" | "column" | "row-reverse" | "column-reverse";
|
|
50
|
+
/**
|
|
51
|
+
* Alignment of items along the main axis.
|
|
52
|
+
* @default "flex-start"
|
|
53
|
+
*/
|
|
27
54
|
justify?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
|
|
55
|
+
/**
|
|
56
|
+
* Alignment of items along the cross axis.
|
|
57
|
+
* @default "stretch"
|
|
58
|
+
*/
|
|
28
59
|
align?: "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
|
|
60
|
+
/**
|
|
61
|
+
* Spacing between flex items.
|
|
62
|
+
* Maps to the design system spacing tokens.
|
|
63
|
+
* @default 0
|
|
64
|
+
*/
|
|
29
65
|
gap?: Spacing;
|
|
66
|
+
/**
|
|
67
|
+
* Controls whether flex items are forced onto one line or can wrap onto multiple lines.
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
30
70
|
wrap?: boolean | "wrap" | "nowrap" | "wrap-reverse";
|
|
31
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* A flexible box container for one-dimensional layouts.
|
|
74
|
+
* Use this as your primary layout tool for aligning items in a row or column,
|
|
75
|
+
* distributing space, and handling wrapping.
|
|
76
|
+
*/
|
|
32
77
|
export declare function Flex({ children, direction, justify, align, gap, wrap, className, style, as: Component, ...props }: FlexProps): import("react/jsx-runtime").JSX.Element;
|
|
33
78
|
export interface StackProps extends Omit<FlexProps, "direction"> {
|
|
79
|
+
/**
|
|
80
|
+
* The direction to stack items. Defaults to vertical ("column").
|
|
81
|
+
* Can be overridden to "row" for semantic or responsive adjustments.
|
|
82
|
+
* @default "column"
|
|
83
|
+
*/
|
|
34
84
|
direction?: "column" | "column-reverse" | "row" | "row-reverse";
|
|
35
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* A specialized Flex container explicitly optimized for vertical stacking.
|
|
88
|
+
* Use this for lists, form fields, card content, or any group of elements
|
|
89
|
+
* that should be arranged vertically with consistent spacing.
|
|
90
|
+
* Note: While it defaults to column, `direction="row"` is supported for semantic overrides.
|
|
91
|
+
*/
|
|
36
92
|
export declare function Stack({ children, direction, gap, align, ...props }: StackProps): import("react/jsx-runtime").JSX.Element;
|
|
37
93
|
export interface SwitcherProps extends FlexProps {
|
|
94
|
+
/**
|
|
95
|
+
* The breakpoint threshold at which the layout switches from horizontal to vertical.
|
|
96
|
+
* e.g., "xs" means it will be horizontal on screens larger than "xs" (480px), and vertical below.
|
|
97
|
+
* @default "xs"
|
|
98
|
+
*/
|
|
38
99
|
threshold?: "xxs" | "xs" | "sm" | "md";
|
|
39
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* A responsive layout component that switches from horizontal to vertical layout
|
|
103
|
+
* based on a container query or breakpoint threshold.
|
|
104
|
+
* Use this for "sidebar + main content" layouts or any pattern that needs
|
|
105
|
+
* to stack on smaller screens but sit side-by-side on larger ones.
|
|
106
|
+
*/
|
|
40
107
|
export declare function Switcher({ children, threshold, className, ...props }: SwitcherProps): import("react/jsx-runtime").JSX.Element;
|
|
41
108
|
export interface ContainerProps extends LayoutProps {
|
|
109
|
+
/**
|
|
110
|
+
* The maximum width of the container.
|
|
111
|
+
* - `sm`: 640px
|
|
112
|
+
* - `md`: 768px
|
|
113
|
+
* - `lg`: 1024px
|
|
114
|
+
* - `xl`: 1280px
|
|
115
|
+
* - `fluid`: 100%
|
|
116
|
+
* @default "xl"
|
|
117
|
+
*/
|
|
42
118
|
maxWidth?: "sm" | "md" | "lg" | "xl" | "fluid";
|
|
43
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* A specific layout component for centering content horizontally on the page.
|
|
122
|
+
* Use this to constrain the maximum width of your page content or sections,
|
|
123
|
+
* ensuring consistent margins and readability on large screens.
|
|
124
|
+
*/
|
|
44
125
|
export declare function Container({ children, maxWidth, className, as: Component, ...props }: ContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
45
126
|
export {};
|
|
@@ -13,7 +13,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import clsx from "clsx";
|
|
15
15
|
import styles from "./Layout.module.css";
|
|
16
|
-
// --- Tokens ---
|
|
17
16
|
const SPACING_MAP = {
|
|
18
17
|
0: "0",
|
|
19
18
|
1: "0.25rem",
|
|
@@ -32,25 +31,55 @@ function resolveGap(gap) {
|
|
|
32
31
|
return undefined;
|
|
33
32
|
return SPACING_MAP[gap];
|
|
34
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* A CSS Grid container for creating two-dimensional layouts.
|
|
36
|
+
* Use this when you need precise control over columns and rows, or complex grid placements.
|
|
37
|
+
*/
|
|
35
38
|
export function Grid(_a) {
|
|
36
39
|
var { children, columns = "1fr", gap = 4, className, style, as: Component = "div" } = _a, props = __rest(_a, ["children", "columns", "gap", "className", "style", "as"]);
|
|
37
40
|
const gridTemplateColumns = typeof columns === "number" ? `repeat(${columns}, 1fr)` : columns;
|
|
38
|
-
|
|
41
|
+
const gridClasses = clsx(styles.grid, className);
|
|
42
|
+
return (_jsx(Component, Object.assign({ className: gridClasses, style: Object.assign({ gridTemplateColumns, gap: resolveGap(gap) }, style) }, props, { children: children })));
|
|
39
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* A flexible box container for one-dimensional layouts.
|
|
46
|
+
* Use this as your primary layout tool for aligning items in a row or column,
|
|
47
|
+
* distributing space, and handling wrapping.
|
|
48
|
+
*/
|
|
40
49
|
export function Flex(_a) {
|
|
41
50
|
var { children, direction = "row", justify = "flex-start", align = "stretch", gap = 0, wrap = false, className, style, as: Component = "div" } = _a, props = __rest(_a, ["children", "direction", "justify", "align", "gap", "wrap", "className", "style", "as"]);
|
|
42
51
|
const flexWrap = typeof wrap === "boolean" ? (wrap ? "wrap" : "nowrap") : wrap;
|
|
43
|
-
|
|
52
|
+
const flexClasses = clsx(styles.flex, styles[`direction-${direction}`], justify && styles[`justify-${justify}`], align && styles[`align-${align}`], className);
|
|
53
|
+
return (_jsx(Component, Object.assign({ className: flexClasses, style: Object.assign({ gap: resolveGap(gap), flexWrap }, style) }, props, { children: children })));
|
|
44
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* A specialized Flex container explicitly optimized for vertical stacking.
|
|
57
|
+
* Use this for lists, form fields, card content, or any group of elements
|
|
58
|
+
* that should be arranged vertically with consistent spacing.
|
|
59
|
+
* Note: While it defaults to column, `direction="row"` is supported for semantic overrides.
|
|
60
|
+
*/
|
|
45
61
|
export function Stack(_a) {
|
|
46
62
|
var { children, direction = "column", gap = 4, align = "stretch" } = _a, props = __rest(_a, ["children", "direction", "gap", "align"]);
|
|
47
63
|
return (_jsx(Flex, Object.assign({ direction: direction, gap: gap, align: align }, props, { children: children })));
|
|
48
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* A responsive layout component that switches from horizontal to vertical layout
|
|
67
|
+
* based on a container query or breakpoint threshold.
|
|
68
|
+
* Use this for "sidebar + main content" layouts or any pattern that needs
|
|
69
|
+
* to stack on smaller screens but sit side-by-side on larger ones.
|
|
70
|
+
*/
|
|
49
71
|
export function Switcher(_a) {
|
|
50
72
|
var { children, threshold = "xs", className } = _a, props = __rest(_a, ["children", "threshold", "className"]);
|
|
51
|
-
|
|
73
|
+
const switcherClasses = clsx(styles.switcher, styles[`switch-${threshold}`], className);
|
|
74
|
+
return (_jsx(Flex, Object.assign({ className: switcherClasses }, props, { children: children })));
|
|
52
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* A specific layout component for centering content horizontally on the page.
|
|
78
|
+
* Use this to constrain the maximum width of your page content or sections,
|
|
79
|
+
* ensuring consistent margins and readability on large screens.
|
|
80
|
+
*/
|
|
53
81
|
export function Container(_a) {
|
|
54
82
|
var { children, maxWidth = "xl", className, as: Component = "div" } = _a, props = __rest(_a, ["children", "maxWidth", "className", "as"]);
|
|
55
|
-
|
|
83
|
+
const containerClasses = clsx(styles.container, styles[maxWidth], className);
|
|
84
|
+
return (_jsx(Component, Object.assign({ className: containerClasses }, props, { children: children })));
|
|
56
85
|
}
|
|
@@ -6,6 +6,66 @@
|
|
|
6
6
|
display: flex;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
.direction-row {
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.direction-column {
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.direction-row-reverse {
|
|
18
|
+
flex-direction: row-reverse;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.direction-column-reverse {
|
|
22
|
+
flex-direction: column-reverse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.justify-flex-start {
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.justify-flex-end {
|
|
30
|
+
justify-content: flex-end;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.justify-center {
|
|
34
|
+
justify-content: center;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.justify-space-between {
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.justify-space-around {
|
|
42
|
+
justify-content: space-around;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.justify-space-evenly {
|
|
46
|
+
justify-content: space-evenly;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.align-flex-start {
|
|
50
|
+
align-items: flex-start;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.align-flex-end {
|
|
54
|
+
align-items: flex-end;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.align-center {
|
|
58
|
+
align-items: center;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.align-stretch {
|
|
62
|
+
align-items: stretch;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.align-baseline {
|
|
66
|
+
align-items: baseline;
|
|
67
|
+
}
|
|
68
|
+
|
|
9
69
|
.container {
|
|
10
70
|
width: 100%;
|
|
11
71
|
margin-left: auto;
|
|
@@ -31,29 +91,28 @@
|
|
|
31
91
|
|
|
32
92
|
.switcher {
|
|
33
93
|
display: flex;
|
|
34
|
-
flex-direction: row;
|
|
35
94
|
}
|
|
36
95
|
@media (max-width: 360px) {
|
|
37
96
|
.switcher.switch-xxs {
|
|
38
97
|
flex-direction: column;
|
|
39
|
-
align-items: flex-start
|
|
98
|
+
align-items: flex-start;
|
|
40
99
|
}
|
|
41
100
|
}
|
|
42
101
|
@media (max-width: 480px) {
|
|
43
102
|
.switcher.switch-xs {
|
|
44
103
|
flex-direction: column;
|
|
45
|
-
align-items: flex-start
|
|
104
|
+
align-items: flex-start;
|
|
46
105
|
}
|
|
47
106
|
}
|
|
48
107
|
@media (max-width: 640px) {
|
|
49
108
|
.switcher.switch-sm {
|
|
50
109
|
flex-direction: column;
|
|
51
|
-
align-items: flex-start
|
|
110
|
+
align-items: flex-start;
|
|
52
111
|
}
|
|
53
112
|
}
|
|
54
113
|
@media (max-width: 768px) {
|
|
55
114
|
.switcher.switch-md {
|
|
56
115
|
flex-direction: column;
|
|
57
|
-
align-items: flex-start
|
|
116
|
+
align-items: flex-start;
|
|
58
117
|
}
|
|
59
118
|
}
|