Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Add animation for light/dark mode toggle

kruzhambusc3c6a0fde907
diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx
index 5f881340f..be62cd237 100644
--- a/src/components/Header/index.jsx
+++ b/src/components/Header/index.jsx
@@ -17,7 +17,6 @@ import {
} from 'redux/constants'
import Dropdown from 'ui/Dropdown'
-import './style.css'
const Header = ({ authenticated, theme }) => {
const { t, i18n: { language } } = useTranslation('common')
@@ -29,7 +28,6 @@ const Header = ({ authenticated, theme }) => {
const switchTheme = () => {
dispatch(UIActions.setTheme(theme === 'dark' ? 'light' : 'dark'))
-
}
const onLanguageChange = (id) => {
@@ -72,15 +70,15 @@ const Header = ({ authenticated, theme }) => {
</div>
</div>
<div className='hidden md:flex justify-center items-center flex-wrap ml-1 md:ml-10 space-y-1 sm:space-y-0 space-x-2 md:space-x-4'>
- {theme === 'dark' ? (
- <div className="sun-logo">
- <SunIcon onClick={switchTheme} className='h-10 w-10 text-gray-200 hover:text-gray-300 cursor-pointer' />
- </div>
- ) : (
- <div className="moon-logo">
- <MoonIcon onClick={switchTheme} className='h-10 w-10 text-indigo-100 hover:text-indigo-200 cursor-pointer' />
- </div>
- )}
+ {theme === 'dark' ? (
+ <div className="transition-all duration-1000 ease-in-out rotate-180">
+ <SunIcon onClick={switchTheme} className='h-10 w-10 text-gray-200 hover:text-gray-300 cursor-pointer' />
+ </div>
+ ) : (
+ <div className="transition-all duration-1000 ease-in-out">
+ <MoonIcon onClick={switchTheme} className='h-10 w-10 text-indigo-100 hover:text-indigo-200 cursor-pointer' />
+ </div>
+ )}
<Dropdown
items={whitelist}
buttonClassName='flex items-center w-full rounded-md border border-gray-300 shadow-sm px-3 md:px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-indigo-500 dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700 dark:hover:bg-gray-600'
@@ -127,11 +125,15 @@ const Header = ({ authenticated, theme }) => {
)}
</div>
<div className='md:hidden flex justify-center items-center'>
- {theme === 'dark' ? (
- <SunIcon onClick={switchTheme} className='h-10 w-10 text-gray-200 hover:text-gray-300 cursor-pointer' />
- ) : (
- <MoonIcon onClick={switchTheme} className='h-10 w-10 text-indigo-100 hover:text-indigo-200 cursor-pointer' />
- )}
+ {theme === 'dark' ? (
+ <div className="transition-all duration-1000 ease-in-out rotate-180">
+ <SunIcon onClick={switchTheme} className='h-10 w-10 text-gray-200 hover:text-gray-300 cursor-pointer' />
+ </div>
+ ) : (
+ <div className="transition-all duration-1000 ease-in-out">
+ <MoonIcon onClick={switchTheme} className='h-10 w-10 text-indigo-100 hover:text-indigo-200 cursor-pointer' />
+ </div>
+ )}
<Popover.Button className='bg-white dark:bg-gray-700 dark:hover:bg-gray-600 dark:text-gray-200 rounded-md p-2 ml-3 inline-flex items-center justify-center text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500'>
<span className='sr-only'>
{t('common.openMenu')}