@fpkit/acss 3.3.0 → 3.4.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/components/alert/alert.min.min.css +2 -0
- package/libs/components/badge/badge.min.min.css +2 -0
- package/libs/components/box/box.min.min.css +2 -0
- package/libs/components/breadcrumbs/breadcrumb.min.min.css +2 -0
- package/libs/components/buttons/button.min.min.css +2 -0
- package/libs/components/cards/card-style.min.min.css +2 -0
- package/libs/components/cards/card.min.min.css +2 -0
- package/libs/components/cluster/cluster.min.min.css +2 -0
- package/libs/components/details/details.min.min.css +2 -0
- package/libs/components/dialog/dialog.min.min.css +2 -0
- package/libs/components/flexbox/flex.min.min.css +2 -0
- package/libs/components/form/form.min.min.css +2 -0
- package/libs/components/grid/grid.min.min.css +2 -0
- package/libs/components/icons/icon.min.min.css +2 -0
- package/libs/components/images/img.min.min.css +2 -0
- package/libs/components/layout/landmarks.min.min.css +2 -0
- package/libs/components/link/link.min.min.css +2 -0
- package/libs/components/list/list.min.min.css +2 -0
- package/libs/components/nav/nav.min.min.css +2 -0
- package/libs/components/progress/progress.min.min.css +2 -0
- package/libs/components/stack/stack.min.min.css +2 -0
- package/libs/components/styles/index.min.min.css +2 -0
- package/libs/components/tag/tag.min.min.css +2 -0
- package/libs/components/text-to-speech/text-to-speech.min.min.css +2 -0
- package/libs/index.cjs +22 -20
- 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 +275 -1
- package/libs/index.d.ts +275 -1
- package/libs/index.js +9 -9
- package/libs/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/col/README.mdx +532 -0
- package/src/components/col/col.stories.tsx +424 -0
- package/src/components/col/col.test.tsx +321 -0
- package/src/components/col/col.tsx +105 -0
- package/src/components/col/col.types.ts +76 -0
- package/src/components/row/README.mdx +324 -0
- package/src/components/row/row.stories.tsx +595 -0
- package/src/components/row/row.test.tsx +358 -0
- package/src/components/row/row.tsx +121 -0
- package/src/components/row/row.types.ts +93 -0
- package/src/index.scss +1 -0
- package/src/index.ts +2 -0
- package/src/sass/README.mdx +597 -0
- package/src/sass/_columns.scss +198 -0
- package/src/sass/columns.stories.tsx +456 -0
- package/src/styles/index.css +340 -0
- package/src/styles/index.css.map +1 -1
- package/src/types/layout-primitives.ts +61 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { within, expect } from "storybook/test";
|
|
3
|
+
import { Row } from "../row/row";
|
|
4
|
+
import { Col } from "./col";
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Col> = {
|
|
7
|
+
title: "FP.React Components/Layout/Col",
|
|
8
|
+
component: Col,
|
|
9
|
+
tags: ["autodocs", "rc", "layout"],
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component:
|
|
14
|
+
"Col provides column elements for use within Row containers. Maps React props (span, offset, order, auto) to column utility classes without a base class. Use with Row component for responsive 12-column layouts.",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
argTypes: {
|
|
19
|
+
span: {
|
|
20
|
+
control: "select",
|
|
21
|
+
options: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
|
22
|
+
description: "Column span (1-12 columns)",
|
|
23
|
+
},
|
|
24
|
+
offset: {
|
|
25
|
+
control: "select",
|
|
26
|
+
options: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
|
|
27
|
+
description: "Column offset (0-11 columns)",
|
|
28
|
+
},
|
|
29
|
+
order: {
|
|
30
|
+
control: "select",
|
|
31
|
+
options: ["first", "last", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
|
32
|
+
description: "Column visual order",
|
|
33
|
+
},
|
|
34
|
+
auto: {
|
|
35
|
+
control: "boolean",
|
|
36
|
+
description: "Auto-width column (content-based)",
|
|
37
|
+
},
|
|
38
|
+
as: {
|
|
39
|
+
control: "select",
|
|
40
|
+
options: ["div", "section", "article", "li"],
|
|
41
|
+
description: "Element type to render",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default meta;
|
|
47
|
+
type Story = StoryObj<typeof meta>;
|
|
48
|
+
|
|
49
|
+
const colStyle = {
|
|
50
|
+
padding: "1rem",
|
|
51
|
+
background: "#e0e7ff",
|
|
52
|
+
border: "1px solid #6366f1",
|
|
53
|
+
borderRadius: "0.25rem",
|
|
54
|
+
textAlign: "center" as const,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Basic Columns - Demonstrates all column span sizes (1-12).
|
|
59
|
+
* Shows the full range of column widths available.
|
|
60
|
+
*/
|
|
61
|
+
export const BasicColumns: Story = {
|
|
62
|
+
render: () => (
|
|
63
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
|
|
64
|
+
<Row>
|
|
65
|
+
<Col span={12} style={colStyle}>
|
|
66
|
+
col-12 (100%)
|
|
67
|
+
</Col>
|
|
68
|
+
</Row>
|
|
69
|
+
<Row>
|
|
70
|
+
<Col span={6} style={colStyle}>
|
|
71
|
+
col-6 (50%)
|
|
72
|
+
</Col>
|
|
73
|
+
<Col span={6} style={colStyle}>
|
|
74
|
+
col-6 (50%)
|
|
75
|
+
</Col>
|
|
76
|
+
</Row>
|
|
77
|
+
<Row>
|
|
78
|
+
<Col span={4} style={colStyle}>
|
|
79
|
+
col-4 (33.33%)
|
|
80
|
+
</Col>
|
|
81
|
+
<Col span={4} style={colStyle}>
|
|
82
|
+
col-4 (33.33%)
|
|
83
|
+
</Col>
|
|
84
|
+
<Col span={4} style={colStyle}>
|
|
85
|
+
col-4 (33.33%)
|
|
86
|
+
</Col>
|
|
87
|
+
</Row>
|
|
88
|
+
<Row>
|
|
89
|
+
<Col span={3} style={colStyle}>
|
|
90
|
+
col-3
|
|
91
|
+
</Col>
|
|
92
|
+
<Col span={3} style={colStyle}>
|
|
93
|
+
col-3
|
|
94
|
+
</Col>
|
|
95
|
+
<Col span={3} style={colStyle}>
|
|
96
|
+
col-3
|
|
97
|
+
</Col>
|
|
98
|
+
<Col span={3} style={colStyle}>
|
|
99
|
+
col-3
|
|
100
|
+
</Col>
|
|
101
|
+
</Row>
|
|
102
|
+
<Row>
|
|
103
|
+
<Col span={2} style={colStyle}>
|
|
104
|
+
col-2
|
|
105
|
+
</Col>
|
|
106
|
+
<Col span={2} style={colStyle}>
|
|
107
|
+
col-2
|
|
108
|
+
</Col>
|
|
109
|
+
<Col span={2} style={colStyle}>
|
|
110
|
+
col-2
|
|
111
|
+
</Col>
|
|
112
|
+
<Col span={2} style={colStyle}>
|
|
113
|
+
col-2
|
|
114
|
+
</Col>
|
|
115
|
+
<Col span={2} style={colStyle}>
|
|
116
|
+
col-2
|
|
117
|
+
</Col>
|
|
118
|
+
<Col span={2} style={colStyle}>
|
|
119
|
+
col-2
|
|
120
|
+
</Col>
|
|
121
|
+
</Row>
|
|
122
|
+
<Row>
|
|
123
|
+
{[...Array(12)].map((_, i) => (
|
|
124
|
+
<Col key={i} span={1} style={colStyle}>
|
|
125
|
+
1
|
|
126
|
+
</Col>
|
|
127
|
+
))}
|
|
128
|
+
</Row>
|
|
129
|
+
</div>
|
|
130
|
+
),
|
|
131
|
+
play: async ({ canvasElement, step }) => {
|
|
132
|
+
const canvas = within(canvasElement);
|
|
133
|
+
|
|
134
|
+
await step("All column sizes render correctly", async () => {
|
|
135
|
+
expect(canvas.getByText("col-12 (100%)")).toBeInTheDocument();
|
|
136
|
+
expect(canvas.getByText("col-6 (50%)")).toBeInTheDocument();
|
|
137
|
+
expect(canvas.getByText("col-4 (33.33%)")).toBeInTheDocument();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
await step("Column classes are applied", async () => {
|
|
141
|
+
const col12 = canvasElement.querySelector(".col-12");
|
|
142
|
+
expect(col12).toBeInTheDocument();
|
|
143
|
+
const col6Elements = canvasElement.querySelectorAll(".col-6");
|
|
144
|
+
expect(col6Elements).toHaveLength(2);
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Column Offsets - Demonstrates offset positioning.
|
|
151
|
+
* Shows how offset prop pushes columns to the right.
|
|
152
|
+
*/
|
|
153
|
+
export const ColumnOffsets: Story = {
|
|
154
|
+
render: () => (
|
|
155
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
|
|
156
|
+
<Row>
|
|
157
|
+
<Col span={6} offset={3} style={colStyle}>
|
|
158
|
+
col-6 offset-3 (Centered)
|
|
159
|
+
</Col>
|
|
160
|
+
</Row>
|
|
161
|
+
<Row>
|
|
162
|
+
<Col span={4} offset={4} style={colStyle}>
|
|
163
|
+
col-4 offset-4 (Centered)
|
|
164
|
+
</Col>
|
|
165
|
+
</Row>
|
|
166
|
+
<Row>
|
|
167
|
+
<Col span={3} offset={0} style={colStyle}>
|
|
168
|
+
col-3 offset-0
|
|
169
|
+
</Col>
|
|
170
|
+
<Col span={3} offset={6} style={colStyle}>
|
|
171
|
+
col-3 offset-6
|
|
172
|
+
</Col>
|
|
173
|
+
</Row>
|
|
174
|
+
<Row>
|
|
175
|
+
<Col span={2} offset={2} style={colStyle}>
|
|
176
|
+
offset-2
|
|
177
|
+
</Col>
|
|
178
|
+
<Col span={2} offset={2} style={colStyle}>
|
|
179
|
+
offset-2
|
|
180
|
+
</Col>
|
|
181
|
+
<Col span={2} offset={2} style={colStyle}>
|
|
182
|
+
offset-2
|
|
183
|
+
</Col>
|
|
184
|
+
</Row>
|
|
185
|
+
</div>
|
|
186
|
+
),
|
|
187
|
+
play: async ({ canvasElement, step }) => {
|
|
188
|
+
await step("Offset classes are applied correctly", async () => {
|
|
189
|
+
const offset3 = canvasElement.querySelector(".col-offset-3");
|
|
190
|
+
expect(offset3).toBeInTheDocument();
|
|
191
|
+
const offset4 = canvasElement.querySelector(".col-offset-4");
|
|
192
|
+
expect(offset4).toBeInTheDocument();
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Column Order - Demonstrates visual reordering with flexbox order.
|
|
199
|
+
* Shows how order prop changes visual position without changing DOM order.
|
|
200
|
+
*/
|
|
201
|
+
export const ColumnOrder: Story = {
|
|
202
|
+
render: () => (
|
|
203
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
|
|
204
|
+
<Row>
|
|
205
|
+
<Col span={4} order={3} style={colStyle}>
|
|
206
|
+
DOM 1st, Visual 3rd
|
|
207
|
+
</Col>
|
|
208
|
+
<Col span={4} order={1} style={colStyle}>
|
|
209
|
+
DOM 2nd, Visual 1st
|
|
210
|
+
</Col>
|
|
211
|
+
<Col span={4} order={2} style={colStyle}>
|
|
212
|
+
DOM 3rd, Visual 2nd
|
|
213
|
+
</Col>
|
|
214
|
+
</Row>
|
|
215
|
+
<Row>
|
|
216
|
+
<Col span={6} order="last" style={colStyle}>
|
|
217
|
+
DOM 1st, order-last
|
|
218
|
+
</Col>
|
|
219
|
+
<Col span={6} order="first" style={colStyle}>
|
|
220
|
+
DOM 2nd, order-first
|
|
221
|
+
</Col>
|
|
222
|
+
</Row>
|
|
223
|
+
<Row>
|
|
224
|
+
<Col span={3} order={0} style={colStyle}>
|
|
225
|
+
order-0
|
|
226
|
+
</Col>
|
|
227
|
+
<Col span={3} order={2} style={colStyle}>
|
|
228
|
+
order-2
|
|
229
|
+
</Col>
|
|
230
|
+
<Col span={3} order={1} style={colStyle}>
|
|
231
|
+
order-1
|
|
232
|
+
</Col>
|
|
233
|
+
<Col span={3} style={colStyle}>
|
|
234
|
+
no order
|
|
235
|
+
</Col>
|
|
236
|
+
</Row>
|
|
237
|
+
</div>
|
|
238
|
+
),
|
|
239
|
+
play: async ({ canvasElement, step }) => {
|
|
240
|
+
await step("Order classes are applied correctly", async () => {
|
|
241
|
+
const orderFirst = canvasElement.querySelector(".col-order-first");
|
|
242
|
+
expect(orderFirst).toBeInTheDocument();
|
|
243
|
+
const orderLast = canvasElement.querySelector(".col-order-last");
|
|
244
|
+
expect(orderLast).toBeInTheDocument();
|
|
245
|
+
const order1 = canvasElement.querySelector(".col-order-1");
|
|
246
|
+
expect(order1).toBeInTheDocument();
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
parameters: {
|
|
250
|
+
docs: {
|
|
251
|
+
description: {
|
|
252
|
+
story:
|
|
253
|
+
"Visual order (left-to-right) differs from DOM order. Screen readers follow DOM order, not visual order.",
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Auto-Width Columns - Demonstrates content-based column widths.
|
|
261
|
+
* Shows how auto prop creates columns that size to their content.
|
|
262
|
+
*/
|
|
263
|
+
export const AutoWidth: Story = {
|
|
264
|
+
render: () => (
|
|
265
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
|
|
266
|
+
<Row>
|
|
267
|
+
<Col auto style={colStyle}>
|
|
268
|
+
Auto width (short)
|
|
269
|
+
</Col>
|
|
270
|
+
<Col span={6} style={colStyle}>
|
|
271
|
+
col-6 (50% fixed)
|
|
272
|
+
</Col>
|
|
273
|
+
<Col auto style={colStyle}>
|
|
274
|
+
Auto width (bit longer)
|
|
275
|
+
</Col>
|
|
276
|
+
</Row>
|
|
277
|
+
<Row>
|
|
278
|
+
<Col auto style={colStyle}>
|
|
279
|
+
Button
|
|
280
|
+
</Col>
|
|
281
|
+
<Col auto style={colStyle}>
|
|
282
|
+
Another Button
|
|
283
|
+
</Col>
|
|
284
|
+
<Col auto style={colStyle}>
|
|
285
|
+
Third Button
|
|
286
|
+
</Col>
|
|
287
|
+
</Row>
|
|
288
|
+
<Row>
|
|
289
|
+
<Col span={3} style={colStyle}>
|
|
290
|
+
Fixed col-3
|
|
291
|
+
</Col>
|
|
292
|
+
<Col auto style={colStyle}>
|
|
293
|
+
Auto fills remaining space when needed
|
|
294
|
+
</Col>
|
|
295
|
+
</Row>
|
|
296
|
+
</div>
|
|
297
|
+
),
|
|
298
|
+
play: async ({ canvasElement, step }) => {
|
|
299
|
+
await step("Auto classes are applied correctly", async () => {
|
|
300
|
+
const autoElements = canvasElement.querySelectorAll(".col-auto");
|
|
301
|
+
expect(autoElements.length).toBeGreaterThan(0);
|
|
302
|
+
});
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Mixed Features - Demonstrates combining span, offset, and order.
|
|
308
|
+
* Shows complex layouts using multiple Col features together.
|
|
309
|
+
*/
|
|
310
|
+
export const MixedFeatures: Story = {
|
|
311
|
+
render: () => (
|
|
312
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
|
|
313
|
+
<Row>
|
|
314
|
+
<Col span={4} offset={2} order={2} style={colStyle}>
|
|
315
|
+
span-4 offset-2 order-2
|
|
316
|
+
</Col>
|
|
317
|
+
<Col span={4} offset={0} order={1} style={colStyle}>
|
|
318
|
+
span-4 offset-0 order-1
|
|
319
|
+
</Col>
|
|
320
|
+
</Row>
|
|
321
|
+
<Row>
|
|
322
|
+
<Col span={3} order="last" style={colStyle}>
|
|
323
|
+
Visually last
|
|
324
|
+
</Col>
|
|
325
|
+
<Col span={6} offset={3} style={colStyle}>
|
|
326
|
+
Centered with offset
|
|
327
|
+
</Col>
|
|
328
|
+
</Row>
|
|
329
|
+
<Row justify="center">
|
|
330
|
+
<Col span={4} offset={0} style={colStyle}>
|
|
331
|
+
col-4
|
|
332
|
+
</Col>
|
|
333
|
+
<Col auto style={colStyle}>
|
|
334
|
+
auto
|
|
335
|
+
</Col>
|
|
336
|
+
<Col span={4} style={colStyle}>
|
|
337
|
+
col-4
|
|
338
|
+
</Col>
|
|
339
|
+
</Row>
|
|
340
|
+
</div>
|
|
341
|
+
),
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Semantic HTML - Demonstrates using different element types.
|
|
346
|
+
* Shows Col rendering as different semantic HTML elements.
|
|
347
|
+
*/
|
|
348
|
+
export const SemanticHTML: Story = {
|
|
349
|
+
render: () => (
|
|
350
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
|
|
351
|
+
<Row as="ul">
|
|
352
|
+
<Col as="li" span={4} style={{ ...colStyle, listStyle: "none" }}>
|
|
353
|
+
List Item 1
|
|
354
|
+
</Col>
|
|
355
|
+
<Col as="li" span={4} style={{ ...colStyle, listStyle: "none" }}>
|
|
356
|
+
List Item 2
|
|
357
|
+
</Col>
|
|
358
|
+
<Col as="li" span={4} style={{ ...colStyle, listStyle: "none" }}>
|
|
359
|
+
List Item 3
|
|
360
|
+
</Col>
|
|
361
|
+
</Row>
|
|
362
|
+
<Row as="section">
|
|
363
|
+
<Col as="article" span={6} style={colStyle}>
|
|
364
|
+
Article 1
|
|
365
|
+
</Col>
|
|
366
|
+
<Col as="article" span={6} style={colStyle}>
|
|
367
|
+
Article 2
|
|
368
|
+
</Col>
|
|
369
|
+
</Row>
|
|
370
|
+
<Row>
|
|
371
|
+
<Col as="section" span={12} style={colStyle}>
|
|
372
|
+
Section Element
|
|
373
|
+
</Col>
|
|
374
|
+
</Row>
|
|
375
|
+
</div>
|
|
376
|
+
),
|
|
377
|
+
play: async ({ canvasElement, step }) => {
|
|
378
|
+
await step("Renders as <ul> and <li> elements", async () => {
|
|
379
|
+
const ul = canvasElement.querySelector("ul.col-row");
|
|
380
|
+
expect(ul).toBeInTheDocument();
|
|
381
|
+
const listItems = canvasElement.querySelectorAll("li.col-4");
|
|
382
|
+
expect(listItems).toHaveLength(3);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
await step("Renders as <article> elements", async () => {
|
|
386
|
+
const articles = canvasElement.querySelectorAll("article.col-6");
|
|
387
|
+
expect(articles).toHaveLength(2);
|
|
388
|
+
});
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Responsive Grid - Demonstrates mobile-first responsive behavior.
|
|
394
|
+
* Shows how columns adapt from mobile (stacked) to desktop (side-by-side).
|
|
395
|
+
*/
|
|
396
|
+
export const ResponsiveGrid: Story = {
|
|
397
|
+
render: () => (
|
|
398
|
+
<Row gap="md">
|
|
399
|
+
<Col span={6} style={colStyle}>
|
|
400
|
+
50% on desktop, 100% on mobile
|
|
401
|
+
</Col>
|
|
402
|
+
<Col span={6} style={colStyle}>
|
|
403
|
+
50% on desktop, 100% on mobile
|
|
404
|
+
</Col>
|
|
405
|
+
<Col span={4} style={colStyle}>
|
|
406
|
+
33% on desktop, 100% on mobile
|
|
407
|
+
</Col>
|
|
408
|
+
<Col span={4} style={colStyle}>
|
|
409
|
+
33% on desktop, 100% on mobile
|
|
410
|
+
</Col>
|
|
411
|
+
<Col span={4} style={colStyle}>
|
|
412
|
+
33% on desktop, 100% on mobile
|
|
413
|
+
</Col>
|
|
414
|
+
</Row>
|
|
415
|
+
),
|
|
416
|
+
parameters: {
|
|
417
|
+
docs: {
|
|
418
|
+
description: {
|
|
419
|
+
story:
|
|
420
|
+
"Resize the viewport to see mobile-first responsive behavior. Columns are 100% width on mobile (<768px) and fractional widths on desktop (>=768px).",
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
};
|