@@ -9,18 +9,26 @@ import {ListContext} from './shared'
9
9
import VisuallyHidden from '../_VisuallyHidden'
10
10
import { ActionListContainerContext } from './ActionListContainerContext'
11
11
import { invariant } from '../utils/invariant'
12
+ import { clsx } from 'clsx'
13
+ import { useFeatureFlag } from '../FeatureFlags'
14
+ import classes from './Heading.module.css'
12
15
13
16
type HeadingLevels = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
17
+ type HeadingVariants = 'large' | 'medium' | 'small'
14
18
export type ActionListHeadingProps = {
15
19
as : HeadingLevels
20
+ size ?: HeadingVariants
16
21
visuallyHidden ?: boolean
22
+ className ?: string
17
23
} & SxProp
18
24
19
25
export const Heading = forwardRef (
20
- ( { as, children, sx = defaultSxProp , visuallyHidden = false , ...props } , forwardedRef ) => {
26
+ ( { as, size , children, sx = defaultSxProp , visuallyHidden = false , className , ...props } , forwardedRef ) => {
21
27
const innerRef = React . useRef < HTMLHeadingElement > ( null )
22
28
useRefObjectAsForwardedRef ( forwardedRef , innerRef )
23
29
30
+ const enabled = useFeatureFlag ( 'primer_react_css_modules_team' )
31
+
24
32
const { headingId : headingId , variant : listVariant } = React . useContext ( ListContext )
25
33
const { container} = React . useContext ( ActionListContainerContext )
26
34
@@ -37,16 +45,49 @@ export const Heading = forwardRef(
37
45
38
46
return (
39
47
< VisuallyHidden isVisible = { ! visuallyHidden } >
40
- < HeadingComponent
41
- as = { as }
42
- ref = { innerRef }
43
- // use custom id if it is provided. Otherwise, use the id from the context
44
- id = { props . id ?? headingId }
45
- sx = { merge < BetterSystemStyleObject > ( styles , sx ) }
46
- { ...props }
47
- >
48
- { children }
49
- </ HeadingComponent >
48
+ { enabled ? (
49
+ sx !== defaultSxProp ? (
50
+ < HeadingComponent
51
+ as = { as }
52
+ variant = { size }
53
+ ref = { innerRef }
54
+ // use custom id if it is provided. Otherwise, use the id from the context
55
+ id = { props . id ?? headingId }
56
+ className = { clsx ( className , classes . ActionListHeader ) }
57
+ data-list-variant = { listVariant }
58
+ sx = { sx }
59
+ { ...props }
60
+ >
61
+ { children }
62
+ </ HeadingComponent >
63
+ ) : (
64
+ < HeadingComponent
65
+ as = { as }
66
+ variant = { size }
67
+ ref = { innerRef }
68
+ // use custom id if it is provided. Otherwise, use the id from the context
69
+ id = { props . id ?? headingId }
70
+ className = { clsx ( className , classes . ActionListHeader ) }
71
+ data-list-variant = { listVariant }
72
+ { ...props }
73
+ >
74
+ { children }
75
+ </ HeadingComponent >
76
+ )
77
+ ) : (
78
+ < HeadingComponent
79
+ as = { as }
80
+ variant = { size }
81
+ ref = { innerRef }
82
+ // use custom id if it is provided. Otherwise, use the id from the context
83
+ id = { props . id ?? headingId }
84
+ sx = { merge < BetterSystemStyleObject > ( styles , sx ) }
85
+ className = { className }
86
+ { ...props }
87
+ >
88
+ { children }
89
+ </ HeadingComponent >
90
+ ) }
50
91
</ VisuallyHidden >
51
92
)
52
93
} ,
0 commit comments