Skip to content

Migrate remaining BEM components to CSS Modules (final batch)#2015

Open
paskal wants to merge 1 commit intobem-to-css-modules-batch1from
bem-to-css-modules-batch2
Open

Migrate remaining BEM components to CSS Modules (final batch)#2015
paskal wants to merge 1 commit intobem-to-css-modules-batch1from
bem-to-css-modules-batch2

Conversation

@paskal
Copy link
Collaborator

@paskal paskal commented Feb 25, 2026

Summary

  • Migrate the last 4 BEM components (subscribe-by-email, comment-form + markdown-toolbar, comment, root) to CSS Modules, completing the full migration
  • Remove bem-react-helper dependency entirely — all components now use clsx
  • Consolidate ~50 BEM CSS files into 4 new + 2 expanded CSS Module files
  • Clean up dead CSS: orphaned comment-actions selectors, unused modifiers (comment_disabled, comment_pinned, comment_guest), dead elements (comment__user-id), dead button type classes, dead mix values

Key implementation details

  • comment_highlighting stays global via :global() — imperatively added by classList in root.tsx
  • Bare .dark/.light theme class preserved on root wrapper (8+ modules depend on :global(.dark))
  • raw-content.css kept as global utility CSS for syntax highlighting

Built artefact comparison (master vs this branch)

File Master Branch Delta
remark.css 43,779 B 36,106 B -17.5%
last-comments.css 18,792 B 13,955 B -25.7%
remark.js 256,709 B 253,637 B -1.2%
last-comments.js 121,726 B 120,795 B -0.8%
Total 441,006 B 424,493 B -3.7%

Visual regression check

Screenshot comparison across light and dark themes: pixel-identical. The only detected 0.21% diff was sub-pixel font rendering on the demo page's "Toggle theme" button — not any remark42 widget element.

Depends on #2014.

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.03%. Comparing base (731f108) to head (8b4a30e).

Additional details and impacted files
@@                      Coverage Diff                      @@
##           bem-to-css-modules-batch1    #2015      +/-   ##
=============================================================
+ Coverage                      62.01%   62.03%   +0.01%     
=============================================================
  Files                            132      132              
  Lines                           3033     3037       +4     
  Branches                         735      788      +53     
=============================================================
+ Hits                            1881     1884       +3     
+ Misses                          1148     1039     -109     
- Partials                           4      114     +110     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

size-limit report 📦

Path Size
public/embed.mjs 2.06 KB (0%)
public/remark.mjs 73.47 KB (-0.44% 🔽)
public/remark.css 7.71 KB (-5.6% 🔽)
public/last-comments.mjs 35.95 KB (-0.64% 🔽)
public/last-comments.css 3.44 KB (-8.1% 🔽)
public/deleteme.mjs 12.42 KB (0%)
public/counter.mjs 747 B (0%)

@paskal paskal force-pushed the bem-to-css-modules-batch2 branch from 4bfaa6a to ea56d22 Compare February 25, 2026 00:18
Migrate the last 4 BEM components to CSS Modules, completing the
migration and removing bem-react-helper from the project entirely.

Components migrated:
- subscribe-by-email (1 BEM CSS file -> 1 module)
- comment-form + markdown-toolbar (20 BEM CSS files -> 2 modules)
- comment (19 BEM CSS files -> expanded existing module)
- root (10 BEM CSS files -> expanded existing module)

Consolidates ~50 BEM CSS files into 4 new + 2 expanded CSS Module files.
Removes bem-react-helper dependency — all components now use clsx for
conditional class composition.

Dead CSS cleanup during migration:
- Orphaned comment-actions selectors in comment theme CSS (already migrated)
- Dead BEM modifiers: comment_disabled, comment_pinned, comment_guest
- Dead element: comment__user-id (CSS existed but never used in TSX)
- Dead button type classes: comment-form__button_type_preview/_send
- Dead mix values: auth-email-login-form__back-button, comment-form__email-dropdown

Key implementation details:
- comment_highlighting stays global via :global() (imperatively added by classList)
- Bare .dark/.light theme class preserved on root wrapper (8+ modules depend on it)
- raw-content.css kept as global utility CSS (syntax highlighting)

Visual regression verification on built artefacts:
- remark.css: 43,779 -> 36,106 bytes (-17.5%)
- last-comments.css: 18,792 -> 13,955 bytes (-25.7%)
- remark.js: 256,709 -> 253,637 bytes (-1.2%)
- last-comments.js: 121,726 -> 120,795 bytes (-0.8%)
- Total: 441,006 -> 424,493 bytes (-3.7%)
- Screenshot comparison: pixel-identical across light/dark themes
@paskal paskal force-pushed the bem-to-css-modules-batch2 branch from ea56d22 to 8b4a30e Compare February 25, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant