forked from umami-software/umami
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored layout. Added NavBar component.
- Loading branch information
Showing
56 changed files
with
599 additions
and
427 deletions.
There are no files selected for viewing
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
components/settings/SettingsButton.js → components/buttons/SettingsButton.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Calendar from 'assets/calendar.svg'; | ||
import Clock from 'assets/clock.svg'; | ||
import Dashboard from 'assets/dashboard.svg'; | ||
import Gear from 'assets/gear.svg'; | ||
import Globe from 'assets/globe.svg'; | ||
import Logo from 'assets/logo.svg'; | ||
import Moon from 'assets/moon.svg'; | ||
import Profile from 'assets/profile.svg'; | ||
import Sun from 'assets/sun.svg'; | ||
import User from 'assets/user.svg'; | ||
import Users from 'assets/users.svg'; | ||
|
||
export { Calendar, Clock, Dashboard, Gear, Globe, Logo, Moon, Profile, Sun, User, Users }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
import { Container } from 'react-basics'; | ||
import Head from 'next/head'; | ||
import Header from 'components/layout/Header'; | ||
import Footer from 'components/layout/Footer'; | ||
import useLocale from 'hooks/useLocale'; | ||
import NavBar from 'components/layout/NavBar'; | ||
import useRequireLogin from 'hooks/useRequireLogin'; | ||
import styles from './AppLayout.module.css'; | ||
|
||
export default function AppLayout({ title, children }) { | ||
useRequireLogin(); | ||
const { dir } = useLocale(); | ||
|
||
return ( | ||
<Container dir={dir} style={{ maxWidth: 1140 }}> | ||
<div className={styles.layout}> | ||
<Head> | ||
<title>{title ? `${title} | umami` : 'umami'}</title> | ||
</Head> | ||
<Header /> | ||
<main>{children}</main> | ||
<Footer /> | ||
</Container> | ||
<div className={styles.nav}> | ||
<NavBar /> | ||
</div> | ||
<div className={styles.body}> | ||
<Container> | ||
<main>{children}</main> | ||
</Container> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
.layout { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
height: 100%; | ||
display: grid; | ||
grid-template-rows: 1fr; | ||
grid-template-columns: minmax(60px, 200px) 1fr; | ||
height: 100vh; | ||
overflow: hidden; | ||
} | ||
|
||
.nav { | ||
grid-row: 1 / 3; | ||
} | ||
|
||
.body { | ||
grid-area: 1 / 2; | ||
overflow: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useState } from 'react'; | ||
import { Icon, Text, Icons } from 'react-basics'; | ||
import classNames from 'classnames'; | ||
import { Dashboard, Logo, Profile, User, Users, Clock, Globe } from 'components/icons'; | ||
import NavGroup from './NavGroup'; | ||
import styles from './NavBar.module.css'; | ||
|
||
const { ChevronDown, Search } = Icons; | ||
|
||
const analytics = [ | ||
{ key: 'dashboard', label: 'Dashboard', url: '/dashboard', icon: <Dashboard /> }, | ||
{ key: 'realtime', label: 'Realtime', url: '/realtime', icon: <Clock /> }, | ||
{ key: 'queries', label: 'Queries', url: '/queries', icon: <Search /> }, | ||
]; | ||
|
||
const settings = [ | ||
{ key: 'websites', label: 'Websites', url: '/settings/websites', icon: <Globe /> }, | ||
{ key: 'users', label: 'Users', url: '/settings/users', icon: <User /> }, | ||
{ key: 'teams', label: 'Teams', url: '/settings/teams', icon: <Users /> }, | ||
]; | ||
|
||
export default function NavBar() { | ||
const [minimized, setMinimized] = useState(false); | ||
|
||
const handleMinimize = () => setMinimized(state => !state); | ||
|
||
return ( | ||
<div className={classNames(styles.navbar, { [styles.minimized]: minimized })}> | ||
<div className={styles.header} onClick={handleMinimize}> | ||
<Icon size="lg"> | ||
<Logo /> | ||
</Icon> | ||
<Text className={styles.text}>umami</Text> | ||
<Icon size="sm" rotate={minimized ? -90 : 90} className={styles.icon}> | ||
<ChevronDown /> | ||
</Icon> | ||
</div> | ||
<NavGroup title="Analytics" items={analytics} minimized={minimized} /> | ||
<NavGroup title="Settings" items={settings} minimized={minimized} /> | ||
<div className={styles.footer}> | ||
<Icon> | ||
<Profile /> | ||
</Icon> | ||
<Text>Profile</Text> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
.navbar { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
background: var(--base75); | ||
height: 100%; | ||
width: 200px; | ||
border-right: 2px solid var(--base200); | ||
} | ||
|
||
.header { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 10px; | ||
font-size: 16px; | ||
font-weight: 700; | ||
padding: 20px 0; | ||
cursor: pointer; | ||
} | ||
|
||
.header:hover .icon { | ||
visibility: visible; | ||
} | ||
|
||
.icon { | ||
position: absolute; | ||
right: 0; | ||
visibility: hidden; | ||
} | ||
|
||
.minimized.navbar { | ||
width: 60px; | ||
} | ||
|
||
.minimized .text { | ||
display: none; | ||
} | ||
|
||
.footer { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: flex-end; | ||
padding: 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useState } from 'react'; | ||
import { Icon, Text, Icons } from 'react-basics'; | ||
import classNames from 'classnames'; | ||
import { useRouter } from 'next/router'; | ||
import Link from 'next/link'; | ||
import styles from './NavGroup.module.css'; | ||
|
||
const { ChevronDown } = Icons; | ||
|
||
export default function NavGroup({ | ||
title, | ||
items, | ||
defaultExpanded = true, | ||
allowExpand = true, | ||
minimized = false, | ||
}) { | ||
const { pathname } = useRouter(); | ||
const [expanded, setExpanded] = useState(defaultExpanded); | ||
|
||
const handleExpand = () => setExpanded(state => !state); | ||
|
||
return ( | ||
<div | ||
className={classNames(styles.group, { | ||
[styles.expanded]: expanded, | ||
[styles.minimized]: minimized, | ||
})} | ||
> | ||
<div className={styles.header} onClick={allowExpand ? handleExpand : undefined}> | ||
<Text>{title}</Text> | ||
<Icon size="sm" rotate={expanded ? 0 : -90}> | ||
<ChevronDown /> | ||
</Icon> | ||
</div> | ||
<div className={styles.body}> | ||
{items.map(({ key, label, url, icon }) => { | ||
return ( | ||
<Link key={key} href={url}> | ||
<a | ||
className={classNames(styles.item, { [styles.selected]: pathname.startsWith(url) })} | ||
> | ||
<Icon>{icon}</Icon> | ||
<Text className={styles.text}>{label}</Text> | ||
</a> | ||
</Link> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.