import React, {useContext, useEffect, useState} from 'react'; import {darkTheme, lightTheme, ThemeContext} from "../contexts/contexts"; import { Accordion as ACCORDION, Button as BUTTON, Form as FORM, FormField as FORM_FIELD, FormGroup as FORM_GROUP, FormInput as FORM_INPUT, Header as HEADER, Icon as ICON, Loader as LOADER, Menu as MENU, Placeholder as PLACEHOLDER, Popup as POPUP, Progress as PROGRESS, Segment as SEGMENT, Statistic as STATISTIC, StatisticGroup as STATISTIC_GROUP, Tab as TAB, Table as TABLE, TabPane as TAB_PANE, TextArea as TEXTAREA } from "semantic-ui-react"; export function ThemeWrapper(props) { const [i, setI] = useState({}); const [s, setS] = useState({}); const [t, setT] = useState({}); const [theme, setTheme] = useState(); const setDarkTheme = () => { console.debug('setDarkTheme'); setI({inverted: true}); setS({style: {backgroundColor: '#1B1C1D', color: '#dddddd'}}); setT({style: {color: '#dddddd'}}); setTheme(darkTheme); document.body.style.background = '#1B1C1D'; } const setLightTheme = () => { console.debug('setLightTheme'); setI({inverted: undefined}); setS({}); setT({}); setTheme(lightTheme); document.body.style.background = '#FFFFFF'; } useEffect(() => { window.matchMedia('(prefers-color-scheme: dark)').matches && setDarkTheme(); window.matchMedia('(prefers-color-scheme: dark)').addEventListener( 'change', (e) => e.matches && setDarkTheme()); window.matchMedia('(prefers-color-scheme: light)').addEventListener( 'change', (e) => e.matches && setLightTheme()); }, []); const themeValue = {i, s, t, theme, setDarkTheme, setLightTheme}; return {props.children} } // Simple wrappers for Semantic UI elements to use the current theme. const invertedNull = (props) => { if (props['inverted'] === true) { props['inverted'] = null; } return props; } export function Button(props) { const {i} = useContext(ThemeContext); props = {...i, ...props}; return