()
| 2 | import PropTypes from 'prop-types'; |
| 3 | |
| 4 | const getInitialTheme = () => { |
| 5 | if (typeof window !== 'undefined' && window.localStorage) { |
| 6 | const storedPrefs = window.localStorage.getItem('color-theme'); |
| 7 | if (typeof storedPrefs === 'string') { |
| 8 | return storedPrefs; |
| 9 | } |
| 10 | const userMedia = window.matchMedia('(prefers-color-scheme: dark)'); |
| 11 | if (userMedia?.matches) { |
| 12 | return 'dark'; |
| 13 | } |
| 14 | } |
| 15 | // If you want to use dark theme as the default, return 'dark' instead |
| 16 | return 'light'; |
| 17 | }; |
| 18 | |
| 19 | export const ThemeContext = React.createContext(); |
| 20 |
nothing calls this directly
no outgoing calls
no test coverage detected