-
Notifications
You must be signed in to change notification settings - Fork 67
BEM usage and modifier ordering policy for chassis classes #120
Comments
Option 3
The main issue i see with multiple modifiers in something besides alphabetical order is that for people...
For programatic implementation of chassis like JS frameworks or markup generated server side there are the additional drawbacks of...
|
To expand on option one: Using the argument "you will always need a cheat sheet" if there are more modifiers than size, type, and state, is like saying you always need a cheat sheet if for a javascript function passing in variables. Since the concern is for Javascript Frameworks, let's use JavaScript terminology. We have a function called uiButton. uiButton has a bunch of arguments that can be passed to it, for example "size," "type", "state", "corners", and whatever other features this button may have. so we have:
It's already been pre-determined that type has four different states it could possibly be in ("info, warning, error, danger"), size has four different possible sizes ("extra-small", "small", "medium", "large"), and a number of different states (focus, active, hover, disabled). So let's say we have two buttons. One button has the arguments (info, small, active), while the other button has (warning, large, focus). In the current naming scheme we have with the buttons PR, the order of the modifiers for the buttons would be:
with the
However, if we go with something like option 2 which all modifiers are listed alphabetically we get something like this:
In JavaScript, we don't reorder the parameters of a function just because the value of the variable has changed, and doing so here would potentially overcomplicate the codebase and complicate the documentation associated with this project. To apply this to CSS terminology, we don't order the margin of a css attribute by ascending order, from least to greatest number, instead margin' has a number of values that may be passed to it, and if four values are passed to it, we know that means The above being said, I'm fine with doing something like option number three, although I think option one wouldn't be too hard to achieve if we clearly define what the different parameters/modifiers are of an element, what are acceptable options of each of those modifiers, and after that, a lot of the code could be generated via mixins. It would mostly involve having a bit more discussion/planning ahead of time before tackling major css components. |
@sfrisk actually too many parameters would be considered bad code smell in JS for example with button there is more then just size, type, and state you would also have AT LEAST corners and display ( block vs inline ) a function with 5 parameters is generally considered very undesirable and would be changed to use an options object where order does not matter and you can exclude arguments because both remembering the order and being forced to pass all params is not desirable from a usage / user perspective.
Thats not true things like this happen all the time. Look at most jQuery methods the parameters and order change based on whats passed for connivance based on the |
I like the option 3 @arschmitz suggested. It will be easier to both code and later maintain. |
I likewise agree that something like Option 3 is the way to go. Trying to cram all the modifiers into one class like Options 1 & 2 makes twiddling one of the modifiers via JS rather annoying to do. And the CSS would have lots of redundancy. Bootstrap uses a scheme similar to Option 3 and it has served us quite well in practice. So taking the button example, it might look something like: |
If one was using javascript to generate the element;
From the JavaScript developers perspective they don't give a flip about the order of the class modifiers name. They want an API they can call to set/get those properties. It's the CSS Developer/implementer that cares about that and they want consistency, which can be handled using the SASS mixins. There is no reason to modify the order in which these properties are rendered the class names. That only makes the mixin's more complicated and makes hand-coding the CSS a pain in the ... |
Between this and Chassis Meetings, Option 3 is a go. |
Earlier in meeting today a concern was raised while discussing #97 : How do we order modifiers for classes.
While we have decided to name classes in pattern : block_element--modifier, for most components there could be multiple modifiers concurrently
block_element--modifier1--modifier2
. The issue is how do we order these modifiers such that the order is easily implemented/ remembered. Since we are a css framework for js libraries, the classes should be possible( preferably with ease) via js code.A concern was also raised if BEM is really good for our project (see #4 )? It takes more effort to code and will make things complicated for js frameworks a bit too.
Options:
The text was updated successfully, but these errors were encountered: