Skip to content

Commit 5d1a3bb

Browse files
lyzno1Copilot
andauthored
refactor: replace isDark conditional logic with Tailwind dark: prefix across remaining components (iflabx#230)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent e0caca3 commit 5d1a3bb

15 files changed

Lines changed: 73 additions & 253 deletions

app/admin/page.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use client';
22

3-
import { useTheme } from '@lib/hooks/use-theme';
43
import { cn } from '@lib/utils';
54
import {
65
ArrowRight,
@@ -25,16 +24,12 @@ interface AdminCardProps {
2524
}
2625

2726
function AdminCard({ title, description, icon: Icon, href }: AdminCardProps) {
28-
const { isDark } = useTheme();
29-
3027
return (
3128
<Link
3229
href={href}
3330
className={cn(
3431
'group block rounded-xl border p-6 transition-all duration-200 hover:shadow-lg',
35-
isDark
36-
? 'hover:bg-stone-750 border-stone-700 bg-stone-800 hover:border-stone-600'
37-
: 'border-stone-200 bg-white hover:border-stone-300 hover:shadow-stone-200/50'
32+
'dark:hover:bg-stone-750 border-stone-200 bg-white hover:border-stone-300 hover:shadow-stone-200/50 dark:border-stone-700 dark:bg-stone-800 dark:hover:border-stone-600'
3833
)}
3934
>
4035
<div className="flex items-start justify-between">
@@ -79,11 +74,9 @@ function AdminCard({ title, description, icon: Icon, href }: AdminCardProps) {
7974
}
8075

8176
export default function AdminPage() {
82-
const { isDark } = useTheme();
8377
const t = useTranslations('pages.admin.main');
8478
const tLayout = useTranslations('pages.admin.layout');
8579

86-
// Admin function card configuration
8780
const adminCards: AdminCardProps[] = [
8881
{
8982
title: tLayout('menuItems.apiConfig.text'),
@@ -126,14 +119,11 @@ export default function AdminPage() {
126119
return (
127120
<div className="min-h-full">
128121
<div className="mx-auto max-w-7xl p-6">
129-
{/* Page title and description - left-aligned layout, consistent with project style */}
130122
<div className="mb-8">
131123
<h1
132124
className={cn(
133125
'mb-3 bg-gradient-to-r bg-clip-text text-4xl font-bold text-transparent',
134-
isDark
135-
? 'from-stone-100 to-stone-300'
136-
: 'from-stone-800 to-stone-600'
126+
'from-stone-800 to-stone-600 dark:from-stone-100 dark:to-stone-300'
137127
)}
138128
>
139129
{t('title')}
@@ -143,7 +133,6 @@ export default function AdminPage() {
143133
</p>
144134
</div>
145135

146-
{/* Admin function card grid - optimized layout and spacing */}
147136
<div className="grid grid-cols-1 gap-6 md:grid-cols-2">
148137
{adminCards.map(card => (
149138
<AdminCard

components/auth/social-auth-buttons.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
import { Button } from '@components/ui/button';
4-
import { useTheme } from '@lib/hooks/use-theme';
54
import { createClient } from '@lib/supabase/client';
65
import { cn } from '@lib/utils';
76

@@ -26,7 +25,6 @@ export function SocialAuthButtons({
2625
redirectTo = '/chat',
2726
className,
2827
}: SocialAuthButtonsProps) {
29-
const { isDark } = useTheme();
3028
const t = useTranslations('pages.auth.social.github');
3129

3230
const [isLoading, setIsLoading] = useState({
@@ -72,7 +70,7 @@ export function SocialAuthButtons({
7270
<div
7371
className={cn(
7472
'rounded-lg border-l-4 border-red-500 p-3 font-serif text-sm',
75-
isDark ? 'bg-red-900/30 text-red-400' : 'bg-red-50 text-red-700'
73+
'bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-400'
7674
)}
7775
>
7876
{error}
@@ -85,9 +83,7 @@ export function SocialAuthButtons({
8583
size="lg"
8684
className={cn(
8785
'relative flex h-12 w-full cursor-pointer items-center justify-center gap-3 font-serif',
88-
isDark
89-
? 'border-stone-700 bg-stone-800 text-white hover:bg-stone-700'
90-
: 'border-stone-300 bg-white text-stone-700 hover:bg-stone-50'
86+
'border-stone-300 bg-white text-stone-700 hover:bg-stone-50 dark:border-stone-700 dark:bg-stone-800 dark:text-white dark:hover:bg-stone-700'
9187
)}
9288
onClick={() => handleSocialAuth('github')}
9389
disabled={isLoading.github}

components/chat-input/button.tsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { Button as UIButton } from '@components/ui/button';
44
import { useMounted } from '@lib/hooks';
5-
import { useThemeColors } from '@lib/hooks/use-theme-colors';
65
import { cn } from '@lib/utils';
76

87
import type React from 'react';
@@ -13,7 +12,6 @@ interface ChatButtonProps {
1312
disabled?: boolean;
1413
className?: string;
1514
variant?: 'function' | 'submit';
16-
isDark?: boolean;
1715
ariaLabel: string;
1816
forceActiveStyle?: boolean;
1917
}
@@ -24,19 +22,15 @@ export const ChatButton = ({
2422
disabled = false,
2523
className,
2624
variant = 'function',
27-
isDark = false,
2825
ariaLabel,
2926
forceActiveStyle = false,
3027
}: ChatButtonProps) => {
3128
const isMounted = useMounted();
32-
// Get theme colors
33-
const { colors } = useThemeColors();
3429

3530
if (!isMounted) {
3631
return null;
3732
}
3833

39-
// Function button - with subtle gray border
4034
if (variant === 'function') {
4135
return (
4236
<UIButton
@@ -47,9 +41,7 @@ export const ChatButton = ({
4741
disabled={disabled}
4842
className={cn(
4943
'flex h-8 w-8 items-center justify-center rounded-lg',
50-
isDark
51-
? `border border-stone-600 bg-stone-600/30 ${colors.mainText.tailwind} ${colors.buttonHover.tailwind}`
52-
: 'border border-gray-200 text-gray-600 hover:bg-gray-50',
44+
'border border-gray-200 text-gray-600 hover:bg-gray-50 dark:border-stone-600 dark:bg-stone-600/30 dark:text-stone-300 dark:hover:bg-stone-700/50',
5345
'bg-transparent',
5446
'cursor-pointer',
5547
className
@@ -61,7 +53,6 @@ export const ChatButton = ({
6153
);
6254
}
6355

64-
// Submit/upload button - empty state is dark gray
6556
return (
6657
<UIButton
6758
type="button"
@@ -71,12 +62,8 @@ export const ChatButton = ({
7162
className={cn(
7263
'flex h-8 w-8 items-center justify-center rounded-full',
7364
forceActiveStyle || !disabled
74-
? isDark
75-
? 'bg-stone-900 text-white hover:bg-stone-800'
76-
: 'bg-black text-white hover:bg-gray-800'
77-
: isDark
78-
? 'bg-stone-600 text-stone-300'
79-
: 'bg-gray-200 text-gray-400',
65+
? 'bg-black text-white hover:bg-gray-800 dark:bg-stone-900 dark:hover:bg-stone-800'
66+
: 'bg-gray-200 text-gray-400 dark:bg-stone-600 dark:text-stone-300',
8067
'cursor-pointer shadow-sm',
8168
className
8269
)}

components/chat-input/container.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
'use client';
22

3-
import { useThemeColors } from '@lib/hooks/use-theme-colors';
43
import { useWelcomeLayout } from '@lib/hooks/use-welcome-layout';
54
import { cn } from '@lib/utils';
65

76
// Container component - uses intelligent layout system
87
interface ChatContainerProps {
98
children: React.ReactNode;
109
isWelcomeScreen?: boolean;
11-
isDark?: boolean;
1210
className?: string;
1311
widthClass: string;
1412
// Whether transitioning from conversation interface to welcome interface
@@ -23,13 +21,10 @@ const INPUT_BOTTOM_MARGIN = '1rem';
2321
export const ChatContainer = ({
2422
children,
2523
isWelcomeScreen = false,
26-
isDark = false,
2724
className,
2825
widthClass,
29-
isTransitioningToWelcome = false,
26+
isTransitioningToWelcome = false, // eslint-disable-line @typescript-eslint/no-unused-vars
3027
}: ChatContainerProps) => {
31-
// Get theme colors and intelligent layout position
32-
const { colors } = useThemeColors();
3328
const { input: inputPosition } = useWelcomeLayout();
3429

3530
// Base styles including absolute positioning and width
@@ -67,7 +62,7 @@ export const ChatContainer = ({
6762
<div
6863
className={cn(
6964
'flex flex-col rounded-2xl',
70-
isDark ? colors.sidebarBackground.tailwind : 'bg-white',
65+
'bg-white dark:bg-stone-800',
7166
'shadow-[0_0_15px_rgba(0,0,0,0.1)]'
7267
)}
7368
>

components/chat-input/file-type-selector.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { hideActiveTooltip } from '@components/ui/tooltip';
55
import { TooltipWrapper } from '@components/ui/tooltip-wrapper';
66
import { useFileTypes } from '@lib/hooks/use-file-types';
77
import { useMobile } from '@lib/hooks/use-mobile';
8-
import { useTheme } from '@lib/hooks/use-theme';
98
import { useAttachmentStore } from '@lib/stores/attachment-store';
109
import { cn } from '@lib/utils';
1110
import { Loader2, Paperclip } from 'lucide-react';
@@ -36,7 +35,6 @@ export const FileTypeSelector = ({
3635
className,
3736
}: FileTypeSelectorProps) => {
3837
const { fileTypes, uploadConfig, isLoading, error } = useFileTypes();
39-
const { isDark } = useTheme();
4038
const isMobile = useMobile();
4139
const [isOpen, setIsOpen] = useState(false);
4240
const attachmentFiles = useAttachmentStore(state => state.files);
@@ -128,7 +126,6 @@ export const FileTypeSelector = ({
128126
<Paperclip className="h-4 w-4" />
129127
)
130128
}
131-
isDark={isDark}
132129
ariaLabel={ariaLabel || t('fileTypeSelector.ariaLabel')}
133130
disabled={isDisabled}
134131
className={cn(
@@ -168,7 +165,7 @@ export const FileTypeSelector = ({
168165
<div
169166
className={cn(
170167
'flex items-center justify-center py-4 font-serif',
171-
isDark ? 'text-gray-400' : 'text-gray-500'
168+
'text-gray-500 dark:text-gray-400'
172169
)}
173170
>
174171
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
@@ -178,7 +175,7 @@ export const FileTypeSelector = ({
178175
<div
179176
className={cn(
180177
'px-3 py-2 font-serif text-sm',
181-
isDark ? 'text-red-300' : 'text-red-500'
178+
'text-red-500 dark:text-red-300'
182179
)}
183180
>
184181
{t('fileTypeSelector.loadError')}
@@ -187,7 +184,7 @@ export const FileTypeSelector = ({
187184
<div
188185
className={cn(
189186
'px-3 py-2 text-center font-serif text-sm',
190-
isDark ? 'text-gray-400' : 'text-gray-500'
187+
'text-gray-500 dark:text-gray-400'
191188
)}
192189
>
193190
{t('fileTypeSelector.noTypesConfigured')}
@@ -198,9 +195,7 @@ export const FileTypeSelector = ({
198195
<div
199196
className={cn(
200197
'mb-1 border-b px-3 py-1 font-serif text-xs',
201-
isDark
202-
? 'border-gray-600 text-gray-400'
203-
: 'border-gray-200 text-gray-500'
198+
'border-gray-200 text-gray-500 dark:border-gray-600 dark:text-gray-400'
204199
)}
205200
>
206201
{uploadConfig.maxFiles > 0 ? (
@@ -216,7 +211,7 @@ export const FileTypeSelector = ({
216211
<div
217212
className={cn(
218213
'mt-1 text-xs',
219-
isDark ? 'text-orange-400' : 'text-orange-600'
214+
'text-orange-600 dark:text-orange-400'
220215
)}
221216
>
222217
{t('fileTypeSelector.reachedLimit', {
@@ -242,7 +237,7 @@ export const FileTypeSelector = ({
242237
<span
243238
className={cn(
244239
'font-serif text-xs',
245-
isDark ? 'text-gray-400' : 'text-gray-500'
240+
'text-gray-500 dark:text-gray-400'
246241
)}
247242
>
248243
{type.maxSize}

components/chat-input/index.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export const ChatInput = ({
103103
isComposing,
104104
setIsComposing,
105105
isWelcomeScreen,
106-
isDark,
107106
} = useChatInputStore();
108107

109108
// 🎯 New: Local submission state to prevent duplicate clicks
@@ -577,14 +576,12 @@ export const ChatInput = ({
577576
return (
578577
<ChatContainer
579578
isWelcomeScreen={effectiveIsWelcomeScreen}
580-
isDark={isDark}
581579
className={className}
582580
widthClass={widthClass}
583581
isTransitioningToWelcome={isTransitioningToWelcome}
584582
>
585583
{/* Attachment preview bar, only show when there are attachments */}
586584
<AttachmentPreviewBar
587-
isDark={isDark}
588585
onHeightChange={handleAttachmentBarHeightChange}
589586
onRetryUpload={handleRetryUpload}
590587
/>
@@ -598,7 +595,6 @@ export const ChatInput = ({
598595
onKeyDown={handleKeyDown}
599596
placeholder={defaultPlaceholder}
600597
maxHeight={maxHeight}
601-
isDark={isDark}
602598
onCompositionStart={handleCompositionStart}
603599
onCompositionEnd={handleCompositionEnd}
604600
onHeightChange={handleTextHeightChange}
@@ -673,7 +669,6 @@ export const ChatInput = ({
673669
(!isProcessing && !message.trim()) ||
674670
!canSubmitWithModel
675671
}
676-
isDark={isDark}
677672
ariaLabel={
678673
isLocalSubmitting
679674
? t('input.sending')

components/mobile/mobile-nav-button.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
import { WidePanelLeft } from '@components/ui';
4-
import { useTheme } from '@lib/hooks/use-theme';
54
import { useSidebarStore } from '@lib/stores/sidebar-store';
65
import { cn } from '@lib/utils';
76
import { ArrowRightToLine } from 'lucide-react';
@@ -10,10 +9,8 @@ import { useTranslations } from 'next-intl';
109

1110
export function MobileNavButton() {
1211
const { isExpanded, showMobileNav } = useSidebarStore();
13-
const { isDark } = useTheme();
1412
const t = useTranslations('mobile.navigation');
1513

16-
// If the sidebar is expanded, return null, do not render the button
1714
if (isExpanded) {
1815
return null;
1916
}
@@ -33,35 +30,27 @@ export function MobileNavButton() {
3330
'select-none',
3431
'border border-transparent',
3532
'cursor-e-resize',
36-
isDark
37-
? 'text-gray-200 focus-visible:ring-stone-500 focus-visible:ring-offset-gray-900'
38-
: 'focus-visible:ring-primary focus-visible:ring-offset-background text-gray-200'
33+
'focus-visible:ring-primary focus-visible:ring-offset-background text-gray-200 dark:focus-visible:ring-stone-500 dark:focus-visible:ring-offset-gray-900'
3934
)}
4035
>
41-
{/* Hover background */}
4236
<div
4337
className={cn(
4438
'absolute inset-0 rounded-lg transition-all duration-150 ease-in-out',
45-
isDark ? 'group-hover:bg-stone-600/60' : 'group-hover:bg-stone-300/80'
39+
'group-hover:bg-stone-300/80 dark:group-hover:bg-stone-600/60'
4640
)}
4741
/>
48-
{/* Icon body */}
4942
<span
5043
className={cn(
5144
'relative z-10 flex h-5 w-5 flex-shrink-0 items-center justify-center',
52-
isDark
53-
? 'text-gray-400 group-hover:text-white'
54-
: 'text-gray-500 group-hover:text-stone-800'
45+
'text-gray-500 group-hover:text-stone-800 dark:text-gray-400 dark:group-hover:text-white'
5546
)}
5647
>
57-
{/* Default window icon - fade in and out when hovering */}
5848
<WidePanelLeft
5949
className={cn(
6050
'absolute h-5 w-5 transition-all duration-150 ease-out',
6151
'group-hover:scale-125 group-hover:opacity-0'
6252
)}
6353
/>
64-
{/* Right arrow displayed when hovering */}
6554
<ArrowRightToLine
6655
className={cn(
6756
'absolute h-4 w-4 transition-all duration-150 ease-out',

0 commit comments

Comments
 (0)