Comments on: A Modest Web Components Styling Proposal: An “I Know What I’m Doing” Selector https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/ Helping Your Journey to Senior Developer Sun, 21 Jan 2024 00:21:19 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: Niko https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/#comment-375 Sun, 21 Jan 2024 00:21:19 +0000 https://frontendmasters.com/blog/?p=479#comment-375 In reply to Chris Coyier.

Not knowing what does and doesn’t have a part is huge. In React, you can use normal CSS to target anything normally. Why not with Web Components too?

]]>
By: Joe Pea (@trusktr) https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/#comment-367 Fri, 19 Jan 2024 23:35:12 +0000 https://frontendmasters.com/blog/?p=479#comment-367 In reply to Michael.

With great power comes great responsibility. 🙂

]]>
By: Joe Pea (@trusktr) https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/#comment-366 Fri, 19 Jan 2024 23:34:45 +0000 https://frontendmasters.com/blog/?p=479#comment-366 In reply to Jochen KĂĽhner.

I remember this! I think we need something similar, but with more control like the idea here.

]]>
By: Joe Pea (@trusktr) https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/#comment-365 Fri, 19 Jan 2024 23:32:49 +0000 https://frontendmasters.com/blog/?p=479#comment-365 In reply to Um Nontasuwan.

Hey Um! Although that’s a great workaround for now, the ideal native solution would not require any JavaScript, only HTML and CSS.

]]>
By: Joren Broekema https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/#comment-306 Sun, 14 Jan 2024 09:02:06 +0000 https://frontendmasters.com/blog/?p=479#comment-306 So basically the reintroduction of ::shadow or /deep/ selectors.

These solutions were removed because they felt way too powerful (and possibly performance? I don’t recall exactly..)

Right now it is designed to give component authors control. My take on that is if a component consumer is desperate enough they will always find a way, it’s what programmers do. I prefer keeping things flexible and it feels like the main thing holding webcomponents back is not being able to style their shadow DOMs. CSS frameworks or just using external global stylesheets (think Tailwind) also just isn’t compatible with the idea and design of shadow DOM, I think Justin Fagnani’s open stylable proposal tackles that use case as well whereas a penetrating shadow selector does not, so I feel like that idea should be considered too.. still opt-in for component authors but perhaps should have a “danger hatch” for consumers to make it open?

]]>
By: Kevin Kipp https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/#comment-305 Sun, 14 Jan 2024 05:40:17 +0000 https://frontendmasters.com/blog/?p=479#comment-305 I 100% get the desire for this, but shadow DOM right now is offering a promise to authors that they can lock users out of styling their web components. I could imagine people being pretty sour if they had built web components using shadow DOM explicitly for this reason and then having that guarantee taken away. Unfortunately, I feel like this would go against the “don’t break the web” ethos — wouldn’t it?

In any case, hopefully people start using more light DOM with web components anyways, obviating the need for something like this.

]]>
By: Jeremy https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/#comment-303 Sun, 14 Jan 2024 01:21:51 +0000 https://frontendmasters.com/blog/?p=479#comment-303 In reply to Chris Coyier.

Beyond changing the distributed component code I do not believe web components easily allow mode switching. This is purposeful because the nested children may not be rendered or used in the same way as the plain html shows.

For example a list component may just have a single ul in the dom but jump across the shadow boundary and that list could be rendered inside a data tables setup with some other magic sauce added. This could work on the regular dom but leveraging the shadow dom allows non-destructive updates. (Changing the list without updating the original or the reverse. Data manipulation that updates the existing dom list)

Web component styling is still a giant pain for no reason though. There are work arounds but the encapsulation is too aggressive. It causes more pain than what it solves.

]]>
By: Chris Coyier https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/#comment-300 Sat, 13 Jan 2024 17:11:34 +0000 https://frontendmasters.com/blog/?p=479#comment-300 In reply to Danny Engelman.

I don’t understand.

]]>
By: Chris Coyier https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/#comment-299 Sat, 13 Jan 2024 17:11:09 +0000 https://frontendmasters.com/blog/?p=479#comment-299 In reply to Jason Smith.

Just not a fan of ::part. It’s fake CSS. You can’t do ::part > h3. You can’t do ::part:checked. You have to document what has a part and what doesn’t so any consumer can find it. It’s not a real styling solution.

]]>
By: Michael https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/#comment-295 Sat, 13 Jan 2024 09:24:10 +0000 https://frontendmasters.com/blog/?p=479#comment-295 I fixed so many awful code during the years, I am sure people who wrote it were all convinced they knew what they were doing

]]>