layers

CCalego3/15/2022
TIL about CSS Layers.
https://developer.mozilla.org/en-US/docs/Web/CSS/@layer

@layer utilities {
  /* creates a named layer called utilities. */
  .foo {
    padding: 5em;
  }
}
CCalego3/15/2022
not super sure how to declare a layer in the DOM
UUUnknown User3/15/2022
2 Messages Not Public
Sign In & Join Server To View
CCalego3/15/2022
the mdn table is outdated, there's more support now
UUUnknown User3/15/2022
2 Messages Not Public
Sign In & Join Server To View
CCalego3/15/2022
I definitely don't understand these, how does an element know which layer to use? is this just for the specificity?
CCalego3/15/2022
Like I thought this was "this part of the app uses the 'dark' layer"
CCalego3/15/2022
but it looks like it's only here to help you with specificity
UUUnknown User3/15/2022
5 Messages Not Public
Sign In & Join Server To View
CCalego3/15/2022
UUUnknown User3/15/2022
2 Messages Not Public
Sign In & Join Server To View
CCalego3/15/2022
So the less specific p is applied after (thus taking precedence) the .box p because .box p is inside a layer.
CCalego3/15/2022
this feels... like it's only going to make this shit more confusing?
UUUnknown User3/15/2022
11 Messages Not Public
Sign In & Join Server To View
CCalego3/15/2022
imports are already a thing though just without the layer bit
CCalego3/15/2022
this is also already a thing, that's the normal cascade
UUUnknown User3/15/2022
Message Not Public
Sign In & Join Server To View
CCalego3/15/2022
oh i didn't think that was a partial import, thought it put the whole file in as that layer you declare
UUUnknown User3/15/2022
2 Messages Not Public
Sign In & Join Server To View
CCalego3/15/2022
UUUnknown User3/15/2022
Message Not Public
Sign In & Join Server To View
UUUnknown User3/15/2022
Message Not Public
Sign In & Join Server To View
CCalego3/15/2022
that' swhat I thought initially, but it doesn't look like you can declare a layer as a specific DOM element, so you're back to normal CSS nesting for these.

Except it seems like if you also declare a layer, the order of precedence doesn't follow specificity anymore.
CCalego3/15/2022
i.e. the layer order supersedes specificity
CCalego3/15/2022
I'm still not sure I'm getting it. You might be closer than I am. But this really doesn't look like it's going to be intutive to work with
UUUnknown User3/15/2022
2 Messages Not Public
Sign In & Join Server To View
CCalego3/15/2022
That would necessitate that you could say "alright this <main> element uses Layer dark", but that doesn't look possible
UUUnknown User3/15/2022
9 Messages Not Public
Sign In & Join Server To View
CCalego3/15/2022
It's not isolating stylesheets to different elements, which would be stupid useful in a lot of cases. It's like customizing the specificity cascade, which is ... not immediately useful to me (as someone who understands the cascade and uses a preprocessor for nesting).
UUUnknown User3/15/2022
3 Messages Not Public
Sign In & Join Server To View