@fpkit/acss 1.0.0-beta.1 → 2.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.
- package/README.md +92 -0
- package/docs/README.md +325 -0
- package/docs/guides/accessibility.md +764 -0
- package/docs/guides/architecture.md +705 -0
- package/docs/guides/composition.md +688 -0
- package/docs/guides/css-variables.md +522 -0
- package/docs/guides/storybook.md +828 -0
- package/docs/guides/testing.md +817 -0
- package/docs/testing/focus-indicator-testing.md +437 -0
- package/libs/{chunk-7XPFW7CB.js → chunk-43TK2ICH.js} +2 -2
- package/libs/chunk-5PJYLVFY.cjs +17 -0
- package/libs/chunk-5PJYLVFY.cjs.map +1 -0
- package/libs/chunk-E4OSROCA.cjs +17 -0
- package/libs/chunk-E4OSROCA.cjs.map +1 -0
- package/libs/chunk-KVKQLRJG.js +10 -0
- package/libs/chunk-KVKQLRJG.js.map +1 -0
- package/libs/{chunk-QVW6W76L.cjs → chunk-MGPWZRBX.cjs} +3 -3
- package/libs/chunk-NNTBIHSD.js +8 -0
- package/libs/chunk-NNTBIHSD.js.map +1 -0
- package/libs/{chunk-X3JCTEPD.js → chunk-QKHPHMG2.js} +2 -2
- package/libs/{chunk-T4T6GWYQ.cjs → chunk-R7NLLZU2.cjs} +3 -3
- package/libs/{chunk-X5LGFCWG.js → chunk-UJAQVHWC.js} +3 -3
- package/libs/{chunk-DKTHCQ5P.cjs → chunk-X5RKCLDC.cjs} +3 -3
- package/libs/components/breadcrumbs/breadcrumb.cjs +5 -5
- package/libs/components/breadcrumbs/breadcrumb.d.cts +1 -1
- package/libs/components/breadcrumbs/breadcrumb.d.ts +1 -1
- package/libs/components/breadcrumbs/breadcrumb.js +2 -2
- package/libs/components/button.cjs +3 -3
- package/libs/components/button.d.cts +1 -1
- package/libs/components/button.d.ts +1 -1
- package/libs/components/button.js +1 -1
- package/libs/components/buttons/button.css +1 -1
- package/libs/components/buttons/button.css.map +1 -1
- package/libs/components/buttons/button.min.css +2 -2
- package/libs/components/dialog/dialog.cjs +4 -4
- package/libs/components/dialog/dialog.js +2 -2
- package/libs/components/icons/icon.d.cts +32 -32
- package/libs/components/icons/icon.d.ts +32 -32
- package/libs/components/link/link.cjs +11 -3
- package/libs/components/link/link.d.cts +131 -3
- package/libs/components/link/link.d.ts +131 -3
- package/libs/components/link/link.js +1 -1
- package/libs/components/list/list.css +1 -1
- package/libs/components/list/list.min.css +1 -1
- package/libs/components/modal.cjs +3 -3
- package/libs/components/modal.js +2 -2
- package/libs/hooks.cjs +3 -3
- package/libs/hooks.d.cts +1 -1
- package/libs/hooks.d.ts +1 -1
- package/libs/hooks.js +2 -2
- package/libs/index.cjs +12 -12
- package/libs/index.css +1 -1
- package/libs/index.css.map +1 -1
- package/libs/index.d.cts +237 -2
- package/libs/index.d.ts +237 -2
- package/libs/index.js +5 -5
- package/package.json +4 -3
- package/src/components/README.mdx +1 -1
- package/src/components/breadcrumbs/breadcrumb.test.tsx +1 -2
- package/src/components/buttons/README.mdx +19 -9
- package/src/components/buttons/button.scss +5 -0
- package/src/components/buttons/button.stories.tsx +8 -5
- package/src/components/buttons/button.tsx +19 -15
- package/src/components/cards/card.stories.tsx +1 -1
- package/src/components/details/details.stories.tsx +1 -1
- package/src/components/form/form.stories.tsx +1 -1
- package/src/components/form/input.stories.tsx +1 -1
- package/src/components/form/select.stories.tsx +1 -1
- package/src/components/heading/README.mdx +292 -0
- package/src/components/icons/icon.stories.tsx +1 -1
- package/src/components/link/link.stories.tsx +205 -8
- package/src/components/link/link.test.tsx +1 -1
- package/src/components/link/link.tsx +22 -0
- package/src/components/link/link.types.ts +11 -3
- package/src/components/list/list.scss +1 -1
- package/src/components/nav/nav.stories.tsx +1 -1
- package/src/components/ui.stories.tsx +53 -19
- package/src/docs/accessibility.mdx +484 -0
- package/src/docs/composition.mdx +549 -0
- package/src/docs/css-variables.mdx +380 -0
- package/src/docs/fpkit-developer.mdx +623 -0
- package/src/introduction.mdx +356 -0
- package/src/styles/buttons/button.css +4 -0
- package/src/styles/buttons/button.css.map +1 -1
- package/src/styles/index.css +9 -3
- package/src/styles/index.css.map +1 -1
- package/src/styles/list/list.css +1 -1
- package/src/styles/utilities/_disabled.scss +5 -4
- package/libs/chunk-33PNJ4LO.cjs +0 -15
- package/libs/chunk-33PNJ4LO.cjs.map +0 -1
- package/libs/chunk-GT77BX4L.cjs +0 -17
- package/libs/chunk-GT77BX4L.cjs.map +0 -1
- package/libs/chunk-OVWLQYMK.js +0 -10
- package/libs/chunk-OVWLQYMK.js.map +0 -1
- package/libs/chunk-UEPAWMDF.js +0 -8
- package/libs/chunk-UEPAWMDF.js.map +0 -1
- package/libs/link-5192f411.d.ts +0 -323
- /package/libs/{chunk-7XPFW7CB.js.map → chunk-43TK2ICH.js.map} +0 -0
- /package/libs/{chunk-QVW6W76L.cjs.map → chunk-MGPWZRBX.cjs.map} +0 -0
- /package/libs/{chunk-X3JCTEPD.js.map → chunk-QKHPHMG2.js.map} +0 -0
- /package/libs/{chunk-T4T6GWYQ.cjs.map → chunk-R7NLLZU2.cjs.map} +0 -0
- /package/libs/{chunk-X5LGFCWG.js.map → chunk-UJAQVHWC.js.map} +0 -0
- /package/libs/{chunk-DKTHCQ5P.cjs.map → chunk-X5RKCLDC.cjs.map} +0 -0
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
# CSS Variables Guide
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
The @fpkit/acss component library uses **CSS custom properties** (CSS variables) to provide flexible theming and customization. This guide explains how to discover, understand, and customize component styles without modifying the library's source code.
|
|
6
|
+
|
|
7
|
+
### Why CSS Variables?
|
|
8
|
+
|
|
9
|
+
CSS variables give you powerful customization capabilities:
|
|
10
|
+
|
|
11
|
+
```css
|
|
12
|
+
/* Override button colors globally */
|
|
13
|
+
:root {
|
|
14
|
+
--btn-primary-bg: #0066cc;
|
|
15
|
+
--btn-primary-color: white;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Or scope to specific contexts */
|
|
19
|
+
.dark-theme {
|
|
20
|
+
--btn-primary-bg: #66b3ff;
|
|
21
|
+
--btn-bg: #2d2d2d;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Component-specific overrides */
|
|
25
|
+
.custom-button {
|
|
26
|
+
--btn-padding-inline: 2rem;
|
|
27
|
+
--btn-radius: 0.25rem;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Quick Start
|
|
32
|
+
|
|
33
|
+
1. **Discover variables**: Use browser DevTools or IDE autocomplete - type `--btn-` to see all button variables
|
|
34
|
+
2. **Override in your CSS**: Define custom values in `:root`, theme classes, or component selectors
|
|
35
|
+
3. **Test**: Changes reflect immediately without rebuilding
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Understanding the Naming Convention
|
|
40
|
+
|
|
41
|
+
All CSS variables in @fpkit/acss follow a consistent hierarchical structure:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
--{component}-{element}-{variant}-{property}-{modifier}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Pattern Breakdown
|
|
48
|
+
|
|
49
|
+
| Segment | Required | Examples | Purpose |
|
|
50
|
+
|---------|----------|----------|---------|
|
|
51
|
+
| **component** | ✅ Yes | `btn`, `alert`, `card`, `nav` | Component namespace |
|
|
52
|
+
| **element** | ❌ Optional | `header`, `footer`, `title`, `icon` | Sub-component part |
|
|
53
|
+
| **variant** | ❌ Optional | `primary`, `error`, `success`, `warning` | Style or semantic variant |
|
|
54
|
+
| **property** | ✅ Yes | `bg`, `color`, `padding`, `border` | CSS property name |
|
|
55
|
+
| **modifier** | ❌ Optional | `offset`, `width`, `radius` | Property modifier |
|
|
56
|
+
|
|
57
|
+
### Common Patterns
|
|
58
|
+
|
|
59
|
+
```scss
|
|
60
|
+
// Component base property
|
|
61
|
+
--btn-bg
|
|
62
|
+
|
|
63
|
+
// Variant-specific property
|
|
64
|
+
--btn-primary-bg
|
|
65
|
+
|
|
66
|
+
// State-specific property
|
|
67
|
+
--btn-hover-bg
|
|
68
|
+
--btn-focus-outline
|
|
69
|
+
|
|
70
|
+
// Element-specific property
|
|
71
|
+
--card-header-padding
|
|
72
|
+
--card-footer-bg
|
|
73
|
+
|
|
74
|
+
// State with modifier
|
|
75
|
+
--btn-focus-outline-offset
|
|
76
|
+
|
|
77
|
+
// Element with variant
|
|
78
|
+
--alert-icon-error-color
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Abbreviation Reference
|
|
84
|
+
|
|
85
|
+
@fpkit/acss uses selective abbreviations to balance brevity with clarity:
|
|
86
|
+
|
|
87
|
+
### ✅ Abbreviated Properties
|
|
88
|
+
|
|
89
|
+
| Abbreviation | Full Name | Example |
|
|
90
|
+
|--------------|-----------|---------|
|
|
91
|
+
| `bg` | background / background-color | `--btn-bg` |
|
|
92
|
+
| `fs` | font-size | `--btn-fs` |
|
|
93
|
+
| `fw` | font-weight | `--btn-fw` |
|
|
94
|
+
| `radius` | border-radius | `--btn-radius` |
|
|
95
|
+
| `gap` | gap | `--btn-gap` |
|
|
96
|
+
|
|
97
|
+
### ✅ Full Word Properties
|
|
98
|
+
|
|
99
|
+
| Property | Variable Pattern | Example |
|
|
100
|
+
|----------|------------------|---------|
|
|
101
|
+
| padding | `--{component}-padding-{direction}` | `--btn-padding-inline` |
|
|
102
|
+
| margin | `--{component}-margin-{direction}` | `--card-margin-block` |
|
|
103
|
+
| color (text) | `--{component}-color` | `--btn-color` |
|
|
104
|
+
| border | `--{component}-border` | `--card-border` |
|
|
105
|
+
| display | `--{component}-display` | `--btn-display` |
|
|
106
|
+
| width | `--{component}-width` | `--input-width` |
|
|
107
|
+
| height | `--{component}-height` | `--input-height` |
|
|
108
|
+
|
|
109
|
+
**Logical Properties:**
|
|
110
|
+
```scss
|
|
111
|
+
/* Inline = horizontal (left/right) */
|
|
112
|
+
--btn-padding-inline: 1.5rem;
|
|
113
|
+
--btn-margin-inline: 0.5rem;
|
|
114
|
+
|
|
115
|
+
/* Block = vertical (top/bottom) */
|
|
116
|
+
--btn-padding-block: 0.5rem;
|
|
117
|
+
--btn-margin-block: 1rem;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## rem Units
|
|
123
|
+
|
|
124
|
+
**All spacing and sizing uses rem units** for accessibility and responsive design.
|
|
125
|
+
|
|
126
|
+
**Conversion formula:** `px / 16 = rem`
|
|
127
|
+
|
|
128
|
+
**Common conversions:**
|
|
129
|
+
- 8px = 0.5rem
|
|
130
|
+
- 12px = 0.75rem
|
|
131
|
+
- 16px = 1rem (base)
|
|
132
|
+
- 20px = 1.25rem
|
|
133
|
+
- 24px = 1.5rem
|
|
134
|
+
- 32px = 2rem
|
|
135
|
+
|
|
136
|
+
**Why rem units?**
|
|
137
|
+
- Respects user font size preferences (accessibility)
|
|
138
|
+
- Consistent scaling across breakpoints
|
|
139
|
+
- Better for responsive design
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Discovering Variables
|
|
144
|
+
|
|
145
|
+
### Method 1: Browser DevTools (Recommended)
|
|
146
|
+
|
|
147
|
+
1. Inspect a component in your browser
|
|
148
|
+
2. Open the **Computed** tab
|
|
149
|
+
3. Scroll to **CSS Variables** section
|
|
150
|
+
4. See all available variables and their current values
|
|
151
|
+
|
|
152
|
+
### Method 2: IDE Autocomplete
|
|
153
|
+
|
|
154
|
+
If using TypeScript/JSX with CSS Modules or styled-components:
|
|
155
|
+
|
|
156
|
+
```css
|
|
157
|
+
/* Type the component prefix */
|
|
158
|
+
--btn- /* IDE shows: --btn-bg, --btn-padding-inline, --btn-radius, etc. */
|
|
159
|
+
--alert- /* IDE shows: --alert-error-bg, --alert-success-bg, etc. */
|
|
160
|
+
--card- /* IDE shows: --card-padding, --card-header-bg, etc. */
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Method 3: Source Code
|
|
164
|
+
|
|
165
|
+
Browse the compiled CSS in `node_modules/@fpkit/acss/libs/index.css` to see all available variables.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Customization Strategies
|
|
170
|
+
|
|
171
|
+
### Global Overrides
|
|
172
|
+
|
|
173
|
+
Override variables globally in `:root`:
|
|
174
|
+
|
|
175
|
+
```css
|
|
176
|
+
/* global.css */
|
|
177
|
+
:root {
|
|
178
|
+
/* Customize all buttons */
|
|
179
|
+
--btn-radius: 0.25rem;
|
|
180
|
+
--btn-padding-inline: 2rem;
|
|
181
|
+
|
|
182
|
+
/* Customize primary buttons */
|
|
183
|
+
--btn-primary-bg: #0066cc;
|
|
184
|
+
--btn-primary-color: white;
|
|
185
|
+
|
|
186
|
+
/* Customize all cards */
|
|
187
|
+
--card-padding: 1.5rem;
|
|
188
|
+
--card-radius: 0.75rem;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Theme Overrides
|
|
193
|
+
|
|
194
|
+
Create theme classes with custom variables:
|
|
195
|
+
|
|
196
|
+
```css
|
|
197
|
+
/* themes.css */
|
|
198
|
+
.light-theme {
|
|
199
|
+
--btn-bg: white;
|
|
200
|
+
--btn-color: #333;
|
|
201
|
+
--card-bg: #f9f9f9;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.dark-theme {
|
|
205
|
+
--btn-bg: #2d2d2d;
|
|
206
|
+
--btn-color: #f0f0f0;
|
|
207
|
+
--card-bg: #1a1a1a;
|
|
208
|
+
--card-border: 1px solid #444;
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
```jsx
|
|
213
|
+
// Apply theme
|
|
214
|
+
<div className="dark-theme">
|
|
215
|
+
<Button>Styled by theme</Button>
|
|
216
|
+
<Card>Also themed</Card>
|
|
217
|
+
</div>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Component-Specific Overrides
|
|
221
|
+
|
|
222
|
+
Override variables for specific instances:
|
|
223
|
+
|
|
224
|
+
```css
|
|
225
|
+
/* custom-components.css */
|
|
226
|
+
.hero-button {
|
|
227
|
+
--btn-padding-inline: 3rem;
|
|
228
|
+
--btn-padding-block: 1rem;
|
|
229
|
+
--btn-fs: 1.25rem;
|
|
230
|
+
--btn-radius: 0.5rem;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.compact-card {
|
|
234
|
+
--card-padding: 0.75rem;
|
|
235
|
+
--card-header-padding: 0.75rem 1rem;
|
|
236
|
+
--card-footer-padding: 0.75rem 1rem;
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
```jsx
|
|
241
|
+
<Button className="hero-button">Large CTA</Button>
|
|
242
|
+
<Card className="compact-card">Compact content</Card>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Inline Overrides
|
|
246
|
+
|
|
247
|
+
Use inline styles for dynamic or one-off customization:
|
|
248
|
+
|
|
249
|
+
```jsx
|
|
250
|
+
<Button
|
|
251
|
+
style={{
|
|
252
|
+
'--btn-bg': '#e63946',
|
|
253
|
+
'--btn-color': 'white',
|
|
254
|
+
}}
|
|
255
|
+
>
|
|
256
|
+
Danger Action
|
|
257
|
+
</Button>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Component Variable Reference
|
|
263
|
+
|
|
264
|
+
### Button Variables
|
|
265
|
+
|
|
266
|
+
```scss
|
|
267
|
+
// Base properties
|
|
268
|
+
--btn-display: inline-flex
|
|
269
|
+
--btn-padding-inline: 1.5rem
|
|
270
|
+
--btn-padding-block: 0.5rem
|
|
271
|
+
--btn-fs: 1rem
|
|
272
|
+
--btn-fw: 600
|
|
273
|
+
--btn-radius: 0.375rem
|
|
274
|
+
--btn-gap: 0.5rem
|
|
275
|
+
|
|
276
|
+
// Variants
|
|
277
|
+
--btn-primary-bg: #0066cc
|
|
278
|
+
--btn-primary-color: white
|
|
279
|
+
--btn-secondary-bg: transparent
|
|
280
|
+
--btn-secondary-color: currentColor
|
|
281
|
+
|
|
282
|
+
// States
|
|
283
|
+
--btn-hover-bg: brightness(1.1)
|
|
284
|
+
--btn-focus-outline: 2px solid currentColor
|
|
285
|
+
--btn-focus-outline-offset: 2px
|
|
286
|
+
--btn-disabled-opacity: 0.6
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Alert Variables
|
|
290
|
+
|
|
291
|
+
```scss
|
|
292
|
+
// Base properties
|
|
293
|
+
--alert-padding: 1rem
|
|
294
|
+
--alert-radius: 0.375rem
|
|
295
|
+
--alert-border-width: 1px
|
|
296
|
+
|
|
297
|
+
// Semantic variants
|
|
298
|
+
--alert-error-bg: #f8d7da
|
|
299
|
+
--alert-error-border: #f5c6cb
|
|
300
|
+
--alert-error-color: #721c24
|
|
301
|
+
|
|
302
|
+
--alert-success-bg: #d4edda
|
|
303
|
+
--alert-success-border: #c3e6cb
|
|
304
|
+
--alert-success-color: #155724
|
|
305
|
+
|
|
306
|
+
--alert-warning-bg: #fff3cd
|
|
307
|
+
--alert-warning-border: #ffeaa7
|
|
308
|
+
--alert-warning-color: #856404
|
|
309
|
+
|
|
310
|
+
--alert-info-bg: #d1ecf1
|
|
311
|
+
--alert-info-border: #bee5eb
|
|
312
|
+
--alert-info-color: #0c5460
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Card Variables
|
|
316
|
+
|
|
317
|
+
```scss
|
|
318
|
+
// Base properties
|
|
319
|
+
--card-padding: 1rem
|
|
320
|
+
--card-bg: white
|
|
321
|
+
--card-radius: 0.5rem
|
|
322
|
+
--card-border: 1px solid #e0e0e0
|
|
323
|
+
|
|
324
|
+
// Header
|
|
325
|
+
--card-header-padding: 1rem 1.5rem
|
|
326
|
+
--card-header-bg: #f9f9f9
|
|
327
|
+
--card-header-border-bottom: 1px solid #e0e0e0
|
|
328
|
+
--card-header-fs: 1.25rem
|
|
329
|
+
--card-header-fw: 600
|
|
330
|
+
|
|
331
|
+
// Footer
|
|
332
|
+
--card-footer-padding: 1rem 1.5rem
|
|
333
|
+
--card-footer-bg: #f9f9f9
|
|
334
|
+
--card-footer-border-top: 1px solid #e0e0e0
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## Variant Organization
|
|
340
|
+
|
|
341
|
+
### Semantic Variants
|
|
342
|
+
|
|
343
|
+
Used for UI states with meaning (alerts, messages):
|
|
344
|
+
|
|
345
|
+
```scss
|
|
346
|
+
// Error variant
|
|
347
|
+
--alert-error-bg: #f8d7da;
|
|
348
|
+
--alert-error-border: #f5c6cb;
|
|
349
|
+
--alert-error-color: #721c24;
|
|
350
|
+
|
|
351
|
+
// Success variant
|
|
352
|
+
--alert-success-bg: #d4edda;
|
|
353
|
+
--alert-success-border: #c3e6cb;
|
|
354
|
+
--alert-success-color: #155724;
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Style Variants
|
|
358
|
+
|
|
359
|
+
Used for visual hierarchy (buttons, badges):
|
|
360
|
+
|
|
361
|
+
```scss
|
|
362
|
+
// Primary button (high emphasis)
|
|
363
|
+
--btn-primary-bg: #0066cc;
|
|
364
|
+
--btn-primary-color: white;
|
|
365
|
+
|
|
366
|
+
// Secondary button (medium emphasis)
|
|
367
|
+
--btn-secondary-bg: transparent;
|
|
368
|
+
--btn-secondary-color: #0066cc;
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## State Variables
|
|
374
|
+
|
|
375
|
+
States represent interactive or conditional component appearances.
|
|
376
|
+
|
|
377
|
+
### Common States
|
|
378
|
+
|
|
379
|
+
| State | Description | Example Use |
|
|
380
|
+
|-------|-------------|-------------|
|
|
381
|
+
| `hover` | Mouse hover | `--btn-hover-bg` |
|
|
382
|
+
| `focus` | Keyboard focus | `--btn-focus-outline` |
|
|
383
|
+
| `active` | Active/pressed | `--btn-active-transform` |
|
|
384
|
+
| `disabled` | Disabled state | `--btn-disabled-opacity` |
|
|
385
|
+
| `visited` | Visited link | `--link-visited-color` |
|
|
386
|
+
| `checked` | Checked input | `--checkbox-checked-bg` |
|
|
387
|
+
|
|
388
|
+
### State Examples
|
|
389
|
+
|
|
390
|
+
```scss
|
|
391
|
+
// Hover state
|
|
392
|
+
--btn-hover-bg: #0052a3;
|
|
393
|
+
--btn-hover-transform: translateY(-1px);
|
|
394
|
+
|
|
395
|
+
// Focus state
|
|
396
|
+
--btn-focus-outline: 2px solid currentColor;
|
|
397
|
+
--btn-focus-outline-offset: 2px;
|
|
398
|
+
|
|
399
|
+
// Disabled state
|
|
400
|
+
--btn-disabled-opacity: 0.6;
|
|
401
|
+
--btn-disabled-cursor: not-allowed;
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## Best Practices
|
|
407
|
+
|
|
408
|
+
### ✅ Do
|
|
409
|
+
|
|
410
|
+
- **Use the naming pattern** when creating custom variables for your components
|
|
411
|
+
- **Use rem units** for spacing and sizing
|
|
412
|
+
- **Use logical properties** (`padding-inline`, `padding-block`) for better RTL support
|
|
413
|
+
- **Test across themes** to ensure customizations work in all contexts
|
|
414
|
+
- **Use semantic naming** for custom variants (e.g., `--btn-danger-bg` not `--btn-red-bg`)
|
|
415
|
+
|
|
416
|
+
### ❌ Don't
|
|
417
|
+
|
|
418
|
+
- **Don't use px units** for spacing or sizing (use rem)
|
|
419
|
+
- **Don't use forbidden abbreviations** (px/py, w/h, cl, dsp, bdr)
|
|
420
|
+
- **Don't use `!important`** unless absolutely necessary
|
|
421
|
+
- **Don't create one-off variables** - follow the component pattern
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## Framework Integration
|
|
426
|
+
|
|
427
|
+
### React
|
|
428
|
+
|
|
429
|
+
```jsx
|
|
430
|
+
// Global overrides
|
|
431
|
+
import './theme.css';
|
|
432
|
+
|
|
433
|
+
// Component-specific
|
|
434
|
+
function CustomButton() {
|
|
435
|
+
return (
|
|
436
|
+
<Button
|
|
437
|
+
style={{
|
|
438
|
+
'--btn-padding-inline': '2rem',
|
|
439
|
+
'--btn-radius': '0.5rem',
|
|
440
|
+
}}
|
|
441
|
+
>
|
|
442
|
+
Custom
|
|
443
|
+
</Button>
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### CSS Modules
|
|
449
|
+
|
|
450
|
+
```css
|
|
451
|
+
/* Button.module.css */
|
|
452
|
+
.customButton {
|
|
453
|
+
--btn-primary-bg: #e63946;
|
|
454
|
+
--btn-primary-color: white;
|
|
455
|
+
--btn-padding-inline: 2rem;
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
```jsx
|
|
460
|
+
import styles from './Button.module.css';
|
|
461
|
+
|
|
462
|
+
<Button className={styles.customButton}>Custom</Button>
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### Styled Components
|
|
466
|
+
|
|
467
|
+
```jsx
|
|
468
|
+
import styled from 'styled-components';
|
|
469
|
+
import { Button } from '@fpkit/acss';
|
|
470
|
+
|
|
471
|
+
const CustomButton = styled(Button)`
|
|
472
|
+
--btn-padding-inline: 2rem;
|
|
473
|
+
--btn-radius: 0.5rem;
|
|
474
|
+
--btn-primary-bg: #e63946;
|
|
475
|
+
`;
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
## Troubleshooting
|
|
481
|
+
|
|
482
|
+
### Variables Not Applying
|
|
483
|
+
|
|
484
|
+
1. **Check specificity**: Ensure your selector has equal or higher specificity
|
|
485
|
+
2. **Check cascade order**: Import fpkit CSS before your overrides
|
|
486
|
+
3. **Check typos**: Variable names are case-sensitive
|
|
487
|
+
|
|
488
|
+
```css
|
|
489
|
+
/* ❌ Won't work - imported after */
|
|
490
|
+
@import '@fpkit/acss/libs/index.css';
|
|
491
|
+
|
|
492
|
+
:root {
|
|
493
|
+
--btn-bg: red; /* Applied first, then overwritten */
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/* ✅ Works - correct order */
|
|
497
|
+
:root {
|
|
498
|
+
--btn-bg: red; /* Overrides fpkit defaults */
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
@import '@fpkit/acss/libs/index.css';
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Finding Variable Names
|
|
505
|
+
|
|
506
|
+
Use browser DevTools Computed tab to see:
|
|
507
|
+
- All available variables for an element
|
|
508
|
+
- Current values (resolved)
|
|
509
|
+
- Where they're defined (inheritance chain)
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
## Additional Resources
|
|
514
|
+
|
|
515
|
+
- **Component Documentation**: See Storybook for complete component APIs
|
|
516
|
+
- **Composition Guide**: `docs/guides/composition.md` for building custom components
|
|
517
|
+
- **Accessibility Guide**: `docs/guides/accessibility.md` for WCAG compliance
|
|
518
|
+
- **Architecture Guide**: `docs/guides/architecture.md` for component patterns
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
For questions or issues, please visit our [GitHub repository](https://github.com/shawn-sandy/acss).
|