Skip to content

refactor(css): modularize styles into common, dashboard, games and add purgecss (#433) - #606

Open
rishab11250 wants to merge 6 commits into
Aditya8369:mainfrom
rishab11250:refactor/css-modularization-433
Open

refactor(css): modularize styles into common, dashboard, games and add purgecss (#433)#606
rishab11250 wants to merge 6 commits into
Aditya8369:mainfrom
rishab11250:refactor/css-modularization-433

Conversation

@rishab11250

Copy link
Copy Markdown
Contributor

Pull Request

Description

Modularizes the 198KB single-file src/styles.css into three focused stylesheets and adds a PostCSS purge step so unused styles are stripped from the production bundle.

The original file had grown to ~10,000 lines and contained a duplicated block appended to itself. This change splits it into src/styles/common.css (tokens, themes, base, shell), src/styles/dashboard.css (dashboard layout, mobile, comparison), and src/styles/games.css (scenario simulator, AQI mission game), with src/styles.css kept as a thin @import aggregator so existing imports keep working.


Related Issue

Closes #433


Type of Change

  • Bug Fix
  • New Feature
  • Documentation
  • UI/UX Improvement
  • Refactoring
  • Performance Improvement
  • Accessibility

Changes Made

  • Split src/styles.css into src/styles/common.css, src/styles/dashboard.css, src/styles/games.css
  • Kept src/styles.css as an @import aggregator for backward compatibility
  • Removed ~3,400 lines of duplicated CSS that had been appended to the file
  • Added postcss.config.js with @fullhuman/postcss-purgecss, enabled for production builds
  • Safelisted dynamically composed classes (e.g. confidence-${level}, cols-${n}) so purge does not strip styles that are built from template literals

Testing

  • Tested locally
  • No console errors
  • Existing functionality works as expected

Screenshots

If applicable, attach screenshots or screen recordings.


Checklist

  • My code follows the project guidelines.
  • I have tested my changes.
  • I have updated the documentation if required.
  • My changes address the related issue.
  • This PR focuses on a single issue.

Additional Notes

Purgecss is production-only. Its safelist covers library classes (leaflet-, recharts-, theme-) plus classes composed dynamically in JSX. The production build previously failed on upstream main due to a pre-existing top-level await transpile error unrelated to this change; CSS module and purge behavior were verified in isolation.

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

@rishab11250 is attempting to deploy a commit to the Aditya Mahajan's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the ECSoC26 Contributions considered under ECSoC'26 label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Thank You for Your Contribution! 🎉

Hi @rishab11250,

Thank you for opening this Pull Request and contributing to our project. We truly appreciate your efforts.

Please make sure that:

  • Your code follows the project's guidelines.
  • You have linked the appropriate issue (if applicable).
  • Screenshots are added for UI/UX changes.
  • Your PR is ready for review.

The maintainer @Aditya8369 will review your PR shortly!

Happy Contributing! 🚀

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pollution-control-hub Error Error Aug 7, 2026 1:34pm

@Aditya8369 Aditya8369 added the good-pr Additional ECSoC label label Aug 7, 2026
@Aditya8369

Copy link
Copy Markdown
Owner

@rishab11250 please fix deployment

Fix three pre-existing issues that broke the production build and the
Vercel deployment:

- HealthAdvisory.jsx: fix mismatched JSX tags in the tips grid (opened
  div, closed with li/ul) that failed the esbuild transform
- vite.config.js: raise the build target to es2022 so the DEV-only
  top-level await from @axe-core/react no longer fails transpilation
- vite.config.js: raise workbox maximumFileSizeToCacheInBytes to 5 MiB
  so the service worker can precache the main bundle
@rishab11250
rishab11250 force-pushed the refactor/css-modularization-433 branch from 1e7b007 to 8c98b4d Compare August 7, 2026 19:19
@rishab11250

Copy link
Copy Markdown
Contributor Author

Hi @Aditya8369 — the deployment is fixed. The Vercel build was failing due to three pre-existing issues on `main` (not from the CSS modularization itself), which I've now fixed and pushed to this PR:

@Aditya8369
Aditya8369 self-requested a review as a code owner August 9, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ECSoC26 Contributions considered under ECSoC'26 good-pr Additional ECSoC label requested-changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSS Modularization & Style Sheet Optimization

2 participants