diff --git a/assets/moon.svg b/assets/moon.svg
new file mode 100644
index 00000000..6c8955ae
--- /dev/null
+++ b/assets/moon.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/sun.svg b/assets/sun.svg
new file mode 100644
index 00000000..ebc20eb2
--- /dev/null
+++ b/assets/sun.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/toggle-off.svg b/assets/toggle-off.svg
deleted file mode 100644
index c9b7fa1d..00000000
--- a/assets/toggle-off.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/assets/toggle-on.svg b/assets/toggle-on.svg
deleted file mode 100644
index 8fbcb384..00000000
--- a/assets/toggle-on.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/components/settings/ThemeButton.js b/components/settings/ThemeButton.js
index 847f8c85..2c036079 100644
--- a/components/settings/ThemeButton.js
+++ b/components/settings/ThemeButton.js
@@ -1,22 +1,44 @@
import React from 'react';
+import { useTransition, animated } from 'react-spring';
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';
+import Sun from 'assets/sun.svg';
+import Moon from 'assets/moon.svg';
+import styles from './ThemeButton.module.css';
+import Icon from '../common/Icon';
export default function ThemeButton() {
const [theme, setTheme] = useTheme();
+ const transitions = useTransition(theme, theme => theme, {
+ from: {
+ opacity: 0,
+ transform: `translateY(${theme === 'light' ? '-20px' : '20px'}) scale(0.5)`,
+ },
+ enter: { opacity: 1, transform: 'translateY(0px) scale(1)' },
+ leave: {
+ opacity: 0,
+ transform: `translateY(${theme === 'light' ? '20px' : '-20px'}) scale(0.5)`,
+ },
+ });
+
function handleClick() {
setTheme(theme === 'light' ? 'dark' : 'light');
}
return (
- : }
- size="large"
- variant="light"
- onClick={handleClick}
- />
+
);
}
diff --git a/components/settings/ThemeButton.module.css b/components/settings/ThemeButton.module.css
index 5a05d5cd..2b312442 100644
--- a/components/settings/ThemeButton.module.css
+++ b/components/settings/ThemeButton.module.css
@@ -1,43 +1,3 @@
-.icon {
+.button svg {
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 c1f02b69..a87cb324 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "umami",
- "version": "0.44.0",
+ "version": "0.45.0",
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
"author": "Mike Cao ",
"license": "MIT",
diff --git a/styles/index.css b/styles/index.css
index 1a73afb7..8eb0449d 100644
--- a/styles/index.css
+++ b/styles/index.css
@@ -92,6 +92,10 @@ main {
flex: 1;
}
+svg {
+ shape-rendering: geometricPrecision;
+}
+
#__next {
display: flex;
flex-direction: column;