-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(fab): Enable padding customization #2959
Changes from 8 commits
2afd27c
785ba54
38a2421
1c710f4
dbbb4c9
a6fbf27
2f51c65
2cf975b
ffff6b0
ba194d9
bef7a63
c068d6e
e1e8e81
852e47f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Change the second sentence to "Useful in lieu of |
||
|
||
The ripple effect for the FAB component is styled using [MDC Ripple](../mdc-ripple) mixins. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
@import "@material/ripple/variables"; | ||
@import "@material/theme/functions"; | ||
@import "@material/theme/mixins"; | ||
@import "@material/rtl/mixins"; | ||
@import "./variables"; | ||
|
||
@mixin mdc-fab-accessible($container-color) { | ||
$fill-tone: mdc-theme-tone($container-color); | ||
|
@@ -54,6 +56,30 @@ | |
width: 100%; | ||
} | ||
|
||
@mixin mdc-fab-extended-padding($icon-padding, $label-padding) { | ||
@include mdc-fab-extended-label-padding($label-padding); | ||
|
||
// Offsets the outer label padding by deducting it from icon padding. | ||
.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 commentThe 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-extended-icon-padding); | ||
} | ||
|
||
// For Extended FAB with text label followed by icon. | ||
.mdc-fab__label + .mdc-fab__icon { | ||
@include mdc-rtl-reflexive-property( | ||
margin, | ||
$mdc-fab-extended-icon-padding, | ||
$mdc-fab-extended-icon-padding - $mdc-fab-extended-label-padding); | ||
} | ||
} | ||
|
||
@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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
$mdc-fab-icon-enter-delay_: 90ms; | ||
$mdc-fab-icon-enter-duration_: 180ms; | ||
$mdc-fab-extended-height_: 48px; | ||
|
@@ -129,11 +155,13 @@ $mdc-fab-extended-height_: 48px; | |
|
||
@mixin mdc-fab--extended_ { | ||
@include mdc-typography(button); | ||
@include mdc-fab-extended-padding( | ||
$mdc-fab-extended-icon-padding, | ||
$mdc-fab-extended-label-padding); | ||
|
||
width: auto; | ||
max-width: 100%; | ||
height: $mdc-fab-extended-height_; | ||
padding: 0 20px 0 16px; | ||
border-radius: $mdc-fab-extended-height_ / 2; | ||
} | ||
|
||
|
@@ -145,7 +173,6 @@ $mdc-fab-extended-height_: 48px; | |
|
||
@mixin mdc-fab__label_ { | ||
justify-content: flex-start; | ||
padding-left: 8px; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Copyright 2018 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
$mdc-fab-extended-icon-padding: 12px; | ||
$mdc-fab-extended-label-padding: 20px; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Nit: put rtl after ripple |
||
} | ||
} |
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."