1- import { Button , Column , Icon , Row , ThemeButton } from '@umami/react-zen' ;
2- import { NavMenu } from '@/components/common/NavMenu' ;
1+ import { IconLabel } from '@/components/common/IconLabel' ;
32import { useMessages , useNavigation , useShare } from '@/components/hooks' ;
43import { AlignEndHorizontal , Clock , Eye , PanelLeft , Sheet , Tag , User } from '@/components/icons' ;
54import { LanguageButton } from '@/components/input/LanguageButton' ;
65import { PreferencesButton } from '@/components/input/PreferencesButton' ;
76import { Funnel , Gauge , Lightning , Magnet , Money , Network , Path , Target } from '@/components/svg' ;
7+ import {
8+ Button ,
9+ Column ,
10+ Focusable ,
11+ Icon ,
12+ Row ,
13+ Text ,
14+ ThemeButton ,
15+ Tooltip ,
16+ TooltipTrigger ,
17+ } from '@umami/react-zen' ;
18+ import Link from 'next/link' ;
819import { ShareBranding } from './ShareBranding' ;
920
1021export function ShareNav ( {
@@ -28,18 +39,8 @@ export function ShareNav({
2839 section : 'traffic' ,
2940 label : t ( labels . traffic ) ,
3041 items : [
31- {
32- id : 'overview' ,
33- label : t ( labels . overview ) ,
34- icon : < Eye /> ,
35- path : renderPath ( '' ) ,
36- } ,
37- {
38- id : 'events' ,
39- label : t ( labels . events ) ,
40- icon : < Lightning /> ,
41- path : renderPath ( '/events' ) ,
42- } ,
42+ { id : 'overview' , label : t ( labels . overview ) , icon : < Eye /> , path : renderPath ( '' ) } ,
43+ { id : 'events' , label : t ( labels . events ) , icon : < Lightning /> , path : renderPath ( '/events' ) } ,
4344 {
4445 id : 'sessions' ,
4546 label : t ( labels . sessions ) ,
@@ -76,18 +77,8 @@ export function ShareNav({
7677 section : 'behavior' ,
7778 label : t ( labels . behavior ) ,
7879 items : [
79- {
80- id : 'goals' ,
81- label : t ( labels . goals ) ,
82- icon : < Target /> ,
83- path : renderPath ( '/goals' ) ,
84- } ,
85- {
86- id : 'funnels' ,
87- label : t ( labels . funnels ) ,
88- icon : < Funnel /> ,
89- path : renderPath ( '/funnels' ) ,
90- } ,
80+ { id : 'goals' , label : t ( labels . goals ) , icon : < Target /> , path : renderPath ( '/goals' ) } ,
81+ { id : 'funnels' , label : t ( labels . funnels ) , icon : < Funnel /> , path : renderPath ( '/funnels' ) } ,
9182 {
9283 id : 'journeys' ,
9384 label : t ( labels . journeys ) ,
@@ -106,18 +97,8 @@ export function ShareNav({
10697 section : 'growth' ,
10798 label : t ( labels . growth ) ,
10899 items : [
109- {
110- id : 'utm' ,
111- label : t ( labels . utm ) ,
112- icon : < Tag /> ,
113- path : renderPath ( '/utm' ) ,
114- } ,
115- {
116- id : 'revenue' ,
117- label : t ( labels . revenue ) ,
118- icon : < Money /> ,
119- path : renderPath ( '/revenue' ) ,
120- } ,
100+ { id : 'utm' , label : t ( labels . utm ) , icon : < Tag /> , path : renderPath ( '/utm' ) } ,
101+ { id : 'revenue' , label : t ( labels . revenue ) , icon : < Money /> , path : renderPath ( '/revenue' ) } ,
121102 {
122103 id : 'attribution' ,
123104 label : t ( labels . attribution ) ,
@@ -145,13 +126,19 @@ export function ShareNav({
145126 return (
146127 < Column
147128 position = { isMobile ? undefined : 'fixed' }
148- padding = "3"
129+ paddingX = { collapsed ? '1' : '3' }
130+ paddingY = "3"
149131 width = { isMobile ? '100%' : collapsed ? '60px' : '240px' }
150132 maxHeight = "100dvh"
151133 height = "100dvh"
152134 border = { isMobile ? undefined : 'right' }
153135 >
154- < Row as = "header" gap alignItems = "center" justifyContent = "space-between" >
136+ < Row
137+ as = "header"
138+ gap
139+ alignItems = "center"
140+ justifyContent = { collapsed ? 'center' : 'space-between' }
141+ >
155142 { ! collapsed && < ShareBranding size = "md" /> }
156143 { ! onItemClick && (
157144 < Button variant = "quiet" onPress = { ( ) => onCollapse ?.( ! collapsed ) } >
@@ -161,16 +148,44 @@ export function ShareNav({
161148 </ Button >
162149 ) }
163150 </ Row >
164- { ! collapsed && (
165- < Column flexGrow = { 1 } overflowY = "auto" marginTop = "6" >
166- < NavMenu
167- items = { items }
168- selectedKey = { selectedKey }
169- allowMinimize = { false }
170- onItemClick = { onItemClick }
171- />
172- </ Column >
173- ) }
151+ < Column flexGrow = { 1 } marginTop = "2" overflowY = "auto" gap = "2" >
152+ { items . map ( ( { label : sectionLabel , items : sectionItems } , index ) => (
153+ < Column key = { `${ sectionLabel } ${ index } ` } gap = "1" marginBottom = "1" >
154+ { ! collapsed && (
155+ < Row padding >
156+ < Text weight = "bold" > { sectionLabel } </ Text >
157+ </ Row >
158+ ) }
159+ { sectionItems . map ( ( { id, path, label, icon } ) => {
160+ const isSelected = selectedKey === id ;
161+ return (
162+ < Link key = { id } href = { path } role = "button" onClick = { onItemClick } >
163+ < TooltipTrigger isDisabled = { ! collapsed } delay = { 0 } >
164+ < Focusable >
165+ < Row
166+ alignItems = "center"
167+ justifyContent = { collapsed ? 'center' : undefined }
168+ hover = { { backgroundColor : 'surface-sunken' } }
169+ backgroundColor = { isSelected ? 'surface-sunken' : undefined }
170+ borderRadius
171+ minHeight = "40px"
172+ >
173+ < IconLabel
174+ icon = { icon }
175+ label = { collapsed ? '' : label }
176+ weight = { isSelected ? 'bold' : undefined }
177+ { ...( ! collapsed && { padding : true } ) }
178+ />
179+ </ Row >
180+ </ Focusable >
181+ < Tooltip placement = "right" > { label } </ Tooltip >
182+ </ TooltipTrigger >
183+ </ Link >
184+ ) ;
185+ } ) }
186+ </ Column >
187+ ) ) }
188+ </ Column >
174189 < Column
175190 flexGrow = { collapsed ? 1 : undefined }
176191 justifyContent = "flex-end"
0 commit comments