add page icons to collapsed share menu
This commit is contained in:
1 parent
9e76bd4cf8
commit
35680918c0
4 files changed
+88
-66
No files matched your search
+13
-13
@@ -1,15 +1,3 @@
|
|||||||
import {
|
|
||||||
Button,
|
|
||||||
type ButtonProps,
|
|
||||||
Column,
|
|
||||||
Focusable,
|
|
||||||
Icon,
|
|
||||||
Row,
|
|
||||||
Text,
|
|
||||||
Tooltip,
|
|
||||||
TooltipTrigger,
|
|
||||||
} from '@umami/react-zen';
|
|
||||||
import Link from 'next/link';
|
|
||||||
import { AdminNav } from '@/app/(main)/admin/AdminNav';
|
import { AdminNav } from '@/app/(main)/admin/AdminNav';
|
||||||
import { SettingsNav } from '@/app/(main)/settings/SettingsNav';
|
import { SettingsNav } from '@/app/(main)/settings/SettingsNav';
|
||||||
import { WebsiteNav } from '@/app/(main)/websites/[websiteId]/WebsiteNav';
|
import { WebsiteNav } from '@/app/(main)/websites/[websiteId]/WebsiteNav';
|
||||||
@@ -25,6 +13,18 @@ import {
|
|||||||
} from '@/components/icons';
|
} from '@/components/icons';
|
||||||
import { UserButton } from '@/components/input/UserButton';
|
import { UserButton } from '@/components/input/UserButton';
|
||||||
import { Logo } from '@/components/svg';
|
import { Logo } from '@/components/svg';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
type ButtonProps,
|
||||||
|
Column,
|
||||||
|
Focusable,
|
||||||
|
Icon,
|
||||||
|
Row,
|
||||||
|
Text,
|
||||||
|
Tooltip,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from '@umami/react-zen';
|
||||||
|
import Link from 'next/link';
|
||||||
|
|
||||||
export function SideNav(props: any) {
|
export function SideNav(props: any) {
|
||||||
const { t, labels } = useMessages();
|
const { t, labels } = useMessages();
|
||||||
@@ -79,7 +79,7 @@ export function SideNav(props: any) {
|
|||||||
minHeight="0"
|
minHeight="0"
|
||||||
margin="2"
|
margin="2"
|
||||||
style={{
|
style={{
|
||||||
width: isCollapsed ? '55px' : '240px',
|
width: isCollapsed ? '60px' : '240px',
|
||||||
transition: 'width 0.2s ease-in-out',
|
transition: 'width 0.2s ease-in-out',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export function WebsiteNav({
|
|||||||
const { items, selectedKey } = useWebsiteNavItems(websiteId);
|
const { items, selectedKey } = useWebsiteNavItems(websiteId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column gap="2">
|
<Column gap="2" marginTop={isCollapsed ? '2' : undefined}>
|
||||||
<Link href={renderUrl('/websites', false)} role="button" onClick={onItemClick}>
|
<Link href={renderUrl('/websites', false)} role="button" onClick={onItemClick}>
|
||||||
<TooltipTrigger isDisabled={!isCollapsed} delay={0}>
|
<TooltipTrigger isDisabled={!isCollapsed} delay={0}>
|
||||||
<Focusable>
|
<Focusable>
|
||||||
|
|||||||
@@ -1,10 +1,21 @@
|
|||||||
import { Button, Column, Icon, Row, ThemeButton } from '@umami/react-zen';
|
import { IconLabel } from '@/components/common/IconLabel';
|
||||||
import { NavMenu } from '@/components/common/NavMenu';
|
|
||||||
import { useMessages, useNavigation, useShare } from '@/components/hooks';
|
import { useMessages, useNavigation, useShare } from '@/components/hooks';
|
||||||
import { AlignEndHorizontal, Clock, Eye, PanelLeft, Sheet, Tag, User } from '@/components/icons';
|
import { AlignEndHorizontal, Clock, Eye, PanelLeft, Sheet, Tag, User } from '@/components/icons';
|
||||||
import { LanguageButton } from '@/components/input/LanguageButton';
|
import { LanguageButton } from '@/components/input/LanguageButton';
|
||||||
import { PreferencesButton } from '@/components/input/PreferencesButton';
|
import { PreferencesButton } from '@/components/input/PreferencesButton';
|
||||||
import { Funnel, Gauge, Lightning, Magnet, Money, Network, Path, Target } from '@/components/svg';
|
import { Funnel, Gauge, Lightning, Magnet, Money, Network, Path, Target } from '@/components/svg';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Column,
|
||||||
|
Focusable,
|
||||||
|
Icon,
|
||||||
|
Row,
|
||||||
|
Text,
|
||||||
|
ThemeButton,
|
||||||
|
Tooltip,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from '@umami/react-zen';
|
||||||
|
import Link from 'next/link';
|
||||||
import { ShareBranding } from './ShareBranding';
|
import { ShareBranding } from './ShareBranding';
|
||||||
|
|
||||||
export function ShareNav({
|
export function ShareNav({
|
||||||
@@ -28,18 +39,8 @@ export function ShareNav({
|
|||||||
section: 'traffic',
|
section: 'traffic',
|
||||||
label: t(labels.traffic),
|
label: t(labels.traffic),
|
||||||
items: [
|
items: [
|
||||||
{
|
{ id: 'overview', label: t(labels.overview), icon: <Eye />, path: renderPath('') },
|
||||||
id: 'overview',
|
{ id: 'events', label: t(labels.events), icon: <Lightning />, path: renderPath('/events') },
|
||||||
label: t(labels.overview),
|
|
||||||
icon: <Eye />,
|
|
||||||
path: renderPath(''),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'events',
|
|
||||||
label: t(labels.events),
|
|
||||||
icon: <Lightning />,
|
|
||||||
path: renderPath('/events'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'sessions',
|
id: 'sessions',
|
||||||
label: t(labels.sessions),
|
label: t(labels.sessions),
|
||||||
@@ -76,18 +77,8 @@ export function ShareNav({
|
|||||||
section: 'behavior',
|
section: 'behavior',
|
||||||
label: t(labels.behavior),
|
label: t(labels.behavior),
|
||||||
items: [
|
items: [
|
||||||
{
|
{ id: 'goals', label: t(labels.goals), icon: <Target />, path: renderPath('/goals') },
|
||||||
id: 'goals',
|
{ id: 'funnels', label: t(labels.funnels), icon: <Funnel />, path: renderPath('/funnels') },
|
||||||
label: t(labels.goals),
|
|
||||||
icon: <Target />,
|
|
||||||
path: renderPath('/goals'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'funnels',
|
|
||||||
label: t(labels.funnels),
|
|
||||||
icon: <Funnel />,
|
|
||||||
path: renderPath('/funnels'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'journeys',
|
id: 'journeys',
|
||||||
label: t(labels.journeys),
|
label: t(labels.journeys),
|
||||||
@@ -106,18 +97,8 @@ export function ShareNav({
|
|||||||
section: 'growth',
|
section: 'growth',
|
||||||
label: t(labels.growth),
|
label: t(labels.growth),
|
||||||
items: [
|
items: [
|
||||||
{
|
{ id: 'utm', label: t(labels.utm), icon: <Tag />, path: renderPath('/utm') },
|
||||||
id: 'utm',
|
{ id: 'revenue', label: t(labels.revenue), icon: <Money />, path: renderPath('/revenue') },
|
||||||
label: t(labels.utm),
|
|
||||||
icon: <Tag />,
|
|
||||||
path: renderPath('/utm'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'revenue',
|
|
||||||
label: t(labels.revenue),
|
|
||||||
icon: <Money />,
|
|
||||||
path: renderPath('/revenue'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'attribution',
|
id: 'attribution',
|
||||||
label: t(labels.attribution),
|
label: t(labels.attribution),
|
||||||
@@ -145,13 +126,19 @@ export function ShareNav({
|
|||||||
return (
|
return (
|
||||||
<Column
|
<Column
|
||||||
position={isMobile ? undefined : 'fixed'}
|
position={isMobile ? undefined : 'fixed'}
|
||||||
padding="3"
|
paddingX={collapsed ? '1' : '3'}
|
||||||
|
paddingY="3"
|
||||||
width={isMobile ? '100%' : collapsed ? '60px' : '240px'}
|
width={isMobile ? '100%' : collapsed ? '60px' : '240px'}
|
||||||
maxHeight="100dvh"
|
maxHeight="100dvh"
|
||||||
height="100dvh"
|
height="100dvh"
|
||||||
border={isMobile ? undefined : 'right'}
|
border={isMobile ? undefined : 'right'}
|
||||||
>
|
>
|
||||||
<Row as="header" gap alignItems="center" justifyContent="space-between">
|
<Row
|
||||||
|
as="header"
|
||||||
|
gap
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent={collapsed ? 'center' : 'space-between'}
|
||||||
|
>
|
||||||
{!collapsed && <ShareBranding size="md" />}
|
{!collapsed && <ShareBranding size="md" />}
|
||||||
{!onItemClick && (
|
{!onItemClick && (
|
||||||
<Button variant="quiet" onPress={() => onCollapse?.(!collapsed)}>
|
<Button variant="quiet" onPress={() => onCollapse?.(!collapsed)}>
|
||||||
@@ -161,16 +148,44 @@ export function ShareNav({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
{!collapsed && (
|
<Column flexGrow={1} marginTop="2" overflowY="auto" gap="2">
|
||||||
<Column flexGrow={1} overflowY="auto" marginTop="6">
|
{items.map(({ label: sectionLabel, items: sectionItems }, index) => (
|
||||||
<NavMenu
|
<Column key={`${sectionLabel}${index}`} gap="1" marginBottom="1">
|
||||||
items={items}
|
{!collapsed && (
|
||||||
selectedKey={selectedKey}
|
<Row padding>
|
||||||
allowMinimize={false}
|
<Text weight="bold">{sectionLabel}</Text>
|
||||||
onItemClick={onItemClick}
|
</Row>
|
||||||
/>
|
)}
|
||||||
</Column>
|
{sectionItems.map(({ id, path, label, icon }) => {
|
||||||
)}
|
const isSelected = selectedKey === id;
|
||||||
|
return (
|
||||||
|
<Link key={id} href={path} role="button" onClick={onItemClick}>
|
||||||
|
<TooltipTrigger isDisabled={!collapsed} delay={0}>
|
||||||
|
<Focusable>
|
||||||
|
<Row
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent={collapsed ? 'center' : undefined}
|
||||||
|
hover={{ backgroundColor: 'surface-sunken' }}
|
||||||
|
backgroundColor={isSelected ? 'surface-sunken' : undefined}
|
||||||
|
borderRadius
|
||||||
|
minHeight="40px"
|
||||||
|
>
|
||||||
|
<IconLabel
|
||||||
|
icon={icon}
|
||||||
|
label={collapsed ? '' : label}
|
||||||
|
weight={isSelected ? 'bold' : undefined}
|
||||||
|
{...(!collapsed && { padding: true })}
|
||||||
|
/>
|
||||||
|
</Row>
|
||||||
|
</Focusable>
|
||||||
|
<Tooltip placement="right">{label}</Tooltip>
|
||||||
|
</TooltipTrigger>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Column>
|
||||||
|
))}
|
||||||
|
</Column>
|
||||||
<Column
|
<Column
|
||||||
flexGrow={collapsed ? 1 : undefined}
|
flexGrow={collapsed ? 1 : undefined}
|
||||||
justifyContent="flex-end"
|
justifyContent="flex-end"
|
||||||
|
|||||||
@@ -59,7 +59,14 @@ function getSharePath(pathname: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function SharePage() {
|
export function SharePage() {
|
||||||
const [navCollapsed, setNavCollapsed] = useState(false);
|
const [navCollapsed, setNavCollapsed] = useState(
|
||||||
|
() => typeof window !== 'undefined' && localStorage.getItem('share:navCollapsed') === 'true',
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleCollapse = (value: boolean) => {
|
||||||
|
localStorage.setItem('share:navCollapsed', String(value));
|
||||||
|
setNavCollapsed(value);
|
||||||
|
};
|
||||||
const share = useShare();
|
const share = useShare();
|
||||||
const { setTheme } = useTheme();
|
const { setTheme } = useTheme();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
@@ -113,7 +120,7 @@ export function SharePage() {
|
|||||||
</MobileMenuButton>
|
</MobileMenuButton>
|
||||||
</Row>
|
</Row>
|
||||||
<Column display={{ base: 'none', lg: 'flex' }} marginRight="2">
|
<Column display={{ base: 'none', lg: 'flex' }} marginRight="2">
|
||||||
<ShareNav collapsed={navCollapsed} onCollapse={setNavCollapsed} />
|
<ShareNav collapsed={navCollapsed} onCollapse={handleCollapse} />
|
||||||
</Column>
|
</Column>
|
||||||
<PageBody gap>
|
<PageBody gap>
|
||||||
<WebsiteProvider websiteId={websiteId}>
|
<WebsiteProvider websiteId={websiteId}>
|
||||||
|
|||||||
Reference in new issue
Block a user