//Dependencies import { loadSettingsConfig } from './config.mjs' // Hooks import { useContext } from 'react' import { useTranslation } from 'next-i18next' import { Popout } from 'shared/components/popout.mjs' // Context import { ModalContext } from 'shared/context/modal-context.mjs' // Components import { ModalWrapper } from 'shared/components/wrappers/modal.mjs' import { Collapse } from 'shared/components/collapse.mjs' import { HelpIcon, DesktopIcon } from 'shared/components/icons.mjs' import { ControlSettingInput, RendererSettingInput, XRaySettingInput } from './inputs.mjs' import { ControlSettingValue, RendererSettingValue, XRaySettingValue } from './values.mjs' //import { ConsoleLog } from './log.mjs' //import { XrayReset } from './reset.mjs' //import { XrayList } from './list.mjs' export const ns = ['ui-settings'] // Facilitate lookup of the value component const values = { control: ControlSettingValue, renderer: RendererSettingValue, xray: XRaySettingValue, } // Facilitate lookup of the input component const inputs = { control: ControlSettingInput, renderer: RendererSettingInput, xray: XRaySettingInput, } const wasChanged = (current, name, settingsConfig) => { if (typeof current === 'undefined') return false if (current === settingsConfig[name].dflt) return false return true } export const UiTitle = ({ name, t, changed, current = null, open = false, emoji = '' }) => (
{emoji} {t(`ui-settings:${name}.t`)} {open ? ':' : ''} {current}
) export const Setting = ({ name, config, current, update, t, settingsConfig, changed, loadDocs, control, ui, setModal, }) => { const drillProps = { name, config, current, update, t, changed, control } // Don't bother with X-Ray in SVG mode if (name === 'xray' && ui.renderer === 'svg') return null const Input = inputs[name] const Value = values[name] const buttons = [] const openButtons = [] if (loadDocs) openButtons.push( ) if (changed) { buttons.push( ) openButtons.push( ) } const titleProps = { name, t, current: , emoji: config.emoji } const boolSettings = ['sabool', 'paperless', 'details'] if (control > 4) { // Save gurus some clicks if (name === 'renderer') return ( } onClick={() => (current === 'svg' ? update.ui([name]) : update.ui([name], 'svg'))} /> ) } return ( } title={} buttons={buttons} openButtons={openButtons} > ) } export const UiSettings = ({ design, update, settings, ui, account, control, language, DynamicDocs, }) => { const { t } = useTranslation(ns) const { setModal } = useContext(ModalContext) const settingsConfig = loadSettingsConfig() const loadDocs = DynamicDocs ? (evt, setting = false) => { evt.stopPropagation() let path = `site/draft/ui-settings` if (setting) path += `/${setting}` setModal(
) } : false const openButtons = [] if (loadDocs) openButtons.push( ) const toggleXray = () => update.ui(['xray', 'enabled'], ui?.xray?.enabled ? false : true) return ( <>
{control > 4 ? (
) : ( <>
{t('ui-settings:uiSettings')}

{t('ui-settings:uiSettings.d')}

)}
{Object.keys(settingsConfig) .filter((name) => settingsConfig[name].control <= control) .map((name) => ( ))} ) }