import { Text } from "preact-i18n"; import styles from "./Panes.module.scss"; import { debounce } from "../../../lib/debounce"; import Button from "../../../components/ui/Button"; import InputBox from "../../../components/ui/InputBox"; import { connectState } from "../../../redux/connector"; import { WithDispatcher } from "../../../redux/reducers"; import TextAreaAutoSize from "../../../lib/TextAreaAutoSize"; import ColourSwatches from "../../../components/ui/ColourSwatches"; import { EmojiPacks, Settings } from "../../../redux/reducers/settings"; import { Theme, ThemeContext, ThemeOptions } from "../../../context/Theme"; import { useCallback, useContext, useEffect, useState } from "preact/hooks"; import { useIntermediate } from "../../../context/intermediate/Intermediate"; // @ts-ignore import pSBC from 'shade-blend-color'; import lightSVG from '../assets/light.svg'; import darkSVG from '../assets/dark.svg'; import mutantSVG from '../assets/mutant_emoji.svg'; import notoSVG from '../assets/noto_emoji.svg'; import openmojiSVG from '../assets/openmoji_emoji.svg'; import twemojiSVG from '../assets/twemoji_emoji.svg'; import CollapsibleSection from "../../../components/common/CollapsibleSection"; interface Props { settings: Settings; } // ! FIXME: code needs to be rewritten to fix jittering export function Component(props: Props & WithDispatcher) { const theme = useContext(ThemeContext); const { writeClipboard, openScreen } = useIntermediate(); function setTheme(theme: ThemeOptions) { props.dispatcher({ type: "SETTINGS_SET_THEME", theme }); } function pushOverride(custom: Partial) { props.dispatcher({ type: "SETTINGS_SET_THEME_OVERRIDE", custom }); } function setAccent(accent: string) { setOverride({ accent, "scrollbar-thumb": pSBC(-0.2, accent) }); } const emojiPack = props.settings.appearance?.emojiPack ?? 'mutant'; function setEmojiPack(emojiPack: EmojiPacks) { props.dispatcher({ type: 'SETTINGS_SET_APPEARANCE', options: { emojiPack } }); } const setOverride = useCallback(debounce(pushOverride, 200), []) as ( custom: Partial ) => void; const [ css, setCSS ] = useState(props.settings.theme?.custom?.css ?? ''); useEffect(() => setOverride({ css }), [ css ]); const selected = props.settings.theme?.preset ?? "dark"; return (

selected !== "light" && setTheme({ preset: "light" }) } />

selected !== "dark" && setTheme({ preset: "dark" }) } />

{/*

} checked > } disabled >
*/}

setEmojiPack('mutant')} data-active={emojiPack === 'mutant'}>

Mutant Remix (by Revolt)

setEmojiPack('twemoji')} data-active={emojiPack === 'twemoji'}>

Twemoji

setEmojiPack('openmoji')} data-active={emojiPack === 'openmoji'}>

Openmoji

setEmojiPack('noto')} data-active={emojiPack === 'noto'}>

Noto Emoji

}>

{[ "accent", "background", "foreground", "primary-background", "primary-header", "secondary-background", "secondary-foreground", "secondary-header", "tertiary-background", "tertiary-foreground", "block", "message-box", "mention", "sidebar-active", "scrollbar-thumb", "scrollbar-track", "status-online", "status-away", "status-busy", "status-streaming", "status-invisible", "success", "warning", "error", "hover" ].map(x => (
{x}
setOverride({ [x]: v.currentTarget.value }) } />
setOverride({ [x]: y.currentTarget.value }) } />
))}

setCSS(ev.currentTarget.value)} />
); } export const Appearance = connectState( Component, state => { return { settings: state.settings }; }, true );