// Liquid toggle component import { LayoutTemplate, Moon, PanelsTopLeft, Sun, SunMoon } from "lucide-react"; import React, { type ComponentProps, useRef } from "react"; import { Button } from "../button"; import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip"; import { useTheme } from "./ThemeProvider"; type LiquidToggleProps = Omit, "onClick" | "children">; export const LiquidToggle: React.FC = ({ className, ...props }) => { const { isLiquid, toggleLiquid } = useTheme(); return ( {isLiquid ? "Dock Layout" : "Liquid Layout"} ); }; /** * Theme color toggle component for light/dark/system. * * Toggle behavior: * - After a timeout (1.5s): prioritizes light ↔ dark toggle * - system (resolves dark) → light → dark → light ... * - system (resolves light) → dark → light → dark ... * - light → dark → light ... * - dark → light → dark ... * - Quick clicks (within 1.5s): cycles through all three options * - light → dark → system → light ... * * This gives casual users a simple light/dark toggle, while quick * clicks still allow access to the system option. */ type ThemeColorToggleProps = Omit, "onClick" | "children">; const QUICK_TOGGLE_TIMEOUT = 1500; // ms export const ThemeColorToggle: React.FC = (props) => { const { baseTheme, setBaseTheme, resolvedTheme } = useTheme(); const lastClickRef = useRef(0); const isDark = resolvedTheme?.includes("dark"); const isSystem = baseTheme === "system"; const handleThemeChange = () => { const now = Date.now(); const timeSinceLastClick = now - lastClickRef.current; lastClickRef.current = now; const isQuickToggle = timeSinceLastClick < QUICK_TOGGLE_TIMEOUT; if (isQuickToggle) { // Quick toggle: cycle through all options, system always last if (baseTheme === "light") { setBaseTheme("dark"); } else if (baseTheme === "dark") { setBaseTheme("system"); } else { setBaseTheme("light"); } } else { // After timeout: prioritize light ↔ dark toggle, system goes to opposite if (baseTheme === "system") { // If system resolves to dark, go to light; if light, go to dark setBaseTheme(isDark ? "light" : "dark"); } else if (baseTheme === "light") { setBaseTheme("dark"); } else { setBaseTheme("light"); } } }; return ( ); };