From 1b44edbac354a2de11380aee9a756188cf15858c Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Mon, 21 Oct 2024 10:56:15 +0900 Subject: [PATCH] feat: Add locale switch --- src/app/layout.js | 4 +++- src/components/LocaleSwitch.jsx | 23 +++++++++++++++++++++++ src/styles/style.scss | 6 +++++- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/components/LocaleSwitch.jsx diff --git a/src/app/layout.js b/src/app/layout.js index e59e28d1..64b374e8 100644 --- a/src/app/layout.js +++ b/src/app/layout.js @@ -16,6 +16,7 @@ import '../styles/style.scss' import '../styles/contents.scss' import Dimmed from '@/components/ui/Dimmed' import SessionProvider from './SessionProvider' +import LocaleSwitch from '@/components/LocaleSwitch' // const inter = Inter({ subsets: ['latin'] }) @@ -76,8 +77,9 @@ export default async function RootLayout({ children }) { diff --git a/src/components/LocaleSwitch.jsx b/src/components/LocaleSwitch.jsx new file mode 100644 index 00000000..291f2043 --- /dev/null +++ b/src/components/LocaleSwitch.jsx @@ -0,0 +1,23 @@ +'use client' + +import { globalLocaleStore } from '@/store/localeAtom' +import { useRecoilState } from 'recoil' + +export default function LocaleSwitch() { + const [globalLocale, setGlobalLocale] = useRecoilState(globalLocaleStore) + + return ( + { + if (globalLocale === 'ko') { + setGlobalLocale('ja') + } else { + setGlobalLocale('ko') + } + }} + > + {globalLocale.toUpperCase()} + + ) +} diff --git a/src/styles/style.scss b/src/styles/style.scss index 1841ebb9..39343d54 100644 --- a/src/styles/style.scss +++ b/src/styles/style.scss @@ -1 +1,5 @@ -@import '_main.scss'; \ No newline at end of file +@import '_main.scss'; + +.locale-switch { + cursor: pointer; +}