Skip to content

Commit

Permalink
[Feature] Settings context #104: Fix casing and import issues in use-…
Browse files Browse the repository at this point in the history
…setting-context.tsx
  • Loading branch information
ballyalley-o committed Mar 31, 2024
1 parent 21390e7 commit 0d15fcf
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/component/setting/use-setting-context.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import PropTypes from 'prop-types'
import { createContext, useContext, useMemo, useCallback, ChangeEvent } from 'react'
import { createContext, useContext, useMemo, useCallback, ChangeEvent, ReactNode } from 'react'
import { useLocalStorage } from 'hook'
import { themePreset } from 'theme'
import localStorageSpace from 'util/local-storage-space'
import { KEY } from 'constant'

const initialState = {
...themePreset,
// Mode
// mode
onToggleMode: () => {},
onChangeMode: () => {},
// Direction
// direction
onToggleDirection: () => {},
onChangeDirection: () => {},
onChangeDirectionByLang: () => {},
// Layout
// layout
onToggleLayout: () => {},
onChangeLayout: () => {},
// Contrast
// contrast
onToggleContrast: () => {},
onChangeContrast: () => {},
presetOption: [],
// Reset
// reset
onResetSetting: () => {}
}

Expand All @@ -34,17 +34,17 @@ export const useSettingContext = () => {
return context
}

SettingProvider.propTypes = {
children: PropTypes.node
interface SettingProviderProps {
children: ReactNode
}

export function SettingProvider({ children }: { children: React.ReactNode }) {
export function SettingProvider({ children }: SettingProviderProps) {
const [settings, setSettings] = useLocalStorage('settings', themePreset)
const storageAvailable = localStorageSpace()
const langStorage = storageAvailable ? localStorage.getItem('i18nextLng') : ''

const onToggleMode = useCallback(() => {
const themeMode = settings.themeMode === 'light' ? 'dark' : 'light'
const themeMode = settings.themeMode === KEY.LIGHT ? KEY.DARK : KEY.LIGHT
setSettings({ ...settings, themeMode })
}, [setSettings, settings])

Expand Down

0 comments on commit 0d15fcf

Please sign in to comment.