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

fix(material-experimental/mdc-typography): update mdc components typography to match spec #21676

Merged
merged 5 commits into from
Feb 2, 2021

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Jan 22, 2021

This PR contains several change that bring the MDC-based components in line with the spec w.r.t typography.

  1. It adds a new typography config generation function that creates a config based on values from MDC itself. This results in changes to some typography levels, most noticeable the body-1 and body-2 levels. Since the config is based on MDC's values it contains rem measurements rather than px measurements that Angular Material as traditionally used. In this PR the new config is used in the dev-app only for the MDC-based components. The MDC-based config is currently not compatible with the old components, but it will be made compatible in a followup PR.
  2. Switches all the MDC components to read 2018 typography levels if they are available in the config. If they are not available, the 2014 levels are mapped to 2018 levels so the MDC components can consume them.
  3. Corrects several places where the wrong typography level was being used (body-1 looks very similar to subtitle-1 which lead to them being used interchangeably).
  4. Corrects some sizing styles for the MDC-based form-field so it looks right with the new typography levels.

Demo: https://mmalerba-demo.web.app/mdc-autocomplete

CARETAKER NOTE: mmalerba will handle syncing

@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 22, 2021
@mmalerba mmalerba force-pushed the mdc-typog-g3 branch 3 times, most recently from 08b60ab to 46a63f6 Compare January 26, 2021 21:20
@mmalerba mmalerba added P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note merge: preserve commits When the PR is merged, a rebase and merge should be performed labels Jan 26, 2021
@mmalerba mmalerba changed the title fix(material-experimental/mdc-typography): fix always using mat-level fix(material-experimental/mdc-typography): use correct typography levels Jan 26, 2021
@mmalerba mmalerba marked this pull request as ready for review January 26, 2021 21:31
// MDC uses the `subtitle1` level for list items, but the spec shows `body1` as the correct
// level.
.mat-mdc-option {
@include mdc-typography(body1, $query: $mat-typography-styles-query);
Copy link
Member

Choose a reason for hiding this comment

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

These seem to be the same between autocomplete and select. Maybe we should do it once inside the option theme instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't see an existing mixin for option typography

Copy link
Member

Choose a reason for hiding this comment

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

There's mat-mdc-option-typography. Also now that I'm thinking about it, we likely need the same typography change for mat-optgroup since it uses the same size as the option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh hmm, don't know how I missed that, I'll move it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just took a look through the external & internal specs as well as demos, and I don't see anything that mentions menu/option groups. I guess maybe we'll just have to pick something reasonable looking for now

Copy link
Member

Choose a reason for hiding this comment

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

The groups are set up to look like options, except that they aren't clickable, so the same styles can be applied.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think they're currently set to be subtitle1 which makes sense, after the typography levels are updated it'll wind up looking nearly identical to the options (except for the letter spacing) https://material.io/design/typography/the-type-system.html#type-scale

Copy link
Member

Choose a reason for hiding this comment

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

Funnily enough, the link you just sent has an example of an option group which is somewhat different than what we have. Anyway, my comment was mostly to raise awareness that we might want to change the option groups as well, I don't have an opinion on what they should be changed to.
The_type_system_-Material_Design-_Google_Chrome_2021-01-26_23-33-08

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created a PR based on this one that uses a config created from MDC's typography settings: #21709 That should give an idea of how things should eventually end up looking. Though looking at it, the form-field appears to need a little more work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like they're using the overline level for the option group, we may want to do that too but I'll leave it for another PR.

@mmalerba mmalerba changed the title fix(material-experimental/mdc-typography): use correct typography levels fix(material-experimental/mdc-typography): update mdc components typography to match spec Jan 28, 2021
@mmalerba
Copy link
Contributor Author

I discussed with Jeremy and we decided its best to roll the function to create a typography config from MDC's values into this PR. I've updated it and added a demo of the latest code in the PR description.

@jelbourn
Copy link
Member

jelbourn commented Jan 28, 2021

Does the mdc-paginator look weird?
image

I feel like the label and the select aren't in proportion

@mmalerba
Copy link
Contributor Author

Yeah it does look a little weird. I think the paginator is just applying the dense form-field styles (which does not change the font size). I can try adding some overrides though

@mmalerba
Copy link
Contributor Author

added an override for the paginator and updated the demo

// MDC uses the `subtitle1` level for list items, but the spec shows `body1` as the correct
// level. Class is repeated for increased specificity.
.mat-mdc-option {
@include mdc-typography(body1, $query: $mat-typography-styles-query);
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a bug filed for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have an internal one filed against our gmat components - the difference is almost imperceptible with the external spec, just the letter spacing is different. I haven't opened an bug against MDC yet.

position: absolute;
top: 0;
left: 0;
right: 0;
Copy link
Member

Choose a reason for hiding this comment

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

Is it intentional to not include bottom here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the idea is to behave like the non-MDC form-field where the user can add multiple error/hint or long ones that wrap, but they'll have to reserve space for it themselves. We only reserve space in the layout for one line worth of message.

Copy link
Member

Choose a reason for hiding this comment

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

We should maybe talk about this- I think we should change our behavior over to what mdc does, but I know that would be pretty breaking, so we should think about doing a follow-up that lets users switch.

border: none;
}

// In order to ensure proper alignment of the floating label, we reset its line-height.
// The line-height is not important as the element is absolutely positioned and only has one line
Copy link
Member

Choose a reason for hiding this comment

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

Instead of saying "is not important", would it be accurate to say "doesn't affect the size of the element" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really, it does affect the size of the element - its just that we absolutely position the element, so the size doesn't affect the rest of the layout, and its not important as far as the line spacing since labels are only one line anyways

@google-cla
Copy link

google-cla bot commented Jan 29, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot removed the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 29, 2021
@google-cla google-cla bot added the cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla label Jan 29, 2021
@google-cla google-cla bot added cla: yes PR author has agreed to Google's Contributor License Agreement and removed cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla labels Jan 29, 2021
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Feb 1, 2021
@mmalerba mmalerba merged commit d7ec42c into angular:master Feb 2, 2021
mmalerba added a commit to mmalerba/components that referenced this pull request Feb 2, 2021
wagnermaciel pushed a commit that referenced this pull request Feb 2, 2021
wagnermaciel pushed a commit to wagnermaciel/components that referenced this pull request Feb 8, 2021
wagnermaciel pushed a commit to wagnermaciel/components that referenced this pull request Feb 8, 2021
@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 Mar 5, 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 cla: yes PR author has agreed to Google's Contributor License Agreement merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note merge: preserve commits When the PR is merged, a rebase and merge should be performed P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants