Replies: 2 comments
-
Can you provide additional examples, so we can better evaluate some more complex scenarios? From the currently provided examples, it seems to me that there isn't a "strongly" established naming convention that fits the scenarios (or hasn't been followed strictly enough due to problems), e.g. considering the above:
I would expect As for the states - I suppose having separate classes like Regarding the syntax - my very opinionated view is that BEM syntax (I agree we are using it as a reference, the exact syntax can be different, but I will still refer to it) is a bit verbose to read. I also do not like the other approach with mixed PascalCase and kebab-case - I find it harder to read and understand. If we really really want to use a mixed approach, then mixing kebab-case and snake_case might be better (something similar to what BEM does, but with doubling the delimiter), e.g. In addition, is there a real benefit for us of having an explicit delimiter to separate the Seems like it boils down more to the order of words rather than strictly looking for some delimiters, e.g. |
Beta Was this translation helpful? Give feedback.
-
The BEM convention seems to be geared towards components, which is great. As noted, that puts it at odds with the idea of global selectors, e.g. for state, that we use in the theme. So we get a watered-down version of BEM at a huge cost for both us and customers. Doesn't look like a great deal. |
Beta Was this translation helpful? Give feedback.
-
Long story short: our class names are ambiguous enough to not be clear which class name means what... Not always, mind you, but close enough.
For instance, previously we used
k-button-icon
to denote a button that only has icon. However, when it came to adding a class name to icons inside the button we also iconk-button-icon
, which was mildly confusing.In other words, we need some order in the chaos. As of now, the best idea seems to be almost BEM or BEM with exceptions. What do I mean by that? Let's first see what BEM is.
BEM stands for:
It's a convention that aims to name things in a way that is not confusing and is clearly distinguishable what is what in a web page"
Before I get to how it may applies to us, I will try to answer a couple of questions that may already be coming this way:
Why should we use BEM?
We don't have to use BEM. We can use anything as long as the class names are easily read. Here a couple of other instances:
MUI (ex Material UI) are using a very interesting combination of PascalCase for their components:
MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButtonBase-root
.Amazon are using something similar to what we are currently:
a-button a-button-selected a-button-thumbnail a-button-toggle
. DevExpress are also using simple dash notation.Who is using BEM?
Yandex, Material Components for Web, Carbon Design System. Is this argument valid at all?
How do we apply it to Kendo UI?
Well, it's simple, really -- every component is a block and its parts are elements. Of course, any child can also be a block too, like the icon is, so it must have classes for both. Modifiers could be the component options.
The last two rules is not something I fully agree with:
k-disabled
,k-hover
,k-required
etc...k-menu.k-hover .k-menu__item
Apart from that, BEM suits us.
I am aware that this is a much bigger change than simple tweaking a few class names... Thoughts?
cc @telerik/web-components-and-tools
Beta Was this translation helpful? Give feedback.
All reactions