refactor: replace isDark conditional logic with Tailwind dark: prefix across codebase#225
Merged
refactor: replace isDark conditional logic with Tailwind dark: prefix across codebase#225
Conversation
… in skeleton and file-preview components Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] refactor: replace isDark conditional logic with Tailwind dark: prefix across codebase
refactor: replace isDark conditional logic with Tailwind dark: prefix across codebase
Aug 14, 2025
lyzno1
reviewed
Aug 14, 2025
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Contributor
Author
Applied Prettier formatting to ensure CI workflow success. All formatting checks now pass. Commit: c4df7e2 |
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Contributor
Author
Completed removal of all |
lyzno1
approved these changes
Aug 14, 2025
zhangxuhe1
approved these changes
Aug 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR systematically refactors the codebase to replace runtime
isDarkconditional logic with Tailwind's staticdark:prefix classes, following official Tailwind CSS best practices for dark mode implementation.Problem
The codebase was using runtime conditional logic throughout components for dark mode theming:
This approach created several issues:
useTheme()hook adds runtime checksSolution
Replaced conditional styling with static Tailwind
dark:classes:Changes Made
Successfully refactored 68
isDarkusages across multiple component categories:Skeleton Components
sidebar-chat-skeleton.tsx- RemovedisDarkprop, converted to static classeschat-skeleton.tsx- Eliminated conditional logic for loading statesFile Preview System
file-preview-canvas.tsx- Comprehensive refactor of all internal components:LoadingSkeleton,ErrorDisplay,FileInfoFallbackuseThemedependency from main componentisDarkpropsUI Components
nav-button.tsx- Converted hover and text stylingsearch-input.tsx- Refactored complex input styling with focus statestyping-dots.tsx- Simple color transformation for animated elementsmore-button.tsx- Complex component with array-based conditional stylingscroll-to-bottom-button.tsx- Removed unusedisDarkdestructuringreturn-to-chat-button.tsx- Border and background state stylingpage-loading-spinner.tsx- Spinner icon color themingAdvanced Patterns Handled
Complex Focus States:
Array-based Conditional Logic:
Core Infrastructure
The foundation was already in place - Tailwind v4 dark mode configuration in
globals.css:This enables the CSS-only theme switching that makes this refactoring possible.
Benefits
✅ Zero runtime overhead - Pure CSS theme switching
✅ Better tree-shaking - Tailwind can properly analyze static classes
✅ Improved maintainability - Static class names are easier to debug
✅ Standards compliance - Follows official Tailwind dark mode patterns
✅ Type safety - Reduces complex conditional logic
Testing
pnpm type-check)Remaining Work
This PR addresses the foundational components and establishes patterns for the remaining 1618
isDarkusages. The systematic approach taken here provides a clear blueprint for future refactoring of more complex components.Addressing #220.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.