Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Update header components. Update theme button.

Mike Cao823fdcbeae0e
diff --git a/assets/toggle-off.svg b/assets/toggle-off.svg
new file mode 100644
index 000000000..c9b7fa1d0
--- /dev/null
+++ b/assets/toggle-off.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M384 96c42.738 0 82.917 16.643 113.137 46.863S544 213.262 544 256s-16.643 82.917-46.863 113.137S426.738 416 384 416H192c-42.738 0-82.917-16.643-113.137-46.863S32 298.738 32 256s16.643-82.917 46.863-113.137S149.262 96 192 96h192m0-32H192C85.961 64 0 149.961 0 256s85.961 192 192 192h192c106.039 0 192-85.961 192-192S490.039 64 384 64zm-192 96c52.935 0 96 43.065 96 96s-43.065 96-96 96-96-43.065-96-96 43.065-96 96-96m0-32c-70.692 0-128 57.307-128 128s57.308 128 128 128 128-57.307 128-128-57.308-128-128-128z"/></svg>
\ No newline at end of file
diff --git a/assets/toggle-on.svg b/assets/toggle-on.svg
new file mode 100644
index 000000000..8fbcb384d
--- /dev/null
+++ b/assets/toggle-on.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M384 96c88.426 0 160 71.561 160 160 0 88.426-71.561 160-160 160H192c-88.426 0-160-71.561-160-160 0-88.425 71.561-160 160-160h192m0-32H192C85.961 64 0 149.961 0 256s85.961 192 192 192h192c106.039 0 192-85.961 192-192S490.039 64 384 64zm0 304c61.856 0 112-50.144 112-112s-50.144-112-112-112-112 50.144-112 112c0 28.404 10.574 54.339 27.999 74.082C320.522 353.335 350.548 368 384 368z"/></svg>
\ No newline at end of file
diff --git a/components/common/Button.module.css b/components/common/Button.module.css
index 351f5ecc4..14e12d966 100644
--- a/components/common/Button.module.css
+++ b/components/common/Button.module.css
@@ -57,7 +57,7 @@
}
.light {
- background: var(--gray50);
+ background: transparent;
}
.light:hover {
diff --git a/components/common/UserButton.js b/components/common/UserButton.js
index fdcc59fb1..4c3ffbe73 100644
--- a/components/common/UserButton.js
+++ b/components/common/UserButton.js
@@ -4,6 +4,7 @@ import { useSelector } from 'react-redux';
import { useRouter } from 'next/router';
import Menu from './Menu';
import Icon from './Icon';
+import Button from './Button';
import useDocumentClick from 'hooks/useDocumentClick';
import User from 'assets/user.svg';
import Chevron from 'assets/chevron-down.svg';
@@ -49,10 +50,15 @@ export default function UserButton() {
return (
<div ref={ref} className={styles.container}>
- <div className={styles.button} onClick={() => setShowMenu(state => !state)}>
- <Icon icon={<User />} size="large" />
+ <Button
+ icon={<User />}
+ className={styles.button}
+ onClick={() => setShowMenu(state => !state)}
+ size="large"
+ variant="light"
+ >
<Icon icon={<Chevron />} size="small" />
- </div>
+ </Button>
{showMenu && (
<Menu
className={styles.menu}
diff --git a/components/layout/Header.js b/components/layout/Header.js
index 46c9b3e4b..de777af4b 100644
--- a/components/layout/Header.js
+++ b/components/layout/Header.js
@@ -16,32 +16,29 @@ export default function Header() {
return (
<header className="container">
<div className={classNames(styles.header, 'row align-items-center')}>
- <div className="col-12 col-md-3">
+ <div className="col-12 col-md-12 col-lg-3">
<div className={styles.title}>
<Icon icon={<Logo />} size="large" className={styles.logo} />
<Link href={user ? '/' : 'https://umami.is'}>umami</Link>
</div>
</div>
- <div className="col-12 col-md-9">
- <div className={styles.nav}>
- {user ? (
- <>
- <Link href="/dashboard">
- <FormattedMessage id="label.dashboard" defaultMessage="Dashboard" />
- </Link>
- <Link href="/settings">
- <FormattedMessage id="label.settings" defaultMessage="Settings" />
- </Link>
- <LanguageButton menuAlign="right" />
- <ThemeButton />
- <UserButton />
- </>
- ) : (
- <>
- <LanguageButton menuAlign="right" />
- <ThemeButton />
- </>
- )}
+ <div className="col-12 col-md-12 col-lg-6">
+ {user && (
+ <div className={styles.nav}>
+ <Link href="/dashboard">
+ <FormattedMessage id="label.dashboard" defaultMessage="Dashboard" />
+ </Link>
+ <Link href="/settings">
+ <FormattedMessage id="label.settings" defaultMessage="Settings" />
+ </Link>
+ </div>
+ )}
+ </div>
+ <div className="col-12 col-md-12 col-lg-3">
+ <div className={styles.buttons}>
+ <LanguageButton menuAlign="right" />
+ <ThemeButton />
+ {user && <UserButton />}
</div>
</div>
</div>
diff --git a/components/layout/Header.module.css b/components/layout/Header.module.css
index 6853eedab..3c5155a77 100644
--- a/components/layout/Header.module.css
+++ b/components/layout/Header.module.css
@@ -13,18 +13,37 @@
.nav {
display: flex;
- justify-content: flex-end;
+ justify-content: center;
align-items: center;
font-size: var(--font-size-normal);
font-weight: 600;
}
.nav > * {
- margin-left: 40px;
+ margin-left: 30px;
+}
+
+.nav > *:first-child {
+ margin: 0;
}
-@media only screen and (max-width: 768px) {
+.buttons {
+ display: flex;
+ justify-content: flex-end;
+}
+
+@media only screen and (max-width: 992px) {
.title {
text-align: center;
}
+
+ .nav {
+ font-size: var(--font-size-large);
+ justify-content: center;
+ padding: 20px 0;
+ }
+
+ .buttons {
+ justify-content: center;
+ }
}
diff --git a/components/settings/LanguageButton.js b/components/settings/LanguageButton.js
index 953204f4d..38329c9b7 100644
--- a/components/settings/LanguageButton.js
+++ b/components/settings/LanguageButton.js
@@ -46,8 +46,8 @@ export default function LanguageButton({ menuPosition = 'bottom', menuAlign = 'l
)}
</Head>
<div ref={ref} className={styles.container}>
- <Button icon={<Globe />} onClick={toggleMenu} size="small">
- <div>{selectedLocale}</div>
+ <Button icon={<Globe />} onClick={toggleMenu} variant="light">
+ <div className={styles.text}>{selectedLocale}</div>
</Button>
{showMenu && (
<Menu
diff --git a/components/settings/LanguageButton.module.css b/components/settings/LanguageButton.module.css
index 55464c4d8..0e8c006ea 100644
--- a/components/settings/LanguageButton.module.css
+++ b/components/settings/LanguageButton.module.css
@@ -7,3 +7,7 @@
.menu {
z-index: 100;
}
+
+.text {
+ font-size: var(--font-size-small);
+}
diff --git a/components/settings/ThemeButton.js b/components/settings/ThemeButton.js
index b16f39706..847f8c85b 100644
--- a/components/settings/ThemeButton.js
+++ b/components/settings/ThemeButton.js
@@ -1,6 +1,8 @@
import React from 'react';
import Button from 'components/common/Button';
import useTheme from 'hooks/useTheme';
+import ToggleOn from 'assets/toggle-on.svg';
+import ToggleOff from 'assets/toggle-off.svg';
export default function ThemeButton() {
const [theme, setTheme] = useTheme();
@@ -9,5 +11,12 @@ export default function ThemeButton() {
setTheme(theme === 'light' ? 'dark' : 'light');
}
- return <Button onClick={handleClick}>{theme}</Button>;
+ return (
+ <Button
+ icon={theme === 'light' ? <ToggleOff /> : <ToggleOn />}
+ size="large"
+ variant="light"
+ onClick={handleClick}
+ />
+ );
}
diff --git a/components/settings/ThemeButton.module.css b/components/settings/ThemeButton.module.css
new file mode 100644
index 000000000..5a05d5cd5
--- /dev/null
+++ b/components/settings/ThemeButton.module.css
@@ -0,0 +1,43 @@
+.icon {
+ position: absolute;
+ left: 50%;
+ top: 50%;
+ transform: translate(-50%, -50%);
+ line-height: 16px;
+}
+
+.sun {
+ height: 16px;
+ width: 16px;
+ border-radius: 100%;
+ background: var(--gray900);
+ z-index: 1;
+}
+
+.moon {
+ height: 16px;
+ width: 16px;
+ border-radius: 100%;
+ background: var(--gray900);
+}
+
+.moon:before {
+ content: '';
+ position: absolute;
+ height: 13px;
+ width: 13px;
+ left: -2px;
+ top: 0;
+ bottom: 0;
+ margin: auto;
+ border-radius: 100%;
+ background: var(--gray50);
+}
+
+.light .moon {
+ display: none;
+}
+
+.dark .sun {
+ display: none;
+}
diff --git a/package.json b/package.json
index ec47c63c3..c1f02b69d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "umami",
- "version": "0.43.0",
+ "version": "0.44.0",
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
"author": "Mike Cao <[email protected]>",
"license": "MIT",