@fpkit/acss 0.5.12 → 0.5.13
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 +89 -0
- package/libs/{chunk-DV56L5YX.cjs → chunk-2LTJ7HHX.cjs} +4 -4
- package/libs/{chunk-EQ67LF46.js → chunk-2Y7W75TT.js} +3 -3
- package/libs/{chunk-KKLTUJFB.cjs → chunk-3MKLDCKQ.cjs} +5 -5
- package/libs/chunk-3MKLDCKQ.cjs.map +1 -0
- package/libs/{chunk-X3EVB7VS.cjs → chunk-5S4ORA4C.cjs} +3 -3
- package/libs/{chunk-O6QZBB6G.js → chunk-772NRB75.js} +5 -5
- package/libs/chunk-772NRB75.js.map +1 -0
- package/libs/{chunk-6BVXFW7U.cjs → chunk-AHDJGCG5.cjs} +3 -3
- package/libs/{chunk-E3XP6BEX.cjs → chunk-B7F5FS6D.cjs} +3 -3
- package/libs/chunk-D4YLRWAO.cjs +18 -0
- package/libs/chunk-D4YLRWAO.cjs.map +1 -0
- package/libs/chunk-ETFLFC2S.js +10 -0
- package/libs/chunk-ETFLFC2S.js.map +1 -0
- package/libs/chunk-GZ4QFPRY.js +9 -0
- package/libs/chunk-GZ4QFPRY.js.map +1 -0
- package/libs/{chunk-LHVJKDMA.cjs → chunk-J32EZPYD.cjs} +3 -3
- package/libs/chunk-JJ43O4Y5.js +8 -0
- package/libs/chunk-JJ43O4Y5.js.map +1 -0
- package/libs/chunk-KUKIVRC2.js +7 -0
- package/libs/chunk-KUKIVRC2.js.map +1 -0
- package/libs/chunk-L75OQKEI.cjs +13 -0
- package/libs/chunk-L75OQKEI.cjs.map +1 -0
- package/libs/{chunk-LL7HTLMS.cjs → chunk-M5RRNTVX.cjs} +3 -3
- package/libs/{chunk-LIQJ7ZZR.js → chunk-NGTJDDFO.js} +2 -2
- package/libs/chunk-OK5QEIMD.cjs +17 -0
- package/libs/chunk-OK5QEIMD.cjs.map +1 -0
- package/libs/chunk-P2DC76ZZ.cjs +18 -0
- package/libs/chunk-P2DC76ZZ.cjs.map +1 -0
- package/libs/chunk-PQ2K3BM6.cjs +17 -0
- package/libs/chunk-PQ2K3BM6.cjs.map +1 -0
- package/libs/{chunk-QCMV4VQZ.js → chunk-QLZWHAMK.js} +2 -2
- package/libs/{chunk-BIP2NY53.js → chunk-RIVUMPOG.js} +2 -2
- package/libs/{chunk-ICCKQ2GC.cjs → chunk-ROZI23GS.cjs} +4 -4
- package/libs/{chunk-NHYXGV3L.js → chunk-SMYRLO3E.js} +2 -2
- package/libs/{chunk-5ZM4XL44.js → chunk-TYRCEX2L.js} +2 -2
- package/libs/chunk-VUH3FXGJ.js +11 -0
- package/libs/chunk-VUH3FXGJ.js.map +1 -0
- package/libs/{chunk-PPOOBUOS.js → chunk-XBA562WW.js} +2 -2
- package/libs/{chunk-QVV34QEH.cjs → chunk-XTQKWY7W.cjs} +3 -3
- package/libs/{chunk-YWOYVRFT.js → chunk-ZANSFMTD.js} +3 -3
- package/libs/components/alert/alert.css +1 -1
- package/libs/components/alert/alert.css.map +1 -1
- package/libs/components/alert/alert.min.css +2 -2
- package/libs/components/badge/badge.css +1 -1
- package/libs/components/badge/badge.css.map +1 -1
- package/libs/components/badge/badge.min.css +2 -2
- package/libs/components/breadcrumbs/breadcrumb.cjs +9 -5
- package/libs/components/breadcrumbs/breadcrumb.d.cts +271 -32
- package/libs/components/breadcrumbs/breadcrumb.d.ts +271 -32
- package/libs/components/breadcrumbs/breadcrumb.js +3 -3
- package/libs/components/button.cjs +4 -4
- package/libs/components/button.d.cts +2 -2
- package/libs/components/button.d.ts +2 -2
- package/libs/components/button.js +2 -2
- 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/card.cjs +7 -7
- package/libs/components/card.d.cts +277 -33
- package/libs/components/card.d.ts +277 -33
- package/libs/components/card.js +2 -2
- package/libs/components/cards/card.css +1 -1
- package/libs/components/cards/card.css.map +1 -1
- package/libs/components/cards/card.min.css +2 -2
- package/libs/components/details/details.css +1 -1
- package/libs/components/details/details.css.map +1 -1
- package/libs/components/details/details.min.css +2 -2
- package/libs/components/dialog/dialog.cjs +7 -7
- package/libs/components/dialog/dialog.css +1 -1
- package/libs/components/dialog/dialog.css.map +1 -1
- package/libs/components/dialog/dialog.d.cts +88 -34
- package/libs/components/dialog/dialog.d.ts +88 -34
- package/libs/components/dialog/dialog.js +5 -5
- package/libs/components/dialog/dialog.min.css +2 -2
- package/libs/components/form/fields.cjs +4 -4
- package/libs/components/form/fields.d.cts +2 -2
- package/libs/components/form/fields.d.ts +2 -2
- package/libs/components/form/fields.js +2 -2
- package/libs/components/form/textarea.cjs +4 -4
- package/libs/components/form/textarea.d.cts +2 -2
- package/libs/components/form/textarea.d.ts +2 -2
- package/libs/components/form/textarea.js +2 -2
- package/libs/components/heading/heading.cjs +3 -3
- package/libs/components/heading/heading.d.cts +3 -14
- package/libs/components/heading/heading.d.ts +3 -14
- package/libs/components/heading/heading.js +2 -2
- package/libs/components/icons/icon.cjs +4 -4
- package/libs/components/icons/icon.d.cts +148 -4
- package/libs/components/icons/icon.d.ts +148 -4
- package/libs/components/icons/icon.js +2 -2
- package/libs/components/images/img.css +1 -1
- package/libs/components/images/img.css.map +1 -1
- package/libs/components/images/img.min.css +2 -2
- package/libs/components/link/link.cjs +4 -4
- package/libs/components/link/link.d.cts +2 -2
- package/libs/components/link/link.d.ts +2 -2
- package/libs/components/link/link.js +2 -2
- package/libs/components/list/list.cjs +5 -5
- package/libs/components/list/list.d.cts +3 -3
- package/libs/components/list/list.d.ts +3 -3
- package/libs/components/list/list.js +2 -2
- package/libs/components/modal.cjs +4 -4
- package/libs/components/modal.js +3 -3
- package/libs/components/nav/nav.cjs +7 -7
- package/libs/components/nav/nav.d.cts +2 -2
- package/libs/components/nav/nav.d.ts +2 -2
- package/libs/components/nav/nav.js +3 -3
- package/libs/components/text/text.cjs +5 -5
- package/libs/components/text/text.d.cts +2 -2
- package/libs/components/text/text.d.ts +2 -2
- package/libs/components/text/text.js +2 -2
- package/libs/heading-3648c538.d.ts +250 -0
- package/libs/hooks.cjs +7 -0
- package/libs/hooks.d.cts +5 -0
- package/libs/hooks.d.ts +5 -0
- package/libs/hooks.js +3 -0
- package/libs/icons.cjs +3 -3
- package/libs/icons.d.cts +1 -1
- package/libs/icons.d.ts +1 -1
- package/libs/icons.js +2 -2
- package/libs/index.cjs +112 -91
- 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 +515 -31
- package/libs/index.d.ts +515 -31
- package/libs/index.js +31 -19
- package/libs/index.js.map +1 -1
- package/libs/ui-645f95b5.d.ts +285 -0
- package/package.json +2 -83
- package/src/components/README-UI.mdx +416 -0
- package/src/components/alert/ACCESSIBILITY.md +319 -0
- package/src/components/alert/README.mdx +475 -19
- package/src/components/alert/alert.scss +113 -6
- package/src/components/alert/alert.stories.tsx +372 -0
- package/src/components/alert/alert.test.tsx +762 -0
- package/src/components/alert/alert.tsx +331 -66
- package/src/components/alert/views/alert-actions.tsx +13 -0
- package/src/components/alert/views/alert-content.tsx +17 -0
- package/src/components/alert/views/alert-icon.tsx +53 -0
- package/src/components/alert/views/alert-screen-reader-text.tsx +30 -0
- package/src/components/alert/views/alert-title.tsx +23 -0
- package/src/components/alert/views/alert-view.tsx +158 -0
- package/src/components/alert/views/index.ts +12 -0
- package/src/components/badge/badge.mdx +186 -49
- package/src/components/badge/badge.scss +20 -2
- package/src/components/badge/badge.stories.tsx +160 -14
- package/src/components/badge/badge.test.tsx +179 -0
- package/src/components/badge/badge.tsx +97 -4
- package/src/components/breadcrumbs/README.mdx +364 -45
- package/src/components/breadcrumbs/__snapshots__/breadcrumb.test.tsx.snap +152 -0
- package/src/components/breadcrumbs/breadcrumb.stories.tsx +7 -3
- package/src/components/breadcrumbs/breadcrumb.test.tsx +490 -0
- package/src/components/breadcrumbs/breadcrumb.tsx +427 -170
- package/src/components/buttons/button.scss +34 -31
- package/src/components/buttons/button.stories.tsx +35 -0
- package/src/components/cards/README.mdx +657 -0
- package/src/components/cards/card.scss +22 -0
- package/src/components/cards/card.stories.tsx +167 -5
- package/src/components/cards/card.test.tsx +360 -20
- package/src/components/cards/card.tsx +200 -79
- package/src/components/cards/card.types.ts +135 -0
- package/src/components/cards/card.utils.ts +79 -0
- package/src/components/details/ACCESSIBILITY-REVIEW-LIVE.md +1050 -0
- package/src/components/details/ACCESSIBILITY-REVIEW.md +502 -0
- package/src/components/details/README.mdx +437 -69
- package/src/components/details/details.scss +16 -7
- package/src/components/details/details.test.tsx +385 -0
- package/src/components/details/details.tsx +101 -69
- package/src/components/details/details.types.ts +76 -0
- package/src/components/dialog/README.mdx +513 -110
- package/src/components/dialog/dialog-modal.tsx +79 -56
- package/src/components/dialog/dialog.scss +53 -3
- package/src/components/dialog/dialog.stories.tsx +10 -7
- package/src/components/dialog/dialog.test.tsx +450 -0
- package/src/components/dialog/dialog.tsx +69 -59
- package/src/components/dialog/dialog.types.ts +133 -0
- package/src/components/dialog/views/dialog-footer.tsx +54 -11
- package/src/components/dialog/views/dialog-header.tsx +20 -15
- package/src/components/heading/heading.stories.tsx +44 -4
- package/src/components/heading/heading.tsx +89 -23
- package/src/components/icons/README.mdx +332 -0
- package/src/components/icons/icon.stories.tsx +74 -1
- package/src/components/icons/icon.tsx +89 -1
- package/src/components/icons/types.ts +47 -0
- package/src/components/images/README.mdx +340 -24
- package/src/components/images/img.scss +19 -3
- package/src/components/images/img.stories.tsx +424 -15
- package/src/components/images/img.test.tsx +354 -25
- package/src/components/images/img.tsx +186 -63
- package/src/components/images/img.types.ts +211 -0
- package/src/components/title/MIGRATION.md +199 -0
- package/src/components/title/README.md +326 -0
- package/src/components/title/README.mdx +452 -0
- package/src/components/title/title.stories.tsx +393 -0
- package/src/components/title/title.test.tsx +251 -0
- package/src/components/title/title.tsx +219 -0
- package/src/components/ui.stories.tsx +894 -0
- package/src/components/ui.test.tsx +559 -0
- package/src/components/ui.tsx +266 -15
- package/src/components/word-count/README.md +240 -0
- package/src/hooks.ts +1 -0
- package/src/index.ts +10 -2
- package/src/sass/_properties.scss +1 -0
- package/src/styles/alert/alert.css +94 -4
- package/src/styles/alert/alert.css.map +1 -1
- package/src/styles/badge/badge.css +20 -2
- package/src/styles/badge/badge.css.map +1 -1
- package/src/styles/buttons/button.css +31 -31
- package/src/styles/buttons/button.css.map +1 -1
- package/src/styles/cards/card.css +16 -0
- package/src/styles/cards/card.css.map +1 -1
- package/src/styles/details/details.css +19 -8
- package/src/styles/details/details.css.map +1 -1
- package/src/styles/dialog/dialog.css +43 -2
- package/src/styles/dialog/dialog.css.map +1 -1
- package/src/styles/images/img.css +15 -3
- package/src/styles/images/img.css.map +1 -1
- package/src/styles/index.css +240 -51
- package/src/styles/index.css.map +1 -1
- package/src/test/setup.d.ts +9 -0
- package/src/test/setup.ts +53 -1
- package/libs/chunk-6TE5QEVE.cjs +0 -13
- package/libs/chunk-6TE5QEVE.cjs.map +0 -1
- package/libs/chunk-7K76RW2A.cjs +0 -18
- package/libs/chunk-7K76RW2A.cjs.map +0 -1
- package/libs/chunk-BSPKFLO4.js +0 -8
- package/libs/chunk-BSPKFLO4.js.map +0 -1
- package/libs/chunk-BV5CLH44.cjs +0 -18
- package/libs/chunk-BV5CLH44.cjs.map +0 -1
- package/libs/chunk-DKGJHKGW.js +0 -9
- package/libs/chunk-DKGJHKGW.js.map +0 -1
- package/libs/chunk-ECLD37WN.cjs +0 -16
- package/libs/chunk-ECLD37WN.cjs.map +0 -1
- package/libs/chunk-HYBZBN4G.js +0 -8
- package/libs/chunk-HYBZBN4G.js.map +0 -1
- package/libs/chunk-KKLTUJFB.cjs.map +0 -1
- package/libs/chunk-M5QL5TAE.cjs +0 -14
- package/libs/chunk-M5QL5TAE.cjs.map +0 -1
- package/libs/chunk-NE6YXTMC.js +0 -7
- package/libs/chunk-NE6YXTMC.js.map +0 -1
- package/libs/chunk-O6QZBB6G.js.map +0 -1
- package/libs/chunk-SXVZSWX6.js +0 -11
- package/libs/chunk-SXVZSWX6.js.map +0 -1
- package/libs/ui-9a6f9f8d.d.ts +0 -24
- package/src/components/cards/README.md +0 -80
- package/src/components/dialog/hooks/useClickOutside.ts +0 -33
- /package/libs/{chunk-DV56L5YX.cjs.map → chunk-2LTJ7HHX.cjs.map} +0 -0
- /package/libs/{chunk-EQ67LF46.js.map → chunk-2Y7W75TT.js.map} +0 -0
- /package/libs/{chunk-X3EVB7VS.cjs.map → chunk-5S4ORA4C.cjs.map} +0 -0
- /package/libs/{chunk-6BVXFW7U.cjs.map → chunk-AHDJGCG5.cjs.map} +0 -0
- /package/libs/{chunk-E3XP6BEX.cjs.map → chunk-B7F5FS6D.cjs.map} +0 -0
- /package/libs/{chunk-LHVJKDMA.cjs.map → chunk-J32EZPYD.cjs.map} +0 -0
- /package/libs/{chunk-LL7HTLMS.cjs.map → chunk-M5RRNTVX.cjs.map} +0 -0
- /package/libs/{chunk-LIQJ7ZZR.js.map → chunk-NGTJDDFO.js.map} +0 -0
- /package/libs/{chunk-QCMV4VQZ.js.map → chunk-QLZWHAMK.js.map} +0 -0
- /package/libs/{chunk-BIP2NY53.js.map → chunk-RIVUMPOG.js.map} +0 -0
- /package/libs/{chunk-ICCKQ2GC.cjs.map → chunk-ROZI23GS.cjs.map} +0 -0
- /package/libs/{chunk-NHYXGV3L.js.map → chunk-SMYRLO3E.js.map} +0 -0
- /package/libs/{chunk-5ZM4XL44.js.map → chunk-TYRCEX2L.js.map} +0 -0
- /package/libs/{chunk-PPOOBUOS.js.map → chunk-XBA562WW.js.map} +0 -0
- /package/libs/{chunk-QVV34QEH.cjs.map → chunk-XTQKWY7W.cjs.map} +0 -0
- /package/libs/{chunk-YWOYVRFT.js.map → chunk-ZANSFMTD.js.map} +0 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import UI from "#components/ui";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Valid HTML heading levels for semantic document structure.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Heading levels establish the document outline and hierarchy for screen readers.
|
|
9
|
+
* Always maintain proper heading order (don't skip levels) for WCAG 2.1 compliance.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // ✅ GOOD: Proper heading hierarchy
|
|
13
|
+
* <Title level="h1">Main Page Title</Title>
|
|
14
|
+
* <Title level="h2">Section Heading</Title>
|
|
15
|
+
* <Title level="h3">Subsection Heading</Title>
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // ❌ BAD: Skipping heading levels
|
|
19
|
+
* <Title level="h1">Main Title</Title>
|
|
20
|
+
* <Title level="h4">Skipped h2 and h3</Title>
|
|
21
|
+
*/
|
|
22
|
+
export type HeadingLevel = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Props for the Title component.
|
|
26
|
+
*
|
|
27
|
+
* @typeParam TLevel - The heading level to render (h1-h6)
|
|
28
|
+
*
|
|
29
|
+
* @property {HeadingLevel} level - The semantic heading level (h1-h6). Defaults to "h2".
|
|
30
|
+
* @property {React.ReactNode} children - The text or elements to render inside the heading.
|
|
31
|
+
* @property {string} [id] - Unique identifier for the heading, useful for anchor links.
|
|
32
|
+
* @property {React.CSSProperties} [styles] - Inline styles to apply to the heading.
|
|
33
|
+
* @property {string} [ui] - Data attribute for UI framework styling hooks.
|
|
34
|
+
* @property {string} [className] - CSS class names to apply.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* This interface extends the polymorphic UI component props, providing full access
|
|
38
|
+
* to native HTML heading attributes and ARIA properties for accessibility.
|
|
39
|
+
*
|
|
40
|
+
* For AI assistants: This component ensures semantic HTML structure for document
|
|
41
|
+
* outlines, which is critical for screen reader navigation and SEO.
|
|
42
|
+
*/
|
|
43
|
+
export type TitleProps = {
|
|
44
|
+
/**
|
|
45
|
+
* The semantic heading level to render.
|
|
46
|
+
*
|
|
47
|
+
* @default "h2"
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* Choose the appropriate level based on your document structure:
|
|
51
|
+
* - h1: Page title (typically one per page)
|
|
52
|
+
* - h2: Major sections
|
|
53
|
+
* - h3-h6: Subsections and nested content
|
|
54
|
+
*
|
|
55
|
+
* WCAG 2.1 requires proper heading hierarchy for screen reader users.
|
|
56
|
+
*/
|
|
57
|
+
level?: HeadingLevel;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The content to display in the heading.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* Can be text, elements, or a combination. Ensure text content is meaningful
|
|
64
|
+
* and descriptive for users navigating with screen readers.
|
|
65
|
+
*/
|
|
66
|
+
children: React.ReactNode;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Unique identifier for the heading element.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Useful for:
|
|
73
|
+
* - Creating anchor links to sections
|
|
74
|
+
* - ARIA relationships (aria-labelledby, aria-describedby)
|
|
75
|
+
* - Testing and automation
|
|
76
|
+
*/
|
|
77
|
+
id?: string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Data attribute for UI framework styling hooks.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Used by fpkit's CSS system to apply component-specific styles.
|
|
84
|
+
* Automatically prefixed with "data-ui" when rendered.
|
|
85
|
+
*/
|
|
86
|
+
ui?: string;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* CSS class names to apply to the heading.
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* Prefer using the `ui` prop for fpkit styling, and this for
|
|
93
|
+
* utility classes or custom overrides.
|
|
94
|
+
*/
|
|
95
|
+
className?: string;
|
|
96
|
+
} & React.ComponentPropsWithoutRef<typeof UI>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Title - A semantic heading component for document structure and hierarchy.
|
|
100
|
+
*
|
|
101
|
+
* The Title component renders semantic HTML headings (h1-h6) with proper
|
|
102
|
+
* accessibility support. It ensures WCAG 2.1 AA compliance by maintaining
|
|
103
|
+
* semantic document structure for screen readers and assistive technologies.
|
|
104
|
+
*
|
|
105
|
+
* ## Key Features
|
|
106
|
+
*
|
|
107
|
+
* - **Semantic HTML**: Renders actual heading elements (h1-h6) for proper document outline
|
|
108
|
+
* - **Accessibility**: Full ARIA support and keyboard navigation
|
|
109
|
+
* - **Flexible Styling**: Supports fpkit's UI system, custom classes, and inline styles
|
|
110
|
+
* - **Type Safety**: Fully typed with TypeScript for developer experience
|
|
111
|
+
* - **Performance**: Memoized to prevent unnecessary re-renders
|
|
112
|
+
*
|
|
113
|
+
* ## Accessibility Considerations
|
|
114
|
+
*
|
|
115
|
+
* ### WCAG 2.1 AA Compliance
|
|
116
|
+
*
|
|
117
|
+
* - **1.3.1 Info and Relationships (Level A)**: Semantic heading elements preserve
|
|
118
|
+
* document structure for screen readers
|
|
119
|
+
* - **2.4.6 Headings and Labels (Level AA)**: Headings should be descriptive and
|
|
120
|
+
* properly ordered
|
|
121
|
+
* - **2.4.10 Section Headings (Level AAA)**: Use headings to organize content
|
|
122
|
+
*
|
|
123
|
+
* ### Best Practices
|
|
124
|
+
*
|
|
125
|
+
* 1. **Maintain Heading Hierarchy**: Don't skip levels (e.g., h1 → h3)
|
|
126
|
+
* 2. **One h1 Per Page**: Use h1 for the main page title only
|
|
127
|
+
* 3. **Descriptive Text**: Headings should clearly describe the following content
|
|
128
|
+
* 4. **Avoid Empty Headings**: Always provide meaningful text content
|
|
129
|
+
*
|
|
130
|
+
* ## Usage Examples
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* // Basic usage with default h2
|
|
134
|
+
* <Title>Section Heading</Title>
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* // Page title with explicit h1
|
|
138
|
+
* <Title level="h1">Welcome to Our Application</Title>
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* // Subsection with custom styling
|
|
142
|
+
* <Title
|
|
143
|
+
* level="h3"
|
|
144
|
+
* id="getting-started"
|
|
145
|
+
* className="text-primary"
|
|
146
|
+
* >
|
|
147
|
+
* Getting Started
|
|
148
|
+
* </Title>
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* // With fpkit UI data attribute
|
|
152
|
+
* <Title level="h2" ui="section-title">
|
|
153
|
+
* Features Overview
|
|
154
|
+
* </Title>
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* // Accessible heading with aria-label for context
|
|
158
|
+
* <Title level="h2" aria-label="User dashboard overview">
|
|
159
|
+
* Dashboard
|
|
160
|
+
* </Title>
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* // Complex heading with mixed content
|
|
164
|
+
* <Title level="h2" id="stats">
|
|
165
|
+
* <Icon name="chart" aria-hidden="true" />
|
|
166
|
+
* <span>Statistics</span>
|
|
167
|
+
* </Title>
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* // ✅ GOOD: Proper heading hierarchy
|
|
171
|
+
* <Title level="h1">Page Title</Title>
|
|
172
|
+
* <Title level="h2">Main Section</Title>
|
|
173
|
+
* <Title level="h3">Subsection</Title>
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* // ❌ BAD: Skipping heading levels (accessibility violation)
|
|
177
|
+
* <Title level="h1">Page Title</Title>
|
|
178
|
+
* <Title level="h4">Skipped h2 and h3</Title>
|
|
179
|
+
*
|
|
180
|
+
* @param {TitleProps} props - Component props
|
|
181
|
+
* @returns {React.ReactElement} A semantic heading element
|
|
182
|
+
*
|
|
183
|
+
* @see {@link https://www.w3.org/WAI/WCAG21/Understanding/info-and-relationships.html WCAG 1.3.1}
|
|
184
|
+
* @see {@link https://www.w3.org/WAI/WCAG21/Understanding/headings-and-labels.html WCAG 2.4.6}
|
|
185
|
+
*/
|
|
186
|
+
const Title = React.memo(
|
|
187
|
+
React.forwardRef<HTMLHeadingElement, TitleProps>(
|
|
188
|
+
(
|
|
189
|
+
{
|
|
190
|
+
level = "h2",
|
|
191
|
+
id,
|
|
192
|
+
styles,
|
|
193
|
+
ui,
|
|
194
|
+
children,
|
|
195
|
+
className,
|
|
196
|
+
...props
|
|
197
|
+
}: TitleProps,
|
|
198
|
+
ref
|
|
199
|
+
) => {
|
|
200
|
+
return (
|
|
201
|
+
<UI
|
|
202
|
+
as={level}
|
|
203
|
+
id={id}
|
|
204
|
+
styles={styles}
|
|
205
|
+
data-ui={ui}
|
|
206
|
+
className={className}
|
|
207
|
+
ref={ref}
|
|
208
|
+
{...props}
|
|
209
|
+
>
|
|
210
|
+
{children}
|
|
211
|
+
</UI>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
Title.displayName = "Title";
|
|
218
|
+
|
|
219
|
+
export default Title;
|