Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created page for :has-slotted and links to reference it #36865

Merged
merged 14 commits into from
Dec 2, 2024

Conversation

dletorey
Copy link
Contributor

Description

  • Added page for :has-slotted
  • Added See also links to:
    • <template> HTML element
    • <slot> HTML element
    • ::slotted CSS pseudo-element

Motivation

Related issues and pull requests

@dletorey dletorey requested review from a team as code owners November 19, 2024 17:11
@dletorey dletorey requested review from estelle and removed request for a team November 19, 2024 17:11
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs Content:HTML Hypertext Markup Language docs labels Nov 19, 2024
@github-actions github-actions bot added the size/m [PR only] 51-500 LoC changed label Nov 19, 2024
Copy link
Contributor

github-actions bot commented Nov 19, 2024

@dletorey dletorey requested review from pepelsbey and removed request for estelle November 19, 2024 17:14
Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks :)

I have a suggestion, still. It took me a while to wrap my head around the example with all templating and slotting. Since it’s a CSS selector, I wonder if we can simplify the demo, even though it would be less practical. I think it’s fine for a reference page. Something like this, maybe?

<p>
  <template shadowrootmode="open">
    <style>
      :has-slotted {
        color: tomato;
      }
    </style>
    <slot name="one">Placeholder 1</slot>
    <slot name="two">Placeholder 2</slot>
  </template>
  <span slot="one">Slotted content</span>
</p>
image

@dletorey
Copy link
Contributor Author

Looks good! Thanks :)

I have a suggestion, still. It took me a while to wrap my head around the example with all templating and slotting. Since it’s a CSS selector, I wonder if we can simplify the demo, even though it would be less practical. I think it’s fine for a reference page. Something like this, maybe?

<p>
  <template shadowrootmode="open">
    <style>
      :has-slotted {
        color: tomato;
      }
    </style>
    <slot name="one">Placeholder 1</slot>
    <slot name="two">Placeholder 2</slot>
  </template>
  <span slot="one">Slotted content</span>
</p>
image

I have added this simple example and also left in the original example.
I have also commented out both of the examples as there is an issue with the Play ground feature not rendering these examples, so once this has been resolved these examples can easily be added back into the page.
I have successfully been able to make this simple example work in a code pen.

@pepelsbey
Copy link
Member

I have also commented out both of the examples as there is an issue with the Playground feature not rendering these examples

I believe the issue affects only the preview. It should be fine in production. So I’d uncomment examples. They should be fine.

As for the complex example, would it be better to have it somewhere in the web components guides/references? I’m concerned that it involves so many APIs that it would be hard to fully understand the :has-slotted role in the final result.

@dletorey
Copy link
Contributor Author

dletorey commented Dec 2, 2024

As for the complex example, would it be better to have it somewhere in the web components guides/references? I’m concerned that it involves so many APIs that it would be hard to fully understand the :has-slotted role in the final result.

I shall remove this then.

Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I hope you can find a use for your example. It’s a good one :)

Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid the term "simple"; it may not be simple for someone.

files/en-us/web/css/_colon_has-slotted/index.md Outdated Show resolved Hide resolved
@pepelsbey
Copy link
Member

please avoid the term "simple"; it may not be simple for someone.

I suggested removing this title altogether.

@estelle By the way, would a “Simpler example” be better in a similar case?

@estelle
Copy link
Member

estelle commented Dec 2, 2024

please avoid the term "simple"; it may not be simple for someone.

I suggested removing this title altogether.

@estelle By the way, would a “Simpler example” be better in a similar case?

Only one example, so your removing suggestion is better than my update suggestion.

I avoid using "simple" in all forms as much as possible because of the issue mentioned above but also because it is a term used in some specs. For example, "simple selector". When needed, though, I try to work in "simpler" instead of "simple". In this case, basic is best because it is a basic example whereas simpler would mean there is a more complex example that this example is simpler than.

(it's way too early for me to be working so apologies if i make little sense)

@dletorey dletorey merged commit f47d719 into mdn:main Dec 2, 2024
8 checks passed
@dletorey dletorey deleted the 36533-has-slotted-pseudo-selector branch December 2, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs Content:HTML Hypertext Markup Language docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants