Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

Discovery: stylesheets for component libraries in React/Preact #13

Open
dvoytenko opened this issue Apr 3, 2020 · 0 comments
Open

Discovery: stylesheets for component libraries in React/Preact #13

dvoytenko opened this issue Apr 3, 2020 · 0 comments

Comments

@dvoytenko
Copy link
Contributor

Let's assume the most naive code setup with two modules:

/1/ component.css

.amp-component {
  outline: none;
}
.amp-component:hover {
  outline: 1px solid blue;
}

/2/ component.js

function AmpComponent() {
  return <div className="amp-component"/>;
}

Is there a safe/universal/always-just-works/no-weird-dependencies way to distribute a npm package with the component.js that automatically installs the components.css stylesheet in the target document when AmpComponent is used?

Things to consider:

  • Client-side vs server-side rendering.
  • Lazy loading, tree shaking and bundling (e.g. what if AmpComponent is not used until later?)
  • Stylesheet ordering. The desire is to put this stylesheet as early as possible (before user stylesheet) to allow easy override in the user stylesheet.
  • Shadow vs light DOM. E.g. what if a component is used inside the shadow subtree?
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant