@@ -5,12 +5,11 @@ import { SxProp } from 'theme-ui'
5
5
6
6
import {
7
7
buildTransition ,
8
- ButtonOrLink ,
9
- ButtonOrLinkProps ,
10
8
Divider ,
11
9
Flex ,
12
10
Icon ,
13
11
IconProps ,
12
+ Link ,
14
13
Spacing ,
15
14
Text ,
16
15
TextProps ,
@@ -30,12 +29,13 @@ const animationCollapse = keyframes({
30
29
export type NavTreeProps = HTMLAttributes < HTMLElement > & {
31
30
textProps ?: TextProps
32
31
}
33
- export type NavTreeItemProps = HTMLAttributes < HTMLElement > &
34
- Pick < AnchorHTMLAttributes < HTMLAnchorElement > , 'href' | 'target' > & {
35
- active ?: boolean
36
- linkProps ?: HTMLAttributes < HTMLElement > & SxProp
37
- diamondProps ?: Partial < IconProps > & SxProp
38
- }
32
+ export type NavTreeItemProps = HTMLAttributes < HTMLElement > & {
33
+ href : NonNullable < AnchorHTMLAttributes < HTMLAnchorElement > [ 'href' ] >
34
+ target ?: AnchorHTMLAttributes < HTMLAnchorElement > [ 'target' ]
35
+ active ?: boolean
36
+ linkProps ?: HTMLAttributes < HTMLElement > & SxProp
37
+ diamondProps ?: Partial < IconProps > & SxProp
38
+ }
39
39
export type NavTreeGroupProps = HTMLAttributes < HTMLElement > & {
40
40
active ?: boolean
41
41
}
@@ -69,7 +69,7 @@ const NavTreeItem = ({
69
69
const { sx : diamondSx , ...diamondOtherProps } = diamondProps
70
70
return (
71
71
< li { ...props } >
72
- < ButtonOrLink
72
+ < Link . Unstyled
73
73
href = { href }
74
74
target = { target }
75
75
sx = { {
@@ -100,7 +100,7 @@ const NavTreeItem = ({
100
100
{ ...diamondOtherProps }
101
101
/>
102
102
) : null }
103
- </ ButtonOrLink >
103
+ </ Link . Unstyled >
104
104
</ li >
105
105
)
106
106
}
@@ -125,7 +125,7 @@ const NavTreeGroup = ({ active = false, children, ...props }: NavTreeGroupProps)
125
125
126
126
const NavTreeGroupHeading = ( { children, buttonProps = { } , ...props } : NavTreeGroupHeadingProps ) => {
127
127
const { sx : buttonSx , ...buttonOtherProps } = buttonProps
128
- const context = useContext ( NavTreeGroupContext )
128
+ const { open , active } = useContext ( NavTreeGroupContext )
129
129
const { t } = useI18n < any > ( )
130
130
131
131
return (
@@ -135,7 +135,7 @@ const NavTreeGroupHeading = ({ children, buttonProps = {}, ...props }: NavTreeGr
135
135
width : '100%' ,
136
136
paddingInline : Spacing [ '24px' ] ,
137
137
py : Spacing [ '12px' ] ,
138
- color : context . open || context . active ? 'White88' : 'White64' ,
138
+ color : open || active ? 'White88' : 'White64' ,
139
139
'&:hover' : { color : 'White' } ,
140
140
transition : buildTransition ( 'COLORS' ) ,
141
141
...buttonSx ,
@@ -148,12 +148,15 @@ const NavTreeGroupHeading = ({ children, buttonProps = {}, ...props }: NavTreeGr
148
148
as = "span"
149
149
sx = { {
150
150
flexShrink : 0 ,
151
- transform : context . open ? 'rotate(90deg)' : 'rotate(0deg)' ,
152
151
transition : buildTransition ( 'TRANSFORM' ) ,
152
+ transform : open ? 'rotate(90deg)' : 'rotate(0deg)' ,
153
+ '&:dir(rtl)' : {
154
+ transform : open ? 'rotate(-90deg)' : 'rotate(0deg)' ,
155
+ } ,
153
156
} }
154
157
>
155
158
< Icon . CaretRight
156
- title = { context . open ? t ( 'global.collapse' ) : t ( 'global.expand' ) }
159
+ title = { open ? t ( 'global.collapse' ) : t ( 'global.expand' ) }
157
160
size = { [ '16px' , null , null , '14px' ] }
158
161
/>
159
162
</ Flex . Column >
0 commit comments