@fpkit/acss 3.3.0 → 3.5.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.
Files changed (99) hide show
  1. package/libs/index.cjs +22 -20
  2. package/libs/index.cjs.map +1 -1
  3. package/libs/index.d.cts +309 -1
  4. package/libs/index.d.ts +309 -1
  5. package/libs/index.js +9 -9
  6. package/libs/index.js.map +1 -1
  7. package/package.json +2 -2
  8. package/src/components/col/README.mdx +661 -0
  9. package/src/components/col/col.stories.tsx +527 -0
  10. package/src/components/col/col.test.tsx +366 -0
  11. package/src/components/col/col.tsx +107 -0
  12. package/src/components/col/col.types.ts +90 -0
  13. package/src/components/row/README.mdx +324 -0
  14. package/src/components/row/row.stories.tsx +595 -0
  15. package/src/components/row/row.test.tsx +358 -0
  16. package/src/components/row/row.tsx +121 -0
  17. package/src/components/row/row.types.ts +93 -0
  18. package/src/index.scss +1 -0
  19. package/src/index.ts +2 -0
  20. package/src/sass/README.mdx +597 -0
  21. package/src/sass/_columns.scss +394 -0
  22. package/src/sass/columns.stories.tsx +456 -0
  23. package/src/styles/index.css +392 -0
  24. package/src/styles/index.css.map +1 -1
  25. package/src/types/layout-primitives.ts +81 -0
  26. package/libs/components/alert/alert.css +0 -1
  27. package/libs/components/alert/alert.css.map +0 -1
  28. package/libs/components/alert/alert.min.css +0 -3
  29. package/libs/components/badge/badge.css +0 -1
  30. package/libs/components/badge/badge.css.map +0 -1
  31. package/libs/components/badge/badge.min.css +0 -3
  32. package/libs/components/box/box.css +0 -1
  33. package/libs/components/box/box.css.map +0 -1
  34. package/libs/components/box/box.min.css +0 -3
  35. package/libs/components/breadcrumbs/breadcrumb.css +0 -1
  36. package/libs/components/breadcrumbs/breadcrumb.css.map +0 -1
  37. package/libs/components/breadcrumbs/breadcrumb.min.css +0 -3
  38. package/libs/components/buttons/button.css +0 -1
  39. package/libs/components/buttons/button.css.map +0 -1
  40. package/libs/components/buttons/button.min.css +0 -3
  41. package/libs/components/cards/card-style.css +0 -1
  42. package/libs/components/cards/card-style.css.map +0 -1
  43. package/libs/components/cards/card-style.min.css +0 -3
  44. package/libs/components/cards/card.css +0 -1
  45. package/libs/components/cards/card.css.map +0 -1
  46. package/libs/components/cards/card.min.css +0 -3
  47. package/libs/components/cluster/cluster.css +0 -1
  48. package/libs/components/cluster/cluster.css.map +0 -1
  49. package/libs/components/cluster/cluster.min.css +0 -3
  50. package/libs/components/details/details.css +0 -1
  51. package/libs/components/details/details.css.map +0 -1
  52. package/libs/components/details/details.min.css +0 -3
  53. package/libs/components/dialog/dialog.css +0 -1
  54. package/libs/components/dialog/dialog.css.map +0 -1
  55. package/libs/components/dialog/dialog.min.css +0 -3
  56. package/libs/components/flexbox/flex.css +0 -1
  57. package/libs/components/flexbox/flex.css.map +0 -1
  58. package/libs/components/flexbox/flex.min.css +0 -3
  59. package/libs/components/form/form.css +0 -1
  60. package/libs/components/form/form.css.map +0 -1
  61. package/libs/components/form/form.min.css +0 -3
  62. package/libs/components/grid/grid.css +0 -1
  63. package/libs/components/grid/grid.css.map +0 -1
  64. package/libs/components/grid/grid.min.css +0 -3
  65. package/libs/components/icons/icon.css +0 -1
  66. package/libs/components/icons/icon.css.map +0 -1
  67. package/libs/components/icons/icon.min.css +0 -3
  68. package/libs/components/images/img.css +0 -1
  69. package/libs/components/images/img.css.map +0 -1
  70. package/libs/components/images/img.min.css +0 -3
  71. package/libs/components/layout/landmarks.css +0 -1
  72. package/libs/components/layout/landmarks.css.map +0 -1
  73. package/libs/components/layout/landmarks.min.css +0 -3
  74. package/libs/components/link/link.css +0 -1
  75. package/libs/components/link/link.css.map +0 -1
  76. package/libs/components/link/link.min.css +0 -3
  77. package/libs/components/list/list.css +0 -1
  78. package/libs/components/list/list.css.map +0 -1
  79. package/libs/components/list/list.min.css +0 -3
  80. package/libs/components/nav/nav.css +0 -1
  81. package/libs/components/nav/nav.css.map +0 -1
  82. package/libs/components/nav/nav.min.css +0 -3
  83. package/libs/components/progress/progress.css +0 -1
  84. package/libs/components/progress/progress.css.map +0 -1
  85. package/libs/components/progress/progress.min.css +0 -3
  86. package/libs/components/stack/stack.css +0 -1
  87. package/libs/components/stack/stack.css.map +0 -1
  88. package/libs/components/stack/stack.min.css +0 -3
  89. package/libs/components/styles/index.css +0 -1
  90. package/libs/components/styles/index.css.map +0 -1
  91. package/libs/components/styles/index.min.css +0 -3
  92. package/libs/components/tag/tag.css +0 -1
  93. package/libs/components/tag/tag.css.map +0 -1
  94. package/libs/components/tag/tag.min.css +0 -3
  95. package/libs/components/text-to-speech/text-to-speech.css +0 -1
  96. package/libs/components/text-to-speech/text-to-speech.css.map +0 -1
  97. package/libs/components/text-to-speech/text-to-speech.min.css +0 -3
  98. package/libs/index.css +0 -1
  99. package/libs/index.css.map +0 -1
@@ -0,0 +1,661 @@
1
+ import { Meta } from "@storybook/addon-docs/blocks";
2
+
3
+ import * as ColStories from "./col.stories";
4
+
5
+ <Meta of={ColStories} />
6
+
7
+ # Col
8
+
9
+ A column component for building responsive 12-column layouts within Row
10
+ containers.
11
+
12
+ ## Overview
13
+
14
+ Col provides a type-safe React wrapper around column utility classes, allowing
15
+ developers to create responsive columns with precise control over width,
16
+ positioning, and visual order. Unlike Row, Col has **no base class** - it's pure
17
+ utility class composition following the Grid.Item pattern.
18
+
19
+ ## Key Features
20
+
21
+ - **No Base Class**: Pure utility class mapping for maximum flexibility
22
+ - **Span Control**: 1-12 column widths via the `span` prop
23
+ - **Flex-Grow Columns**: Fill remaining space with `span="flex"`
24
+ - **Offset Positioning**: Push columns right with `offset` prop
25
+ - **Visual Reordering**: Change display order with `order` prop
26
+ - **Auto-Width**: Content-based width with `auto` prop
27
+ - **Polymorphic**: Render as any semantic HTML element
28
+ - **Type-Safe**: Full TypeScript support with literal types
29
+
30
+ ## When to Use
31
+
32
+ Use Col when you need:
33
+
34
+ - Responsive column layouts within Row containers
35
+ - Precise control over column widths (12-column grid)
36
+ - Offset positioning to create whitespace
37
+ - Visual reordering without changing DOM order
38
+ - Content-based column widths
39
+
40
+ ## Props
41
+
42
+ ### span
43
+
44
+ Column span (width) from 1-12 columns, or "flex" for flex-grow behavior. Ignored
45
+ if `auto` is true.
46
+
47
+ - **Type**: `1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | "flex"`
48
+ - **Default**: `undefined`
49
+ - **CSS Class**: `.col-{span}` or `.col-flex`
50
+ - **Calculation**: `span / 12 * 100%` (for numeric values)
51
+
52
+ **Numeric Examples:**
53
+
54
+ - `span={12}` = 100% width (`.col-12`)
55
+ - `span={6}` = 50% width (`.col-6`)
56
+ - `span={4}` = 33.33% width (`.col-4`)
57
+ - `span={3}` = 25% width (`.col-3`)
58
+
59
+ **Flex Example:**
60
+
61
+ - `span="flex"` = Grows to fill remaining space (`.col-flex`)
62
+ - Desktop: `flex: 1 1 0%` (grows to fill available space)
63
+ - Mobile: Stacks to 100% width like other columns
64
+
65
+ ### offset
66
+
67
+ Column offset (left margin) from 0-11 columns. Pushes column to the right.
68
+
69
+ - **Type**: `0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11`
70
+ - **Default**: `undefined`
71
+ - **CSS Class**: `.col-offset-{offset}`
72
+ - **Calculation**: `offset / 12 * 100%`
73
+
74
+ **Examples:**
75
+
76
+ - `offset={3}` = Push right by 25% (`.col-offset-3`)
77
+ - `offset={0}` = No offset (`.col-offset-0`)
78
+
79
+ ### order
80
+
81
+ Visual display order using flexbox `order` property. Does not change DOM order.
82
+
83
+ - **Type**:
84
+ `"first" | "last" | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12`
85
+ - **Default**: `undefined`
86
+ - **CSS Class**: `.col-order-{order}`
87
+
88
+ **Examples:**
89
+
90
+ - `order="first"` = Display first (order: -1)
91
+ - `order="last"` = Display last (order: 13)
92
+ - `order={1}` = Display in position 1
93
+
94
+ ### auto
95
+
96
+ Auto-width column based on content. Takes precedence over `span` (including
97
+ `span="flex"`).
98
+
99
+ - **Type**: `boolean`
100
+ - **Default**: `false`
101
+ - **CSS Class**: `.col-auto`
102
+
103
+ When `true`, column width adjusts to fit content instead of spanning a fixed
104
+ number of columns.
105
+
106
+ **Note**: For columns that grow to fill remaining space (not content-based), use
107
+ `span="flex"` instead of `auto`.
108
+
109
+ ### as
110
+
111
+ Element type to render. Supports semantic HTML elements.
112
+
113
+ - **Type**: `"div" | "section" | "article" | "li"`
114
+ - **Default**: `"div"`
115
+
116
+ ### className
117
+
118
+ Additional CSS classes to merge with utility classes.
119
+
120
+ - **Type**: `string`
121
+ - **Default**: `undefined`
122
+
123
+ ## Basic Usage
124
+
125
+ ```jsx
126
+ import { Row, Col } from "@fpkit/acss";
127
+
128
+ function MyLayout() {
129
+ return (
130
+ <Row>
131
+ <Col span={6}>Left column (50%)</Col>
132
+ <Col span={6}>Right column (50%)</Col>
133
+ </Row>
134
+ );
135
+ }
136
+ ```
137
+
138
+ ## Examples
139
+
140
+ ### Column Spans
141
+
142
+ ```jsx
143
+ <Row gap="md">
144
+ {/* Full width */}
145
+ <Col span={12}>100% width</Col>
146
+
147
+ {/* Half width */}
148
+ <Col span={6}>50% width</Col>
149
+ <Col span={6}>50% width</Col>
150
+
151
+ {/* Thirds */}
152
+ <Col span={4}>33.33% width</Col>
153
+ <Col span={4}>33.33% width</Col>
154
+ <Col span={4}>33.33% width</Col>
155
+
156
+ {/* Quarters */}
157
+ <Col span={3}>25%</Col>
158
+ <Col span={3}>25%</Col>
159
+ <Col span={3}>25%</Col>
160
+ <Col span={3}>25%</Col>
161
+ </Row>
162
+ ```
163
+
164
+ ### Column Offsets
165
+
166
+ ```jsx
167
+ <Row gap="md">
168
+ {/* Centered column */}
169
+ <Col span={6} offset={3}>
170
+ Centered (50% width, 25% left margin)
171
+ </Col>
172
+
173
+ {/* Two columns with gap in middle */}
174
+ <Col span={3}>Left column</Col>
175
+ <Col span={3} offset={6}>
176
+ Right column (50% gap between)
177
+ </Col>
178
+
179
+ {/* Multiple offsets */}
180
+ <Col span={2} offset={2}>
181
+ offset-2
182
+ </Col>
183
+ <Col span={2} offset={2}>
184
+ offset-2
185
+ </Col>
186
+ <Col span={2} offset={2}>
187
+ offset-2
188
+ </Col>
189
+ </Row>
190
+ ```
191
+
192
+ ### Visual Reordering
193
+
194
+ ```jsx
195
+ <Row gap="md">
196
+ {/* Source order: 1, 2, 3 */}
197
+ {/* Visual order: 3, 1, 2 */}
198
+ <Col span={4} order={2}>DOM 1st, Visual 3rd</Col>
199
+ <Col span={4} order={0}>DOM 2nd, Visual 1st</Col>
200
+ <Col span={4} order={1}>DOM 3rd, Visual 2nd</Col>
201
+ </Row>
202
+
203
+ <Row gap="md">
204
+ {/* order-first and order-last */}
205
+ <Col span={6} order="last">Appears last visually</Col>
206
+ <Col span={6} order="first">Appears first visually</Col>
207
+ </Row>
208
+ ```
209
+
210
+ ### Auto-Width Columns
211
+
212
+ ```jsx
213
+ <Row gap="sm">
214
+ {/* Content-based width */}
215
+ <Col auto>Button</Col>
216
+ <Col auto>Another Button</Col>
217
+ <Col auto>Third Button</Col>
218
+ </Row>
219
+
220
+ <Row gap="md">
221
+ {/* Mix fixed and auto */}
222
+ <Col span={3}>Fixed 25%</Col>
223
+ <Col auto>Auto width (content-based)</Col>
224
+ <Col span={2}>Fixed 16.66%</Col>
225
+ </Row>
226
+ ```
227
+
228
+ ### Flex Columns (Fill Remaining Space)
229
+
230
+ Use `span="flex"` to create columns that grow to fill available space after
231
+ fixed-width columns. This is different from `auto` which sizes to content.
232
+
233
+ ```jsx
234
+ {/* Flex vs Auto Comparison */}
235
+ <Row gap="md">
236
+ <Col span={3}>Fixed 25%</Col>
237
+ <Col span="flex">Flex (grows to fill 75%)</Col>
238
+ </Row>
239
+
240
+ <Row gap="md">
241
+ <Col span={3}>Fixed 25%</Col>
242
+ <Col auto>Auto (sizes to content only)</Col>
243
+ </Row>
244
+ ```
245
+
246
+ **Multiple flex columns share space equally:**
247
+
248
+ ```jsx
249
+ <Row gap="md">
250
+ <Col span={2}>Fixed sidebar</Col>
251
+ <Col span="flex">Section 1 (50% of remaining)</Col>
252
+ <Col span="flex">Section 2 (50% of remaining)</Col>
253
+ </Row>
254
+ ```
255
+
256
+ **Common Patterns:**
257
+
258
+ ```jsx
259
+ {/* Sidebar layout */}
260
+ <Row gap="lg">
261
+ <Col span={3}>Sidebar (25%)</Col>
262
+ <Col span="flex">Main content (grows to fill 75%)</Col>
263
+ </Row>
264
+
265
+ {/* Button group with spacer */}
266
+ <Row gap="sm" align="center">
267
+ <Col auto><Button>Save</Button></Col>
268
+ <Col span="flex">{/* Flexible spacer */}</Col>
269
+ <Col auto><Button>Cancel</Button></Col>
270
+ </Row>
271
+
272
+ {/* App layout */}
273
+ <Row gap="md">
274
+ <Col span={2}>Navigation</Col>
275
+ <Col span="flex">Main Content</Col>
276
+ <Col span={3}>Sidebar</Col>
277
+ </Row>
278
+
279
+ {/* Form layout with label and input */}
280
+ <Row gap="sm" align="center">
281
+ <Col auto><Label>Email:</Label></Col>
282
+ <Col span="flex"><Input type="email" /></Col>
283
+ <Col auto><Button>Subscribe</Button></Col>
284
+ </Row>
285
+ ```
286
+
287
+ **Key Differences:**
288
+
289
+ | Feature | `auto` | `span="flex"` |
290
+ | ----------------- | ---------------------- | --------------------------- |
291
+ | **CSS** | `flex: 0 0 auto` | `flex: 1 1 0%` |
292
+ | **Behavior** | Sizes to content width | Grows to fill space |
293
+ | **Use case** | Buttons, labels, icons | Main content areas |
294
+ | **Mobile** | Content-based | 100% width (stacked) |
295
+ | **Desktop** | Content-based | Fills remaining space |
296
+ | **Multiple cols** | Each sizes to content | Share remaining space equally |
297
+
298
+ ### Responsive Columns
299
+
300
+ ```jsx
301
+ <Row gap="md">
302
+ {/* Mobile: 100%, Tablet: 50%, Desktop: 33% */}
303
+ <Col span={12} className="col-md-6 col-lg-4">
304
+ Responsive column
305
+ </Col>
306
+ <Col span={12} className="col-md-6 col-lg-4">
307
+ Responsive column
308
+ </Col>
309
+ <Col span={12} className="col-md-6 col-lg-4">
310
+ Responsive column
311
+ </Col>
312
+ </Row>
313
+ ```
314
+
315
+ ### Semantic HTML
316
+
317
+ ```jsx
318
+ {
319
+ /* List items */
320
+ }
321
+ <Row as="ul" gap="sm">
322
+ <Col as="li" span={4}>
323
+ List item 1
324
+ </Col>
325
+ <Col as="li" span={4}>
326
+ List item 2
327
+ </Col>
328
+ <Col as="li" span={4}>
329
+ List item 3
330
+ </Col>
331
+ </Row>;
332
+
333
+ {
334
+ /* Article sections */
335
+ }
336
+ <Row as="section">
337
+ <Col as="article" span={6}>
338
+ Article content 1
339
+ </Col>
340
+ <Col as="article" span={6}>
341
+ Article content 2
342
+ </Col>
343
+ </Row>;
344
+ ```
345
+
346
+ ## Accessibility
347
+
348
+ ### Visual vs. DOM Order
349
+
350
+ **Important**: The `order` prop changes **visual order only**, not DOM order.
351
+ Screen readers and keyboard navigation follow DOM order, not visual order.
352
+
353
+ ```jsx
354
+ {
355
+ /* Screen readers read: "Column A", "Column B"
356
+ Visually displays: "Column B", "Column A" */
357
+ }
358
+ <Row>
359
+ <Col span={6} order={2}>
360
+ Column A
361
+ </Col>
362
+ <Col span={6} order={1}>
363
+ Column B
364
+ </Col>
365
+ </Row>;
366
+ ```
367
+
368
+ **Best Practice**: Only use `order` when visual reordering doesn't affect
369
+ content comprehension. Avoid reordering critical content like navigation or form
370
+ fields.
371
+
372
+ ### Semantic Elements
373
+
374
+ Use appropriate HTML elements via the `as` prop:
375
+
376
+ ```jsx
377
+ {
378
+ /* Good: Semantic list */
379
+ }
380
+ <Row as="ul">
381
+ <Col as="li" span={4}>
382
+ Item
383
+ </Col>
384
+ </Row>;
385
+
386
+ {
387
+ /* Good: Article sections */
388
+ }
389
+ <Row>
390
+ <Col as="article" span={6}>
391
+ Article 1
392
+ </Col>
393
+ <Col as="article" span={6}>
394
+ Article 2
395
+ </Col>
396
+ </Row>;
397
+ ```
398
+
399
+ ### Focus Order
400
+
401
+ Keyboard navigation follows DOM order, not visual `order`. Ensure tab order is
402
+ logical:
403
+
404
+ ```jsx
405
+ {
406
+ /* Tab order: Input 1 → Input 2 → Button
407
+ Visual order may differ if using order prop */
408
+ }
409
+ <Row>
410
+ <Col span={6} order={1}>
411
+ <input id="input1" />
412
+ </Col>
413
+ <Col span={6} order={2}>
414
+ <input id="input2" />
415
+ </Col>
416
+ <Col span={12} order={0}>
417
+ <button>Submit</button>
418
+ </Col>
419
+ </Row>;
420
+ ```
421
+
422
+ ## Responsive Behavior
423
+
424
+ Col uses a **mobile-first** approach:
425
+
426
+ - **Mobile** (`<768px`): Columns default to 100% width and stack vertically
427
+ - **Desktop** (`≥768px`): Columns use their specified span values
428
+
429
+ ### Responsive Classes
430
+
431
+ Use responsive utility classes on Col for breakpoint-specific widths:
432
+
433
+ ```jsx
434
+ <Col
435
+ span={12} // Mobile: 100%
436
+ className="col-md-6 col-lg-4" // Tablet: 50%, Desktop: 33%
437
+ >
438
+ Responsive content
439
+ </Col>
440
+ ```
441
+
442
+ **Available Breakpoints:**
443
+
444
+ - `col-md-*` - Tablet and up (`≥768px`)
445
+ - `col-lg-*` - Desktop and up (`≥992px`)
446
+ - `col-xl-*` - Large desktop and up (`≥1280px`)
447
+
448
+ ## Advanced Patterns
449
+
450
+ ### Asymmetric Layouts
451
+
452
+ ```jsx
453
+ <Row gap="lg">
454
+ <Col span={8}>Main content (66.66%)</Col>
455
+ <Col span={4}>Sidebar (33.33%)</Col>
456
+ </Row>
457
+
458
+ <Row gap="lg">
459
+ <Col span={3}>Nav (25%)</Col>
460
+ <Col span={6}>Content (50%)</Col>
461
+ <Col span={3}>Aside (25%)</Col>
462
+ </Row>
463
+ ```
464
+
465
+ ### Complex Grid
466
+
467
+ ```jsx
468
+ <Row gap="md">
469
+ <Col span={12}>Header</Col>
470
+ <Col span={8} className="col-lg-9">
471
+ Main content
472
+ </Col>
473
+ <Col span={4} className="col-lg-3">
474
+ Sidebar
475
+ </Col>
476
+ <Col span={6} className="col-lg-3">
477
+ Footer column 1
478
+ </Col>
479
+ <Col span={6} className="col-lg-3">
480
+ Footer column 2
481
+ </Col>
482
+ <Col span={12} className="col-lg-6">
483
+ Footer column 3
484
+ </Col>
485
+ </Row>
486
+ ```
487
+
488
+ ### Dashboard Metrics
489
+
490
+ ```jsx
491
+ <Row gap="md" align="stretch">
492
+ {/* 4 equal columns on desktop, stacked on mobile */}
493
+ <Col span={12} className="col-sm-6 col-lg-3">
494
+ <Card>
495
+ <h3>Total Users</h3>
496
+ <p>1,234</p>
497
+ </Card>
498
+ </Col>
499
+ <Col span={12} className="col-sm-6 col-lg-3">
500
+ <Card>
501
+ <h3>Revenue</h3>
502
+ <p>$12,345</p>
503
+ </Card>
504
+ </Col>
505
+ <Col span={12} className="col-sm-6 col-lg-3">
506
+ <Card>
507
+ <h3>Conversions</h3>
508
+ <p>567</p>
509
+ </Card>
510
+ </Col>
511
+ <Col span={12} className="col-sm-6 col-lg-3">
512
+ <Card>
513
+ <h3>Growth</h3>
514
+ <p>+23%</p>
515
+ </Card>
516
+ </Col>
517
+ </Row>
518
+ ```
519
+
520
+ ### Form Layout
521
+
522
+ ```jsx
523
+ <Row gap="md">
524
+ <Col span={12} className="col-md-6">
525
+ <Field>
526
+ <FieldLabel htmlFor="first-name">First Name</FieldLabel>
527
+ <FieldInput id="first-name" />
528
+ </Field>
529
+ </Col>
530
+ <Col span={12} className="col-md-6">
531
+ <Field>
532
+ <FieldLabel htmlFor="last-name">Last Name</FieldLabel>
533
+ <FieldInput id="last-name" />
534
+ </Field>
535
+ </Col>
536
+ <Col span={12}>
537
+ <Field>
538
+ <FieldLabel htmlFor="email">Email</FieldLabel>
539
+ <FieldInput id="email" type="email" />
540
+ </Field>
541
+ </Col>
542
+ <Col span={12}>
543
+ <button type="submit">Submit</button>
544
+ </Col>
545
+ </Row>
546
+ ```
547
+
548
+ ## Related Components
549
+
550
+ - **Row** - Flex container for Col components
551
+ - **Grid** - Alternative grid system using CSS Grid
552
+ - **Grid.Item** - Item component for Grid (similar pattern to Col)
553
+
554
+ ## Best Practices
555
+
556
+ 1. **Always use Col within Row**: Col is designed for use within Row containers
557
+ 2. **Total span = 12**: Columns in a row should sum to 12 (or less if
558
+ intentional gaps)
559
+ 3. **Mobile-first responsive**: Start with mobile layout, enhance for desktop
560
+ 4. **Semantic HTML**: Use `as` prop for appropriate elements (li, article,
561
+ section)
562
+ 5. **Avoid order for critical content**: Only reorder decorative or non-critical
563
+ content
564
+ 6. **Consistent gaps**: Use Row's `gap` prop for uniform spacing
565
+
566
+ ## Technical Notes
567
+
568
+ ### CSS Classes
569
+
570
+ Col renders with **no base class**. Only utility classes are applied:
571
+
572
+ - Span: `.col-{1-12}` (fixed width columns)
573
+ - Flex: `.col-flex` (flex-grow column)
574
+ - Offset: `.col-offset-{0-11}`
575
+ - Order: `.col-order-{first|last|0-12}`
576
+ - Auto: `.col-auto` (content-based width)
577
+
578
+ ### Column Width Calculation
579
+
580
+ Column widths are calculated as:
581
+
582
+ ```
583
+ width = (span / 12) * 100%
584
+ ```
585
+
586
+ **Examples:**
587
+
588
+ - `.col-12` = 100% (12/12)
589
+ - `.col-6` = 50% (6/12)
590
+ - `.col-4` = 33.33% (4/12)
591
+ - `.col-3` = 25% (3/12)
592
+ - `.col-1` = 8.33% (1/12)
593
+
594
+ ### Offset Calculation
595
+
596
+ Offsets use margin-inline-start:
597
+
598
+ ```
599
+ margin-inline-start = (offset / 12) * 100%
600
+ ```
601
+
602
+ **Examples:**
603
+
604
+ - `.col-offset-3` = 25% left margin
605
+ - `.col-offset-6` = 50% left margin
606
+
607
+ ### Auto-Width Behavior
608
+
609
+ `.col-auto` uses `flex: 0 0 auto` with `width: auto`, allowing the column to
610
+ size based on its content.
611
+
612
+ ### Flex-Grow Behavior
613
+
614
+ `.col-flex` uses responsive flex properties to fill remaining space:
615
+
616
+ **Mobile (`< 768px`):**
617
+
618
+ ```css
619
+ .col-flex {
620
+ flex: 0 0 100%; /* Stack to full width */
621
+ min-width: 0;
622
+ box-sizing: border-box;
623
+ }
624
+ ```
625
+
626
+ **Desktop (`≥ 768px`):**
627
+
628
+ ```css
629
+ .col-flex {
630
+ flex: 1 1 0%; /* Grow to fill available space */
631
+ }
632
+ ```
633
+
634
+ **How it works:**
635
+
636
+ - `flex-grow: 1` - Column grows to fill available space
637
+ - `flex-shrink: 1` - Column can shrink if constrained
638
+ - `flex-basis: 0%` - Ensures equal distribution when multiple flex columns exist
639
+ - Multiple flex columns share remaining space equally
640
+
641
+ **Example calculations:**
642
+
643
+ ```jsx
644
+ // Container width: 1200px
645
+ <Row>
646
+ <Col span={3}>Fixed 300px (25%)</Col>
647
+ <Col span="flex">Grows to 900px (75%)</Col>
648
+ </Row>
649
+
650
+ // Multiple flex columns
651
+ <Row>
652
+ <Col span={2}>Fixed 200px (16.67%)</Col>
653
+ <Col span="flex">Flex 1: 500px (41.67%)</Col>
654
+ <Col span="flex">Flex 2: 500px (41.67%)</Col>
655
+ </Row>
656
+ ```
657
+
658
+ ### Performance
659
+
660
+ Col is a lightweight wrapper with no runtime overhead. All layout calculations
661
+ are handled via CSS utility classes at build time.