Skip to content

Commit 3014334

Browse files
authored
chore(BranchName): Remove the CSS modules feature flag from the BranchName component (#5875)
1 parent e66b3c4 commit 3014334

File tree

2 files changed

+14
-41
lines changed

2 files changed

+14
-41
lines changed

.changeset/fancy-webs-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': minor
3+
---
4+
5+
Remove the CSS modules feature flag from the BranchName component

packages/react/src/BranchName/BranchName.tsx

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,26 @@
11
import React, {type ForwardedRef} from 'react'
22
import {clsx} from 'clsx'
3-
import styled from 'styled-components'
4-
import {get} from '../constants'
53
import type {SxProp} from '../sx'
6-
import sx from '../sx'
7-
import {useFeatureFlag} from '../FeatureFlags'
8-
import Box from '../Box'
94
import classes from './BranchName.module.css'
10-
11-
const StyledBranchName = styled.a<SxProp>`
12-
display: inline-block;
13-
padding: 2px 6px;
14-
font-size: var(--text-body-size-small, ${get('fontSizes.0')});
15-
font-family: var(--fontStack-monospace, ${get('fonts.mono')});
16-
color: var(--fgColor-link, ${get('colors.accent.fg')});
17-
background-color: var(--bgColor-accent-muted, ${get('colors.accent.subtle')});
18-
border-radius: var(--borderRadius-medium, ${get('radii.2')});
19-
text-decoration: none;
20-
&:is(:not(a)) {
21-
color: var(--fgColor-muted);
22-
}
23-
${sx};
24-
`
5+
import {toggleSxComponent} from '../internal/utils/toggleSxComponent'
256

267
type BranchNameProps<As extends React.ElementType> = {
278
as?: As
289
} & DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? 'a' : As>, 'as'> &
10+
Omit<SxProp, 'sx'> &
2911
SxProp
3012

13+
const BaseComponent = toggleSxComponent('div') as React.ComponentType<
14+
React.PropsWithChildren<BranchNameProps<React.ElementType> & React.RefAttributes<HTMLElement>>
15+
>
16+
3117
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3218
function BranchName<As extends React.ElementType>(props: BranchNameProps<As>, ref: ForwardedRef<any>) {
33-
const {as: BaseComponent = 'a', className, children, sx, ...rest} = props
34-
const enabled = useFeatureFlag('primer_react_css_modules_ga')
35-
36-
if (enabled) {
37-
if (sx) {
38-
return (
39-
<Box {...rest} ref={ref} as={BaseComponent} className={clsx(className, classes.BranchName)} sx={sx}>
40-
{children}
41-
</Box>
42-
)
43-
}
44-
45-
return (
46-
<BaseComponent {...rest} ref={ref} className={clsx(className, classes.BranchName)}>
47-
{children}
48-
</BaseComponent>
49-
)
50-
}
51-
19+
const {as: Component = 'a', className, children, ...rest} = props
5220
return (
53-
<StyledBranchName {...rest} as={BaseComponent} ref={ref} className={className} sx={sx}>
21+
<BaseComponent as={Component} {...rest} ref={ref} className={clsx(className, classes.BranchName)}>
5422
{children}
55-
</StyledBranchName>
23+
</BaseComponent>
5624
)
5725
}
5826

0 commit comments

Comments
 (0)