-
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.
Feat: UI 설정 편집 기능 개발 (#DUT-575) (#65)
* Feat: 멘토링 피드백 반영 * Feat: UI 설정 편집 기능 개발
- Loading branch information
1 parent
03e20ae
commit 801ac13
Showing
19 changed files
with
344 additions
and
120 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
interface ToggleProps { | ||
isOn: boolean; | ||
setIsOn: (isOn: boolean) => void; | ||
} | ||
|
||
const Toggle = ({ isOn, setIsOn }: ToggleProps) => { | ||
const handleToggle = () => { | ||
setIsOn(!isOn); | ||
}; | ||
|
||
return ( | ||
<div | ||
onClick={handleToggle} | ||
className={`relative h-[1rem] w-[1.875rem] cursor-pointer rounded-[1rem] transition-[0.8s] ${ | ||
isOn ? 'bg-main-1' : 'bg-sub-4' | ||
}`} | ||
> | ||
<div | ||
className={`absolute top-0 h-[1rem] w-[1rem] rounded-[1rem] border-[.0625rem] bg-white transition-[0.8s] ${ | ||
isOn ? 'left-[100%] translate-x-[-100%] border-main-1' : 'left-0 border-sub-4' | ||
}`} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Toggle; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { shallow } from 'zustand/shallow'; | ||
import { useUIConfigStore } from './store'; | ||
|
||
const useUIConfig = () => { | ||
const [separateWeekendColor, shiftTypeColorStyle, setState] = useUIConfigStore( | ||
(state) => [state.separateWeekendColor, state.shiftTypeColorStyle, state.setState], | ||
shallow | ||
); | ||
|
||
const handleChangeSeparateWeekendColor = (value: boolean) => { | ||
setState('separateWeekendColor', value); | ||
}; | ||
|
||
const handleShiftTypeColorStyle = (value: typeof shiftTypeColorStyle) => { | ||
setState('shiftTypeColorStyle', value); | ||
}; | ||
|
||
return { | ||
state: { | ||
separateWeekendColor, | ||
shiftTypeColorStyle, | ||
}, | ||
actions: { | ||
handleChangeSeparateWeekendColor, | ||
handleShiftTypeColorStyle, | ||
}, | ||
}; | ||
}; | ||
|
||
export default useUIConfig; |
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,43 @@ | ||
import { create } from 'zustand'; | ||
import { devtools, persist } from 'zustand/middleware'; | ||
import { produce } from 'immer'; | ||
|
||
interface State { | ||
separateWeekendColor: boolean; | ||
shiftTypeColorStyle: 'background' | 'text'; | ||
} | ||
|
||
interface Store extends State { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
setState: (key: keyof State, value: any) => void; | ||
initState: () => void; | ||
} | ||
|
||
const initialState: State = { | ||
separateWeekendColor: false, | ||
shiftTypeColorStyle: 'background', | ||
}; | ||
|
||
export const useUIConfigStore = create<Store>()( | ||
devtools( | ||
persist( | ||
(set, get) => ({ | ||
...initialState, | ||
setState: (state, value) => | ||
set( | ||
produce(get(), (draft) => { | ||
draft[state] = value as never; | ||
}) | ||
), | ||
initState: () => set(initialState), | ||
}), | ||
{ | ||
name: 'useUIConfigStore', | ||
partialize: ({ separateWeekendColor, shiftTypeColorStyle }: Store) => ({ | ||
separateWeekendColor, | ||
shiftTypeColorStyle, | ||
}), | ||
} | ||
) | ||
) | ||
); |
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
Oops, something went wrong.