Most active commenters
  • MrJohz(5)
  • owebmaster(4)
  • omnimus(3)
  • reactordev(3)

←back to thread

304 points ulrischa | 18 comments | | HN request time: 0.204s | source | bottom
Show context
ricardobeat ◴[] No.44689124[source]

    <el-dialog-panel class="mx-auto block max-w-3xl transform overflow-hidden rounded-xl bg-white shadow-2xl ring-1 ring-black/5 transition-all group-data-closed/dialog:scale-95 group-data-closed/dialog:opacity-0 group-data-enter/dialog:duration-300 group-data-enter/dialog:ease-out group-data-leave/dialog:duration-200 group-data-leave/dialog:ease-in">
Lovely. Verbosity aside, now on top of knowing CSS you need to learn another hierarchical system within class names.
replies(14): >>44689142 #>>44689193 #>>44689633 #>>44690309 #>>44690466 #>>44690969 #>>44691000 #>>44691208 #>>44691531 #>>44692110 #>>44692147 #>>44692803 #>>44694185 #>>44700048 #
tomnipotent ◴[] No.44690309[source]
Groups are great. It lets a child element activate an effect on a parent element.

    <div id="parent" class="group"><a class="group/hover:bg-black">Hover</a></div>
This eliminates the need for JS for a wide range of things.
replies(1): >>44690573 #
reactordev ◴[] No.44690573[source]
But at what cost? If it’s not a CSS builtin, it’s going to use JS - it may not be something you care about, but it will be there. There’s no other way.
replies(2): >>44690657 #>>44691700 #
lemonberry ◴[] No.44690657[source]
I believe it's regular old css. The :has() pseudo class.

https://developer.mozilla.org/en-US/docs/Web/CSS/:has

replies(2): >>44690920 #>>44691260 #
1. MrJohz ◴[] No.44691260[source]
It's not even :has, it's just how child selectors in CSS have always worked.

    // Not actually needed, here
    // for competition
    .group {}

    // Child selector
    .group:hover group\/hover\:bg-black {
      background-color: black; 
    }

    // Which is essentially the same as
    .group:hover child {
      background-color: black; 
    }
replies(3): >>44692538 #>>44692563 #>>44693265 #
2. luckylion ◴[] No.44692538[source]
That doesn't affect the parent (.group) based on the child though.
replies(2): >>44692586 #>>44692753 #
3. omnimus ◴[] No.44692563[source]
Isn’t it funny that in a thread about how Tailwind is bad and people should learn real css… people also think css selectors require JS?
replies(1): >>44692727 #
4. omnimus ◴[] No.44692586[source]
Atleast in Tailwind that’s what it should do. You hover over card (.group) and some elements inside change.
5. MrJohz ◴[] No.44692727[source]
:has doesn't require JS, I think the previous poster was just confused about which selector `group` is equivalent to.
replies(1): >>44693270 #
6. MrJohz ◴[] No.44692753[source]
No, but `group` doesn't affect the parent in Tailwind. You put `group` in the parent to mark it, and then use the `group/...` syntax to apply different properties to the child, depending on the different states of the parent. This doesn't require `:has`.

I don't think Tailwind has a built-in `:has` tool, but I suspect it would be easy to add one as a custom class.

replies(4): >>44693208 #>>44693819 #>>44696147 #>>44699353 #
7. luckylion ◴[] No.44693208{3}[source]
Oh, I misunderstood the GP then, thanks for clarifying!
8. owebmaster ◴[] No.44693265[source]
is it possible to add the hover to the parent without also adding it to the child ?
replies(1): >>44693587 #
9. owebmaster ◴[] No.44693270{3}[source]
Which is a indication they might not know CSS that well.
replies(2): >>44693508 #>>44696125 #
10. MrJohz ◴[] No.44693508{4}[source]
Based on other replies, I believe they understood CSS well enough, but didn't understand the exact behaviour of the `group` class in Tailwind. Given neither of your comments seem to have made much sense given the context of the discussion, I wonder if you're just looking for confirmation of things you already 'know'.

EDIT: I'm sorry, I mixed you up with the other user who was replying criticising other people's CSS knowledge.

11. MrJohz ◴[] No.44693587[source]
What do you mean? It's possible to apply attributes to any element in an arbitrary state: `hover:bg-black` would give an element a black background on hover. It's also apparently possible to apply attributes based on whether a state is fulfilled for a child element (i.e. the :has selector). E.g. `has-[:hover]:bg-black` would give an element a black background if any child is hovered.
replies(1): >>44697358 #
12. omnimus ◴[] No.44693819{3}[source]
Tailwind has few :has tools but it’s imho terrible. They keep inflating the system to nonsense.
13. reactordev ◴[] No.44696125{4}[source]
I’m sorry but :has is new. 2023. Forgive this grey beard that built the world you know.
replies(2): >>44697304 #>>44698014 #
14. reactordev ◴[] No.44696147{3}[source]
This.
15. owebmaster ◴[] No.44697304{5}[source]
No need to apologize, it just does not make sense to belittle other people's work when you lack the knowledge to judge it. Nobody told you it used JS for the effect, you conjured that up yourself.
16. owebmaster ◴[] No.44697358{3}[source]
> What do you mean?

the second part of your answer answered it perfectly. Thanks

17. Rapzid ◴[] No.44698014{5}[source]
Baseline 2023 meaning all major browsers supported it in their latest versions sometime in 2023.. Like all new CSS stuff it's probably been a very long time coming. Everyone can't pay attention to everything though, regardless of their beard color.
18. ◴[] No.44699353{3}[source]