Skip to content

[perf] Replace inline styles in challenge edit page with CSS module classes#125

Open
github-actions[bot] wants to merge 1 commit intomainfrom
perf/challenge-edit-css-module-afae7348a0a9eb92
Open

[perf] Replace inline styles in challenge edit page with CSS module classes#125
github-actions[bot] wants to merge 1 commit intomainfrom
perf/challenge-edit-css-module-afae7348a0a9eb92

Conversation

@github-actions
Copy link
Copy Markdown

Summary

Tier: 2 — Render & API Performance

Replaces 7 static inline style=\{\{}} objects in src/app/challenge/edit/[id]/page.tsx with CSS module classes, eliminating per-render JavaScript object allocation on a 'use client' page.


Baseline

Before this change, challenge/edit/[id]/page.tsx contained 7 inline style objects that were re-created as new JS objects on every render:

(div style=\{\{ display: 'flex', alignItems: 'center', justifyContent: 'center', minHeight: '400px' }})
(div style=\{\{ maxWidth: '700px', margin: '0 auto', padding: '24px' }})
(Stack ... style=\{\{ marginBottom: '24px' }})
<span style=\{\{ color: 'var(--fgColor-accent)' }}>
(Banner ... style=\{\{ marginBottom: '16px' }})
(Button ... style=\{\{ marginTop: '16px' }})   {/* ×2 */}
(Stack ... style=\{\{ marginTop: '16px' }})

Each style=\{\{}} literal allocates a new object per render in JavaScript. Moving these to CSS module classes makes them zero-cost at runtime (static class strings).


Fix

Added 7 new classes to src/app/challenge/challenge.module.css:

Class Replaces
.editLoadingCenter display:flex; align-items:center; justify-content:center; min-height:400px
.editFormContainer max-width:700px; margin:0 auto; padding:24px
.editFormHeader margin-bottom:24px
.editIconAccent color:var(--fgColor-accent)
.editActionTop margin-top:16px (used on 2 error-state buttons)
.editActionsFooter margin-top:16px (form submit row)
.editSaveErrorBanner margin-bottom:16px

All values are static (non-dynamic), making this a safe mechanical replacement with zero behaviour change.


Result

  • 0 inline style=\{\{}} objects remain in edit/[id]/page.tsx (was 7)
  • No per-render JS object allocation for layout styles on this page
  • CSS module classes are deduplicated and cached by the browser's style engine

Verification

  • npm run lint — passes (0 errors)
  • npm test — 1025/1035 tests pass; 10 failures are pre-existing in src/lib/github/client.test.ts, profile.test.ts, workspace-export.test.ts (unrelated to this change)
  • ✅ No inline style=\{\{}} remains in the changed file
  • ✅ Pure CSS-only change — no logic or behaviour altered

Generated by Daily Performance Improver

Move 7 static inline style objects from challenge/edit/[id]/page.tsx into
challenge.module.css, eliminating per-render object allocation on every
render of the edit page.

New CSS classes added to challenge.module.css:
- .editLoadingCenter  (display:flex; align-items:center; justify-content:center; min-height:400px)
- .editFormContainer  (max-width:700px; margin:0 auto; padding:24px)
- .editFormHeader     (margin-bottom:24px)
- .editIconAccent     (color:var(--fgColor-accent))
- .editActionTop      (margin-top:16px)  -- shared by both error-state buttons
- .editActionsFooter  (margin-top:16px)  -- form submit row
- .editSaveErrorBanner (margin-bottom:16px)

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

Pull request created: #125

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