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

adopted stylesheets / CSS Modules #8

Closed
wants to merge 1 commit into from

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Nov 4, 2023

As part of #7 , was playing around with what CSS Modules could look like, and ended up creating an demo around adopted stylesheets.

.heading {
  color: red;
}
import styles from './hero.css';

export default class Hero extends HTMLElement {
  connectedCallback() {
    document.adoptedStyleSheets.push(styles);

    this.innerHTML = `
      <h2 class="heading">Hello from Hero banner</h2>
    `
  }
}

customElements.define('app-hero', Hero);

Screenshot 2023-11-04 at 6 30 40 PM

Not sure what we can do with it, but seemed interesting to at least put a PR together. 🤓

(currently the plugin isn't doing anything)


TODO

  1. Not sure why the CSS import works to produce CSSStyleSheet instance? Maybe an ES Modules Shims thing?

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

netlify bot commented Nov 4, 2023

Deploy Preview for super-tapioca-5987ce failed.

Name Link
🔨 Latest commit 65ff816
🔍 Latest deploy log https://app.netlify.com/sites/super-tapioca-5987ce/deploys/6546c64bd1bd760008824d34

@thescientist13 thescientist13 mentioned this pull request Nov 21, 2023
18 tasks
@thescientist13
Copy link
Member Author

I think #11 and #13 are better demonstrations, so closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant