Skip to content

Commit

Permalink
Merge pull request #44 from Nexters/feature/theme-switch-logging
Browse files Browse the repository at this point in the history
feat: 테마 변경 로깅 추가
  • Loading branch information
cs-shin authored Feb 21, 2025
2 parents b950957 + c88d506 commit dda65b8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/components/ResponsiveContainer/common/ThemeSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,38 @@ import { useTheme } from 'next-themes';
import { useMount } from '@/hooks/useMount';
import clsx from 'clsx';
import { Icon } from '@/assets/icons';
import useLogging from '@/hooks/useLogging';

export default function ThemeSwitch() {
const { theme, setTheme } = useTheme();
const mounted = useMount();
const { sendLog } = useLogging();

const handleThemeChange = (theme: string) => {
setTheme(theme);
sendLog({ eventName: '테마_변경', eventProperties: { 변경_테마: theme } });
};

if (!mounted) {
return null;
}

return (
<div className=" w-[100%] flex p-[0.4rem] bg-gray-200 rounded-full">
<div className="flex w-[100%] rounded-full bg-gray-200 p-[0.4rem]">
<button
onClick={() => setTheme('light')}
onClick={() => handleThemeChange('light')}
className={clsx(
'w-[100%] flex items-center justify-center px-[20px] py-[4px] gap-[6px] rounded-full',
'flex w-[100%] items-center justify-center gap-[6px] rounded-full px-[20px] py-[4px]',
theme === 'light' ? 'bg-white' : ''
)}
>
<Icon name={'LightMode'} className={theme === 'light' ? 'fill-gray-900' : 'fill-gray-500'} />
<span className={clsx('text-body-1-medium', theme === 'light' ? 'text-gray-800' : 'text-gray-500')}>Light</span>
</button>
<button
onClick={() => setTheme('dark')}
onClick={() => handleThemeChange('dark')}
className={clsx(
'w-[100%] flex items-center justify-center px-[20px] py-[4px] gap-[6px] rounded-full',
'flex w-[100%] items-center justify-center gap-[6px] rounded-full px-[20px] py-[4px]',
theme === 'dark' ? 'bg-dark' : ''
)}
>
Expand Down

0 comments on commit dda65b8

Please sign in to comment.