-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/theme change transition (#1445)
* Added animatiions while theme change * bookmark Co-authored-by: Sargam <[email protected]>
- Loading branch information
Showing
6 changed files
with
97 additions
and
49 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,33 +1,40 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import { Moon, Sun } from 'lucide-react'; | ||
import { useTheme } from 'next-themes'; | ||
import { Button } from './ui/button'; | ||
|
||
export default function ThemeToggler() { | ||
const { theme, setTheme } = useTheme(); | ||
|
||
const switchTheme = () => { | ||
switch (theme) { | ||
case 'light': | ||
setTheme('dark'); | ||
break; | ||
case 'dark': | ||
setTheme('light'); | ||
break; | ||
default: | ||
break; | ||
} | ||
}; | ||
|
||
const toggleTheme = () => { | ||
if (!document.startViewTransition) switchTheme(); | ||
|
||
document.startViewTransition(switchTheme); | ||
}; | ||
|
||
export function SelectTheme({ text }: { text?: boolean }) { | ||
const { setTheme, theme } = useTheme(); | ||
return ( | ||
<> | ||
{text === false ? ( | ||
<button | ||
className={`flex items-center gap-2 rounded-lg p-3 text-center transition-all duration-300 hover:bg-blue-600/5 hover:text-blue-500`} | ||
onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')} | ||
> | ||
<Sun className="size-6 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" /> | ||
<Moon className="absolute size-6 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" /> | ||
</button> | ||
) : ( | ||
<button | ||
className={`flex items-center gap-2 rounded-lg text-center transition-all duration-300 hover:bg-blue-600/5 hover:text-blue-500`} | ||
onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')} | ||
> | ||
<Sun className="size-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" /> | ||
<Moon className="absolute size-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" /> | ||
<span className="text-base"> | ||
{theme === 'light' ? 'Dark' : 'Light'} Mode | ||
</span> | ||
</button> | ||
)} | ||
</> | ||
<Button | ||
onClick={toggleTheme} | ||
size="icon" | ||
className="group rounded-lg border-none bg-transparent shadow-none hover:bg-blue-600/5" | ||
> | ||
<Moon className="absolute size-6 rotate-90 scale-0 transition-all group-hover:text-blue-500 dark:rotate-0 dark:scale-100 dark:text-white" /> | ||
<Sun className="size-6 rotate-0 scale-100 text-black transition-all group-hover:text-blue-500 dark:-rotate-90 dark:scale-0" /> | ||
<span className="sr-only">Toggle theme</span> | ||
</Button> | ||
); | ||
} |
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,27 @@ | ||
import { Bookmark } from 'lucide-react'; | ||
import Image from 'next/image'; | ||
import React from 'react'; | ||
|
||
const NoBookmark = () => { | ||
return ( | ||
<div className="flex w-full flex-col items-center justify-start gap-1 overflow-hidden"> | ||
<Image | ||
src={`/NoBookmark.svg`} | ||
alt="No Bookmarks" | ||
width={40} | ||
height={40} | ||
className="size-[40%] min-w-[400px] opacity-90 invert dark:invert-0" | ||
/> | ||
<h1 className="lg:font-5xl text-center text-2xl font-bold text-black dark:text-white"> | ||
Well.. You have'nt Bookmarked anything yet.... | ||
</h1> | ||
<p className="text-center text-lg max-sm:text-base sm:w-[400px]"> | ||
💡When you find something you want to save for later, Click the “ | ||
<Bookmark className="inline" /> | ||
” icon and it will appear here. | ||
</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default NoBookmark; |