import { patchModel, settingsAtom } from '@yaakapp-internal/models'; import { useAtomValue } from 'jotai'; import React from 'react'; import { activeWorkspaceAtom } from '../../hooks/useActiveWorkspace'; import { useResolvedAppearance } from '../../hooks/useResolvedAppearance'; import { useResolvedTheme } from '../../hooks/useResolvedTheme'; import { getThemes } from '../../lib/theme/themes'; import { isThemeDark } from '../../lib/theme/window'; import type { ButtonProps } from '../core/Button'; import { Editor } from '../core/Editor/Editor'; import type { IconProps } from '../core/Icon'; import { Icon } from '../core/Icon'; import { IconButton } from '../core/IconButton'; import { Select } from '../core/Select'; import type { SelectProps } from '../core/Select'; 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_triangle', 'arrow_big_right_dash', 'download', 'copy', 'magic_wand', 'settings', 'trash', 'sparkles', 'pencil', 'paste', 'search', 'send_horizontal', ]; const { themes } = getThemes(); export function SettingsTheme() { const workspace = useAtomValue(activeWorkspaceAtom); const settings = useAtomValue(settingsAtom); const appearance = useResolvedAppearance(); const activeTheme = useResolvedTheme(); if (settings == null || workspace == null) { return null; } const lightThemes: SelectProps['options'] = themes .filter((theme) => !isThemeDark(theme)) .map((theme) => ({ label: theme.name, value: theme.id, })); const darkThemes: SelectProps['options'] = themes .filter((theme) => isThemeDark(theme)) .map((theme) => ({ label: theme.name, value: theme.id, })); return ( } name="lightTheme" label="Light Theme" size="sm" className="flex-1" value={activeTheme.light.id} options={lightThemes} onChange={(themeLight) => patchModel(settings, { themeLight })} /> )} {(settings.appearance === 'system' || settings.appearance === 'dark') && (