@@ -2,24 +2,19 @@ import React, { Children, useState } from 'react';
2
2
import PropTypes from 'prop-types' ;
3
3
import styled from 'styled-components' ;
4
4
import { Box } from '../../Box' ;
5
- import { Flex } from '../../Flex' ;
6
5
import { Badge } from '../../Badge' ;
6
+ import { Stack } from '../../Stack' ;
7
7
import { SubNavSectionLabel } from './SubNavSectionLabel' ;
8
8
import { useId } from '../../helpers/useId' ;
9
9
10
10
const SubNavSectionWrapper = styled ( Box ) `
11
- max-height: ${ 32 / 16 } rem;
12
11
svg {
13
12
height: ${ 4 / 16 } rem;
14
13
path {
15
14
fill: ${ ( { theme } ) => theme . colors . neutral500 } ;
16
15
}
17
16
}
18
17
` ;
19
- const SubNavSectionBadge = styled ( Badge ) `
20
- display: flex;
21
- align-items: center;
22
- ` ;
23
18
24
19
export const SubNavSection = ( { collapsable, label, badgeLabel, children, id } ) => {
25
20
const [ isOpen , setOpenLinks ] = useState ( true ) ;
@@ -30,9 +25,9 @@ export const SubNavSection = ({ collapsable, label, badgeLabel, children, id })
30
25
} ;
31
26
32
27
return (
33
- < Box >
28
+ < Stack spacing = { 1 } >
34
29
< SubNavSectionWrapper paddingLeft = { 6 } paddingTop = { 2 } paddingBottom = { 2 } paddingRight = { 4 } >
35
- < Flex justifyContent = "space-between" >
30
+ < Box position = "relative" paddingRight = { badgeLabel ? 6 : 0 } >
36
31
< SubNavSectionLabel
37
32
onClick = { handleClick }
38
33
ariaExpanded = { isOpen }
@@ -41,20 +36,27 @@ export const SubNavSection = ({ collapsable, label, badgeLabel, children, id })
41
36
label = { label }
42
37
/>
43
38
{ badgeLabel && (
44
- < SubNavSectionBadge backgroundColor = "neutral150" textColor = "neutral600" >
39
+ < Badge
40
+ backgroundColor = "neutral150"
41
+ textColor = "neutral600"
42
+ position = "absolute"
43
+ right = { 0 }
44
+ top = "50%"
45
+ transform = "translateY(-50%)"
46
+ >
45
47
{ badgeLabel }
46
- </ SubNavSectionBadge >
48
+ </ Badge >
47
49
) }
48
- </ Flex >
50
+ </ Box >
49
51
</ SubNavSectionWrapper >
50
52
{ ( ! collapsable || isOpen ) && (
51
- < ul id = { listId } >
53
+ < ol id = { listId } >
52
54
{ Children . map ( children , ( child , index ) => {
53
55
return < li key = { index } > { child } </ li > ;
54
56
} ) }
55
- </ ul >
57
+ </ ol >
56
58
) }
57
- </ Box >
59
+ </ Stack >
58
60
) ;
59
61
} ;
60
62
0 commit comments