@emotion/react#ThemeProvider JavaScript Examples

The following examples show how to use @emotion/react#ThemeProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: layout.js    From velocitypowered.com with MIT License 6 votes vote down vote up
export default function Layout(props) {
  const [themeName, setThemeName] = useState(undefined)
  useEffect(() => {
    const root = window.document.documentElement;
    const seenColorMode = root.style.getPropertyValue('--initial-color-mode');
    if (seenColorMode) {
      setThemeName(seenColorMode);
    }
  }, [])
  useEffect(() => {
    if (typeof themeName !== 'undefined') {
      setupThemeProperties(themes[themeName]);
      localStorage.setItem('__velocity_preferred_theme', themeName);
    }
  }, [themeName])

  const theme = themes[typeof themeName === 'undefined' ? 'dark' : themeName]
  const injectedProps = { themeName, setThemeName, ...props }
  return (
    <ThemeProvider theme={theme} >
      <LayoutChildren {...injectedProps} />
    </ThemeProvider>
  )
}
Example #2
Source File: App.js    From aava.sh with MIT License 6 votes vote down vote up
function App() {
  return (
     <ThemeProvider theme={darkMode}>
        <Global styles={globalCss}/>
        <TitleBar/>
        <Clock/>
        <Prompts/>
    </ThemeProvider>
    );
}
Example #3
Source File: index.js    From SimpleWeather with MIT License 6 votes vote down vote up
ReactDOM.render(
    <Provider store={store}>
        <ThemeProvider theme={theme}>
            <BrowserRouter basename='/SimpleWeather'>
                <App/>
            </BrowserRouter>
        </ThemeProvider>
    </Provider>,
    rootElement
)