Skip to content

Commit

Permalink
[FE] FIX: updateLocalStorageDisplayStyleToggle 생성 & 적용 #1649
Browse files Browse the repository at this point in the history
  • Loading branch information
jnkeniaem committed Dec 19, 2024
1 parent 4301c42 commit 15bba7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ const toggleList: IToggleItemSeparated[] = [
},
];

export const updateLocalStorageDisplayStyleToggle = (
toggleType: DisplayStyleToggleType
) => {
localStorage.setItem("display-style-toggle", toggleType);
};

const DisplayStyleCard = () => {
const [toggleType, setToggleType] = useRecoilState(displayStyleState);

const handleButtonClick = (key: DisplayStyleToggleType) => {
if (toggleType === key) return;
setToggleType(key);
localStorage.setItem("display-style-toggle", key);
updateLocalStorageDisplayStyleToggle(key);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCallback, useEffect, useState } from "react";
import { useRecoilState } from "recoil";
import styled from "styled-components";
import { displayStyleState } from "@/Cabinet/recoil/atoms";
import { updateLocalStorageDisplayStyleToggle } from "@/Cabinet/components/Card/DisplayStyleCard/DisplayStyleCard";
import { getInitialDisplayStyle } from "@/Cabinet/components/Card/DisplayStyleCard/DisplayStyleCard.container";
import {
getDisplayStyleFromLocalStorage,
Expand Down Expand Up @@ -69,7 +70,7 @@ const DarkModeToggleSwitch = ({ id }: { id: string }) => {
: DisplayStyleToggleType.LIGHT;
}

localStorage.setItem("display-style-toggle", newToggleType);
updateLocalStorageDisplayStyleToggle(newToggleType);
setDisplayStyleToggle(newToggleType);
}, [displayStyleType]);

Expand Down

0 comments on commit 15bba7a

Please sign in to comment.