import { Brush } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { Link } from "react-router-dom"; // @ts-expect-error shade-blend-color does not have typings. import pSBC from "shade-blend-color"; import { Text } from "preact-i18n"; import TextAreaAutoSize from "../../lib/TextAreaAutoSize"; import { useApplicationState } from "../../mobx/State"; import { Fonts, FONTS, FONT_KEYS, MonospaceFonts, MONOSPACE_FONTS, MONOSPACE_FONT_KEYS, } from "../../context/Theme"; import Checkbox from "../ui/Checkbox"; import ColourSwatches from "../ui/ColourSwatches"; import ComboBox from "../ui/ComboBox"; import Radio from "../ui/Radio"; import CategoryButton from "../ui/fluent/CategoryButton"; import { EmojiSelector } from "./appearance/EmojiSelector"; import { ThemeBaseSelector } from "./appearance/ThemeBaseSelector"; /** * Component providing a way to switch the base theme being used. */ export const ThemeBaseSelectorShim = observer(() => { const theme = useApplicationState().settings.theme; return ( { theme.setBase(base); theme.reset(); }} /> ); }); /** * Component providing a link to the theme shop. * Only appears if experiment is enabled. * TODO: stabilise */ export const ThemeShopShim = () => { return ( } action="chevron" description={ } hover> ); }; /** * Component providing a way to change current accent colour. */ export const ThemeAccentShim = observer(() => { const theme = useApplicationState().settings.theme; return ( <>

{ theme.setVariable("accent", colour as string); theme.setVariable("scrollbar-thumb", pSBC(-0.2, colour)); }} /> ); }); /** * Component providing a way to edit custom CSS. */ export const ThemeCustomCSSShim = observer(() => { const theme = useApplicationState().settings.theme; return ( <>

theme.setCSS(ev.currentTarget.value)} /> ); }); /** * Component providing a way to switch between compact and normal message view. */ export const DisplayCompactShim = () => { // TODO: WIP feature return ( <>

} checked> } disabled>
); }; /** * Component providing a way to change primary text font. */ export const DisplayFontShim = observer(() => { const theme = useApplicationState().settings.theme; return ( <>

theme.setFont(e.currentTarget.value as Fonts)}> {FONT_KEYS.map((key) => ( ))} ); }); /** * Component providing a way to change secondary, monospace text font. */ export const DisplayMonospaceFontShim = observer(() => { const theme = useApplicationState().settings.theme; return ( <>

theme.setMonospaceFont( e.currentTarget.value as MonospaceFonts, ) }> {MONOSPACE_FONT_KEYS.map((key) => ( ))} ); }); /** * Component providing a way to toggle font ligatures. */ export const DisplayLigaturesShim = observer(() => { const settings = useApplicationState().settings; if (settings.theme.getFont() !== "Inter") return null; return ( <> settings.set("appearance:ligatures", v)} description={ }> ); }); /** * Component providing a way to toggle seasonal themes. */ export const DisplaySeasonalShim = observer(() => { const settings = useApplicationState().settings; return ( settings.set("appearance:seasonal", v)} description={ }> ); }); /** * Component providing a way to toggle transparency effects. */ export const DisplayTransparencyShim = observer(() => { const settings = useApplicationState().settings; return ( settings.set("appearance:transparency", v)} description={ }> ); }); /** * Component providing a way to change emoji pack. */ export const DisplayEmojiShim = observer(() => { const settings = useApplicationState().settings; return ( settings.set("appearance:emoji", v)} /> ); });