You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trialling out GPS, some old stuff from ECSS, and my idea: "Thema styles".
I'm not entirely convinced yet about GPS-style css, but I DO believe in minimalism and increasingly have a brutalist mindset. While it's nice to have a fancy UI, it isn't necessary, and it's a real bugger to maintain and update as the code complexity increases. CSS is definitely not one of the nicest languages to code in.
For example, with ECSS you'd write a special .scoped-Class for each and every item. This is a big no-no in GPS and it advocates for simplifying the class names, using raw html elements to style, and reducing repetition. However, some naming conventions are necessary ...
What about <div>s when there's no relevant HTML element to use? It's quite helpful to have some visual indication when you're scanning the css document as to what component lives where. If you don't have a nested element such as .gl-Card header, and you've got two nested div > div that gives no information.
<!-- simple naming convention --><divclass="split"><divclass="split-left">
...
</div></div><!-- ECSS naming convention --><divclass="gl-Section"><!-- If it's a global element GPS condones scoping as `.gl-`obal --><divclass="gl-Section_Left">
...
</div></div>
The general idea with GPS is to scope things as .gl-obal, #page level, or section (nested under it's page). It aims to reduce bloat that BEM and ECSS bring with (some would say) unnecessary class names. The problems that seem to crop up when changing to this format are:
If you have a fragment (like #answer) which is just for linking to, where does this live?
Are there any instances where inheritance becomes a potential problem? (unique ECSS classes solved this problem)
If templates are slightly different, how do we deal with these? (Missing! div#answer is in a different position)
Slight variations in templates mean they share .gl- styles except for very slight changes.
With ECSS we'd completely separate (and duplicate) those styles into two distinct css files.
Remember Elm Lang's lessons: just because something is similar does not mean it is the same!
Another subtle example is our #demo page. It's serving two distinct templates but they're basically exactly the same:2
At what point does a .gl- element become a distinct #page #section and vice-versa?
Should I be naming #demo a .gl-Demo rather than a distinct #page type?
Can #page elements be repeated or must they be unique?
Another what-if in a similar vain is ... is it every OK to style a .gl- element under a #page level one?3
You could style it in the global-element.less file like .gl-Element { #page & { ... } }
Or otherwise you could convert a .gl-Element to a #page #element but that's waaaaay overkill in my case.
Or, you could add a -variant class, such as .gl-Element-changed ...
TL;DR
One of the biggest upsides of using ECSS is isolation and descriptiveness. .gl-Card_KeyPoint-selected is very descriptive. You lose that a bit with GPS.
So whatever you do, make rules concrete.
Use decent HTML5 tags where possible to style content. Make them obvious and accessible.
section, header, aside, nav are descriptive enough, sort of.
p and ul feel a bit weaker, especially if it's a design system element (is it descriptive enough without a class?)
If <div> is used, and it's a child of another div, consider naming them as parent and child somehow.
Ideally you'd want to style as much as possible in your raw html /partials folder.
For our Anki cards, we really only have one style of heading, but that's inside a .gl-Card.
Are we ever going to use a h1 outside of this context? How much do we style in /partials?
To me .gl-Card is a component. I'm not sure it should live as the specimen file (basic h1 -> h6 styles)
When dealing with similar but not the same.gl-, #page, #section elements, WE NEED A PLAN!
Unique #section elements should always be wrapped in a #page
Footnotes
One example of this is <code> styling. We want to style the default, but it also needs styling in a few different occasions: Within a <header> element, inside <pre> tags (specifically with .sourceCode which is a Skylighting class), so on. For h1 code we want font-style: inherit but where does that code live? We're only really using headings inside of our .gl-Card but we might need header styles as regular headings at some point. Do we style the raw HTML or the .gl-Card header h1? And if we're placing "inherit" in our raw html styles (in /partials), will code inherit the styles from our .gl-Card headings too? I don't know! Test it out! ↩↩2
Im not sure that GPS gives us definitive answers to these problems. It's kind of subjective in these cases. ↩
This is another area with nuance that we've got to be aware of. At what point do you split out a .global style into a different (but similar) global style? I think it's generally that a #section should be UNIQUE. But it might be similar to a global design component. Again, we don't worry about this with ECSS. ↩
The text was updated successfully, but these errors were encountered:
Great advice from helpful articles
I'm not entirely convinced yet about GPS-style css, but I DO believe in minimalism and increasingly have a brutalist mindset. While it's nice to have a fancy UI, it isn't necessary, and it's a real bugger to maintain and update as the code complexity increases. CSS is definitely not one of the nicest languages to code in.
The general idea
For example, with ECSS you'd write a special
.scoped-Class
for each and every item. This is a big no-no in GPS and it advocates for simplifying the class names, using raw html elements to style, and reducing repetition. However, some naming conventions are necessary ...What about
<div>
s when there's no relevant HTML element to use? It's quite helpful to have some visual indication when you're scanning the css document as to what component lives where. If you don't have a nested element such as.gl-Card header
, and you've got two nesteddiv > div
that gives no information.The general idea with GPS is to scope things as
.gl-
obal,#page
level, orsection
(nested under it's page). It aims to reduce bloat that BEM and ECSS bring with (some would say) unnecessary class names. The problems that seem to crop up when changing to this format are:#answer
) which is just for linking to, where does this live?div#answer
is in a different position).class
or not?.gl-Form p
seems a bit weak compared to more explicit.gl-Form_Error
which is far more explicit ....gl-Form .error
?gl-Card_KeyPoint
tells me a lot about what it is and who its parent is..gl-Card > p
would break if you movedp
inside adiv
. Perhaps this is just something you have to be aware of..gl-Wrapper
class that hasn't been styled yet. Is it really needed?.gl-Card { .wrapper { ... } }
vs.gl-Card .wrapper
.gl-Card h1 code b
seems a bit too nested for my tastes, but perhaps it's just habit..nightmode
class, should all override styles live together, or style in-place multiple times?.gl-Card { .nightmode & { ... } }
?@media
styles. They can add up pretty fast (see Print First CSS).gl-
styles except for very slight changes.#demo
page. It's serving two distinct templates but they're basically exactly the same:2.gl-
element become a distinct#page #section
and vice-versa?#demo
a.gl-Demo
rather than a distinct#page
type?#page
elements be repeated or must they be unique?.gl-
element under a#page
level one?3global-element.less
file like.gl-Element { #page & { ... } }
.gl-Element
to a#page #element
but that's waaaaay overkill in my case.-variant
class, such as.gl-Element-changed
...TL;DR
section
,header
,aside
,nav
are descriptive enough, sort of.p
andul
feel a bit weaker, especially if it's a design system element (is it descriptive enough without a class?)<div>
is used, and it's a child of anotherdiv
, consider naming them as parent and child somehow./partials
folder..gl-Card
.h1
outside of this context? How much do we style in/partials
?.gl-Card
is a component. I'm not sure it should live as the specimen file (basich1 -> h6
styles).gl-
,#page
,#section
elements, WE NEED A PLAN!#section
elements should always be wrapped in a#page
Footnotes
One example of this is
<code>
styling. We want to style the default, but it also needs styling in a few different occasions: Within a<header>
element, inside<pre>
tags (specifically with.sourceCode
which is a Skylighting class), so on. Forh1 code
we wantfont-style: inherit
but where does that code live? We're only really using headings inside of our.gl-Card
but we might need header styles as regular headings at some point. Do we style the raw HTML or the.gl-Card header h1
? And if we're placing "inherit" in our raw html styles (in/partials
), willcode
inherit the styles from our.gl-Card
headings too? I don't know! Test it out! ↩ ↩2Im not sure that GPS gives us definitive answers to these problems. It's kind of subjective in these cases. ↩
This is another area with nuance that we've got to be aware of. At what point do you split out a
.gl
obal style into a different (but similar) global style? I think it's generally that a#section
should be UNIQUE. But it might be similar to a global design component. Again, we don't worry about this with ECSS. ↩The text was updated successfully, but these errors were encountered: