import axios from 'axios'; import { CSSProperties, useContext, useEffect, useState } from 'react'; import { userPreferences } from '../api/api'; import PreferencesContext from '../components/preferencesContext'; import { Button } from './ui'; type previewThemeColors = { bg: string; fg: string; a: string; b: string; }; export type themeInfo = { name: string; url: string; dark: previewThemeColors; light: previewThemeColors; }; export type themeJSON = themeInfo[]; export default function ThemePicker(props: { preferences?: userPreferences; }) { var { preferences, updatePreference } = useContext(PreferencesContext); var [themes, setThemes] = useState([]); useEffect(() => { axios.request({ method: 'get', url: '/themes/themes.json', }).then(response => { setThemes(response.data); }).catch(err => { console.error(err); }); }, []); return <> {themes.map(theme => updatePreference({ theme })} /> )} ; } export function ThemeCard(props: { theme: themeInfo; dark?: boolean; setTheme: (theme: string) => void; }) { var mode = props.dark ? 'dark' : 'light'; return
; }