csstyle
csstyle copied to clipboard
considering removing locations
After some great feedback from Paul Irish and a lot of brainstorming, I think we could probably remove locations entirely. Locations' purpose are to allow consumers of a component to override aspects of the component when it's being used in a certain context. It's a common use case and csstyle needs to support it. Locations have a couple of problems however:
- Because they use
id
they automatically override every part of component, including its options. So if you wanted to override the base style of a component using a location but leave it alone when it's using an option, you're out of luck. - People start using locations in places where they really should be using a component.
- There are a lot of semantics to remember with components, parts, options, tweaks, & locations.
I think components themselves provide enough context:
@include component(sidebar){
@include component(button){
// override some aspect of button when inside sidebar
}
}
And they do this with a single class name rather than an id. The only problem with this is that options and parts also only add a single class name. This would lead to load-order importance which is something csstyle is supposed to handle for you. One option would be to have csstyle add another class onto the parts & options selectors that get generated so that they are automatically more specific than the base styles applied to a component inside of another component.
I'm open to ideas and feedback before making a breaking change like this.
I don't think they are really needed. The use cases can easily be achieved in other ways, like a simple option for some custom page that is a little different.
+1
+1 for anything that anything that drops using id
.
Planning on removing locations. @stinoga the id will still be used for tweaks, unless we can think of some other clever way to make them automatically override any level of nested components/parts/options.
@geddski If you are still thinking of removing @locations, maybe you should do so before too many people marry themselves to it. Or at least remove it from the http://csstyle.io page to discourage it's use. Thoughts?
+1
that is a good idea. I'll remove it from the docs and tests to start.
He's alive!
@JesseLeite indubitably :)
http://www.csstyle.io/ updated to remove locations.
Good job @geddski !
This should be closed, right :)?