ember-component-css
ember-component-css copied to clipboard
Inheritance/Composition. Is feasible in the CSS Modules fashion?
Wouldn't be great be able to reuse one related component styles into another?
Do you have a concrete example how that could look?
Maybe you want to take a look at ember-css-modules? :smile:
Yes indeed I just came from there. I find awesome to isolate the styles in each pod, but in order to create similar components based in common CSS I'd need some kind of composition and in addition to ember-css-modules, I'm looking for different solutions.
@davidgarsan A couple of suggestions, and let me know if any of these work for you.
-
We're going to implement a solution for #48 so that if a component extends another component, you can use the parent class css rather then the individual's components css. (The api for this, or any work for that matter, has yet to be done, so open to suggestions in that issue)
-
There is still nothing wrong with creating reusable css "modules" and importing them into the main app.{ext} file. Currently you control where in that file the pod styles is imported, so you can import another file before it, and use those methods/variables/modules in any of the component styles.
-
The styles are included in hierarchical order. Meaning if you have
my-component
then the componentmy-component/thing-one
andmy-component/thing-two
you can put the styles into themy-component
styles file and it will be included before the children components.
These are the three approaches that I thought up off the top of my head. If none of these fit what you ultimately want to do, feel free to propose a use case and we'll let you know what we thing about it, and if if fits into this project.
I guess that the best option is 1. On the other hand, approach 2 lives in the global scope, which is something I'd like to avoid. Option 3 doesn't fit my project hierarchy.
Hey @webark , looks like #48 is still open as of today (April 2017). Do you have any updates about it ?
@bartocc hmmm.. i think you could have them just do the base styles.. but i'm unsure how to get both the base and the current.. I'll dive into it and let you know what i find.