diff --git a/src/components/continue-learning.tsx b/src/components/continue-learning.tsx new file mode 100644 index 0000000..00bc246 --- /dev/null +++ b/src/components/continue-learning.tsx @@ -0,0 +1,43 @@ +import { useEffect, useState } from "react"; +import { ArrowRight } from "lucide-react"; +import { getLearnProgress, type LearnProgress } from "@/lib/learn-progress"; +import { cn } from "@/lib/utils"; + +/** + * Renders only when localStorage already has a learn path. + * First visit stays empty — never a decorative Continue chip. + */ +export function ContinueLearningChip({ + hideIfPath, + className, +}: { + hideIfPath?: string; + className?: string; +}) { + const [progress, setProgress] = useState(null); + + useEffect(() => { + const next = getLearnProgress(); + if (next && hideIfPath && next.path === hideIfPath) { + setProgress(null); + return; + } + setProgress(next); + }, [hideIfPath]); + + if (!progress) return null; + + return ( + + Continue Learning + · {progress.title} + + + ); +} diff --git a/src/components/site-chrome.tsx b/src/components/site-chrome.tsx index 2a16a22..3f87ffe 100644 --- a/src/components/site-chrome.tsx +++ b/src/components/site-chrome.tsx @@ -1,21 +1,20 @@ -import type { ReactNode } from "react"; +import { useEffect, type ReactNode } from "react"; import { Link } from "@tanstack/react-router"; import { BrandMark } from "@/components/brand-mark"; import { SupportNudge } from "@/components/support-nudge"; import { BRAND, NAV_LINKS } from "@/lib/brand"; +import { markLearnProgress } from "@/lib/learn-progress"; import { LEARNING_PATH } from "@/lib/learning-path"; import { cn } from "@/lib/utils"; /** Marketing / docs chrome — shipx402.com product site */ -export function SiteChrome({ - children, - activePath, -}: { - children: ReactNode; - activePath?: string; -}) { +export function SiteChrome({ children, activePath }: { children: ReactNode; activePath?: string }) { const guideLinks = LEARNING_PATH.filter((i) => i.path.startsWith("/guides/")); + useEffect(() => { + if (activePath) markLearnProgress(activePath); + }, [activePath]); + return (
-