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(Button): Move Button CSS module feature flag from staff to ga #5086

Merged
merged 5 commits into from
Oct 18, 2024
Merged
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/pink-lemons-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Move Button CSS module feature flag from staff to ga
2 changes: 1 addition & 1 deletion packages/react/src/Button/ButtonBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const ButtonBase = forwardRef(
...rest
} = props

const enabled = useFeatureFlag('primer_react_css_modules_staff')
const enabled = useFeatureFlag('primer_react_css_modules_ga')
const innerRef = React.useRef<HTMLButtonElement>(null)
useRefObjectAsForwardedRef(forwardedRef, innerRef)

Expand Down
83 changes: 42 additions & 41 deletions packages/react/src/Button/__tests__/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,48 @@ const StatefulLoadingButton = (props: StatefulLoadingButtonProps) => {
return <Button loading={isLoading} onClick={handleClick} {...props} />
}

describe('IconButton', () => {
it('should support `className` on the outermost element', () => {
const Element = () => <IconButton className={'test-class-name'} icon={SearchIcon} aria-label="Search button" />
const FeatureFlagElement = () => {
return (
<FeatureFlags
flags={{
primer_react_css_modules_team: true,
primer_react_css_modules_staff: true,
primer_react_css_modules_ga: true,
}}
>
<Element />
</FeatureFlags>
)
}
expect(render(<Element />).container.firstChild).toHaveClass('test-class-name')
expect(render(<FeatureFlagElement />).container.firstChild).toHaveClass('test-class-name')
})
})

describe('LinkButton', () => {
it('should support `className` on the outermost element', () => {
const Element = () => <LinkButton className={'test-class-name'} />
const FeatureFlagElement = () => {
return (
<FeatureFlags
flags={{
primer_react_css_modules_team: true,
primer_react_css_modules_staff: true,
primer_react_css_modules_ga: true,
}}
>
<Element />
</FeatureFlags>
)
}
expect(render(<Element />).container.firstChild).toHaveClass('test-class-name')
expect(render(<FeatureFlagElement />).container.firstChild).toHaveClass('test-class-name')
})
})

describe('Button', () => {
behavesAsComponent({
Component: TestButton,
Expand Down Expand Up @@ -320,45 +362,4 @@ describe('Button', () => {
expect(tooltipEl).toBeInTheDocument()
expect(triggerEl.getAttribute('aria-describedby')).toEqual(expect.stringContaining(tooltipEl.id))
})

describe('with primer_react_css_modules_staff enabled', () => {
it('iconbutton should support custom `className` along with default classnames', () => {
const {container} = render(
<FeatureFlags
flags={{
primer_react_css_modules_staff: true,
}}
>
<IconButton className="test" aria-label="Test" icon={HeartIcon} />
</FeatureFlags>,
)
expect(container.firstChild).toHaveClass('IconButton')
})

it('button should support custom `className` along with default classnames', () => {
const {container} = render(
<FeatureFlags
flags={{
primer_react_css_modules_staff: true,
}}
>
<Button className="test">Hello</Button>
</FeatureFlags>,
)
expect(container.firstChild).toHaveClass('ButtonBase')
})

it('linkbutton should support custom `className` along with default classnames', () => {
const {container} = render(
<FeatureFlags
flags={{
primer_react_css_modules_staff: true,
}}
>
<LinkButton className="test">Hello</LinkButton>
</FeatureFlags>,
)
expect(container.firstChild).toHaveClass('ButtonBase')
})
})
})
Loading