Skip to content

docs(material/theming): revise customizing-component-styles #22466

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

Merged
merged 1 commit into from
Apr 21, 2021

Conversation

jelbourn
Copy link
Member

This change updates the customizing-component-styles doc to give more
specific guidance on overriding component styles. In particular:

  • Much stronger language to make it clear that this is not supported or
    recommended.
  • Reorganize content such that topics have a bit more cohesion/flow
  • Call out that layout/positioning styles on host elements are the only
    safe styles to apply.
  • Emphasize the perils of overrides in general

@jelbourn jelbourn added P2 The issue is important to a large percentage of users, with a workaround docs This issue is related to documentation merge safe target: major This PR is targeted for the next major release area: theming labels Apr 12, 2021
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Apr 12, 2021
@jelbourn jelbourn force-pushed the customizing-component-styles branch from abd4797 to 9330875 Compare April 12, 2021 23:15
@jelbourn jelbourn added target: rc This PR is targeted for the next release-candidate and removed target: major This PR is targeted for the next major release labels Apr 14, 2021
Copy link
Contributor

@twerske twerske left a comment

Choose a reason for hiding this comment

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

minor comments - lgtm overall!

[Angular documentation](https://angular.io/guide/component-styles#view-encapsulation). You may
also wish to take a look at
also wish to take a review
[_The State of CSS in Angular_](https://blog.angular.io/the-state-of-css-in-angular-4a52d4bd2700)
Copy link
Contributor

Choose a reason for hiding this comment

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

We're probably due for an update on The State of CSS in Angular with these new changes, this article is a bit dated (both date and content).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we should probably update our guidance once we drop IE11 support and we can throw our weight behind css variables (and maybe constructible stylesheets will be a thing by then, too)

This change updates the customizing-component-styles doc to give more
specific guidance on overriding component styles. In particular:
* Much stronger language to make it clear that this is not supported or
  recommended.
* Reorganize content such that topics have a bit more cohesion/flow
* Call out that layout/positioning styles on host elements are the only
  safe styles to apply.
* Emphasize the perils of overrides in general
@jelbourn jelbourn force-pushed the customizing-component-styles branch from 9330875 to a3a83c6 Compare April 16, 2021 23:32
@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Apr 16, 2021
Copy link

@TeriGlover TeriGlover left a comment

Choose a reason for hiding this comment

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

Editing review; a few minor suggestions.

### Component host elements

For any Angular Material component, you can safely define custom CSS for a component's host element
that affect the positioning or layout of that component, such as `margin`, `position`, `top`,

Choose a reason for hiding this comment

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

Suggested change
that affect the positioning or layout of that component, such as `margin`, `position`, `top`,
that affects the positioning or layout of that component, such as `margin`, `position`, `top`,


### Internal component elements

Avoid any custom styles or overrides on internal elements within a Angular Material components.

Choose a reason for hiding this comment

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

Suggested change
Avoid any custom styles or overrides on internal elements within a Angular Material components.
Avoid any custom styles or overrides on internal elements within Angular Material components.

Removed stray word.

[Angular documentation](https://angular.io/guide/component-styles#view-encapsulation). You may
also wish to take a look at
also wish to review

Choose a reason for hiding this comment

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

Suggested change
also wish to review
also want to review

The developer documentation style guide says to avoid this term.

// Add this to your global stylesheet after your theme setup
.myapp-no-padding-dialog .mat-dialog-container {
padding: 0;
// Add this to your global stylesheet after including theme mixins.

Choose a reason for hiding this comment

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

Suggested change
// Add this to your global stylesheet after including theme mixins.
// Add this to your global style sheet after including theme mixins.

Two words

affect the elements explicitly defined in your template. To affect descendants of components used
in your template, you can use one of the following approaches:

1. Define custom styles in a global stylesheet declared in the `styles` array of your `angular.json`

Choose a reason for hiding this comment

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

Suggested change
1. Define custom styles in a global stylesheet declared in the `styles` array of your `angular.json`
1. Define custom styles in a global style sheet declared in the `styles` array of your `angular.json`

Two words

@TeriGlover
Copy link

TeriGlover commented Apr 20, 2021 via email

@wagnermaciel wagnermaciel merged commit 52ac1e4 into angular:master Apr 21, 2021
wagnermaciel pushed a commit that referenced this pull request Apr 21, 2021
This change updates the customizing-component-styles doc to give more
specific guidance on overriding component styles. In particular:
* Much stronger language to make it clear that this is not supported or
  recommended.
* Reorganize content such that topics have a bit more cohesion/flow
* Call out that layout/positioning styles on host elements are the only
  safe styles to apply.
* Emphasize the perils of overrides in general

(cherry picked from commit 52ac1e4)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: theming cla: yes PR author has agreed to Google's Contributor License Agreement docs This issue is related to documentation P2 The issue is important to a large percentage of users, with a workaround target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants