Skip to content

Commit e67e87b

Browse files
committed
fix: added gap control for directory
1 parent 44b1450 commit e67e87b

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

packages/blend/lib/components/Directory/Directory.tsx

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,17 @@ import { createRef, useEffect, useRef } from 'react'
55
import type { DirectoryProps } from './types'
66
import Section from './Section'
77
import Block from '../Primitives/Block/Block'
8-
import styled from 'styled-components'
98
import { handleSectionNavigation } from './utils'
109
import { ActiveItemProvider } from './NavItem'
11-
12-
const StyledNav = styled(Block).withConfig({
13-
shouldForwardProp: (prop) =>
14-
![
15-
'flexGrow',
16-
'flexDirection',
17-
'gap',
18-
'alignItems',
19-
'paddingY',
20-
'width',
21-
'height',
22-
'display',
23-
'overflow',
24-
].includes(prop),
25-
})`
26-
&::-webkit-scrollbar {
27-
display: none;
28-
}
29-
-ms-overflow-style: none;
30-
scrollbar-width: none;
31-
`
10+
import { useResponsiveTokens } from '../../hooks/useResponsiveTokens'
11+
import { SidebarTokenType } from '../Sidebar/sidebar.tokens'
3212

3313
const Directory = ({ directoryData, className }: DirectoryProps) => {
3414
const sectionRefs = useRef<Array<React.RefObject<HTMLDivElement | null>>>(
3515
[]
3616
)
3717

18+
const tokens = useResponsiveTokens<SidebarTokenType>('SIDEBAR')
3819
useEffect(() => {
3920
sectionRefs.current = directoryData.map(() =>
4021
createRef<HTMLDivElement | null>()
@@ -43,19 +24,20 @@ const Directory = ({ directoryData, className }: DirectoryProps) => {
4324

4425
return (
4526
<ActiveItemProvider>
46-
<StyledNav
27+
<Block
4728
as="nav"
4829
width="100%"
4930
height="100%"
5031
flexGrow={1}
5132
display="flex"
5233
flexDirection="column"
53-
gap="16px"
5434
alignItems="center"
5535
overflow="auto"
56-
paddingY="16px"
5736
className={className}
5837
aria-label="Directory navigation"
38+
gap={tokens.directory.gap}
39+
paddingX={tokens.directory.paddingX}
40+
paddingY={tokens.directory.paddingY}
5941
>
6042
{directoryData.map((section, sectionIndex) => (
6143
<Section
@@ -71,7 +53,7 @@ const Directory = ({ directoryData, className }: DirectoryProps) => {
7153
}
7254
/>
7355
))}
74-
</StyledNav>
56+
</Block>
7557
</ActiveItemProvider>
7658
)
7759
}

packages/blend/lib/components/Directory/Section.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ const Section = ({
108108
flexDirection="column"
109109
gap="4px"
110110
width="100%"
111-
padding="12px 8px"
112111
ref={sectionRef}
113112
data-state={isOpen ? 'open' : 'closed'}
114113
data-sidebar-section={section.label || `section-${sectionIndex}`}

packages/blend/lib/components/Sidebar/sidebar.tokens.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ export type SidebarTokenType = {
8181
}
8282
}
8383

84+
directory: {
85+
gap: CSSObject['gap']
86+
paddingX: CSSObject['padding']
87+
paddingY: CSSObject['padding']
88+
}
89+
8490
// Controls the bottom footer section containing actions and information
8591
footer: {
8692
backgroundColor: CSSObject['backgroundColor'] // Footer background color
@@ -159,6 +165,12 @@ export const getSidebarTokens = (
159165
},
160166
},
161167

168+
directory: {
169+
gap: foundationToken.unit[24],
170+
paddingX: foundationToken.unit[12],
171+
paddingY: foundationToken.unit[12],
172+
},
173+
162174
// Footer section (bottom actions and info)
163175
footer: {
164176
backgroundColor: foundationToken.colors.gray[25],
@@ -231,6 +243,12 @@ export const getSidebarTokens = (
231243
},
232244
},
233245

246+
directory: {
247+
gap: foundationToken.unit[24],
248+
paddingX: foundationToken.unit[12],
249+
paddingY: foundationToken.unit[12],
250+
},
251+
234252
// Footer section (bottom actions and info)
235253
footer: {
236254
backgroundColor: foundationToken.colors.gray[25],

0 commit comments

Comments
 (0)