@fpkit/acss 1.0.0-beta.1 → 1.0.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 (43) hide show
  1. package/README.md +32 -0
  2. package/docs/README.md +325 -0
  3. package/docs/guides/accessibility.md +764 -0
  4. package/docs/guides/architecture.md +705 -0
  5. package/docs/guides/composition.md +688 -0
  6. package/docs/guides/css-variables.md +522 -0
  7. package/docs/guides/storybook.md +828 -0
  8. package/docs/guides/testing.md +817 -0
  9. package/docs/testing/focus-indicator-testing.md +437 -0
  10. package/libs/components/buttons/button.css +1 -1
  11. package/libs/components/buttons/button.css.map +1 -1
  12. package/libs/components/buttons/button.min.css +2 -2
  13. package/libs/components/icons/icon.d.cts +32 -32
  14. package/libs/components/icons/icon.d.ts +32 -32
  15. package/libs/components/list/list.css +1 -1
  16. package/libs/components/list/list.min.css +1 -1
  17. package/libs/index.css +1 -1
  18. package/libs/index.css.map +1 -1
  19. package/package.json +4 -3
  20. package/src/components/README.mdx +1 -1
  21. package/src/components/buttons/button.scss +5 -0
  22. package/src/components/buttons/button.stories.tsx +8 -5
  23. package/src/components/cards/card.stories.tsx +1 -1
  24. package/src/components/details/details.stories.tsx +1 -1
  25. package/src/components/form/form.stories.tsx +1 -1
  26. package/src/components/form/input.stories.tsx +1 -1
  27. package/src/components/form/select.stories.tsx +1 -1
  28. package/src/components/heading/README.mdx +292 -0
  29. package/src/components/icons/icon.stories.tsx +1 -1
  30. package/src/components/list/list.scss +1 -1
  31. package/src/components/nav/nav.stories.tsx +1 -1
  32. package/src/components/ui.stories.tsx +53 -19
  33. package/src/docs/accessibility.mdx +484 -0
  34. package/src/docs/composition.mdx +549 -0
  35. package/src/docs/css-variables.mdx +380 -0
  36. package/src/docs/fpkit-developer.mdx +545 -0
  37. package/src/introduction.mdx +356 -0
  38. package/src/styles/buttons/button.css +4 -0
  39. package/src/styles/buttons/button.css.map +1 -1
  40. package/src/styles/index.css +9 -3
  41. package/src/styles/index.css.map +1 -1
  42. package/src/styles/list/list.css +1 -1
  43. package/src/styles/utilities/_disabled.scss +5 -4
@@ -0,0 +1,380 @@
1
+ import { Meta, Canvas, Story } from "@storybook/addon-docs/blocks";
2
+ import { Button } from "../components/buttons/button";
3
+
4
+ <Meta title="Guides/CSS Variables" />
5
+
6
+ # CSS Variables Guide
7
+
8
+ Learn how to discover and customize CSS custom properties in @fpkit/acss
9
+ components.
10
+
11
+ > **📖 Full Guide:** For comprehensive documentation, see
12
+ > [docs/guides/css-variables.md](https://github.com/shawn-sandy/acss/blob/main/packages/fpkit/docs/guides/css-variables.md)
13
+
14
+ ---
15
+
16
+ ## Quick Start
17
+
18
+ All fpkit components use CSS custom properties for theming:
19
+
20
+ ```css
21
+ /* Global overrides */
22
+ :root {
23
+ --btn-primary-bg: #0066cc;
24
+ --btn-padding-inline: 2rem;
25
+ }
26
+
27
+ /* Component-specific */
28
+ .hero-button {
29
+ --btn-padding-inline: 3rem;
30
+ --btn-fs: 1.25rem;
31
+ }
32
+ ```
33
+
34
+ ```tsx
35
+ /* Inline styles */
36
+ <Button
37
+ style={{
38
+ "--btn-bg": "#e63946",
39
+ "--btn-color": "white",
40
+ }}
41
+ >
42
+ Custom Button
43
+ </Button>
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Naming Convention
49
+
50
+ All CSS variables follow a consistent pattern:
51
+
52
+ ```
53
+ --{component}-{element}-{variant}-{property}-{modifier}
54
+ ```
55
+
56
+ ### Examples
57
+
58
+ ```scss
59
+ // Component base property
60
+ --btn-bg
61
+
62
+ // Variant-specific property
63
+ --btn-primary-bg
64
+
65
+ // State-specific property
66
+ --btn-hover-bg
67
+ --btn-focus-outline
68
+
69
+ // Element-specific property
70
+ --card-header-padding
71
+ --card-footer-bg
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Discovering Variables
77
+
78
+ ### Method 1: Browser DevTools (Recommended)
79
+
80
+ 1. Inspect a component
81
+ 2. Open **Computed** tab
82
+ 3. Scroll to **CSS Variables** section
83
+ 4. See all available variables and values
84
+
85
+ ### Method 2: IDE Autocomplete
86
+
87
+ ```css
88
+ /* Type the component prefix */
89
+ --btn- /* IDE shows: --btn-bg, --btn-padding-inline, --btn-radius, etc. */
90
+ --alert- /* IDE shows: --alert-error-bg, --alert-success-bg, etc. */
91
+ ```
92
+
93
+ ### Method 3: Source Code
94
+
95
+ Browse compiled CSS in `node_modules/@fpkit/acss/libs/index.css`
96
+
97
+ ---
98
+
99
+ ## Common Customization Patterns
100
+
101
+ ### Global Theme
102
+
103
+ ```css
104
+ /* global.css */
105
+ :root {
106
+ /* Buttons */
107
+ --btn-radius: 0.25rem;
108
+ --btn-padding-inline: 2rem;
109
+ --btn-primary-bg: #0066cc;
110
+ --btn-primary-color: white;
111
+
112
+ /* Cards */
113
+ --card-padding: 1.5rem;
114
+ --card-radius: 0.75rem;
115
+ --card-border: 1px solid #e0e0e0;
116
+ }
117
+ ```
118
+
119
+ ### Theme Classes
120
+
121
+ ```css
122
+ /* themes.css */
123
+ .light-theme {
124
+ --btn-bg: white;
125
+ --btn-color: #333;
126
+ --card-bg: #f9f9f9;
127
+ }
128
+
129
+ .dark-theme {
130
+ --btn-bg: #2d2d2d;
131
+ --btn-color: #f0f0f0;
132
+ --card-bg: #1a1a1a;
133
+ --card-border: 1px solid #444;
134
+ }
135
+ ```
136
+
137
+ ```tsx
138
+ <div className="dark-theme">
139
+ <Button>Styled by theme</Button>
140
+ </div>
141
+ ```
142
+
143
+ ### Component-Specific
144
+
145
+ ```css
146
+ /* custom.css */
147
+ .hero-button {
148
+ --btn-padding-inline: 3rem;
149
+ --btn-padding-block: 1rem;
150
+ --btn-fs: 1.25rem;
151
+ }
152
+ ```
153
+
154
+ ```tsx
155
+ <Button className="hero-button">Large CTA</Button>
156
+ ```
157
+
158
+ ### Inline Overrides
159
+
160
+ ```tsx
161
+ <Button
162
+ style={{
163
+ "--btn-bg": "#e63946",
164
+ "--btn-color": "white",
165
+ "--btn-padding-inline": "2.5rem",
166
+ }}
167
+ >
168
+ Danger Action
169
+ </Button>
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Button Variables Reference
175
+
176
+ ```scss
177
+ // Base properties
178
+ --btn-display: inline-flex --btn-padding-inline: 1.5rem --btn-padding-block:
179
+ 0.5rem --btn-fs: 1rem --btn-fw: 600 --btn-radius: 0.375rem --btn-gap: 0.5rem
180
+ // Variants
181
+ --btn-primary-bg: #0066cc --btn-primary-color: white --btn-secondary-bg: transparent
182
+ --btn-secondary-color: currentColor // States
183
+ --btn-hover-bg: brightness(1.1) --btn-focus-outline: 2px solid currentColor --btn-focus-outline-offset:
184
+ 2px --btn-disabled-opacity: 0.6;
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Alert Variables Reference
190
+
191
+ ```scss
192
+ // Base properties
193
+ --alert-padding: 1rem --alert-radius: 0.375rem --alert-border-width: 1px
194
+ // Semantic variants
195
+ --alert-error-bg: #f8d7da --alert-error-border: #f5c6cb --alert-error-color: #721c24
196
+ --alert-success-bg: #d4edda --alert-success-border: #c3e6cb --alert-success-color:
197
+ #155724 --alert-warning-bg: #fff3cd --alert-warning-border: #ffeaa7 --alert-warning-color:
198
+ #856404 --alert-info-bg: #d1ecf1 --alert-info-border: #bee5eb --alert-info-color:
199
+ #0c5460;
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Card Variables Reference
205
+
206
+ ```scss
207
+ // Base properties
208
+ --card-padding: 1rem --card-bg: white --card-radius: 0.5rem --card-border: 1px
209
+ solid #e0e0e0 // Header
210
+ --card-header-padding: 1rem 1.5rem --card-header-bg: #f9f9f9 --card-header-border-bottom:
211
+ 1px solid #e0e0e0 --card-header-fs: 1.25rem --card-header-fw: 600 // Footer
212
+ --card-footer-padding: 1rem 1.5rem --card-footer-bg: #f9f9f9
213
+ --card-footer-border-top: 1px solid #e0e0e0;
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Abbreviation Reference
219
+
220
+ ### ✅ Abbreviated Properties
221
+
222
+ | Abbreviation | Full Name | Example |
223
+ | ------------ | ----------------------------- | -------------- |
224
+ | `bg` | background / background-color | `--btn-bg` |
225
+ | `fs` | font-size | `--btn-fs` |
226
+ | `fw` | font-weight | `--btn-fw` |
227
+ | `radius` | border-radius | `--btn-radius` |
228
+ | `gap` | gap | `--btn-gap` |
229
+
230
+ ### ✅ Full Word Properties
231
+
232
+ | Property | Variable Pattern |
233
+ | -------- | ----------------------------------- |
234
+ | padding | `--{component}-padding-{direction}` |
235
+ | margin | `--{component}-margin-{direction}` |
236
+ | color | `--{component}-color` |
237
+ | border | `--{component}-border` |
238
+ | display | `--{component}-display` |
239
+ | width | `--{component}-width` |
240
+ | height | `--{component}-height` |
241
+
242
+ ---
243
+
244
+ ## rem Units
245
+
246
+ **All spacing and sizing uses rem units** for accessibility.
247
+
248
+ **Conversion:** `px / 16 = rem`
249
+
250
+ **Common values:**
251
+
252
+ - 8px = 0.5rem
253
+ - 12px = 0.75rem
254
+ - 16px = 1rem (base)
255
+ - 20px = 1.25rem
256
+ - 24px = 1.5rem
257
+ - 32px = 2rem
258
+
259
+ **Why rem?**
260
+
261
+ - Respects user font size preferences
262
+ - Consistent scaling across breakpoints
263
+ - Better for responsive design
264
+
265
+ ---
266
+
267
+ ## Framework Integration
268
+
269
+ ### React
270
+
271
+ ```jsx
272
+ import "./theme.css"; // Global overrides
273
+
274
+ function CustomButton() {
275
+ return (
276
+ <Button
277
+ style={{
278
+ "--btn-padding-inline": "2rem",
279
+ "--btn-radius": "0.5rem",
280
+ }}
281
+ >
282
+ Custom
283
+ </Button>
284
+ );
285
+ }
286
+ ```
287
+
288
+ ### CSS Modules
289
+
290
+ ```css
291
+ /* Button.module.css */
292
+ .customButton {
293
+ --btn-primary-bg: #e63946;
294
+ --btn-primary-color: white;
295
+ --btn-padding-inline: 2rem;
296
+ }
297
+ ```
298
+
299
+ ```jsx
300
+ import styles from "./Button.module.css";
301
+
302
+ <Button className={styles.customButton}>Custom</Button>;
303
+ ```
304
+
305
+ ### Styled Components
306
+
307
+ ```jsx
308
+ import styled from "styled-components";
309
+ import { Button } from "@fpkit/acss";
310
+
311
+ const CustomButton = styled(Button)`
312
+ --btn-padding-inline: 2rem;
313
+ --btn-radius: 0.5rem;
314
+ --btn-primary-bg: #e63946;
315
+ `;
316
+ ```
317
+
318
+ ---
319
+
320
+ ## Best Practices
321
+
322
+ ### ✅ Do
323
+
324
+ - Use the naming pattern when creating custom variables
325
+ - Use rem units for spacing and sizing
326
+ - Use logical properties (`padding-inline`, `padding-block`)
327
+ - Test across themes to ensure customizations work
328
+ - Use semantic naming for custom variants
329
+
330
+ ### ❌ Don't
331
+
332
+ - Don't use px units (use rem)
333
+ - Don't use forbidden abbreviations (px/py, w/h, cl, dsp, bdr)
334
+ - Don't use `!important` unless absolutely necessary
335
+ - Don't create one-off variables - follow the component pattern
336
+
337
+ ---
338
+
339
+ ## Troubleshooting
340
+
341
+ ### Variables Not Applying
342
+
343
+ 1. **Check specificity** - Ensure your selector has equal or higher specificity
344
+ 2. **Check cascade order** - Import fpkit CSS before your overrides
345
+ 3. **Check typos** - Variable names are case-sensitive
346
+
347
+ ```css
348
+ /* ❌ Won't work - imported after */
349
+ @import "@fpkit/acss/libs/index.css";
350
+
351
+ :root {
352
+ --btn-bg: red; /* Applied first, then overwritten */
353
+ }
354
+
355
+ /* ✅ Works - correct order */
356
+ :root {
357
+ --btn-bg: red; /* Overrides fpkit defaults */
358
+ }
359
+
360
+ @import "@fpkit/acss/libs/index.css";
361
+ ```
362
+
363
+ ---
364
+
365
+ ## Additional Resources
366
+
367
+ - **📖
368
+ [Full CSS Variables Guide](https://github.com/shawn-sandy/acss/blob/main/packages/fpkit/docs/guides/css-variables.md)** -
369
+ Comprehensive documentation
370
+ - **📘
371
+ [Composition Guide](https://github.com/shawn-sandy/acss/blob/main/packages/fpkit/docs/guides/composition.md)** -
372
+ Building custom components
373
+ - **♿
374
+ [Accessibility Guide](https://github.com/shawn-sandy/acss/blob/main/packages/fpkit/docs/guides/accessibility.md)** -
375
+ WCAG compliance
376
+
377
+ ---
378
+
379
+ **Explore component stories** in this Storybook to see CSS variable
380
+ customization examples in action!