File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,12 @@ export function SpacesDropdown(props: { space: Space; spaces: Space[] }) {
33
33
{ spaces . map ( ( otherSpace , index ) => (
34
34
< SpacesDropdownMenuItem
35
35
key = { `${ otherSpace . id } -${ index } ` }
36
- currentSpace = { space }
37
- variantSpace = { otherSpace }
36
+ variantSpace = { {
37
+ id : otherSpace . id ,
38
+ title : otherSpace . title ,
39
+ url : otherSpace . urls . published ?? otherSpace . urls . app ,
40
+ } }
41
+ active = { otherSpace . id === space . id }
38
42
/>
39
43
) ) }
40
44
</ DropdownMenu >
Original file line number Diff line number Diff line change @@ -5,25 +5,24 @@ import { useSelectedLayoutSegment } from 'next/navigation';
5
5
6
6
import { DropdownMenuItem } from './Dropdown' ;
7
7
8
- function useVariantSpaceHref ( variantSpace : Space ) {
8
+ function useVariantSpaceHref ( variantSpaceUrl : string ) {
9
9
const currentPathname = useSelectedLayoutSegment ( ) ?? '' ;
10
- const targetUrl = new URL ( variantSpace . urls . published ?? variantSpace . urls . app ) ;
10
+ const targetUrl = new URL ( variantSpaceUrl ) ;
11
11
targetUrl . pathname += `/${ currentPathname } ` ;
12
12
targetUrl . pathname = targetUrl . pathname . replace ( / \/ { 2 , } / g, '/' ) . replace ( / \/ $ / , '' ) ;
13
13
14
14
return targetUrl . toString ( ) ;
15
15
}
16
16
17
- export function SpacesDropdownMenuItem ( props : { variantSpace : Space ; currentSpace : Space } ) {
18
- const { variantSpace, currentSpace } = props ;
19
- const variantHref = useVariantSpaceHref ( variantSpace ) ;
17
+ export function SpacesDropdownMenuItem ( props : {
18
+ variantSpace : { id : Space [ 'id' ] ; title : Space [ 'title' ] ; url : string } ;
19
+ active : boolean ;
20
+ } ) {
21
+ const { variantSpace, active } = props ;
22
+ const variantHref = useVariantSpaceHref ( variantSpace . url ) ;
20
23
21
24
return (
22
- < DropdownMenuItem
23
- key = { variantSpace . id }
24
- href = { variantHref }
25
- active = { variantSpace . id === currentSpace . id }
26
- >
25
+ < DropdownMenuItem key = { variantSpace . id } href = { variantHref } active = { active } >
27
26
{ variantSpace . title }
28
27
</ DropdownMenuItem >
29
28
) ;
You can’t perform that action at this time.
0 commit comments