-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(fab): Enable padding customization #2959
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2959 +/- ##
======================================
Coverage 98.3% 98.3%
======================================
Files 101 101
Lines 4368 4368
Branches 564 564
======================================
Hits 4294 4294
Misses 74 74 Continue to review full report at Codecov.
|
Discussed with @abhiomkar offline. Instead of using global variables, we'll create mixins, to allow for the potential of different customizations for FABs on different views (e.g. a primary/front view vs. secondary/subsidiary views). I had initially pondered encoding the relationship between icon size and padding all within the icon-size mixin, but Abhinay pointed out that it would probably require significantly more mental overhead for the simple case where someone has redlines they want to apply. So instead, we'll expose mixins allowing direct adjustment of the icon and label paddings. Otherwise, the approach in this PR is nice, since the negative margin automatically accommodates the intended difference between label-side and icon-side edge padding. |
packages/mdc-fab/_mixins.scss
Outdated
} | ||
|
||
@mixin mdc-fab-extended-label-padding($label-padding) { | ||
padding: 0 $mdc-fab-extended-label-padding; |
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.
$label-padding
packages/mdc-fab/_mixins.scss
Outdated
.mdc-fab__icon { | ||
@include mdc-rtl-reflexive-property( | ||
margin, | ||
$mdc-fab-extended-icon-padding - $mdc-fab-extended-label-padding, |
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 variable names throughout these mixins need to be updated to reference the mixin parameters, otherwise they will never actually customize anything.
We should ideally have an additional screenshot test page under mdc-fab/mixins
to test these.
packages/mdc-fab/README.md
Outdated
@@ -112,6 +112,8 @@ Mixin | Description | |||
`mdc-fab-container-color($color)` | Sets the container color to the given color | |||
`mdc-fab-icon-size($width, $height)` | Sets the icon `width`, `height`, and `font-size` properties to the specified `width` and `height`. `$height` is optional and will default to `$width` if omitted. The `font-size` will be set to the provided `$width` value. | |||
`mdc-fab-ink-color($color)` | Sets the ink color to the given color | |||
`mdc-fab-extended-padding($icon-padding, $label-padding)` | Sets the padding of icon sides (Left side and gutter space) and label side for Extended FAB. The left & right padding of the icon are equal. |
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'm suggesting some rephrasings for each of these, to try to simplify and clarify when to use each.
"Sets the padding on both sides of the icon, and between the label and the edge of the FAB. In cases where there is no icon, $label-padding
will apply to both sides."
packages/mdc-fab/README.md
Outdated
@@ -112,6 +112,8 @@ Mixin | Description | |||
`mdc-fab-container-color($color)` | Sets the container color to the given color | |||
`mdc-fab-icon-size($width, $height)` | Sets the icon `width`, `height`, and `font-size` properties to the specified `width` and `height`. `$height` is optional and will default to `$width` if omitted. The `font-size` will be set to the provided `$width` value. | |||
`mdc-fab-ink-color($color)` | Sets the ink color to the given color | |||
`mdc-fab-extended-padding($icon-padding, $label-padding)` | Sets the padding of icon sides (Left side and gutter space) and label side for Extended FAB. The left & right padding of the icon are equal. | |||
`mdc-fab-extended-label-padding($label-padding)` | Sets the label side padding for Extended FAB. This padding size will be applied to both sides when Extended FAB is rendered without icon. |
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.
Change the second sentence to "Useful in lieu of mdc-fab-extended-padding
when styling an Extended FAB with no icon."
…to README." Also added new screenshot tests for mixins
packages/mdc-fab/README.md
Outdated
@@ -112,8 +112,8 @@ Mixin | Description | |||
`mdc-fab-container-color($color)` | Sets the container color to the given color | |||
`mdc-fab-icon-size($width, $height)` | Sets the icon `width`, `height`, and `font-size` properties to the specified `width` and `height`. `$height` is optional and will default to `$width` if omitted. The `font-size` will be set to the provided `$width` value. | |||
`mdc-fab-ink-color($color)` | Sets the ink color to the given color | |||
`mdc-fab-extended-padding($icon-padding, $label-padding)` | Sets the padding of icon sides (Left side and gutter space) and label side for Extended FAB. The left & right padding of the icon are equal. | |||
`mdc-fab-extended-label-padding($label-padding)` | Sets the label side padding for Extended FAB. This padding size will be applied to both sides when Extended FAB is rendered without icon. | |||
`mdc-fab-extended-padding($icon-padding, $label-padding)` | Sets the padding on both sides of the icon, and between the label and the edge of the FAB. In cases where there is no icon, $label-padding will apply to both sides. |
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.
Nit: backticks around $label-padding
test/screenshot/golden.json
Outdated
@@ -125,6 +125,15 @@ | |||
"desktop_windows_ie@11": "https://storage.googleapis.com/mdc-web-screenshot-tests/kfranqueiro/2018/05/25/21_14_58_299/6b0f3e00/mdc-fab/classes/mini.html.win10_ie11.png" | |||
} | |||
}, | |||
"mdc-fab/mixins/mdc-fab-extended-label-adding.html": { |
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.
Typo in filename? adding -> padding?
packages/mdc-fab/package.json
Outdated
@@ -18,6 +18,7 @@ | |||
"@material/elevation": "^0.36.1", | |||
"@material/ripple": "^0.36.0", | |||
"@material/theme": "^0.35.0", | |||
"@material/typography": "^0.35.0" | |||
"@material/typography": "^0.35.0", | |||
"@material/rtl": "^0.36.0" |
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.
Nit: put rtl after ripple
Fixes #2900
This change enables padding customization for Extended FAB including icon & label side padding. This approach uses Sass variables instead of mixins since the icons side padding needs to be calculated based on the label side padding. It avoids creating additional class name for Extended FAB without icon.