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

MDC Migration: Globally restyle mat-icon-button #6608

Merged
merged 5 commits into from
Oct 3, 2023

Conversation

rileyajones
Copy link
Contributor

@rileyajones rileyajones commented Sep 28, 2023

Motivation for features / changes

One of the biggest changes we have noticed during the mdc migration appears in the mat-icon-button. I am opting to attempt to fix them all at once by modifying the global files present in the theme file, then tweaking specific buttons.

Screenshots of UI changes (or N/A)

Before

Light Mode

image

Dark Mode

image

Extent Button

image

Table Header Buttons

image

After

Light Mode

image

Dark Mode

image

Extent Button

image

Table Header Buttons

image

After with Restyling

Light Mode

image

Dark Mode

image

Extent Button

image

Table Header Buttons

image

Googlers see

Light Mode
Dark Mode

@rileyajones rileyajones marked this pull request as ready for review September 28, 2023 23:29
@rileyajones rileyajones requested a review from bmd3k September 28, 2023 23:30

mat-icon.mat-icon,
svg {
width: 1em;
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly, the affect of setting width and height to "1em" is that we can now control svg size by using "font-size" property?

That's interesting but I also think it's counter intuitive and probably the wrong path to go down. Consider:

  • Angular defines its icon and button sizes in terms of pixels.
  • We load our icons in terms of pixels (they are all loaded as 24px).
  • The large majority of our icons are displayed as 24px x 24px and that has been perfectly fine.

We really should just put:
height: 24px;
width: 24px;
To be consistent with the defaults of the current UI.

If there is a component that wants to specify a smaller icon (say, for example, the icons in the runs table) then they can just also specify their overrides in terms of pixels.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do you feel about meeting in the middle with a css variable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, a css variable seems like a reasonable idea.

I don't have a lot of experience with them - is there a way to document the variable in a way that is discoverable and understandable by those who actually need to use it?

}

mat-icon.mat-icon {
min-width: 1em;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think what you're really looking for is:

flex-shrink: 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, that is cleaner

@@ -60,6 +50,18 @@ $_icon_size: 12px;
line-height: 1;
}

button.sorting-icon-container,
Copy link
Contributor

Choose a reason for hiding this comment

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

  button[mat-icon-button].mat-mdc-icon-button {
    &.sorting-icon-container,
    &.context-menu-container {
      border-radius: 5px;
      font-size: 0;
      height: $_icon_size + 4px;
      padding: 0;
      width: $_icon_size + 4px;

      mat-icon, ::ng-deep svg {
        height: $_icon_size;
        line-height: 1;
        width: $_icon_size;
      }
    }

@@ -291,6 +291,33 @@ $tb-dark-theme: map_merge(
}
}

body,
Copy link
Contributor

Choose a reason for hiding this comment

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

To summarize various comments below:

  body,
  body.dark-mode {
    a[mat-icon-button].mat-mdc-icon-button,
    button[mat-icon-button].mat-mdc-icon-button {
      height: 40px;
      width: 40px;
      display: inline-flex;
      justify-content: center;
      align-items: center;

      .mat-mdc-button-touch-target {
        height: 100%;
        width: 100%;
      }

      mat-icon.mat-icon {
        flex-shrink: 0;
      }

      mat-icon.mat-icon,
      svg {
        height: 24px;
        width: 24px;
      }
    }
  }

@@ -61,6 +61,10 @@ $metrics-min-card-height: 320px;
@mixin metrics-card-controls {
@include tb-theme-foreground-prop(color, secondary-text);
white-space: nowrap;

::ng-deep button[mat-icon-button] {
font-size: 16px;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is unnecessary with my other suggestions. I think the 24px x 24px default is perfectly fine here.


::ng-deep button[mat-icon-button] {
font-size: 16px;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Somewhere in the metrics code we (unsuccessfully) try to override the height of the pin icon to 18px (I see it in the css browser but it doesn't get applied). Can you remove that as part of this change?

I think it looks perfectly fine at 24px x 24px. The reason it might look odd to someone is because the two icons directly surrounding it are a bit squat - but that's not really the pin icon's problem.

@rileyajones rileyajones requested a review from bmd3k October 3, 2023 17:58

// ::ng-deep button[mat-icon-button] {
// font-size: 16px;
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Somewhere in the metrics code we (unsuccessfully) try to override the height of the pin icon to 18px (I see it in the css browser but it doesn't get applied). Can you remove that as part of this change?

Can you address this comment I left previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch on the pin icon size. I removed the failed overrides.

@rileyajones rileyajones merged commit 21bef1b into tensorflow:MDCMigration Oct 3, 2023
rileyajones added a commit that referenced this pull request Jan 30, 2024
## Motivation for features / changes
During the mdc-migration I restyled all the buttons via #6608 and only
recently noticed that the `mat-calendar` component (which is only used
internally) looked pretty off...

To resolve this I am allowing button widths and heights to be set
separately then overriding them in the internal date picker component
(Googlers see cl/601592566).

## Screenshots of UI changes (or N/A)

Before - https://screenshot.googleplex.com/AKuAQqzf9g6K2GF
After - https://screenshot.googleplex.com/7s6vm8SsajKg9v7
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.

3 participants