Skip to content

Commit c177e5e

Browse files
authored
[CSS Module Migration] Remove feature flag for Underline Panel (#5836)
1 parent cc69a5b commit c177e5e

5 files changed

Lines changed: 51 additions & 297 deletions

File tree

.changeset/strong-pens-cross.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+
Removes css module flag for UnderlinePanels and associated components.
-4 Bytes
Loading

packages/react/src/UnderlineNav/UnderlineNav.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ import {useTheme} from '../ThemeProvider'
1010
import type {ChildWidthArray, ResponsiveProps, ChildSize} from './types'
1111
import VisuallyHidden from '../_VisuallyHidden'
1212
import {moreBtnStyles, getDividerStyle, menuStyles, menuItemStyles, baseMenuStyles, baseMenuMinWidth} from './styles'
13-
import {
14-
StyledUnderlineItemList,
15-
StyledUnderlineWrapper,
16-
LoadingCounter,
17-
GAP,
18-
} from '../internal/components/UnderlineTabbedInterface'
13+
import {UnderlineItemList, UnderlineWrapper, LoadingCounter, GAP} from '../internal/components/UnderlineTabbedInterface'
1914
import styled from 'styled-components'
2015
import {Button} from '../Button'
2116
import {TriangleDownIcon} from '@primer/octicons-react'
@@ -311,8 +306,8 @@ export const UnderlineNav = forwardRef(
311306
}}
312307
>
313308
{ariaLabel && <VisuallyHidden as="h2">{`${ariaLabel} navigation`}</VisuallyHidden>}
314-
<StyledUnderlineWrapper as={as} aria-label={ariaLabel} ref={navRef} sx={sxProp}>
315-
<StyledUnderlineItemList ref={listRef} role="list">
309+
<UnderlineWrapper as={as} aria-label={ariaLabel} ref={navRef} sx={sxProp}>
310+
<UnderlineItemList ref={listRef} role="list">
316311
{listItems}
317312
{menuItems.length > 0 && (
318313
<MoreMenuListItem ref={moreMenuRef}>
@@ -404,8 +399,8 @@ export const UnderlineNav = forwardRef(
404399
</ActionList>
405400
</MoreMenuListItem>
406401
)}
407-
</StyledUnderlineItemList>
408-
</StyledUnderlineWrapper>
402+
</UnderlineItemList>
403+
</UnderlineWrapper>
409404
</UnderlineNavContext.Provider>
410405
)
411406
},

packages/react/src/experimental/UnderlinePanels/UnderlinePanels.tsx

Lines changed: 12 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,21 @@ import {TabContainerElement} from '@github/tab-container-element'
1212
import type {IconProps} from '@primer/octicons-react'
1313
import {createComponent} from '../../utils/create-component'
1414
import {
15-
StyledUnderlineItemList,
16-
StyledUnderlineWrapper,
15+
UnderlineItemList,
16+
UnderlineWrapper,
1717
UnderlineItem,
1818
type UnderlineItemProps,
1919
} from '../../internal/components/UnderlineTabbedInterface'
2020
import Box, {type BoxProps} from '../../Box'
2121
import {useId} from '../../hooks'
2222
import {invariant} from '../../utils/invariant'
23-
import {merge, type BetterSystemStyleObject, type SxProp} from '../../sx'
23+
import {type SxProp} from '../../sx'
2424
import {defaultSxProp} from '../../utils/defaultSxProp'
2525
import {useResizeObserver, type ResizeObserverEntry} from '../../hooks/useResizeObserver'
2626
import useIsomorphicLayoutEffect from '../../utils/useIsomorphicLayoutEffect'
27-
import {useFeatureFlag} from '../../FeatureFlags'
2827
import classes from './UnderlinePanels.module.css'
29-
import {toggleStyledComponent} from '../../internal/utils/toggleStyledComponent'
3028
import {clsx} from 'clsx'
3129

32-
const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_ga'
33-
3430
export type UnderlinePanelsProps = {
3531
/**
3632
* Tabs (UnderlinePanels.Tab) and panels (UnderlinePanels.Panel) to render
@@ -82,12 +78,6 @@ export type PanelProps = Omit<BoxProps, 'as'>
8278

8379
const TabContainerComponent = createComponent(TabContainerElement, 'tab-container')
8480

85-
const StyledTabContainerComponent = toggleStyledComponent(
86-
CSS_MODULES_FEATURE_FLAG,
87-
'tab-container',
88-
TabContainerComponent,
89-
)
90-
9181
const UnderlinePanels: FC<UnderlinePanelsProps> = ({
9282
'aria-label': ariaLabel,
9383
'aria-labelledby': ariaLabelledBy,
@@ -139,8 +129,6 @@ const UnderlinePanels: FC<UnderlinePanelsProps> = ({
139129

140130
const tabsHaveIcons = tabs.some(tab => React.isValidElement(tab) && tab.props.icon)
141131

142-
const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG)
143-
144132
// this is a workaround to get the list's width on the first render
145133
const [listWidth, setListWidth] = useState(0)
146134
useIsomorphicLayoutEffect(() => {
@@ -164,7 +152,7 @@ const UnderlinePanels: FC<UnderlinePanelsProps> = ({
164152
setIconsVisible(wrapperWidth > listWidth)
165153
},
166154
wrapperRef,
167-
[enabled],
155+
[],
168156
)
169157

170158
if (__DEV__) {
@@ -182,53 +170,22 @@ const UnderlinePanels: FC<UnderlinePanelsProps> = ({
182170
)
183171
}
184172

185-
if (enabled) {
186-
return (
187-
<StyledTabContainerComponent>
188-
<StyledUnderlineWrapper
189-
ref={wrapperRef}
190-
slot="tablist-wrapper"
191-
data-icons-visible={iconsVisible}
192-
sx={sxProp}
193-
className={clsx(className, classes.StyledUnderlineWrapper)}
194-
{...props}
195-
>
196-
<StyledUnderlineItemList ref={listRef} aria-label={ariaLabel} aria-labelledby={ariaLabelledBy} role="tablist">
197-
{tabs}
198-
</StyledUnderlineItemList>
199-
</StyledUnderlineWrapper>
200-
{tabPanels}
201-
</StyledTabContainerComponent>
202-
)
203-
}
204-
205173
return (
206-
<StyledTabContainerComponent>
207-
<StyledUnderlineWrapper
174+
<TabContainerComponent>
175+
<UnderlineWrapper
208176
ref={wrapperRef}
209177
slot="tablist-wrapper"
210178
data-icons-visible={iconsVisible}
211-
sx={merge<BetterSystemStyleObject>(
212-
{
213-
width: '100%',
214-
overflowX: 'auto',
215-
overflowY: 'hidden',
216-
'-webkit-overflow-scrolling': 'auto',
217-
'&[data-icons-visible="false"] [data-component="icon"]': {
218-
display: 'none',
219-
},
220-
},
221-
sxProp as SxProp,
222-
)}
223-
className={className}
179+
sx={sxProp}
180+
className={clsx(className, classes.StyledUnderlineWrapper)}
224181
{...props}
225182
>
226-
<StyledUnderlineItemList ref={listRef} aria-label={ariaLabel} aria-labelledby={ariaLabelledBy} role="tablist">
183+
<UnderlineItemList ref={listRef} aria-label={ariaLabel} aria-labelledby={ariaLabelledBy} role="tablist">
227184
{tabs}
228-
</StyledUnderlineItemList>
229-
</StyledUnderlineWrapper>
185+
</UnderlineItemList>
186+
</UnderlineWrapper>
230187
{tabPanels}
231-
</StyledTabContainerComponent>
188+
</TabContainerComponent>
232189
)
233190
}
234191

0 commit comments

Comments
 (0)