Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(list): fix checkbox alignment and match dense heights to spec
Browse files Browse the repository at this point in the history
- match the spec update where `md-dense` list items are `40px` in height by default
  - was `48px` in height
- support `.md-dense-disabled`
- for `.md-dense` lists: align heights with spec for list items with primary icons,
  avatars/avatar icons, secondary buttons, and checkboxes
- `md-subheaders` in `.md-dense` lists should match the single line list item height
  - `48px` -> `40px`

Fixes #11966

BREAKING CHANGE: `md-list` with the `md-dense` class has been updated to align with the Material Design specification. This means that `md-list-item`s heights have changed when using `md-dense`. The `md-dense-disabled` class is now supported on `md-list`. After updating to this version, you may need to adjust the layout of your app if you use `md-dense` with `md-list` or customize the layout of `md-checkbox`s within `md-list-item`s.
  • Loading branch information
Splaktar committed Jul 22, 2020
1 parent f2fca2e commit a13722e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
2 changes: 0 additions & 2 deletions src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ $button-fab-mini-line-height: rem(4.00) !default;

$button-fab-toast-offset: $button-fab-height * 0.75 !default;

$icon-button-height: rem(4.000) !default;
$icon-button-width: rem(4.000) !default;
$icon-button-margin: rem(0.600) !default;

// Fix issue causing buttons in Firefox to be 2px bigger than they should
Expand Down
34 changes: 26 additions & 8 deletions src/components/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $list-item-height: 6 * $baseline-grid !default;
$list-item-two-line-height: 9 * $baseline-grid !default;
$list-item-three-line-height: 11 * $baseline-grid !default;

$list-item-dense-height: 12 * $dense-baseline-grid !default;
$list-item-dense-height: 10 * $dense-baseline-grid !default;
$list-item-dense-two-line-height: 15 * $dense-baseline-grid !default;
$list-item-dense-three-line-height: 19 * $dense-baseline-grid !default;
$list-item-dense-primary-icon-width: $dense-baseline-grid * 5 !default;
Expand All @@ -48,7 +48,7 @@ md-list {
line-height: $list-header-line-height;
}

&.md-dense {
&.md-dense:not(.md-dense-disabled) {
md-list-item {
&,
.md-list-item-inner {
Expand All @@ -65,15 +65,28 @@ md-list {

> md-icon:first-child:not(.md-avatar-icon) {
@include rtl-prop(margin-right, margin-left, $list-item-primary-width - $list-item-dense-primary-icon-width, auto);
margin-top: $dense-baseline-grid;
margin-bottom: $dense-baseline-grid;
}
.md-avatar, .md-avatar-icon {
@include rtl-prop(margin-right, margin-left, $list-item-primary-width - $list-item-dense-primary-avatar-width, auto);
margin-top: $dense-baseline-grid + 2px;
margin-bottom: $dense-baseline-grid + 2px;
}
.md-avatar {
flex: none;
width: $list-item-dense-primary-avatar-width;
height: $list-item-dense-primary-avatar-width;
}
.md-secondary-container {
.md-secondary.md-button {
margin-top: $dense-baseline-grid;
margin-bottom: $dense-baseline-grid;
}
md-checkbox:not(.md-dense-disabled) {
min-height: $icon-button-height;
}
}
}

&.md-2-line,
Expand Down Expand Up @@ -123,6 +136,10 @@ md-list {
}
}
}
.md-subheader-inner {
padding-top: $dense-baseline-grid * 3;
padding-bottom: $dense-baseline-grid * 3;
}
}
}

Expand Down Expand Up @@ -277,9 +294,9 @@ md-list-item {

& > md-checkbox {
width: 3 * $baseline-grid;
@include rtl(margin-left, 3px, 29px);
@include rtl(margin-right, 29px, 3px);
margin-top: 16px;
min-height: $icon-button-height;
@include rtl(margin-left, 0px, 29px);
@include rtl(margin-right, 29px, 0px);
}

.md-secondary-container {
Expand Down Expand Up @@ -311,11 +328,12 @@ md-list-item {
}

md-checkbox {
margin-top: 0;
margin-bottom: 0;
margin: 0 6px;
padding: 0 8px;
min-height: $icon-button-height;

&:last-child {
width: 3 * $baseline-grid;
width: $icon-button-width;
@include rtl-prop(margin-right, margin-left, 0, auto);
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/core/style/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ $layout-breakpoint-sm: 960px !default;
$layout-breakpoint-md: 1280px !default;
$layout-breakpoint-lg: 1920px !default;

// Button
$button-left-right-padding: rem(0.800) !default;

// Icon
$icon-size: rem(2.400) !default;

Expand Down Expand Up @@ -119,8 +116,12 @@ $material-leave-duration: 0.3s;
$material-leave-timing-function: cubic-bezier(0.4, 0.0, 1, 1);
$material-leave: all $material-leave-duration $material-leave-timing-function;

// Button
$button-left-right-padding: rem(0.800) !default;
$icon-button-height: rem(4.000) !default;
$icon-button-width: rem(4.000) !default;

// Fab Buttons (shared between buttons.scss and fab*.scss)
// -------------------------------------------
$button-fab-width: rem(5.600) !default;
$button-fab-height: rem(5.600) !default;
$button-fab-padding: rem(1.60) !default;
Expand Down

0 comments on commit a13722e

Please sign in to comment.