Skip to content

[perf] Replace 8 inline style objects in daily-focus-section with CSS classes#105

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
perf/daily-focus-inline-styles-3cdfa15397334b6f
Draft

[perf] Replace 8 inline style objects in daily-focus-section with CSS classes#105
github-actions[bot] wants to merge 1 commit intomainfrom
perf/daily-focus-inline-styles-3cdfa15397334b6f

Conversation

@github-actions
Copy link
Copy Markdown

Tier 2 — Inline Style Elimination

Baseline

daily-focus-section.tsx contained 8 static inline style=\{\{}} objects in the Dashboard's most frequently rendered component. Every time habit/challenge/goal state changes (including loading transitions), React creates a new object literal for each inline style, forcing the browser to:

  1. Allocate a new JS object on the heap
  2. Diff the style properties
  3. Schedule a style recalculation pass

Since the dashboard re-renders on every focus state change (streamed AI responses, tab switches, skeleton states), these costs compound.

Fix

Added 6 new utility CSS classes to Dashboard.module.css:

Class Property Replaces
.iconInline margin-right: 4px; display: inline-flex AI-Powered label icon span
.skeletonLoadingRow margin-bottom: 8px 3× loading state header Stack rows
.skeletonMbSm margin-bottom: 8px Challenge SkeletonBox
.skeletonMbMd margin-bottom: 16px Goal SkeletonBox
.skeletonFlex flex: 1 Topic skeleton flex wrapper div
.skeletonMbXs margin-bottom: 4px Topic inner SkeletonBox

All values use Primer CSS custom properties (e.g. var(--base-size-8, 8px)) for token consistency.

Result

  • 8 inline style=\{\{}} objects eliminated from the dashboard's hot render path
  • CSS classes are evaluated once and cached by the browser
  • No allocation on re-render for these styles

Verification

npx tsc --noEmit  ✅ clean
npm run lint      ✅ clean
npm test          ✅ 1025 passed (10 pre-existing client.test.ts auth failures unrelated to this change)

No behaviour change. No new dependencies.

Generated by Daily Performance Improver

…classes

Each inline style={{ ... }} object is allocated on every render, forcing
the browser to diff and reapply the style on every re-render of the
Dashboard — which happens on every habit/challenge/goal state change.

Replace with static CSS classes in Dashboard.module.css:
- .iconInline (marginRight: 4px, display: inline-flex) — AI-Powered label icon
- .skeletonLoadingRow (marginBottom: 8px) — 3 loading state header rows
- .skeletonMbSm (marginBottom: 8px) — challenge skeleton SkeletonBox
- .skeletonMbMd (marginBottom: 16px) — goal skeleton SkeletonBox
- .skeletonFlex (flex: 1) — topic skeleton flex wrapper div
- .skeletonMbXs (marginBottom: 4px) — topic skeleton inner SkeletonBox

No behaviour change. Zero new dependencies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Author

Pull request created: #105

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants