fix: board not found flicker on reloading public boards (#149)

* fix: board not found flicker on reloading public boards

* fix: using netx-theme's ThemeProvider

* chore: installing next-theme

* fix: theme issue on landing page

* fix: image theme hydration issue
This commit is contained in:
Ridham Khandar
2025-08-22 20:58:59 +05:30
committed by GitHub
parent ba2fd7f695
commit 3233c35836
11 changed files with 53 additions and 40 deletions

View File

@@ -10,7 +10,7 @@ import { authClient } from "@kan/auth/client";
import { useClickOutside } from "~/hooks/useClickOutside";
import { useModal } from "~/providers/modal";
import { useTheme } from "~/providers/theme";
import { useTheme } from "next-themes";
import { WorkspaceProvider } from "~/providers/workspace";
import FeedbackModal from "./FeedbackModal";
import Modal from "./modal";
@@ -41,7 +41,7 @@ export default function Dashboard({
rightPanel,
hasRightPanel = false,
}: DashboardProps) {
const theme = useTheme();
const { theme } = useTheme();
const { modalContentType } = useModal();
const { data: session, isPending: sessionLoading } = authClient.useSession();
@@ -90,7 +90,7 @@ export default function Dashboard({
}
});
const isDarkMode = theme.activeTheme === "dark";
const isDarkMode = theme === "dark";
return (
<>

View File

@@ -18,7 +18,7 @@ import settingsIconLight from "~/assets/settings-light.json";
import ReactiveButton from "~/components/ReactiveButton";
import UserMenu from "~/components/UserMenu";
import WorkspaceMenu from "~/components/WorkspaceMenu";
import { useTheme } from "~/providers/theme";
import { useTheme } from "next-themes";
interface SideNavigationProps {
user: UserType;
@@ -59,9 +59,9 @@ export default function SideNavigation({
const { pathname } = router;
const { activeTheme } = useTheme();
const { theme, resolvedTheme } = useTheme();
const isDarkMode = activeTheme === "dark";
const isDarkMode = resolvedTheme === "dark";
const navigation = [
{

View File

@@ -1,23 +1,22 @@
import { CgDarkMode } from "react-icons/cg";
import { useTheme } from "~/providers/theme";
import { useTheme } from "next-themes";
const ThemeToggle = () => {
const { themePreference, switchTheme } = useTheme();
const { theme, setTheme } = useTheme();
const toggleTheme = () => {
switchTheme(themePreference === "light" ? "dark" : "light");
setTheme(theme === "light" ? "dark" : "light");
};
return (
<button
onClick={toggleTheme}
className="rounded p-1.5 transition-all hover:bg-light-200 dark:hover:bg-dark-100"
aria-label={`Switch to ${themePreference === "light" ? "dark" : "light"} theme`}
aria-label={`Switch to ${theme === "light" ? "dark" : "light"} theme`}
>
<CgDarkMode
className={`h-4 w-4 text-light-900 transition-transform duration-200 dark:text-dark-900 ${
themePreference === "dark" ? "rotate-180" : "rotate-0"
theme === "dark" ? "rotate-180" : "rotate-0"
}`}
/>
</button>

View File

@@ -10,7 +10,7 @@ import { authClient } from "@kan/auth/client";
import { useIsMobile } from "~/hooks/useMediaQuery";
import { useModal } from "~/providers/modal";
import { useTheme } from "~/providers/theme";
import { useTheme } from "next-themes";
import { getAvatarUrl } from "~/utils/helpers";
interface UserMenuProps {
@@ -29,7 +29,7 @@ export default function UserMenu({
onCloseSideNav,
}: UserMenuProps) {
const router = useRouter();
const { themePreference, switchTheme } = useTheme();
const { theme, setTheme } = useTheme();
const { openModal } = useModal();
const isMobile = useIsMobile();
@@ -127,12 +127,12 @@ export default function UserMenu({
</div>
<Menu.Item>
<button
onClick={() => switchTheme("system")}
onClick={() => setTheme("system")}
className="flex w-full items-center rounded-[5px] px-3 py-2 text-left text-xs hover:bg-light-200 dark:hover:bg-dark-400"
>
<span
className={twMerge(
themePreference === "system" ? "visible" : "invisible",
theme === "system" ? "visible" : "invisible",
"mr-4 h-[6px] w-[6px] rounded-full bg-light-900 dark:bg-dark-900",
)}
/>
@@ -141,12 +141,12 @@ export default function UserMenu({
</Menu.Item>
<Menu.Item>
<button
onClick={() => switchTheme("dark")}
onClick={() => setTheme("dark")}
className="flex w-full items-center rounded-[5px] px-3 py-2 text-left text-xs hover:bg-light-200 dark:hover:bg-dark-400"
>
<span
className={twMerge(
themePreference === "dark" ? "visible" : "invisible",
theme === "dark" ? "visible" : "invisible",
"mr-4 h-[6px] w-[6px] rounded-full bg-light-900 dark:bg-dark-900",
)}
/>
@@ -155,12 +155,12 @@ export default function UserMenu({
</Menu.Item>
<Menu.Item>
<button
onClick={() => switchTheme("light")}
onClick={() => setTheme("light")}
className="flex w-full items-center rounded-[5px] px-3 py-2 text-left text-xs hover:bg-light-200 dark:hover:bg-dark-400"
>
<span
className={twMerge(
themePreference === "light" ? "visible" : "invisible",
theme === "light" ? "visible" : "invisible",
"mr-4 h-[6px] w-[6px] rounded-full bg-light-900 dark:bg-dark-900",
)}
/>