@fpkit/acss 3.1.1 → 3.2.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/libs/{chunk-2NRIP6RB.cjs → chunk-2C3YLBWP.cjs} +3 -3
- package/libs/{chunk-NWJDAHP6.cjs → chunk-2GJHKWEK.cjs} +3 -3
- package/libs/{chunk-FVROL3V5.js → chunk-2JCDEC32.js} +3 -3
- package/libs/{chunk-IRLFZ3OL.js → chunk-3XJC4XUG.js} +2 -2
- package/libs/{chunk-L6PRDL6F.cjs → chunk-5CJPTDK3.cjs} +3 -3
- package/libs/{chunk-E4OSROCA.cjs → chunk-5QSNJQVH.cjs} +3 -3
- package/libs/{chunk-O3JIHC5M.cjs → chunk-6BUJZ4DJ.cjs} +3 -3
- package/libs/{chunk-WXBFBWYF.cjs → chunk-AFINOD2L.cjs} +3 -3
- package/libs/{chunk-HRRHPLER.js → chunk-AWZLSWDO.js} +2 -2
- package/libs/chunk-DDSXKOUB.js +7 -0
- package/libs/chunk-DDSXKOUB.js.map +1 -0
- package/libs/{chunk-CWRNJA4P.js → chunk-DIJBIOFE.js} +3 -3
- package/libs/chunk-EJ6KYBFE.cjs +13 -0
- package/libs/chunk-EJ6KYBFE.cjs.map +1 -0
- package/libs/{chunk-GUJSMQ3V.cjs → chunk-EKJYOCLY.cjs} +3 -3
- package/libs/{chunk-X5RKCLDC.cjs → chunk-F64GE6RG.cjs} +4 -4
- package/libs/{chunk-5RAWNUVD.js → chunk-IBUTNPTQ.js} +2 -2
- package/libs/chunk-IWP4VJEP.cjs +18 -0
- package/libs/chunk-IWP4VJEP.cjs.map +1 -0
- package/libs/{chunk-ZFJ4U45S.js → chunk-KDMX3FAW.js} +2 -2
- package/libs/{chunk-DYFAUAB7.cjs → chunk-LXODKKA3.cjs} +4 -4
- package/libs/{chunk-MPTMPBFT.js → chunk-M7JLT62Q.js} +2 -2
- package/libs/{chunk-IQ76HGVP.js → chunk-MBWI67UT.js} +2 -2
- package/libs/{chunk-O5XAJ7BY.cjs → chunk-NCGVF2QS.cjs} +4 -4
- package/libs/{chunk-W2UIN7EV.cjs → chunk-NPWHQVYB.cjs} +3 -3
- package/libs/{chunk-43TK2ICH.js → chunk-PMWL5XZ4.js} +3 -3
- package/libs/{chunk-KVKQLRJG.js → chunk-TF3GQKOY.js} +2 -2
- package/libs/{chunk-IEB64SWY.js → chunk-U5VA34SU.js} +2 -2
- package/libs/chunk-UGMP72J2.js +8 -0
- package/libs/chunk-UGMP72J2.js.map +1 -0
- package/libs/{chunk-EE3ZWSBY.cjs → chunk-URBGDUFN.cjs} +6 -6
- package/libs/{chunk-TPIB3RQP.js → chunk-ZF6Y7W57.js} +5 -5
- package/libs/component-props-50e69975.d.ts +66 -0
- package/libs/components/box/box.css +1 -0
- package/libs/components/box/box.css.map +1 -0
- package/libs/components/box/box.min.css +3 -0
- package/libs/components/breadcrumbs/breadcrumb.cjs +6 -6
- package/libs/components/breadcrumbs/breadcrumb.js +3 -3
- package/libs/components/button.cjs +4 -4
- package/libs/components/button.d.cts +10 -3
- package/libs/components/button.d.ts +10 -3
- package/libs/components/button.js +2 -2
- package/libs/components/card.cjs +7 -7
- package/libs/components/card.d.cts +13 -85
- package/libs/components/card.d.ts +13 -85
- package/libs/components/card.js +2 -2
- package/libs/components/cards/card.css +1 -1
- package/libs/components/cards/card.css.map +1 -1
- package/libs/components/cards/card.min.css +2 -2
- package/libs/components/cluster/cluster.css +1 -0
- package/libs/components/cluster/cluster.css.map +1 -0
- package/libs/components/cluster/cluster.min.css +3 -0
- package/libs/components/dialog/dialog.cjs +7 -7
- package/libs/components/dialog/dialog.js +5 -5
- package/libs/components/form/fields.cjs +4 -4
- package/libs/components/form/fields.js +2 -2
- package/libs/components/form/textarea.cjs +4 -4
- package/libs/components/form/textarea.js +2 -2
- package/libs/components/grid/grid.css +1 -0
- package/libs/components/grid/grid.css.map +1 -0
- package/libs/components/grid/grid.min.css +3 -0
- package/libs/components/heading/heading.cjs +3 -3
- package/libs/components/heading/heading.js +2 -2
- package/libs/components/icons/icon.cjs +4 -4
- package/libs/components/icons/icon.d.cts +2 -2
- package/libs/components/icons/icon.d.ts +2 -2
- package/libs/components/icons/icon.js +2 -2
- package/libs/components/link/link.cjs +6 -6
- package/libs/components/link/link.js +2 -2
- package/libs/components/list/list.cjs +5 -5
- package/libs/components/list/list.js +2 -2
- package/libs/components/modal.cjs +4 -4
- package/libs/components/modal.d.cts +1 -1
- package/libs/components/modal.d.ts +1 -1
- package/libs/components/modal.js +3 -3
- package/libs/components/nav/nav.cjs +7 -7
- package/libs/components/nav/nav.js +3 -3
- package/libs/components/stack/stack.css +1 -0
- package/libs/components/stack/stack.css.map +1 -0
- package/libs/components/stack/stack.min.css +3 -0
- package/libs/components/tables/table.d.cts +1 -1
- package/libs/components/tables/table.d.ts +1 -1
- package/libs/components/text/text.cjs +5 -5
- package/libs/components/text/text.js +2 -2
- package/libs/hooks.cjs +4 -4
- package/libs/hooks.js +3 -3
- package/libs/{icons-287fce3a.d.ts → icons-df8e744f.d.ts} +1 -1
- package/libs/icons.cjs +3 -3
- package/libs/icons.d.cts +2 -2
- package/libs/icons.d.ts +2 -2
- package/libs/icons.js +2 -2
- package/libs/index.cjs +64 -63
- package/libs/index.cjs.map +1 -1
- package/libs/index.css +1 -1
- package/libs/index.css.map +1 -1
- package/libs/index.d.cts +923 -4
- package/libs/index.d.ts +923 -4
- package/libs/index.js +28 -28
- package/libs/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/alert/STYLES.mdx +790 -0
- package/src/components/badge/STYLES.mdx +610 -0
- package/src/components/box/README.mdx +401 -0
- package/src/components/box/STYLES.mdx +360 -0
- package/src/components/box/box.scss +245 -0
- package/src/components/box/box.stories.tsx +395 -0
- package/src/components/box/box.test.tsx +425 -0
- package/src/components/box/box.tsx +170 -0
- package/src/components/box/box.types.ts +166 -0
- package/src/components/breadcrumbs/STYLES.mdx +99 -0
- package/src/components/buttons/STYLES.mdx +766 -0
- package/src/components/cards/STYLES.mdx +835 -0
- package/src/components/cards/card.scss +29 -21
- package/src/components/cards/card.tsx +13 -3
- package/src/components/cards/card.types.ts +13 -0
- package/src/components/cluster/README.mdx +595 -0
- package/src/components/cluster/STYLES.mdx +626 -0
- package/src/components/cluster/cluster.scss +86 -0
- package/src/components/cluster/cluster.stories.tsx +385 -0
- package/src/components/cluster/cluster.test.tsx +655 -0
- package/src/components/cluster/cluster.tsx +94 -0
- package/src/components/cluster/cluster.types.ts +75 -0
- package/src/components/details/STYLES.mdx +445 -0
- package/src/components/dialog/STYLES.mdx +888 -0
- package/src/components/flexbox/STYLES.mdx +1 -1
- package/src/components/form/STYLES.mdx +821 -0
- package/src/components/grid/README.mdx +709 -0
- package/src/components/grid/STYLES.mdx +785 -0
- package/src/components/grid/grid.scss +287 -0
- package/src/components/grid/grid.stories.tsx +486 -0
- package/src/components/grid/grid.test.tsx +981 -0
- package/src/components/grid/grid.tsx +222 -0
- package/src/components/grid/grid.types.ts +344 -0
- package/src/components/icons/STYLES.mdx +56 -0
- package/src/components/images/STYLES.mdx +75 -0
- package/src/components/layout/STYLES.mdx +556 -0
- package/src/components/link/STYLES.mdx +75 -0
- package/src/components/list/STYLES.mdx +631 -0
- package/src/components/nav/STYLES.mdx +460 -0
- package/src/components/progress/STYLES.mdx +64 -0
- package/src/components/stack/README.mdx +400 -0
- package/src/components/stack/STYLES.mdx +414 -0
- package/src/components/stack/stack.scss +109 -0
- package/src/components/stack/stack.stories.tsx +559 -0
- package/src/components/stack/stack.test.tsx +426 -0
- package/src/components/stack/stack.tsx +141 -0
- package/src/components/stack/stack.types.ts +133 -0
- package/src/components/tag/STYLES.mdx +105 -0
- package/src/components/text-to-speech/STYLES.mdx +80 -0
- package/src/components/ui.tsx +3 -3
- package/src/index.scss +5 -1
- package/src/index.ts +305 -12
- package/src/sass/GLOBALS-STYLES.md +631 -0
- package/src/sass/_globals.scss +45 -24
- package/src/styles/box/box.css +220 -0
- package/src/styles/box/box.css.map +1 -0
- package/src/styles/cards/card.css +22 -17
- package/src/styles/cards/card.css.map +1 -1
- package/src/styles/cluster/cluster.css +71 -0
- package/src/styles/cluster/cluster.css.map +1 -0
- package/src/styles/grid/grid.css +238 -0
- package/src/styles/grid/grid.css.map +1 -0
- package/src/styles/index.css +667 -49
- package/src/styles/index.css.map +1 -1
- package/src/styles/stack/stack.css +86 -0
- package/src/styles/stack/stack.css.map +1 -0
- package/src/types/component-props.ts +42 -14
- package/src/types/layout-primitives.ts +48 -0
- package/src/types/shared.ts +10 -26
- package/libs/chunk-ENTCUJ3A.cjs +0 -13
- package/libs/chunk-ENTCUJ3A.cjs.map +0 -1
- package/libs/chunk-HHLNOC5T.js +0 -7
- package/libs/chunk-HHLNOC5T.js.map +0 -1
- package/libs/chunk-KK47SYZI.js +0 -8
- package/libs/chunk-KK47SYZI.js.map +0 -1
- package/libs/chunk-W5TKWBFC.cjs +0 -18
- package/libs/chunk-W5TKWBFC.cjs.map +0 -1
- package/libs/component-props-67d978a2.d.ts +0 -38
- /package/libs/{chunk-2NRIP6RB.cjs.map → chunk-2C3YLBWP.cjs.map} +0 -0
- /package/libs/{chunk-NWJDAHP6.cjs.map → chunk-2GJHKWEK.cjs.map} +0 -0
- /package/libs/{chunk-FVROL3V5.js.map → chunk-2JCDEC32.js.map} +0 -0
- /package/libs/{chunk-IRLFZ3OL.js.map → chunk-3XJC4XUG.js.map} +0 -0
- /package/libs/{chunk-L6PRDL6F.cjs.map → chunk-5CJPTDK3.cjs.map} +0 -0
- /package/libs/{chunk-E4OSROCA.cjs.map → chunk-5QSNJQVH.cjs.map} +0 -0
- /package/libs/{chunk-O3JIHC5M.cjs.map → chunk-6BUJZ4DJ.cjs.map} +0 -0
- /package/libs/{chunk-WXBFBWYF.cjs.map → chunk-AFINOD2L.cjs.map} +0 -0
- /package/libs/{chunk-HRRHPLER.js.map → chunk-AWZLSWDO.js.map} +0 -0
- /package/libs/{chunk-CWRNJA4P.js.map → chunk-DIJBIOFE.js.map} +0 -0
- /package/libs/{chunk-GUJSMQ3V.cjs.map → chunk-EKJYOCLY.cjs.map} +0 -0
- /package/libs/{chunk-X5RKCLDC.cjs.map → chunk-F64GE6RG.cjs.map} +0 -0
- /package/libs/{chunk-5RAWNUVD.js.map → chunk-IBUTNPTQ.js.map} +0 -0
- /package/libs/{chunk-ZFJ4U45S.js.map → chunk-KDMX3FAW.js.map} +0 -0
- /package/libs/{chunk-DYFAUAB7.cjs.map → chunk-LXODKKA3.cjs.map} +0 -0
- /package/libs/{chunk-MPTMPBFT.js.map → chunk-M7JLT62Q.js.map} +0 -0
- /package/libs/{chunk-IQ76HGVP.js.map → chunk-MBWI67UT.js.map} +0 -0
- /package/libs/{chunk-O5XAJ7BY.cjs.map → chunk-NCGVF2QS.cjs.map} +0 -0
- /package/libs/{chunk-W2UIN7EV.cjs.map → chunk-NPWHQVYB.cjs.map} +0 -0
- /package/libs/{chunk-43TK2ICH.js.map → chunk-PMWL5XZ4.js.map} +0 -0
- /package/libs/{chunk-KVKQLRJG.js.map → chunk-TF3GQKOY.js.map} +0 -0
- /package/libs/{chunk-IEB64SWY.js.map → chunk-U5VA34SU.js.map} +0 -0
- /package/libs/{chunk-EE3ZWSBY.cjs.map → chunk-URBGDUFN.cjs.map} +0 -0
- /package/libs/{chunk-TPIB3RQP.js.map → chunk-ZF6Y7W57.js.map} +0 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import UI from "../ui";
|
|
3
|
+
import type { GridProps, GridItemProps } from "./grid.types";
|
|
4
|
+
|
|
5
|
+
// Re-export types for convenience
|
|
6
|
+
export type { GridProps, GridItemProps } from "./grid.types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Grid - A CSS Grid-based layout primitive for responsive multi-column layouts.
|
|
10
|
+
*
|
|
11
|
+
* Grid provides a flexible, declarative way to create responsive grid layouts
|
|
12
|
+
* with explicit column control, auto-fit/auto-fill behavior, gap spacing, and
|
|
13
|
+
* alignment options. Pair with Grid.Item for column span control.
|
|
14
|
+
*
|
|
15
|
+
* ## Key Features
|
|
16
|
+
* - **CSS Grid**: Native CSS Grid for true 2D layouts
|
|
17
|
+
* - **Responsive Columns**: 1-12 column layouts or auto-fit/auto-fill
|
|
18
|
+
* - **Grid.Item**: Sub-component for column and row span control
|
|
19
|
+
* - **Fluid Spacing**: Responsive gap using CSS clamp()
|
|
20
|
+
* - **Polymorphic**: Render as any semantic HTML element
|
|
21
|
+
* - **Type-Safe**: Full TypeScript support
|
|
22
|
+
*
|
|
23
|
+
* ## Use Cases
|
|
24
|
+
* - Multi-column card grids
|
|
25
|
+
* - Responsive layouts (main content + sidebar)
|
|
26
|
+
* - Image galleries
|
|
27
|
+
* - Dashboard layouts
|
|
28
|
+
* - Form layouts with label/input pairs
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // 3-column grid
|
|
32
|
+
* <Grid columns={3} gap="md">
|
|
33
|
+
* <Grid.Item>Card 1</Grid.Item>
|
|
34
|
+
* <Grid.Item>Card 2</Grid.Item>
|
|
35
|
+
* <Grid.Item>Card 3</Grid.Item>
|
|
36
|
+
* </Grid>
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // Auto-fit grid
|
|
40
|
+
* <Grid auto="fit" minColumnWidth="15rem" gap="lg">
|
|
41
|
+
* <Grid.Item>Card 1</Grid.Item>
|
|
42
|
+
* <Grid.Item>Card 2</Grid.Item>
|
|
43
|
+
* </Grid>
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // 12-column layout with custom spans
|
|
47
|
+
* <Grid columns={12} gap="md">
|
|
48
|
+
* <Grid.Item span={8}>Main content</Grid.Item>
|
|
49
|
+
* <Grid.Item span={4}>Sidebar</Grid.Item>
|
|
50
|
+
* </Grid>
|
|
51
|
+
*
|
|
52
|
+
* @see {@link GridProps} for complete props documentation
|
|
53
|
+
*/
|
|
54
|
+
export const Grid = React.forwardRef<HTMLElement, GridProps>(
|
|
55
|
+
(
|
|
56
|
+
{
|
|
57
|
+
columns,
|
|
58
|
+
auto,
|
|
59
|
+
minColumnWidth,
|
|
60
|
+
gap,
|
|
61
|
+
gapX,
|
|
62
|
+
gapY,
|
|
63
|
+
justifyItems,
|
|
64
|
+
alignItems,
|
|
65
|
+
as = "div",
|
|
66
|
+
className,
|
|
67
|
+
classes,
|
|
68
|
+
children,
|
|
69
|
+
style,
|
|
70
|
+
styles,
|
|
71
|
+
...props
|
|
72
|
+
},
|
|
73
|
+
ref
|
|
74
|
+
) => {
|
|
75
|
+
// Build utility classes array based on props
|
|
76
|
+
const utilityClasses: string[] = ["grid"];
|
|
77
|
+
|
|
78
|
+
// Column layout (explicit columns)
|
|
79
|
+
if (columns) {
|
|
80
|
+
utilityClasses.push(`grid-cols-${columns}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Auto-fit/auto-fill layout
|
|
84
|
+
if (auto) {
|
|
85
|
+
utilityClasses.push(`grid-auto-${auto}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Gap utilities
|
|
89
|
+
if (gap) {
|
|
90
|
+
utilityClasses.push(`grid-gap-${gap}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Gap X (column gap)
|
|
94
|
+
if (gapX) {
|
|
95
|
+
utilityClasses.push(`grid-gap-x-${gapX}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Gap Y (row gap)
|
|
99
|
+
if (gapY) {
|
|
100
|
+
utilityClasses.push(`grid-gap-y-${gapY}`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Justify items
|
|
104
|
+
if (justifyItems) {
|
|
105
|
+
utilityClasses.push(`grid-justify-items-${justifyItems}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Align items
|
|
109
|
+
if (alignItems) {
|
|
110
|
+
utilityClasses.push(`grid-align-items-${alignItems}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Merge all classes
|
|
114
|
+
const allClasses = [...utilityClasses, className, classes]
|
|
115
|
+
.filter(Boolean)
|
|
116
|
+
.join(" ");
|
|
117
|
+
|
|
118
|
+
// Build inline styles
|
|
119
|
+
const inlineStyles: React.CSSProperties = {
|
|
120
|
+
...(style || {}),
|
|
121
|
+
...(styles || {}),
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Add custom grid-template-columns for auto layouts
|
|
125
|
+
if (auto && minColumnWidth) {
|
|
126
|
+
inlineStyles.gridTemplateColumns = `repeat(auto-${auto}, minmax(${minColumnWidth}, 1fr))`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<UI
|
|
131
|
+
as={as}
|
|
132
|
+
ref={ref}
|
|
133
|
+
classes={allClasses}
|
|
134
|
+
style={Object.keys(inlineStyles).length > 0 ? inlineStyles : undefined}
|
|
135
|
+
{...props}
|
|
136
|
+
>
|
|
137
|
+
{children}
|
|
138
|
+
</UI>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
Grid.displayName = "Grid";
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Grid.Item - A grid item component with column and row span control.
|
|
147
|
+
*
|
|
148
|
+
* Grid.Item represents a single item within a Grid layout. It supports
|
|
149
|
+
* column spanning (1-12 columns) and row spanning for flexible grid layouts.
|
|
150
|
+
*
|
|
151
|
+
* ## Key Features
|
|
152
|
+
* - **Column Span**: Span 1-12 columns
|
|
153
|
+
* - **Row Span**: Span multiple rows
|
|
154
|
+
* - **Polymorphic**: Render as any semantic HTML element
|
|
155
|
+
* - **Type-Safe**: Full TypeScript support
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* // Span 2 columns
|
|
159
|
+
* <Grid.Item span={2}>Wide item</Grid.Item>
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* // Span 2 rows
|
|
163
|
+
* <Grid.Item rowSpan={2}>Tall item</Grid.Item>
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* // Main content + sidebar layout
|
|
167
|
+
* <Grid columns={12} gap="md">
|
|
168
|
+
* <Grid.Item span={8}>Main content</Grid.Item>
|
|
169
|
+
* <Grid.Item span={4}>Sidebar</Grid.Item>
|
|
170
|
+
* </Grid>
|
|
171
|
+
*
|
|
172
|
+
* @see {@link GridItemProps} for complete props documentation
|
|
173
|
+
*/
|
|
174
|
+
export const GridItem = React.forwardRef<HTMLElement, GridItemProps>(
|
|
175
|
+
(
|
|
176
|
+
{
|
|
177
|
+
span,
|
|
178
|
+
rowSpan,
|
|
179
|
+
as = "div",
|
|
180
|
+
className,
|
|
181
|
+
classes,
|
|
182
|
+
children,
|
|
183
|
+
...props
|
|
184
|
+
},
|
|
185
|
+
ref
|
|
186
|
+
) => {
|
|
187
|
+
// Build utility classes array based on props
|
|
188
|
+
const utilityClasses: string[] = [];
|
|
189
|
+
|
|
190
|
+
// Column span
|
|
191
|
+
if (span) {
|
|
192
|
+
utilityClasses.push(`grid-col-span-${span}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Row span
|
|
196
|
+
if (rowSpan) {
|
|
197
|
+
utilityClasses.push(`grid-row-span-${rowSpan}`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Merge all classes
|
|
201
|
+
const allClasses = [...utilityClasses, className, classes]
|
|
202
|
+
.filter(Boolean)
|
|
203
|
+
.join(" ");
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<UI as={as} ref={ref} classes={allClasses} {...props}>
|
|
207
|
+
{children}
|
|
208
|
+
</UI>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
GridItem.displayName = "GridItem";
|
|
214
|
+
|
|
215
|
+
// Attach Grid.Item as a sub-component
|
|
216
|
+
const GridWithItem = Grid as typeof Grid & {
|
|
217
|
+
Item: typeof GridItem;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
GridWithItem.Item = GridItem;
|
|
221
|
+
|
|
222
|
+
export default GridWithItem;
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import type { ComponentProps } from "../../types";
|
|
2
|
+
import type { SpacingScale, GridElement, GridItemElement } from "../../types/layout-primitives";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Number of columns in the grid (1-12)
|
|
6
|
+
*/
|
|
7
|
+
export type GridColumns = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Grid auto-fit/auto-fill behavior
|
|
11
|
+
*/
|
|
12
|
+
export type GridAuto = "fit" | "fill";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Props for the Grid component
|
|
16
|
+
*
|
|
17
|
+
* Grid provides a CSS Grid-based layout primitive for responsive multi-column layouts.
|
|
18
|
+
* Supports explicit column counts, auto-fit/auto-fill, gap spacing, and alignment control.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* // 3-column grid
|
|
23
|
+
* <Grid columns={3} gap="md">
|
|
24
|
+
* <Grid.Item>Card 1</Grid.Item>
|
|
25
|
+
* <Grid.Item>Card 2</Grid.Item>
|
|
26
|
+
* <Grid.Item>Card 3</Grid.Item>
|
|
27
|
+
* </Grid>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // Auto-fit grid with minimum column width
|
|
33
|
+
* <Grid auto="fit" minColumnWidth="15rem" gap="lg">
|
|
34
|
+
* <Grid.Item>Card 1</Grid.Item>
|
|
35
|
+
* <Grid.Item>Card 2</Grid.Item>
|
|
36
|
+
* </Grid>
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* // Grid with custom column spans
|
|
42
|
+
* <Grid columns={12} gap="md">
|
|
43
|
+
* <Grid.Item span={8}>Main content</Grid.Item>
|
|
44
|
+
* <Grid.Item span={4}>Sidebar</Grid.Item>
|
|
45
|
+
* </Grid>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export interface GridProps
|
|
49
|
+
extends Partial<ComponentProps>,
|
|
50
|
+
Omit<React.HTMLAttributes<HTMLElement>, "className"> {
|
|
51
|
+
/**
|
|
52
|
+
* Number of columns in the grid (1-12)
|
|
53
|
+
*
|
|
54
|
+
* Creates an explicit column layout with equal-width columns.
|
|
55
|
+
* Mutually exclusive with `auto` prop.
|
|
56
|
+
*
|
|
57
|
+
* @default 1
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* <Grid columns={3}>
|
|
62
|
+
* <div>Column 1</div>
|
|
63
|
+
* <div>Column 2</div>
|
|
64
|
+
* <div>Column 3</div>
|
|
65
|
+
* </Grid>
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
columns?: GridColumns;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Auto-fit or auto-fill behavior
|
|
72
|
+
*
|
|
73
|
+
* - `fit`: Columns expand to fill available space (grid-template-columns: repeat(auto-fit, ...))
|
|
74
|
+
* - `fill`: Creates as many columns as fit, even if empty (repeat(auto-fill, ...))
|
|
75
|
+
*
|
|
76
|
+
* Requires `minColumnWidth` to be set. Mutually exclusive with `columns` prop.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* <Grid auto="fit" minColumnWidth="15rem" gap="md">
|
|
81
|
+
* <div>Item 1</div>
|
|
82
|
+
* <div>Item 2</div>
|
|
83
|
+
* <div>Item 3</div>
|
|
84
|
+
* </Grid>
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
auto?: GridAuto;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Minimum column width for auto-fit/auto-fill grids
|
|
91
|
+
*
|
|
92
|
+
* Must be specified in rem units (e.g., "15rem", "20rem").
|
|
93
|
+
* Used with `auto` prop to create responsive grids without media queries.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```tsx
|
|
97
|
+
* <Grid auto="fit" minColumnWidth="15rem">
|
|
98
|
+
* <div>Card</div>
|
|
99
|
+
* </Grid>
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
minColumnWidth?: string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Gap spacing between grid items
|
|
106
|
+
*
|
|
107
|
+
* Uses the unified spacing scale from globals.
|
|
108
|
+
*
|
|
109
|
+
* @default undefined (uses default `.grid` gap)
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* <Grid columns={3} gap="md">
|
|
114
|
+
* <div>Item 1</div>
|
|
115
|
+
* <div>Item 2</div>
|
|
116
|
+
* </Grid>
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
gap?: SpacingScale;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Horizontal gap spacing (column gap)
|
|
123
|
+
*
|
|
124
|
+
* Overrides `gap` for horizontal spacing only.
|
|
125
|
+
* Uses the unified spacing scale.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```tsx
|
|
129
|
+
* <Grid columns={3} gapX="lg" gapY="sm">
|
|
130
|
+
* <div>Item 1</div>
|
|
131
|
+
* <div>Item 2</div>
|
|
132
|
+
* </Grid>
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
gapX?: SpacingScale;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Vertical gap spacing (row gap)
|
|
139
|
+
*
|
|
140
|
+
* Overrides `gap` for vertical spacing only.
|
|
141
|
+
* Uses the unified spacing scale.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```tsx
|
|
145
|
+
* <Grid columns={3} gapX="lg" gapY="sm">
|
|
146
|
+
* <div>Item 1</div>
|
|
147
|
+
* <div>Item 2</div>
|
|
148
|
+
* </Grid>
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
gapY?: SpacingScale;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Horizontal alignment of grid items (justify-items)
|
|
155
|
+
*
|
|
156
|
+
* Controls horizontal alignment of items within their grid cells.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```tsx
|
|
160
|
+
* <Grid columns={3} justifyItems="center">
|
|
161
|
+
* <div>Centered item</div>
|
|
162
|
+
* </Grid>
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
justifyItems?: "start" | "center" | "end" | "stretch";
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Vertical alignment of grid items (align-items)
|
|
169
|
+
*
|
|
170
|
+
* Controls vertical alignment of items within their grid cells.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```tsx
|
|
174
|
+
* <Grid columns={3} alignItems="center">
|
|
175
|
+
* <div>Vertically centered</div>
|
|
176
|
+
* </Grid>
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
alignItems?: "start" | "center" | "end" | "stretch";
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* HTML element to render as
|
|
183
|
+
*
|
|
184
|
+
* @default "div"
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```tsx
|
|
188
|
+
* <Grid as="section" columns={2}>
|
|
189
|
+
* <article>Post 1</article>
|
|
190
|
+
* <article>Post 2</article>
|
|
191
|
+
* </Grid>
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
as?: GridElement;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Additional CSS class name(s)
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```tsx
|
|
201
|
+
* <Grid className="custom-grid" columns={3}>
|
|
202
|
+
* <div>Item</div>
|
|
203
|
+
* </Grid>
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
className?: string;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Additional CSS class name(s) (alternative to className)
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```tsx
|
|
213
|
+
* <Grid classes="utility-class" columns={3}>
|
|
214
|
+
* <div>Item</div>
|
|
215
|
+
* </Grid>
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
classes?: string;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Children elements (typically Grid.Item components)
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```tsx
|
|
225
|
+
* <Grid columns={3}>
|
|
226
|
+
* <Grid.Item>Item 1</Grid.Item>
|
|
227
|
+
* <Grid.Item span={2}>Item 2 (2 columns wide)</Grid.Item>
|
|
228
|
+
* </Grid>
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
children?: React.ReactNode;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Props for the Grid.Item component
|
|
236
|
+
*
|
|
237
|
+
* Grid.Item represents a single item within a Grid layout.
|
|
238
|
+
* Supports column span control for flexible grid layouts.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```tsx
|
|
242
|
+
* <Grid columns={12}>
|
|
243
|
+
* <Grid.Item span={8}>Main content (8/12)</Grid.Item>
|
|
244
|
+
* <Grid.Item span={4}>Sidebar (4/12)</Grid.Item>
|
|
245
|
+
* </Grid>
|
|
246
|
+
* ```
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```tsx
|
|
250
|
+
* <Grid columns={4}>
|
|
251
|
+
* <Grid.Item>1 column</Grid.Item>
|
|
252
|
+
* <Grid.Item span={2}>2 columns</Grid.Item>
|
|
253
|
+
* <Grid.Item>1 column</Grid.Item>
|
|
254
|
+
* </Grid>
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
export interface GridItemProps
|
|
258
|
+
extends Partial<ComponentProps>,
|
|
259
|
+
Omit<React.HTMLAttributes<HTMLElement>, "className"> {
|
|
260
|
+
/**
|
|
261
|
+
* Number of columns this item should span (1-12)
|
|
262
|
+
*
|
|
263
|
+
* Determines the width of the grid item relative to the parent grid's columns.
|
|
264
|
+
*
|
|
265
|
+
* @default 1
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```tsx
|
|
269
|
+
* <Grid columns={12}>
|
|
270
|
+
* <Grid.Item span={6}>Half width</Grid.Item>
|
|
271
|
+
* <Grid.Item span={6}>Half width</Grid.Item>
|
|
272
|
+
* </Grid>
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
span?: GridColumns;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Row span for the grid item
|
|
279
|
+
*
|
|
280
|
+
* Determines how many rows this item should span.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```tsx
|
|
284
|
+
* <Grid columns={3}>
|
|
285
|
+
* <Grid.Item rowSpan={2}>Tall item</Grid.Item>
|
|
286
|
+
* <Grid.Item>Normal</Grid.Item>
|
|
287
|
+
* <Grid.Item>Normal</Grid.Item>
|
|
288
|
+
* </Grid>
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
rowSpan?: number;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* HTML element to render as
|
|
295
|
+
*
|
|
296
|
+
* @default "div"
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```tsx
|
|
300
|
+
* <Grid as="ul" columns={3}>
|
|
301
|
+
* <Grid.Item as="li">List item 1</Grid.Item>
|
|
302
|
+
* <Grid.Item as="li">List item 2</Grid.Item>
|
|
303
|
+
* </Grid>
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
as?: GridItemElement;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Additional CSS class name(s)
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```tsx
|
|
313
|
+
* <Grid.Item className="featured" span={2}>
|
|
314
|
+
* Featured content
|
|
315
|
+
* </Grid.Item>
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
318
|
+
className?: string;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Additional CSS class name(s) (alternative to className)
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```tsx
|
|
325
|
+
* <Grid.Item classes="utility-class" span={3}>
|
|
326
|
+
* Content
|
|
327
|
+
* </Grid.Item>
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
classes?: string;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Children elements
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```tsx
|
|
337
|
+
* <Grid.Item span={2}>
|
|
338
|
+
* <h2>Title</h2>
|
|
339
|
+
* <p>Content</p>
|
|
340
|
+
* </Grid.Item>
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
children?: React.ReactNode;
|
|
344
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="FP.REACT Components/Icons/Styles" />
|
|
4
|
+
|
|
5
|
+
# Icon Styles
|
|
6
|
+
|
|
7
|
+
Flexbox-based icon wrapper for consistent icon display and alignment.
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
The fpkit icon system provides a flexible wrapper for icon elements using the
|
|
12
|
+
`data-icon` attribute with flexbox layout.
|
|
13
|
+
|
|
14
|
+
### Key Features
|
|
15
|
+
|
|
16
|
+
- **Flexbox layout** - Centered icon alignment
|
|
17
|
+
- **Gap control** - Spacing between icon and text
|
|
18
|
+
- **Size control** - Width and height management
|
|
19
|
+
- **CSS custom properties** - Full layout control
|
|
20
|
+
|
|
21
|
+
## CSS Custom Properties
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
[data-icon] {
|
|
25
|
+
--icon-display: inline-flex;
|
|
26
|
+
--icon-direction: row;
|
|
27
|
+
--icons-placement: center;
|
|
28
|
+
--icon-width: max-content;
|
|
29
|
+
--icon-gap: 0.2rem; /* 3.2px */
|
|
30
|
+
--icon-height: max-content;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Basic Usage
|
|
35
|
+
|
|
36
|
+
### Icon with Text
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<span data-icon>
|
|
40
|
+
<svg><!-- icon --></svg>
|
|
41
|
+
<span>Label</span>
|
|
42
|
+
</span>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Icon Button
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<button data-icon>
|
|
49
|
+
<svg><!-- icon --></svg>
|
|
50
|
+
<span>Click me</span>
|
|
51
|
+
</button>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Related Resources
|
|
55
|
+
|
|
56
|
+
- **MDN: SVG** - https://developer.mozilla.org/en-US/docs/Web/SVG
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="FP.REACT Components/Images/Styles" />
|
|
4
|
+
|
|
5
|
+
# Image Styles
|
|
6
|
+
|
|
7
|
+
Responsive image styling with figure support and CSS custom properties.
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
The fpkit image system provides responsive, accessible image styling with
|
|
12
|
+
support for figures and captions.
|
|
13
|
+
|
|
14
|
+
### Key Features
|
|
15
|
+
|
|
16
|
+
- **Responsive by default** - Max-width 100% with auto height
|
|
17
|
+
- **Object-fit support** - Control image scaling
|
|
18
|
+
- **Aspect ratio** - Maintain proportions
|
|
19
|
+
- **Figure captions** - Styled figcaption support
|
|
20
|
+
- **CSS custom properties** - Full control over display
|
|
21
|
+
- **Rem-based sizing** - All measurements use rem units (1rem = 16px)
|
|
22
|
+
|
|
23
|
+
## CSS Custom Properties
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
img[alt] {
|
|
27
|
+
--img-max-width: 100%;
|
|
28
|
+
--img-height: auto;
|
|
29
|
+
--img-object-fit: cover;
|
|
30
|
+
--img-object-position: center;
|
|
31
|
+
--img-aspect-ratio: auto 2/3;
|
|
32
|
+
--img-display: inline-block;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
figure:has(img[alt]) {
|
|
36
|
+
--fig-display: flex;
|
|
37
|
+
--fig-padding: 0.5rem;
|
|
38
|
+
--fig-bg: rgba(245, 245, 245, 0.683);
|
|
39
|
+
--fig-width: fit-content;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Basic Usage
|
|
44
|
+
|
|
45
|
+
### Responsive Image
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<img src="/image.jpg" alt="Description" />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Image with Figure
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<figure>
|
|
55
|
+
<img src="/image.jpg" alt="Description" />
|
|
56
|
+
<figcaption>Image caption</figcaption>
|
|
57
|
+
</figure>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Custom Aspect Ratio
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<img
|
|
64
|
+
src="/image.jpg"
|
|
65
|
+
alt="Square image"
|
|
66
|
+
style="--img-aspect-ratio: 1/1; --img-object-fit: cover"
|
|
67
|
+
/>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Related Resources
|
|
71
|
+
|
|
72
|
+
- **MDN: Images** -
|
|
73
|
+
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img
|
|
74
|
+
- **MDN: Figure** -
|
|
75
|
+
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure
|