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

feat(fab): Enable padding customization #2959

Merged
merged 14 commits into from
Jun 22, 2018

Conversation

abhiomkar
Copy link
Contributor

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.

@codecov-io
Copy link

codecov-io commented Jun 19, 2018

Codecov Report

Merging #2959 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 153e737...852e47f. Read the comment docs.

@kfranqueiro
Copy link
Contributor

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.

}

@mixin mdc-fab-extended-label-padding($label-padding) {
padding: 0 $mdc-fab-extended-label-padding;
Copy link
Contributor

Choose a reason for hiding this comment

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

$label-padding

.mdc-fab__icon {
@include mdc-rtl-reflexive-property(
margin,
$mdc-fab-extended-icon-padding - $mdc-fab-extended-label-padding,
Copy link
Contributor

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.

@@ -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.
Copy link
Contributor

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."

@@ -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.
Copy link
Contributor

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."

@@ -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.
Copy link
Contributor

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

@@ -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": {
Copy link
Contributor

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?

@@ -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"
Copy link
Contributor

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

@abhiomkar abhiomkar merged commit 1f5fd1f into master Jun 22, 2018
@kfranqueiro kfranqueiro deleted the feat_extendedfab_padding_issue_2900 branch August 1, 2018 16:19
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.

None yet

3 participants