Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/components/common/layout/LoginButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Popover } from '@/components/common/Popover';
import { UserAvatar } from '@/components/common/UserAvatar';
import { useAuthStore } from '@/stores/authStore';
import { useHomeStore } from '@/stores/homeStore';
import { useThemeStore } from '@/stores/themeStore';
import { isAnonymousEmail } from '@/utils/auth';
import { showToast } from '@/utils/toast';
import { getUserDisplayName } from '@/utils/user';
Expand All @@ -32,6 +33,8 @@ export function LoginButton() {
const openLoginModal = useAuthStore((s) => s.openLoginModal);
const logout = useAuthStore((s) => s.logout);
const resetHome = useHomeStore((s) => s.reset);
const resolvedTheme = useThemeStore((s) => s.resolvedTheme);
const setTheme = useThemeStore((s) => s.setTheme);

const [isWithdrawModalOpen, setIsWithdrawModalOpen] = useState(false);
const [isWithdrawing, setIsWithdrawing] = useState(false);
Expand Down Expand Up @@ -111,6 +114,32 @@ export function LoginButton() {
</div>

<div className="mt-2 border-t border-gray-200 pt-2">
<button
type="button"
className="flex w-full items-center justify-between rounded-lg px-3 py-2.5 text-left transition-colors hover:bg-gray-100"
onClick={() => setTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}
>
<div>
<p className="text-body-s-bold text-gray-800">다크모드</p>
<p className="text-caption text-gray-600">
{resolvedTheme === 'dark' ? '현재 다크모드 사용 중' : '현재 라이트모드 사용 중'}
</p>
</div>
<span
className={`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${
resolvedTheme === 'dark' ? 'bg-main' : 'bg-gray-300'
}`}
>
<span
className={`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${
resolvedTheme === 'dark' ? 'translate-x-6' : 'translate-x-1'
}`}
/>
</span>
Comment on lines +128 to +138
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and align with the project's convention of using clsx for conditional class names, it's recommended to refactor the className attributes. This avoids template literals for dynamic classes, making the code cleaner and more maintainable.

Make sure to import clsx at the top of the file:

import clsx from 'clsx';
                <span
                  className={clsx(
                    'relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors',
                    resolvedTheme === 'dark' ? 'bg-main' : 'bg-gray-300',
                  )}
                >
                  <span
                    className={clsx(
                      'inline-block h-4 w-4 transform rounded-full bg-white transition-transform',
                      resolvedTheme === 'dark' ? 'translate-x-6' : 'translate-x-1',
                    )}
                  />
                </span>
References
  1. Extract complex or repetitive conditional className logic into a helper function, using utilities like clsx to improve readability and maintainability.

</button>
</div>

<div className="mt-1 border-t border-gray-200 pt-2">
<button
type="button"
className="flex w-full items-center justify-between rounded-lg px-3 py-2.5 text-left text-body-s text-gray-800 transition-colors hover:bg-gray-100"
Expand Down
Loading