Skip to content

feat(theme): implement GitHub-aligned light mode with centralized col…#898

Open
hunnyboy1217 wants to merge 2 commits intoentrius:testfrom
hunnyboy1217:feat/881-light-mode
Open

feat(theme): implement GitHub-aligned light mode with centralized col…#898
hunnyboy1217 wants to merge 2 commits intoentrius:testfrom
hunnyboy1217:feat/881-light-mode

Conversation

@hunnyboy1217
Copy link
Copy Markdown

Summary

  • Full light mode implementation across 74 files, tuned to match GitHub Primer color tokens exactly
  • Theme toggle relocated to top-right header (icon-only, next to search bar)
  • Logo uses brightness(0) CSS filter in light mode for solid black rendering
  • All hardcoded hex values removed from components — colors now live exclusively in theme.ts as named exports (CHART_COLORS, INSIGHT_COLORS, WATCHLIST_COLORS, UI_COLORS, etc.)
  • New modeActiveTabSx utility in src/utils/themeUtils.ts replaces repeated dark/light active-tab ternary patterns across 5+ components
  • Duplicate ECharts tooltip functions merged into a shared base in gittensorChartTheme.ts

Related Issues

Closes #881

Type of Change

  • New feature
  • Refactor

Screenshots

Recording.2026-04-30.081356.mp4

Checklist

  • New components are modularized/separated where sensible
  • Uses predefined theme (e.g. no hardcoded colors)
  • Responsive/mobile checked
  • Tested against the test API
  • npm run format and npm run lint:fix have been run
  • npm run build passes
  • Screenshots included for any UI/visual changes

@xiao-xiao-mao xiao-xiao-mao Bot added feature Net-new functionality refactor Code restructuring without behavior change labels Apr 30, 2026
@hunnyboy1217
Copy link
Copy Markdown
Author

Hi, @e35ventura ,
Could you please review my PR?

@hunnyboy1217 hunnyboy1217 force-pushed the feat/881-light-mode branch from 4ff965d to fa8c9bc Compare May 3, 2026 08:11
@ericwong0256-a11y
Copy link
Copy Markdown

ericwong0256-a11y commented May 3, 2026

Good job, Hope to see this in Gittensor platform.

@ventura-oss
Copy link
Copy Markdown
Contributor

Please resolve merge conflicts.

@hunnyboy1217
Copy link
Copy Markdown
Author

Hi, @ventura-oss ,
I resolved conflicts again.
Could you please review my PR?

@e35ventura
Copy link
Copy Markdown
Collaborator

please resolve conflicts

@hunnyboy1217
Copy link
Copy Markdown
Author

Sorry for the late reply, @ventura-oss , @e35ventura ,
Could you please review my PR?
I am ready for review.
Thanks.

@hunnyboy1217 hunnyboy1217 force-pushed the feat/881-light-mode branch 3 times, most recently from ff7d0c4 to 1202596 Compare May 9, 2026 17:51
Replaces hardcoded colour values across the codebase with theme.palette
references and adds a light/dark mode split aligned with GitHub's design
system.

Highlights:
- Centralised colour tokens through theme.palette.* — every component now
  reads colours from the theme rather than from constants.
- Light mode: GitHub-aligned canvas, surface, and text tokens; dedicated
  highlight palette for success/warning/error chip backgrounds.
- Dark mode: preserved the existing palette while routing it through the
  same theme structure.
- Theme toggle integrated into the sidebar footer with refined link layout.
- Chart colour hooks (getPositiveColor, getChartSegmentColors) so charts
  pick the correct mode-aware tint without local conditionals.
- modeActiveTabSx helper for active/hover styling shared across filter
  buttons and tab controls.
- Component-level adaptations: MinerCard, LeaderboardSidebar, Sidebar,
  AppLayout, IssueHeaderCard, IssueSubmissionsTable, BountyCard,
  RepositoryPRsTable, RepositoryCheckTab, RepositoryContributorsTable,
  RepositoriesPage, RepositoryDetailsPage, WatchlistPage,
  TopRepositoriesTable, ContributionTrends, FilterButton, etc.
…ites

Three additions on top of the GitHub-aligned light mode commit:

1) src/utils/themeUtils.ts — extends the existing helper with structural
   exports that centralise the 'theme.palette.mode === "dark" ? X : Y'
   branching pattern repeated across 30+ callsites:

     - isDarkMode(theme) / isLightMode(theme)   — typed predicates
     - themeAware<T>(theme, dark, light)        — generic value picker
     - mode<T>(theme, { dark, light })          — labelled object form
     - darkOnly<T>(theme, value, fallback?)     — overloaded conditional
     - lightOnly<T>(theme, value, fallback?)    — mirror of darkOnly
     - tintedText / tintedSurface / modeBorder  — palette-aware tints
     - getNegativeColor / getWarningColor       — palette-derived selectors
     - darkOnlySx / lightOnlySx                 — sx-fragment spreads

2) src/utils/themeContrast.ts (new) — WCAG 2.x contrast utilities so the
   light-mode rollout can verify text legibility on coloured surfaces:

     - parseColor / relativeLuminance / contrastRatio
     - WCAG_AA_NORMAL / WCAG_AA_LARGE / WCAG_AAA_NORMAL / WCAG_AAA_LARGE
     - meetsContrast(fg, bg, level, size)
     - readableForegroundFor(theme, bg)
     - pickHighestContrast(bg, candidates)
     - ensureReadable(theme, fg, bg, level, size)

3) src/hooks/useThemedSx.ts (new) — three hooks for memoising theme-derived
   values so child components don't re-render on unrelated parent updates:

     - useThemedSx(builder)        — single sx
     - useThemedSxBatch(builders)  — array of sx
     - useThemedValue(selector)    — non-sx values

Refactored seven high-traffic callsites to consume the new helpers:
  - MinerCard, LeaderboardSidebar, Sidebar (boxShadow / hover / nav state)
  - AppLayout (drawer tint colour + mobile logo filter)
  - GlobalSearchBar (search-field shadow)
  - RankBadge (podium colour predicate)
  - ContributionTrends (3 toggle-button mode branches → mode() calls)

All helpers preserve the caller's static type via generics and have JSDoc
describing intent + a usage example.
@hunnyboy1217 hunnyboy1217 force-pushed the feat/881-light-mode branch from f62a5a8 to b34c42d Compare May 9, 2026 20:57
@hunnyboy1217
Copy link
Copy Markdown
Author

Hi, @ventura-oss ,
I am ready for review.
Could you please review my PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Net-new functionality refactor Code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

theme: add light mode with user-toggleable color scheme

4 participants