File tree 2 files changed +19
-33
lines changed
2 files changed +19
-33
lines changed Original file line number Diff line number Diff line change @@ -10,25 +10,30 @@ import { NavIcon } from './NavIcon'
10
10
import styles from './Navigation.module.css'
11
11
12
12
function ItemLink ( {
13
+ className,
13
14
item,
14
- pathname,
15
15
onLinkClick,
16
- className,
16
+ parent,
17
+ pathname,
17
18
} : {
19
+ className ?: string
18
20
item : NavigationItem
19
- pathname : string
20
21
onLinkClick ?: React . MouseEventHandler < HTMLAnchorElement >
21
- className ?: string
22
+ parent ?: NavigationItem
23
+ pathname : string
22
24
} ) {
25
+ const isSelected =
26
+ parent && item . href === parent . href
27
+ ? // This is for sub item with same link as parent (For example: Cypress of Test Runner)
28
+ pathname === parent . href
29
+ : // Rest of items
30
+ item . href && pathname . includes ( item . href )
31
+
23
32
return (
24
33
< Link
25
34
href = { item . href || '#' }
26
35
onClick = { item . href ? onLinkClick : undefined }
27
- className = { clsx (
28
- styles . item ,
29
- className ,
30
- item . href && pathname . includes ( item . href ) && styles . selected ,
31
- ) }
36
+ className = { clsx ( styles . item , className , isSelected && styles . selected ) }
32
37
>
33
38
< NavIcon
34
39
icon = { item . icon }
@@ -116,29 +121,11 @@ export function Navigation({
116
121
>
117
122
< ItemLink
118
123
item = { subItem }
124
+ parent = { item }
119
125
pathname = { pathname }
120
126
onLinkClick = { onLinkClick }
121
127
/>
122
128
</ Disclosure . Button >
123
- { subItem . links && (
124
- < Disclosure . Panel as = "ul" >
125
- { subItem . links . map ( ( tertiary ) => (
126
- < li key = { tertiary . title } >
127
- < Disclosure . Button
128
- className = { `${ styles . button } ${ styles . tertiary } ` }
129
- >
130
- < Link
131
- href = { tertiary . href }
132
- onClick = { onLinkClick }
133
- className = { clsx ( styles . item ) }
134
- >
135
- { tertiary . title }
136
- </ Link >
137
- </ Disclosure . Button >
138
- </ li >
139
- ) ) }
140
- </ Disclosure . Panel >
141
- ) }
142
129
</ li >
143
130
) ) }
144
131
</ Disclosure . Panel >
Original file line number Diff line number Diff line change @@ -8,8 +8,7 @@ export type NavigationItem = {
8
8
title : string
9
9
}
10
10
11
-
12
- export const navigation : NavigationItem [ ] = [
11
+ export const navigation : NavigationItem [ ] = [
13
12
{
14
13
title : 'Intro to time travel' ,
15
14
href : '/time-travel-intro' ,
@@ -149,7 +148,7 @@ export const navigation: NavigationItem[] = [
149
148
{ title : 'Overview' , href : '/test-runners/overview' , icon : 'overview' } ,
150
149
{
151
150
title : 'Cypress.io' ,
152
- href : '' ,
151
+ href : '/test-runners/cypress-io ' ,
153
152
icon : 'cypress' ,
154
153
links : [
155
154
{
@@ -191,7 +190,7 @@ export const navigation: NavigationItem[] = [
191
190
} ,
192
191
{
193
192
title : 'Playwright' ,
194
- href : '' ,
193
+ href : '/test-runners/playwright/record-your-first-replay ' ,
195
194
icon : 'playwright' ,
196
195
links : [
197
196
{
@@ -202,7 +201,7 @@ export const navigation: NavigationItem[] = [
202
201
{
203
202
title : 'Debugging tests' ,
204
203
href : '/test-runners/playwright/debugging-tests' ,
205
- icon : 'debuggingtests'
204
+ icon : 'debuggingtests' ,
206
205
} ,
207
206
{
208
207
title : 'GitHub actions' ,
You can’t perform that action at this time.
0 commit comments