Skip to content

Commit 16c31e6

Browse files
authored
fix(Blankslate): Don't use Box to render heading when flag is enabled (#4857)
* Don't use Box to render heading when flag is enabled * Create soft-tips-chew.md
1 parent 873249a commit 16c31e6

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

.changeset/soft-tips-chew.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
fix(Blankslate): Don't use Box to render heading when flag is enabled

packages/react/src/Blankslate/Blankslate.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ export type HeadingProps = React.PropsWithChildren<{
174174
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
175175
}>
176176

177-
function Heading({as = 'h2', children}: HeadingProps) {
177+
function Heading({as: Component = 'h2', children}: HeadingProps) {
178178
const enabled = useFeatureFlag('primer_react_css_modules')
179+
180+
if (enabled) {
181+
return <Component className={cx('Blankslate-Heading', classes.Heading)}>{children}</Component>
182+
}
183+
179184
return (
180-
<Box
181-
as={as}
182-
className={cx('Blankslate-Heading', {
183-
[classes.Heading]: enabled,
184-
})}
185-
>
185+
<Box as={Component} className={cx('Blankslate-Heading')}>
186186
{children}
187187
</Box>
188188
)

0 commit comments

Comments
 (0)