import React from 'react'; import { useActiveWorkspace } from '../../hooks/useActiveWorkspace'; import { useResolvedAppearance } from '../../hooks/useResolvedAppearance'; import { useResolvedTheme } from '../../hooks/useResolvedTheme'; import { useSettings } from '../../hooks/useSettings'; import { useThemes } from '../../hooks/useThemes'; import { useUpdateSettings } from '../../hooks/useUpdateSettings'; import { trackEvent } from '../../lib/analytics'; import { clamp } from '../../lib/clamp'; import { isThemeDark } from '../../lib/theme/window'; import type { ButtonProps } from '../core/Button'; import { Editor } from '../core/Editor'; import type { IconProps } from '../core/Icon'; import { IconButton } from '../core/IconButton'; import { PlainInput } from '../core/PlainInput'; import type { SelectOption } from '../core/Select'; import { Select } from '../core/Select'; import { Separator } from '../core/Separator'; import { HStack, VStack } from '../core/Stacks'; const buttonColors: ButtonProps['color'][] = [ 'primary', 'info', 'success', 'notice', 'warning', 'danger', 'secondary', 'default', ]; const icons: IconProps['icon'][] = [ 'info', 'box', 'update', 'alert', 'arrowBigRightDash', 'download', 'copy', 'magicWand', 'settings', 'trash', 'sparkles', 'pencil', 'paste', 'search', 'sendHorizontal', ]; export function SettingsAppearance() { const workspace = useActiveWorkspace(); const settings = useSettings(); const updateSettings = useUpdateSettings(); const appearance = useResolvedAppearance(); const { themes } = useThemes(); const activeTheme = useResolvedTheme(); if (settings == null || workspace == null) { return null; } const lightThemes: SelectOption[] = themes .filter((theme) => !isThemeDark(theme)) .map((theme) => ({ label: theme.name, value: theme.id, })); const darkThemes: SelectOption[] = themes .filter((theme) => isThemeDark(theme)) .map((theme) => ({ label: theme.name, value: theme.id, })); return ( parseInt(value) >= 8 && parseInt(value) <= 30} onChange={(v) => updateSettings.mutate({ ...settings, interfaceFontSize: clamp(parseInt(v) || 16, 8, 30), }) } /> parseInt(value) >= 8 && parseInt(value) <= 30} onChange={(v) => updateSettings.mutate({ ...settings, editorFontSize: clamp(parseInt(v) || 14, 8, 30), }) } /> { await updateSettings.mutateAsync({ ...settings, themeLight }); trackEvent('setting', 'update', { themeLight }); }} /> )} {(settings.appearance === 'system' || settings.appearance === 'dark') && (