Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Pagehead): Remove the CSS module feature flag from Pagehead #5462

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/two-jokes-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Remove the CSS module feature flag from Pagehead
18 changes: 0 additions & 18 deletions packages/react/src/Pagehead/Pagehead.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,4 @@ Playground.argTypes = {
options: ['div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
},
},
forwardedAs: {
controls: false,
table: {
disable: true,
},
},
ref: {
controls: false,
table: {
disable: true,
},
},
theme: {
controls: false,
table: {
disable: true,
},
},
}
3 changes: 1 addition & 2 deletions packages/react/src/Pagehead/Pagehead.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import Pagehead from '../Pagehead'
import theme from '../theme'
import {behavesAsComponent, checkExports} from '../utils/testing'
import {render as HTMLRender} from '@testing-library/react'
import axe from 'axe-core'
Expand All @@ -13,7 +12,7 @@ describe('Pagehead', () => {
})

it('should have no axe violations', async () => {
const {container} = HTMLRender(<Pagehead theme={theme}>Pagehead</Pagehead>)
const {container} = HTMLRender(<Pagehead>Pagehead</Pagehead>)
const results = await axe.run(container)
expect(results).toHaveNoViolations()
})
Expand Down
44 changes: 12 additions & 32 deletions packages/react/src/Pagehead/Pagehead.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,22 @@
import styled from 'styled-components'
import React, {type ComponentProps} from 'react'
import React from 'react'
import {clsx} from 'clsx'
import {get} from '../constants'
import sx, {type SxProp} from '../sx'
import {toggleStyledComponent} from '../internal/utils/toggleStyledComponent'
import {type SxProp} from '../sx'
import classes from './Pagehead.module.css'
import {useFeatureFlag} from '../FeatureFlags'
import {defaultSxProp} from '../utils/defaultSxProp'
import Box from '../Box'

const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_ga'

/**
* @deprecated
*/
const StyledComponentPagehead = toggleStyledComponent(
CSS_MODULES_FEATURE_FLAG,
'div',
styled.div<SxProp>`
position: relative;
padding-top: ${get('space.4')};
padding-bottom: ${get('space.4')};
margin-bottom: ${get('space.4')};
border-bottom: 1px solid ${get('colors.border.default')};
${sx};
`,
)

const Pagehead = ({className, ...rest}: PageheadProps) => {
const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG)

if (enabled) {
return <StyledComponentPagehead className={clsx(classes.Pagehead, className)} {...rest} />
const Pagehead = ({className, sx: sxProp = defaultSxProp, ...rest}: PageheadProps) => {
if (sxProp !== defaultSxProp || rest.as) {
return <Box sx={sxProp} className={clsx(classes.Pagehead, className)} {...rest} />
}

return <StyledComponentPagehead {...rest} />
return <div className={clsx(classes.Pagehead, className)} {...rest} />
}

/**
* @deprecated
*/
export type PageheadProps = ComponentProps<typeof StyledComponentPagehead> & SxProp
export type PageheadProps = SxProp &
React.ComponentPropsWithoutRef<'div'> & {
as?: React.ElementType
}
export default Pagehead
4 changes: 0 additions & 4 deletions packages/react/src/Pagehead/Pagehead.types.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ import Pagehead from '../Pagehead'
export function shouldAcceptCallWithNoProps() {
return <Pagehead />
}

export function shouldNotAcceptSystemProps() {
return <Pagehead backgroundColor="orchid" />
}
Loading