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

@@ -1,17 +1,17 @@
import PatternedBackground from "~/components/PatternedBackground";
import { useTheme } from "~/providers/theme";
import { useTheme } from "next-themes";
import Footer from "./Footer";
import Header from "./Header";
import { authClient } from "@kan/auth/client";
export default function Layout({ children }: { children: React.ReactNode }) {
const theme = useTheme();
const { theme } = useTheme();
const { data: session } = authClient.useSession();
const isLoggedIn = !!session?.user;
const isDarkMode = theme.activeTheme === "dark";
const isDarkMode = theme === "dark";
return (
<>

View File

@@ -6,7 +6,7 @@ import { IoLogoGithub, IoLogoHackernews } from "react-icons/io";
import Button from "~/components/Button";
import { PageHead } from "~/components/PageHead";
import { useTheme } from "~/providers/theme";
import { useTheme } from "next-themes";
import Cta from "./components/Cta";
import FAQs from "./components/Faqs";
import Features from "./components/Features";
@@ -14,9 +14,10 @@ import Layout from "./components/Layout";
import Pricing from "./components/Pricing";
export default function HomeView() {
const theme = useTheme();
const { resolvedTheme } = useTheme();
const isDarkMode = resolvedTheme === "dark";
const isDarkMode = theme.activeTheme === "dark";
return (
<Layout>
<PageHead title="Kan.bn | The open source alternative to Trello" />
@@ -88,19 +89,27 @@ export default function HomeView() {
</div>
<div className="px-4">
<div className="mb-24 rounded-[16px] border border-light-300 bg-light-50 p-1 shadow-md dark:border-dark-300 dark:bg-dark-100 lg:rounded-[24px] lg:p-2">
<div className="overflow-hidden rounded-[12px] border border-light-300 shadow-sm dark:border-dark-300 lg:rounded-[16px]">
<div className="relative overflow-hidden rounded-[12px] border border-light-300 shadow-sm dark:border-dark-300 lg:rounded-[16px]">
<Image
src={`/hero-${isDarkMode ? "dark" : "light"}.png`}
src={`/hero-light.png`}
alt="kanban"
width={1100}
height={1000}
className="block dark:hidden"
/>
<Image
src={`/hero-dark.png`}
alt="kanban"
width={1100}
height={1000}
className="hidden dark:block"
/>
</div>
</div>
</div>
<div className="relative pt-10">
<div id="features" className="absolute -top-20" />
<Features theme={theme.activeTheme} />
<Features theme={resolvedTheme === "dark" ? "dark" : "light"} />
</div>
<div className="relative pt-10">
<div id="pricing" className="absolute -top-20" />
@@ -111,7 +120,7 @@ export default function HomeView() {
<FAQs />
</div>
<div className="relative">
<Cta theme={theme.activeTheme} />
<Cta theme={resolvedTheme ?? "light"} />
</div>
</div>
</Layout>

View File

@@ -45,7 +45,7 @@ export default function PublicBoardView() {
members: formatToArray(router.query.members),
labels: formatToArray(router.query.labels),
},
{ enabled: !!boardSlug, placeholderData: keepPreviousData },
{ enabled: router.isReady && !!boardSlug, placeholderData: keepPreviousData },
);
const CopyBoardLink = () => {
@@ -107,7 +107,7 @@ export default function PublicBoardView() {
<div className="relative h-full overflow-hidden rounded-md border pb-8 dark:border-dark-200">
<PatternedBackground />
<div className="z-10 flex w-full justify-between p-8">
{isLoading ? (
{isLoading || !router.isReady ? (
<div className="flex space-x-2">
<div className="h-[2.3rem] w-[150px] animate-pulse rounded-[5px] bg-light-200 dark:bg-dark-100" />
</div>
@@ -134,13 +134,13 @@ export default function PublicBoardView() {
</div>
<div className="scrollbar-w-none scrollbar-track-rounded-[4px] scrollbar-thumb-rounded-[4px] scrollbar-h-[8px] relative h-full flex-1 overflow-y-hidden overflow-x-scroll overscroll-contain scrollbar scrollbar-track-light-200 scrollbar-thumb-light-400 dark:scrollbar-track-dark-100 dark:scrollbar-thumb-dark-300">
{isLoading ? (
{isLoading || !router.isReady ? (
<div className="ml-[2rem] flex">
<div className="0 mr-5 h-[500px] w-[18rem] animate-pulse rounded-md bg-light-200 dark:bg-dark-100" />
<div className="0 mr-5 h-[275px] w-[18rem] animate-pulse rounded-md bg-light-200 dark:bg-dark-100" />
<div className="0 mr-5 h-[375px] w-[18rem] animate-pulse rounded-md bg-light-200 dark:bg-dark-100" />
</div>
) : !data ? (
) : !data && !isLoading && router.isReady && !!boardSlug ? (
<div className="z-10 flex h-full w-full flex-col items-center justify-center space-y-8 pb-[150px]">
<div className="flex flex-col items-center">
<HiOutlineLockClosed className="h-10 w-10 text-light-800 dark:text-dark-800" />