@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,292 @@
1
+ import { Meta } from "@storybook/addon-docs/blocks";
2
+
3
+ <Meta title="FP.REACT Components/Heading (Deprecated)/Readme" />
4
+
5
+ # Heading (Deprecated)
6
+
7
+ > ⚠️ **DEPRECATED**: This component is deprecated and will be removed in **v3.0.0**. Please use the [`Title`](?path=/docs/fp-react-components-title--docs) component instead.
8
+
9
+ ---
10
+
11
+ ## Deprecation Notice
12
+
13
+ <div style={{ padding: '1.5rem', background: '#fef3c7', border: '2px solid #f59e0b', borderRadius: '0.5rem', marginBottom: '2rem' }}>
14
+ <strong style={{ color: '#92400e', fontSize: '1.125rem' }}>⚠️ This component is deprecated</strong>
15
+ <p style={{ marginTop: '0.5rem', color: '#78350f' }}>
16
+ The <code>Heading</code> component has been replaced by the new <code>Title</code> component
17
+ which offers improved API design, better accessibility features, and enhanced performance.
18
+ </p>
19
+ <p style={{ marginTop: '0.5rem', color: '#78350f' }}>
20
+ <strong>Removal Timeline:</strong> This component will be removed in v3.0.0 (TBD)
21
+ </p>
22
+ </div>
23
+
24
+ ---
25
+
26
+ ## Quick Migration
27
+
28
+ ### Before (Deprecated)
29
+
30
+ ```tsx
31
+ import { Heading } from '@fpkit/acss';
32
+
33
+ <Heading type="h2">Section Title</Heading>
34
+ ```
35
+
36
+ ### After (Recommended)
37
+
38
+ ```tsx
39
+ import { Title } from '@fpkit/acss';
40
+
41
+ <Title level="h2">Section Title</Title>
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Why We Deprecated Heading
47
+
48
+ The new `Title` component provides several advantages over the deprecated `Heading` component:
49
+
50
+ <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(250px, 1fr))', gap: '1rem', margin: '1.5rem 0' }}>
51
+ <div style={{ padding: '1rem', border: '1px solid #e0e0e0', borderRadius: '0.5rem' }}>
52
+ <strong>✅ Better API</strong>
53
+ <p style={{ fontSize: '0.875rem', color: '#666' }}>The <code>level</code> prop is more semantic and descriptive than <code>type</code></p>
54
+ </div>
55
+ <div style={{ padding: '1rem', border: '1px solid #e0e0e0', borderRadius: '0.5rem' }}>
56
+ <strong>✅ Improved Accessibility</strong>
57
+ <p style={{ fontSize: '0.875rem', color: '#666' }}>Enhanced WCAG 2.1 AA compliance with better screen reader support</p>
58
+ </div>
59
+ <div style={{ padding: '1rem', border: '1px solid #e0e0e0', borderRadius: '0.5rem' }}>
60
+ <strong>✅ Better Documentation</strong>
61
+ <p style={{ fontSize: '0.875rem', color: '#666' }}>Comprehensive JSDoc comments for improved TypeScript IntelliSense</p>
62
+ </div>
63
+ <div style={{ padding: '1rem', border: '1px solid #e0e0e0', borderRadius: '0.5rem' }}>
64
+ <strong>✅ Performance</strong>
65
+ <p style={{ fontSize: '0.875rem', color: '#666' }}>React.memo optimization prevents unnecessary re-renders</p>
66
+ </div>
67
+ </div>
68
+
69
+ ---
70
+
71
+ ## Migration Guide
72
+
73
+ ### Step-by-Step Migration
74
+
75
+ #### 1. Update Imports
76
+
77
+ ```tsx
78
+ // Before
79
+ import { Heading } from '@fpkit/acss';
80
+
81
+ // After
82
+ import { Title } from '@fpkit/acss';
83
+ ```
84
+
85
+ #### 2. Rename the Component
86
+
87
+ ```tsx
88
+ // Before
89
+ <Heading type="h2">Section Title</Heading>
90
+
91
+ // After
92
+ <Title level="h2">Section Title</Title>
93
+ ```
94
+
95
+ #### 3. Update the Prop Name
96
+
97
+ The only prop that changed is `type` → `level`:
98
+
99
+ | Old Prop | New Prop | Description |
100
+ |----------|----------|-------------|
101
+ | `type` | `level` | The semantic heading level (h1-h6) |
102
+
103
+ #### 4. Review Default Behavior
104
+
105
+ **IMPORTANT:** The default heading level changed:
106
+
107
+ - **Heading (old)**: Default is `h3`
108
+ - **Title (new)**: Default is `h2`
109
+
110
+ If you relied on the default, you may need to explicitly specify `h3`:
111
+
112
+ ```tsx
113
+ // Before (implicitly h3)
114
+ <Heading>Default Heading</Heading>
115
+
116
+ // After (explicitly h3 to maintain behavior)
117
+ <Title level="h3">Default Heading</Title>
118
+
119
+ // Or use the new default (h2)
120
+ <Title>Default Title</Title>
121
+ ```
122
+
123
+ ---
124
+
125
+ ## All Heading Levels
126
+
127
+ The `Heading` component supports all six semantic heading levels, just like `Title`:
128
+
129
+ ```tsx
130
+ // h1 - Page title (use once per page)
131
+ <Heading type="h1">Main Page Title</Heading>
132
+
133
+ // h2 - Major sections
134
+ <Heading type="h2">Section Heading</Heading>
135
+
136
+ // h3 - Subsections (default)
137
+ <Heading type="h3">Subsection Heading</Heading>
138
+
139
+ // h4-h6 - Deeper nesting
140
+ <Heading type="h4">Level Four Heading</Heading>
141
+ <Heading type="h5">Level Five Heading</Heading>
142
+ <Heading type="h6">Level Six Heading</Heading>
143
+ ```
144
+
145
+ **Migrate to:**
146
+
147
+ ```tsx
148
+ // h1 - Page title (use once per page)
149
+ <Title level="h1">Main Page Title</Title>
150
+
151
+ // h2 - Major sections (now default)
152
+ <Title level="h2">Section Heading</Title>
153
+
154
+ // h3 - Subsections
155
+ <Title level="h3">Subsection Heading</Title>
156
+
157
+ // h4-h6 - Deeper nesting
158
+ <Title level="h4">Level Four Heading</Title>
159
+ <Title level="h5">Level Five Heading</Title>
160
+ <Title level="h6">Level Six Heading</Title>
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Props
166
+
167
+ > **Note**: These props still work but are deprecated. Refer to the [Title component documentation](?path=/docs/fp-react-components-title--docs) for the current API.
168
+
169
+ | Prop | Type | Default | Description |
170
+ |------|------|---------|-------------|
171
+ | `type` | `"h1" \| "h2" \| "h3" \| "h4" \| "h5" \| "h6"` | `"h3"` | **Deprecated.** Use `level` on Title component instead |
172
+ | `children` | `React.ReactNode` | *required* | The content to display in the heading |
173
+ | `ui` | `string` | - | Data attribute for fpkit styling hooks |
174
+ | `className` | `string` | - | CSS class names to apply |
175
+ | `ref` | `React.Ref<HTMLHeadingElement>` | - | Forwarded ref to the heading element |
176
+
177
+ All other standard HTML heading attributes and ARIA properties are also supported.
178
+
179
+ ---
180
+
181
+ ## Current Behavior
182
+
183
+ The `Heading` component still works for backwards compatibility but:
184
+
185
+ ### Development Warnings
186
+
187
+ In development mode, the component logs deprecation warnings to the console:
188
+
189
+ ```
190
+ [@fpkit/acss] Heading component is deprecated and will be removed in v3.0.0.
191
+ Please use the Title component instead.
192
+ Migration: <Heading type="h2"> → <Title level="h2">
193
+ See documentation: https://fpkit.dev/components/title
194
+ ```
195
+
196
+ ### Production Behavior
197
+
198
+ - No console warnings in production builds
199
+ - Full backwards compatibility maintained
200
+ - All props forwarded correctly to Title component
201
+ - Performance identical to direct Title usage
202
+
203
+ ---
204
+
205
+ ## TypeScript Support
206
+
207
+ The component maintains full TypeScript support:
208
+
209
+ ```tsx
210
+ import { Heading, type TitleProps } from '@fpkit/acss';
211
+
212
+ // Old API (still typed correctly)
213
+ <Heading type="h2">Typed Heading</Heading>
214
+
215
+ // Type-safe with all Title props
216
+ const props: TitleProps = {
217
+ type: 'h3',
218
+ children: 'Section Title',
219
+ className: 'custom-class'
220
+ };
221
+ <Heading {...props} />
222
+ ```
223
+
224
+ However, TypeScript will show deprecation warnings in your IDE for better migration visibility.
225
+
226
+ ---
227
+
228
+ ## Migration Checklist
229
+
230
+ Use this checklist to ensure a smooth migration:
231
+
232
+ - [ ] Find all `<Heading>` imports in your codebase
233
+ - [ ] Replace `import { Heading }` with `import { Title }`
234
+ - [ ] Replace all `<Heading>` tags with `<Title>`
235
+ - [ ] Replace all `type` props with `level`
236
+ - [ ] Review uses without explicit `type` prop (default changed from `h3` → `h2`)
237
+ - [ ] Test all migrated components
238
+ - [ ] Remove any `Heading` imports
239
+ - [ ] Search for any remaining references to `Heading` component
240
+
241
+ ### Find and Replace Tips
242
+
243
+ **VS Code / IDE Search:**
244
+
245
+ ```regex
246
+ # Find
247
+ <Heading\s+type="(h[1-6])"
248
+
249
+ # Replace with
250
+ <Title level="$1"
251
+ ```
252
+
253
+ **Command Line (ripgrep):**
254
+
255
+ ```bash
256
+ # Find all Heading usage
257
+ rg "Heading" --type tsx --type ts
258
+
259
+ # Find Heading imports
260
+ rg "import.*Heading.*from.*@fpkit/acss"
261
+ ```
262
+
263
+ ---
264
+
265
+ ## Related Components
266
+
267
+ - **[Title](?path=/docs/fp-react-components-title--docs)** - The recommended replacement component
268
+ - **Text** - For body text and paragraphs
269
+
270
+ ---
271
+
272
+ ## Support & Resources
273
+
274
+ - **Title Component Docs**: [View documentation](?path=/docs/fp-react-components-title--docs)
275
+ - **GitHub**: [fpkit/acss](https://github.com/fpkit/acss)
276
+ - **Migration Help**: Open an issue if you need assistance migrating
277
+
278
+ ---
279
+
280
+ <div style={{ padding: '1.5rem', background: '#f0f9ff', border: '1px solid #0ea5e9', borderRadius: '0.5rem', marginTop: '2rem' }}>
281
+ <strong>💡 Migration Tip:</strong> The Title component maintains the same functionality
282
+ while providing better DX and accessibility. The migration is straightforward and can be done incrementally.
283
+ Start by migrating new code, then gradually update existing components.
284
+ </div>
285
+
286
+ <div style={{ padding: '1.5rem', background: '#fef3c7', border: '2px solid #f59e0b', borderRadius: '0.5rem', marginTop: '1rem' }}>
287
+ <strong style={{ color: '#92400e' }}>⚠️ Removal Timeline</strong>
288
+ <p style={{ marginTop: '0.5rem', color: '#78350f', marginBottom: 0 }}>
289
+ Plan to complete your migration before upgrading to v3.0.0.
290
+ This component will be completely removed in that release.
291
+ </p>
292
+ </div>
@@ -9,7 +9,7 @@ import "./icon.scss";
9
9
  const meta: Meta<typeof Icon> = {
10
10
  component: Icon,
11
11
  title: "FP.React Components/Icons",
12
- tags: ["rc"],
12
+ tags: ["stable"],
13
13
  args: {
14
14
  // styles: Icon.styles,
15
15
  },
@@ -18,7 +18,7 @@ dl {
18
18
  --list-margin-top: 0;
19
19
  --list-margin-bottom: 1rem; // 16px
20
20
  --list-margin-inline: 0;
21
- --list-padding-inline: 2.5rem; // 40px - default browser indent
21
+ --list-padding-inline: 0.5rem; // 40px - default browser indent
22
22
  --list-gap: 0.5rem; // 8px - gap between items
23
23
 
24
24
  // List marker/bullet styling
@@ -9,7 +9,7 @@ import Link from "../link/link";
9
9
  const meta: Meta<typeof Nav> = {
10
10
  title: "FP.REACT Components/Nav",
11
11
  component: Nav,
12
- tags: ["rc"],
12
+ tags: ["stable"],
13
13
  parameters: {
14
14
  actions: { argTypesRegex: "^on.*" },
15
15
  docs: {
@@ -15,7 +15,7 @@ import UI from "./ui";
15
15
  * - Zero runtime overhead
16
16
  */
17
17
  const meta = {
18
- title: "FP.UI",
18
+ title: "FP/UI",
19
19
  component: UI,
20
20
  tags: ["autodocs", "primitive"],
21
21
  parameters: {
@@ -782,7 +782,9 @@ export const CommonAccessibilityMistakes: Story = {
782
782
 
783
783
  {/* Missing accessible name */}
784
784
  <div>
785
- <h4 style={{ marginTop: 0, marginBottom: "0.5rem", color: "#dc3545" }}>
785
+ <h4
786
+ style={{ marginTop: 0, marginBottom: "0.5rem", color: "#dc3545" }}
787
+ >
786
788
  ❌ BAD: Icon button without accessible name
787
789
  </h4>
788
790
  <UI
@@ -800,15 +802,24 @@ export const CommonAccessibilityMistakes: Story = {
800
802
  >
801
803
  ×
802
804
  </UI>
803
- <p style={{ fontSize: "0.875rem", color: "#721c24", marginTop: "0.5rem" }}>
804
- <strong>Problem:</strong> Screen readers cannot identify this button's
805
- purpose. <strong>Fix:</strong> Add <code>aria-label="Close"</code>
805
+ <p
806
+ style={{
807
+ fontSize: "0.875rem",
808
+ color: "#721c24",
809
+ marginTop: "0.5rem",
810
+ }}
811
+ >
812
+ <strong>Problem:</strong> Screen readers cannot identify this
813
+ button's purpose. <strong>Fix:</strong> Add{" "}
814
+ <code>aria-label="Close"</code>
806
815
  </p>
807
816
  </div>
808
817
 
809
818
  {/* Non-semantic clickable div */}
810
819
  <div>
811
- <h4 style={{ marginTop: 0, marginBottom: "0.5rem", color: "#dc3545" }}>
820
+ <h4
821
+ style={{ marginTop: 0, marginBottom: "0.5rem", color: "#dc3545" }}
822
+ >
812
823
  ❌ BAD: Clickable div without keyboard support
813
824
  </h4>
814
825
  <UI
@@ -825,16 +836,25 @@ export const CommonAccessibilityMistakes: Story = {
825
836
  >
826
837
  Click me (but you can't use keyboard!)
827
838
  </UI>
828
- <p style={{ fontSize: "0.875rem", color: "#721c24", marginTop: "0.5rem" }}>
829
- <strong>Problem:</strong> Not keyboard accessible or announced to screen
830
- readers. <strong>Fix:</strong> Use <code>as="button"</code> or add{" "}
831
- <code>role="button"</code>, <code>tabIndex=0</code>, and keyboard handlers.
839
+ <p
840
+ style={{
841
+ fontSize: "0.875rem",
842
+ color: "#721c24",
843
+ marginTop: "0.5rem",
844
+ }}
845
+ >
846
+ <strong>Problem:</strong> Not keyboard accessible or announced to
847
+ screen readers. <strong>Fix:</strong> Use <code>as="button"</code>{" "}
848
+ or add <code>role="button"</code>, <code>tabIndex=0</code>, and
849
+ keyboard handlers.
832
850
  </p>
833
851
  </div>
834
852
 
835
853
  {/* Poor contrast focus indicator */}
836
854
  <div>
837
- <h4 style={{ marginTop: 0, marginBottom: "0.5rem", color: "#dc3545" }}>
855
+ <h4
856
+ style={{ marginTop: 0, marginBottom: "0.5rem", color: "#dc3545" }}
857
+ >
838
858
  ❌ BAD: Insufficient focus indicator contrast
839
859
  </h4>
840
860
  <UI
@@ -851,16 +871,24 @@ export const CommonAccessibilityMistakes: Story = {
851
871
  >
852
872
  Low contrast focus
853
873
  </UI>
854
- <p style={{ fontSize: "0.875rem", color: "#721c24", marginTop: "0.5rem" }}>
855
- <strong>Problem:</strong> Focus indicator contrast ratio is less than 3:1
856
- (WCAG 2.4.7). <strong>Fix:</strong> Use a contrasting color like dark blue
857
- on light blue background.
874
+ <p
875
+ style={{
876
+ fontSize: "0.875rem",
877
+ color: "#721c24",
878
+ marginTop: "0.5rem",
879
+ }}
880
+ >
881
+ <strong>Problem:</strong> Focus indicator contrast ratio is less
882
+ than 3:1 (WCAG 2.4.7). <strong>Fix:</strong> Use a contrasting color
883
+ like dark blue on light blue background.
858
884
  </p>
859
885
  </div>
860
886
 
861
887
  {/* Vague link text */}
862
888
  <div>
863
- <h4 style={{ marginTop: 0, marginBottom: "0.5rem", color: "#dc3545" }}>
889
+ <h4
890
+ style={{ marginTop: 0, marginBottom: "0.5rem", color: "#dc3545" }}
891
+ >
864
892
  ❌ BAD: Non-descriptive link text
865
893
  </h4>
866
894
  <UI
@@ -873,10 +901,16 @@ export const CommonAccessibilityMistakes: Story = {
873
901
  >
874
902
  Click here
875
903
  </UI>
876
- <p style={{ fontSize: "0.875rem", color: "#721c24", marginTop: "0.5rem" }}>
904
+ <p
905
+ style={{
906
+ fontSize: "0.875rem",
907
+ color: "#721c24",
908
+ marginTop: "0.5rem",
909
+ }}
910
+ >
877
911
  <strong>Problem:</strong> "Click here" doesn't describe the link's
878
- destination. <strong>Fix:</strong> Use descriptive text like "View product
879
- documentation".
912
+ destination. <strong>Fix:</strong> Use descriptive text like "View
913
+ product documentation".
880
914
  </p>
881
915
  </div>
882
916
  </div>