All files / src/commands Display.tsx

75% Statements 3/4
37.5% Branches 3/8
50% Functions 1/2
75% Lines 3/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33              33x             33x   33x                                
import { useTheme } from "@/ahuora-design-system/ThemeProvider";
import { defineCommand } from "just-search-it";
import { MoonStar, Sun } from "lucide-react";
import { RegisterCommand } from "./CommandProvider";
 
type Theme = "light" | "dark";
 
const SwitchThemeCommand = defineCommand<[Theme], void>("switchTheme");
 
/***
 * Switches between light and dark theme
 * Accessible in the Search bar
 */
function SwitchThemes() {
  const { theme, setTheme } = useTheme();
 
  return (
    <>
      <RegisterCommand
        command={SwitchThemeCommand}
        args={[theme === "light" ? "dark" : "light"]}
        name={theme === "light" ? "Dark Mode" : "Light Mode"}
        description="Switches between light and dark theme"
        group="Display & flowsheet controls"
        icon={theme === "light" ? <MoonStar /> : <Sun />}
        action={() => setTheme(theme === "light" ? "dark" : "light")}
      />
    </>
  );
}
 
export { SwitchThemes };