-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat(layout-grid): Add fixed column width layout grid modifier. #816
Conversation
abd9153
to
7084558
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ 💯 Looks great
Codecov Report
@@ Coverage Diff @@
## master #816 +/- ##
=======================================
Coverage 99.93% 99.93%
=======================================
Files 68 68
Lines 3144 3144
Branches 387 387
=======================================
Hits 3142 3142
Misses 2 2 Continue to review full report at Codecov.
|
demos/layout-grid.html
Outdated
@@ -342,6 +384,21 @@ | |||
document.documentElement.style.setProperty('--mdc-layout-grid-gutter-phone', gutterSelectPhone.value); | |||
}); | |||
|
|||
var ColumnWidthSelectDesktop = document.querySelector('#desktop-column-width'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason these variables are capitalized?
packages/mdc-layout-grid/README.md
Outdated
A grid consists of a group of cells, which get positioned in sequence according to a predefined number of columns. | ||
Cells specify how many columns to span (the default being 4), and get placed side by side while there is room. When | ||
there isn't enough room for a cell, it gets moved to the beginning of the next row, and placement continues as usual. | ||
A grid is a container that consists of a group of cells. The grids can define its own max-width or designate its column to be a certain width. Cells get positioned in sequence according to a predefined number of columns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The grids"...do you mean "the cells"? I thought there was only one grid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. The grids I meant for mdc grids in general, but it seems use single will remove some confusion, changing that.
packages/mdc-layout-grid/README.md
Outdated
|
||
The grid has 12 columns in desktop mode (>= 840px), 8 columns in tablet mode (>= 480px), and 4 columns in phone mode | ||
(< 480px). Column widths are variable; margins and gutters are fixed, with columns taking up the remainder of the space. | ||
(< 480px). Cells specify how many columns to span (the default being 4), and get placed side by side while there is room. When there isn't enough room for a cell, it gets moved to the beginning of the next row, and placement continues as usual. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cells specify how many columns to span (the default is 4). Cells are placed side by side until there is no more room, then the next cell is placed at the beginning of the next row.
packages/mdc-layout-grid/README.md
Outdated
|
||
Margins (the space between the edge of the grid and the edge of the first cell) and gutters (the space between edges of adjacent cells) can be customized on different devices respectively based on design needs. Layout grids set default margins and gutters to 24px on desktop, 16px on tablet and phone, according to the Material Design spec. | ||
Margins (the space between the edge of the grid and the edge of the first cell) and gutters (the space between edges of adjacent cells) can be customized on different devices respectively based on design needs. The columns are evenly distributed after container minus all margin and gutter width. Layout grids set default margins and gutters to 24px on desktop, 16px on tablet and phone, according to the Material Design spec. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The columns are evenly distributed within the container width, minus the width of all margins and gutters.
@@ -122,3 +122,17 @@ | |||
align-self: stretch; | |||
} | |||
} | |||
|
|||
@mixin mdc-layout-grid-fixed-column-width($size, $margin, $gutter, $column-width) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$size is kinda a vague variable...can it be $platform-type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add the same error handling in the sass as we do in mdc-theme
? e.g.:
@if not map-has-key($mdc-layout-grid-columns, $size) {
@error "Invalid style specified! Choose one of #{map-keys($mdc-layout-grid-columns)}";
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the original code meant screen-size
and I don't think it is vague. Since we both documented that clearly and do the type check, I feel fine to leave just as it is. WDYT?
@@ -122,3 +122,17 @@ | |||
align-self: stretch; | |||
} | |||
} | |||
|
|||
@mixin mdc-layout-grid-fixed-column-width($size, $margin, $gutter, $column-width) { | |||
$columns: map-get($mdc-layout-grid-columns, $size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$columnCount?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit, one improvement requested 😺
@@ -122,3 +122,17 @@ | |||
align-self: stretch; | |||
} | |||
} | |||
|
|||
@mixin mdc-layout-grid-fixed-column-width($size, $margin, $gutter, $column-width) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add the same error handling in the sass as we do in mdc-theme
? e.g.:
@if not map-has-key($mdc-layout-grid-columns, $size) {
@error "Invalid style specified! Choose one of #{map-keys($mdc-layout-grid-columns)}";
}
@@ -36,6 +36,12 @@ $mdc-layout-grid-default-gutter: ( | |||
phone: 16px | |||
) !default; | |||
|
|||
$mdc-layout-grid-column-width: ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe $mdc-layout-grid-platform-column-widths
? It more closely follows the naming conventions of this pattern in other components.
It would obviously have to be changed in _mixins.scss
as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to look up for this pattern but haven't seen any one have this pattern 😞 The thing I search and found that use sass map to define different property based on screen size only appears in mdc-layout-grid
.
Not sure if I misunderstand what you meant here, could you elaborate a bit?
7084558
to
3022b65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Closes #748.