Skip to content

Commit

Permalink
Improve jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
jzempel committed Jan 16, 2025
1 parent 11478e0 commit 248b92f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/theming/src/elements/ColorSchemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import React, {
useMemo,
useState
} from 'react';
import PropTypes from 'prop-types';
import {
ColorScheme,
IColorSchemeContext,
Expand All @@ -23,7 +24,7 @@ import {
const mediaQuery =
typeof window === 'undefined' ? undefined : window.matchMedia('(prefers-color-scheme: dark)');

const useColorScheme = (initialState?: ColorScheme, colorSchemeKey = 'color-scheme') => {
const useColorScheme = (initialState: ColorScheme, colorSchemeKey: string) => {
/* eslint-disable-next-line n/no-unsupported-features/node-builtins */
const localStorage = typeof window === 'undefined' ? undefined : window.localStorage;

Expand Down Expand Up @@ -59,8 +60,8 @@ export const ColorSchemeContext = createContext<IColorSchemeContext | undefined>

export const ColorSchemeProvider = ({
children,
colorSchemeKey,
initialColorScheme
colorSchemeKey = 'color-scheme',
initialColorScheme = 'system'
}: PropsWithChildren<IColorSchemeProviderProps>) => {
const { isSystem, colorScheme, setColorScheme } = useColorScheme(
initialColorScheme,
Expand Down Expand Up @@ -91,3 +92,8 @@ export const ColorSchemeProvider = ({

return <ColorSchemeContext.Provider value={contextValue}>{children}</ColorSchemeContext.Provider>;
};

ColorSchemeProvider.propTypes = {
colorSchemeKey: PropTypes.string,
initialColorScheme: PropTypes.oneOf(['light', 'dark', 'system'])
};

0 comments on commit 248b92f

Please sign in to comment.