import "./ToolIcon.scss"; import React from "react"; import { t } from "../i18n"; import { ToolButton } from "./ToolButton"; import { THEME } from "../constants"; import { Theme } from "../element/types"; // We chose to use only explicit toggle and not a third option for system value, // but this could be added in the future. export const DarkModeToggle = (props: { value: Theme; onChange: (value: Theme) => void; title?: string; }) => { const title = props.title || (props.value === "dark" ? t("buttons.lightMode") : t("buttons.darkMode")); return ( props.onChange(props.value === THEME.DARK ? THEME.LIGHT : THEME.DARK) } data-testid="toggle-dark-mode" /> ); }; const ICONS = { SUN: ( ), MOON: ( ), };