Skip to content

docs(guide): add CSS Shadow Parts guide - #1530

Merged
brandyscarney merged 5 commits into
masterfrom
docs-css-shadow-parts
Jul 29, 2020
Merged

brandyscarney merged 5 commits into
masterfrom
docs-css-shadow-parts

Conversation

@brandyscarney

Copy link
Copy Markdown
Member

@perrygovier
perrygovier temporarily deployed to ionic-docs-pr-1530 July 16, 2020 20:51 Inactive
@brandyscarney
brandyscarney temporarily deployed to ionic-docs-pr-1530 July 16, 2020 21:21 Inactive
Comment thread src/pages/theming/css-shadow-parts.md Resolved
Comment thread src/pages/theming/css-shadow-parts.md Resolved
Comment thread src/pages/theming/css-shadow-parts.md Resolved
Comment thread src/pages/theming/css-shadow-parts.md Outdated

For example, `my-component::part(button)::part(label)` does not match anything. This is because doing so would expose more structural information than is intended.

If the `<my-component>`’s internal button uses something like `part="label => button-label"` to forward the button’s internal parts up into the panel’s own part element map, then a selector like `my-component::part(button-label)` would select just the one button’s label, ignoring any other labels. No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I haven't seen this syntax before label => button-label. Is there an MDN doc we can link to where people can read more?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@liamdebeasi liamdebeasi Jul 17, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok that should be fine. I guess it just doesn't make a lot of sense to me - the spec doesn't give much information as to the => syntax. (also the example they use doesn't make sense. why not just apply part="confirm-label" directly to the label?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree it's confusing. It's like the following:

<my-component>
  #shadow-root
    <my-button part="button">
      #shadow-root
      <div part="label"></div>
    </my-button>
</my-component>

So this wouldn't work:

my-component::part(button)::part(label) {

but if the button somehow forwards the part then it would work like:

my-component::part(button-label)

I guess it would look like this:

<my-component>
  #shadow-root
    <my-button part="button label => button-label">
      #shadow-root
      <div part="label"></div>
    </my-button>
</my-component>

I need to test this out though and then maybe I could add more usage. I don't think it applies to Ionic components right now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ohh I see ok that makes sense. Yeah I don't think we use this in the framework anywhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not right now. This could maybe end up being a problem for things like ion-infinite-scroll-content, for example, if we allowed them to target parts on the spinner.

@mhartington mhartington left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great! Left one small suggestion, but this could be merged in as it if it doesn't make sense.

See <a href="https://github.com/w3c/csswg-drafts/issues/4530" target="_blank" rel="noopener noreferrer">this issue on GitHub</a> for more information.


### Structural Pseudo-Classes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we have an example just to show what would work?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For structural pseudo classes?

Comment thread src/pages/theming/css-shadow-parts.md Resolved
@brandyscarney
brandyscarney merged commit 36fc046 into master Jul 29, 2020
@brandyscarney
brandyscarney deleted the docs-css-shadow-parts branch July 29, 2020 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

theming: include documentation on shadow parts

5 participants