-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71d3800
commit 9993af7
Showing
16 changed files
with
85 additions
and
181 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
.../ui/src/lib-base/ui/switch.theme/index.ts → ...avigation/component/switch.theme/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import UiSwitchTheme from './switch.theme.view'; | ||
|
||
export { UiSwitchTheme }; | ||
// export * from './switch.enum'; |
3 changes: 1 addition & 2 deletions
3
...ui/switch.theme/switch.theme.interface.ts → ...nt/switch.theme/switch.theme.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
libs/features/src/lib/navigation/component/switch.theme/switch.theme.view.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { memo, ReactElement, useEffect } from 'react'; | ||
|
||
import { ThemeTypeEnum, useThemeStore } from '@pokemon-pet-shop/store'; | ||
import { IconTypeEnum, SwitchStatusEnum, UiSwitch } from '@pokemon-pet-shop/ui'; | ||
|
||
import { SwitchProps } from './switch.theme.interface'; | ||
|
||
const SwitchTheme = ({ className }: SwitchProps): ReactElement => { | ||
const { theme, updateTheme } = useThemeStore(); | ||
|
||
const updateTheming = (newTheme: ThemeTypeEnum) => { | ||
updateTheme(newTheme); | ||
const el = document.querySelector('html'); | ||
|
||
el?.classList.toggle(ThemeTypeEnum.DARK); | ||
el?.classList.toggle(ThemeTypeEnum.LIGHT); | ||
}; | ||
|
||
const turnLightOnClick = () => { | ||
updateTheming(ThemeTypeEnum.LIGHT); | ||
}; | ||
|
||
const turnDarkOnClick = () => { | ||
updateTheming(ThemeTypeEnum.DARK); | ||
}; | ||
|
||
useEffect(() => { | ||
const el = document.querySelector('html'); | ||
|
||
el?.classList.add(theme); | ||
|
||
return () => { | ||
el?.classList.remove(theme); | ||
}; | ||
}, [theme]); | ||
|
||
return ( | ||
<UiSwitch | ||
className={className} | ||
iconLeft={IconTypeEnum.ICON_SUN} | ||
iconRight={IconTypeEnum.ICON_MOON} | ||
val={theme === ThemeTypeEnum.LIGHT ? SwitchStatusEnum.ON : SwitchStatusEnum.OFF} | ||
onLeftClick={turnLightOnClick} | ||
onRightClick={turnDarkOnClick} | ||
/> | ||
); | ||
}; | ||
|
||
export default memo(SwitchTheme); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
libs/ui/src/lib-base/ui/switch.theme/switch.theme.module.css
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
libs/ui/src/lib-base/ui/switch.theme/switch.theme.module.native.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
61 changes: 0 additions & 61 deletions
61
libs/ui/src/lib-base/ui/switch.theme/switch.theme.view.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import UiSwitch from './switch.view'; | ||
|
||
export { UiSwitch }; | ||
// export * from './switch.enum'; | ||
export * from './switch.enum'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum SwitchStatusEnum { | ||
ON = 'ON', | ||
OFF = 'OFF', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.