Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Modules #11

Merged
merged 22 commits into from
May 25, 2024
Merged

CSS Modules #11

merged 22 commits into from
May 25, 2024

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Nov 21, 2023

Related Issue

Final part of #7, to compliment our usage of #38

Summary of Changes

  1. A very early and naive implementation of CSS Modules

TODOs

  1. prerender / static optimization support
  2. support recursively walking script imports (e.g. header.js depends on navigation.js)
  3. scope class names
  4. extract import lines out of JavaScript, aka zero "runtime" (only at build time?)
  5. hash based class names (only at build time?)
  6. check production build integration
  7. Test interop with native CSS Modules
  8. Track upstream plugin / CLI support per upstream feature / fixes tracking #37
  9. remove header demo code, rebase after Header Component #26
  10. Update CONTRIBUTING.md and Storybook tech stack docs - will do as own PR

Questions / Discussions

Tracking this all here - ProjectEvergreen/greenwood#1233

  1. refactor to avoid having to use intermediate output file (I think this is needed for prerendering because things run in a Worker Thread? 🤔 )
  2. Should hashing / runtime removal only happen at build time, or also have it happen in dev too? (avoid extra work when not necessary, especially when using a dev server) - not much of a big deal, since we have to fetch the contents anyway, and this helps with naming collisions
  3. conform to icss specification (leverage postcss-modules package?)
  4. only useful for Light DOM use cases?
  5. should we shim / conform to Constructable Stylesheets API? This actually gets us the CSS rules 🤩 . Also see demo/home page with prototype of HTML / CSS modules (separation of technologies) #13
    Screenshot 2024-01-21 at 6 13 09 PM
  6. Any flexibility of the import usage API, e.g.
    // hardcoded import
    import styles from './something.module.css'
    
    // vs
    import myCss from './something.module.css'
  7. Any flexibility in the usage of the import?
     // needs to reference the import name
     <h1 class="${styles.heading}">Welcome to Greenwood!</h1>
    
     // as opposed to
     const { heading } = styles;
     <h1 class="${heading}">Welcome to Greenwood!</h1>
  8. Could use a better data structure for sheets, like a Map or Set?

@thescientist13 thescientist13 self-assigned this Nov 21, 2023
Copy link

netlify bot commented Nov 21, 2023

Deploy Preview for super-tapioca-5987ce ready!

Name Link
🔨 Latest commit
🔍 Latest deploy log https://app.netlify.com/sites/super-tapioca-5987ce/deploys/665240157d71399f0d49f8bb
😎 Deploy Preview https://deploy-preview-11--super-tapioca-5987ce.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@thescientist13 thescientist13 added the question Further information is requested label Nov 22, 2023
@@ -0,0 +1,139 @@
/*
*
* Manages web standard resource related operations for CSS.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, just a little copy 🍝 here 😅

contents: scopedCssContents
})
// sheets.push(cssContents);
} else if(node.source.value.endsWith('.js')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO - how to handle other file types / extensions? Do we even need to check, can was assume something should already be there to handle it?

This was referenced Apr 5, 2024
@thescientist13 thescientist13 force-pushed the css-modules branch 3 times, most recently from a71ef1f to c8c5786 Compare May 8, 2024 01:41
@thescientist13 thescientist13 marked this pull request as ready for review May 8, 2024 02:22
@thescientist13 thescientist13 added documentation Improvements or additions to developer documentation enhancement New feature or request labels May 8, 2024
@thescientist13 thescientist13 added needs upstream and removed question Further information is requested needs upstream labels May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
demo documentation Improvements or additions to developer documentation enhancement New feature or request needs upstream
Projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant