import { open } from '@tauri-apps/plugin-dialog'; import React, { useState } from 'react'; import { useLocalStorage } from 'react-use'; import { useThemes } from '../../hooks/useThemes'; import { capitalize } from '../../lib/capitalize'; import { invokeCmd } from '../../lib/tauri'; import { yaakDark } from '../../lib/theme/themes/yaak'; import { getThemeCSS } from '../../lib/theme/window'; import { Banner } from '../core/Banner'; import { Button } from '../core/Button'; import { Editor } from '../core/Editor'; import type { IconProps } from '../core/Icon'; import { Icon } from '../core/Icon'; import { IconButton } from '../core/IconButton'; import { InlineCode } from '../core/InlineCode'; import { Input } from '../core/Input'; import { Separator } from '../core/Separator'; import { HStack, VStack } from '../core/Stacks'; const buttonColors = [ 'primary', 'secondary', 'info', 'success', 'warning', 'danger', 'default', ] as const; const icons: IconProps['icon'][] = [ 'info', 'box', 'update', 'alert', 'arrowBigRightDash', 'download', 'copy', 'magicWand', 'settings', 'trash', 'sparkles', 'pencil', 'paste', 'search', 'sendHorizontal', ]; export function SettingsDesign() { const themes = useThemes(); const [exportDir, setExportDir] = useLocalStorage('theme_export_dir', null); const [loadingExport, setLoadingExport] = useState(false); const saveThemes = () => { setLoadingExport(true); setTimeout(async () => { const allThemesCSS = themes.themes.map(getThemeCSS).join('\n\n'); const coreThemeCSS = [yaakDark].map(getThemeCSS).join('\n\n'); try { await invokeCmd('cmd_write_file_dev', { pathname: exportDir + '/themes-all.css', contents: allThemesCSS, }); await invokeCmd('cmd_write_file_dev', { pathname: exportDir + '/themes-slim.css', contents: coreThemeCSS, }); } catch (err) { console.log('FAILED', err); } setLoadingExport(false); }, 500); }; return (
{exportDir} } />
{buttonColors.map((c, i) => ( ))}
{buttonColors.map((c, i) => ( ))}
{icons.map((v, i) => ( ))}
Primary banner Secondary banner Danger banner Warning banner Success banner
); }