Skip to content

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

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 5 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tensorboard/webapp/metrics/views/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

}

@mixin metrics-empty-message {
Expand Down
30 changes: 30 additions & 0 deletions tensorboard/webapp/theme/_tb_theme.template.scss
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,36 @@ $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;
      }
    }
  }

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

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

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

mat-icon.mat-icon,
svg {
width: var(--tb-icon-size);
height: var(--tb-icon-size);
}
}
}
}

// Cannot use `tb-dark-theme` as :host-context in the global stylesheet is
// meaningless.
body.dark-mode {
Expand Down
23 changes: 13 additions & 10 deletions tensorboard/webapp/widgets/data_table/header_cell_component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.

$_accent: map-get(mat.get-color-config($tb-theme), accent);
$_icon_size: 12px;
$_icon_padding: 4px;

:host {
display: table-cell;
Expand All @@ -40,16 +41,6 @@ $_icon_size: 12px;
}
}

.sorting-icon-container,
.context-menu-container {
width: $_icon_size + 4px;
height: $_icon_size + 4px;
border-radius: 5px;
display: flex;
justify-content: center;
align-items: center;
}

.cell {
align-items: center;
display: flex;
Expand All @@ -60,6 +51,18 @@ $_icon_size: 12px;
line-height: 1;
}

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

.sorting-icon-container {
::ng-deep path {
fill: unset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</g>
</svg>
<button
[class.extent-edit-button]="true"
class="extent-edit-button"
[class.extent-edit-menu-opened]="editMenuOpened"
mat-icon-button
#matMenuTrigger="matMenuTrigger"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,30 @@ text {
user-select: none;
}

$_icon_size: 16px;

.axis {
display: flex;
height: 100%;
width: 100%;

.extent-edit-button {
--tb-icon-size: #{$_icon_size};
height: 24px;
line-height: 24px;
position: absolute;
right: 5px;
top: 5px;
visibility: hidden;
width: 24px;
padding: 0;

mat-icon {
height: $_icon_size;
width: $_icon_size;
line-height: $_icon_size;
}
}
}

.major,
Expand Down Expand Up @@ -112,24 +132,6 @@ text {
}
}

.extent-edit-button {
background-color: mat.get-color-from-palette(mat.$gray-palette, 200);
font-size: 0;
height: 24px;
line-height: 24px;
position: absolute;
right: 5px;
top: 5px;
visibility: hidden;
width: 24px;

mat-icon {
height: 16px;
width: 16px;
line-height: 16px;
}
}

.extent-edit-input {
align-items: center;
column-gap: 5px;
Expand Down