Skip to content

Commit 611c1a5

Browse files
Remove unnecessary styles (scroll behaviour styles)
1 parent de75d8e commit 611c1a5

File tree

3 files changed

+7
-29
lines changed

3 files changed

+7
-29
lines changed

src/UnderlineNav2/UnderlineNav.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import CounterLabel from '../CounterLabel'
99
import {useTheme} from '../ThemeProvider'
1010
import {ChildWidthArray, ResponsiveProps} from './types'
1111

12-
import {moreBtnStyles, getDividerStyle, getNavStyles, ulStyles, moreMenuStyles, menuItemStyles, GAP} from './styles'
12+
import {moreBtnStyles, getDividerStyle, getNavStyles, ulStyles, menuItemStyles, GAP} from './styles'
1313
import styled from 'styled-components'
1414
import {LoadingCounter} from './LoadingCounter'
1515

@@ -48,9 +48,8 @@ const overflowEffect = (
4848
updateListAndMenu: (props: ResponsiveProps, iconsVisible: boolean) => void
4949
) => {
5050
let iconsVisible = true
51-
let overflowStyles: BetterSystemStyleObject | null = {}
5251
if (childWidthArray.length === 0) {
53-
updateListAndMenu({items: childArray, actions: [], overflowStyles}, iconsVisible)
52+
updateListAndMenu({items: childArray, actions: []}, iconsVisible)
5453
}
5554

5655
const numberOfItemsPossible = calculatePossibleItems(childWidthArray, navWidth)
@@ -74,7 +73,6 @@ const overflowEffect = (
7473
} else {
7574
// if we can't fit all the items without icons, we keep the icons hidden and show the rest in the menu
7675
iconsVisible = false
77-
overflowStyles = moreMenuStyles
7876
for (const [index, child] of childArray.entries()) {
7977
if (index < numberOfItemsPossibleWithMoreMenu) {
8078
items.push(child)
@@ -89,7 +87,7 @@ const overflowEffect = (
8987
}
9088
}
9189

92-
updateListAndMenu({items, actions, overflowStyles}, iconsVisible)
90+
updateListAndMenu({items, actions}, iconsVisible)
9391
}
9492

9593
const getValidChildren = (children: React.ReactNode) => {
@@ -163,10 +161,7 @@ export const UnderlineNav = forwardRef(
163161
// Add itemsToAddToMenu array's items to the menu at the index of the prospectiveListItem and remove 1 count of items (prospectiveListItem)
164162
updatedMenuItems.splice(indexOfProspectiveListItem, 1, ...itemsToAddToMenu)
165163
setSelectedLinkText(prospectiveListItem.props.children)
166-
callback(
167-
{items: updatedItemList, actions: updatedMenuItems, overflowStyles: responsiveProps.overflowStyles},
168-
false
169-
)
164+
callback({items: updatedItemList, actions: updatedMenuItems}, false)
170165
}
171166
// How many items do we need to pull in to the menu to make room for the selected menu item.
172167
function getBreakpointForItemSwapping(widthToFitIntoList: number, availableSpace: number) {
@@ -204,8 +199,7 @@ export const UnderlineNav = forwardRef(
204199

205200
const [responsiveProps, setResponsiveProps] = useState<ResponsiveProps>({
206201
items: getValidChildren(children),
207-
actions: [],
208-
overflowStyles: {}
202+
actions: []
209203
})
210204

211205
const updateListAndMenu = useCallback((props: ResponsiveProps, displayIcons: boolean) => {
@@ -266,7 +260,7 @@ export const UnderlineNav = forwardRef(
266260
aria-label={ariaLabel}
267261
ref={navRef}
268262
>
269-
<NavigationList sx={merge<BetterSystemStyleObject>(responsiveProps.overflowStyles, ulStyles)} ref={listRef}>
263+
<NavigationList sx={ulStyles} ref={listRef}>
270264
{responsiveProps.items}
271265
{actions.length > 0 && (
272266
<MoreMenuListItem ref={moreMenuRef}>

src/UnderlineNav2/styles.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const getNavStyles = (theme?: Theme, props?: Partial<Pick<UnderlineNavPro
4747
export const ulStyles = {
4848
display: 'flex',
4949
listStyle: 'none',
50+
whiteSpace: 'nowrap',
5051
paddingY: 0,
5152
paddingX: 0,
5253
margin: 0,
@@ -134,21 +135,6 @@ export const getLinkStyles = (
134135
}
135136
})
136137

137-
export const scrollStyles: BetterSystemStyleObject = {
138-
whiteSpace: 'nowrap',
139-
overflowX: 'auto',
140-
// Hiding scrollbar on Firefox
141-
scrollbarWidth: 'none',
142-
// Hiding scrollbar on IE 10+
143-
msOverflowStyle: 'none',
144-
// Hiding scrollbar on Chrome, Safari and Opera
145-
'&::-webkit-scrollbar': {
146-
display: 'none'
147-
}
148-
}
149-
150-
export const moreMenuStyles: BetterSystemStyleObject = {whiteSpace: 'nowrap'}
151-
152138
export const menuItemStyles = {
153139
// This is needed to hide the selected check icon on the menu item. https://github.com/primer/react/blob/main/src/ActionList/Selection.tsx#L32
154140
'& > span': {

src/UnderlineNav2/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import {BetterSystemStyleObject} from '../sx'
21
export type ChildWidthArray = Array<{text: string; width: number}>
32
export type ResponsiveProps = {
43
items: Array<React.ReactElement>
54
actions: Array<React.ReactElement>
6-
overflowStyles: BetterSystemStyleObject
75
}

0 commit comments

Comments
 (0)