feat: add demo mode feature flag using Redacted Script font
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
import { Link, useMatchRoute } from "@tanstack/react-router";
|
||||
import { motion } from "framer-motion";
|
||||
import { Boxes, Brain, ChevronRight, LayoutDashboard, Moon, Settings, Sun } from "lucide-react";
|
||||
import {
|
||||
Boxes,
|
||||
Brain,
|
||||
ChevronRight,
|
||||
Eye,
|
||||
EyeOff,
|
||||
LayoutDashboard,
|
||||
Moon,
|
||||
Settings,
|
||||
Sun,
|
||||
} from "lucide-react";
|
||||
import { useDemo } from "@/hooks/useDemo";
|
||||
import { useTheme } from "@/hooks/useTheme";
|
||||
import { loadConfig } from "@/lib/config";
|
||||
import { COLOR } from "@/lib/constants";
|
||||
@@ -15,6 +26,7 @@ export function Sidebar() {
|
||||
const matchRoute = useMatchRoute();
|
||||
const config = loadConfig();
|
||||
const { theme, toggle } = useTheme();
|
||||
const { demo, toggle: toggleDemo } = useDemo();
|
||||
|
||||
return (
|
||||
<motion.aside
|
||||
@@ -110,23 +122,42 @@ export function Sidebar() {
|
||||
<p className="text-xs font-mono hidden sm:block" style={{ color: "var(--text-4)" }}>
|
||||
API v3
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={toggle}
|
||||
className="w-7 h-7 rounded-md flex items-center justify-center transition-colors mx-auto sm:mx-0"
|
||||
style={{
|
||||
background: "var(--surface)",
|
||||
border: "1px solid var(--border)",
|
||||
color: "var(--text-3)",
|
||||
}}
|
||||
title={theme === "dark" ? "Switch to light mode" : "Switch to dark mode"}
|
||||
>
|
||||
{theme === "dark" ? (
|
||||
<Sun className="w-3.5 h-3.5" strokeWidth={1.5} />
|
||||
) : (
|
||||
<Moon className="w-3.5 h-3.5" strokeWidth={1.5} />
|
||||
)}
|
||||
</button>
|
||||
<div className="flex items-center gap-1.5 mx-auto sm:mx-0">
|
||||
<button
|
||||
type="button"
|
||||
onClick={toggleDemo}
|
||||
className="w-7 h-7 rounded-md flex items-center justify-center transition-colors"
|
||||
style={{
|
||||
background: demo ? "var(--accent-dim)" : "var(--surface)",
|
||||
border: `1px solid ${demo ? "var(--accent-border)" : "var(--border)"}`,
|
||||
color: demo ? "var(--accent-text)" : "var(--text-3)",
|
||||
}}
|
||||
title={demo ? "Disable demo mode" : "Enable demo mode"}
|
||||
>
|
||||
{demo ? (
|
||||
<EyeOff className="w-3.5 h-3.5" strokeWidth={1.5} />
|
||||
) : (
|
||||
<Eye className="w-3.5 h-3.5" strokeWidth={1.5} />
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={toggle}
|
||||
className="w-7 h-7 rounded-md flex items-center justify-center transition-colors"
|
||||
style={{
|
||||
background: "var(--surface)",
|
||||
border: "1px solid var(--border)",
|
||||
color: "var(--text-3)",
|
||||
}}
|
||||
title={theme === "dark" ? "Switch to light mode" : "Switch to dark mode"}
|
||||
>
|
||||
{theme === "dark" ? (
|
||||
<Sun className="w-3.5 h-3.5" strokeWidth={1.5} />
|
||||
) : (
|
||||
<Moon className="w-3.5 h-3.5" strokeWidth={1.5} />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</motion.aside>
|
||||
);
|
||||
|
||||
16
packages/web/src/hooks/useDemo.ts
Normal file
16
packages/web/src/hooks/useDemo.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { applyDemoMode, getDemoMode } from "@/lib/demo";
|
||||
|
||||
export function useDemo() {
|
||||
const [demo, setDemo] = useState<boolean>(() => getDemoMode());
|
||||
|
||||
useEffect(() => {
|
||||
applyDemoMode(demo);
|
||||
}, [demo]);
|
||||
|
||||
function toggle() {
|
||||
setDemo((d) => !d);
|
||||
}
|
||||
|
||||
return { demo, toggle };
|
||||
}
|
||||
@@ -5,6 +5,23 @@
|
||||
@import "@fontsource/dm-sans/500.css";
|
||||
@import "@fontsource/dm-sans/600.css";
|
||||
|
||||
/* Redacted font — loaded on demand for demo mode */
|
||||
@font-face {
|
||||
font-family: "Redacted Script";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src:
|
||||
url("https://cdn.jsdelivr.net/gh/christiannaths/redacted-font@0.0.2/fonts/web/redacted-script-regular.woff2")
|
||||
format("woff2"),
|
||||
url("https://cdn.jsdelivr.net/gh/christiannaths/redacted-font@0.0.2/fonts/web/redacted-script-regular.woff")
|
||||
format("woff");
|
||||
}
|
||||
|
||||
[data-demo="true"] *:not(svg):not(path):not(circle):not(line):not(polyline):not(rect):not(polygon) {
|
||||
font-family: "Redacted Script", cursive !important;
|
||||
}
|
||||
|
||||
/* ─── Tailwind v4 theme bridge ─── */
|
||||
@theme inline {
|
||||
--color-background: var(--bg);
|
||||
|
||||
10
packages/web/src/lib/demo.ts
Normal file
10
packages/web/src/lib/demo.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
const DEMO_KEY = "openconcho:demo";
|
||||
|
||||
export function getDemoMode(): boolean {
|
||||
return localStorage.getItem(DEMO_KEY) === "true";
|
||||
}
|
||||
|
||||
export function applyDemoMode(enabled: boolean): void {
|
||||
document.documentElement.setAttribute("data-demo", String(enabled));
|
||||
localStorage.setItem(DEMO_KEY, String(enabled));
|
||||
}
|
||||
@@ -2,9 +2,12 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { createRouter, RouterProvider } from "@tanstack/react-router";
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { applyDemoMode, getDemoMode } from "@/lib/demo";
|
||||
import { routeTree } from "./routeTree.gen";
|
||||
import "./index.css";
|
||||
|
||||
applyDemoMode(getDemoMode());
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
|
||||
Reference in New Issue
Block a user