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

fix(toolbar): Fix icon padding for ripples, and vertical alignment in FF/IE/Edge #2138

Merged
merged 21 commits into from
Feb 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d6901d6
WIP fix(toolbar): Adjust vertical padding to fix icon ripples
Jan 30, 2018
8a65147
WIP Replace last-of-type extra padding w/ margin
Jan 30, 2018
fd1c307
fix(toolbar): Set align-items to center to fix section alignment in I…
Jan 30, 2018
b2fc4c2
docs(toolbar): Add ripples to hero region in toolbar demo
Jan 30, 2018
d0fdcb4
fix(toolbar): Fix padding for flexible toolbar
williamernest Feb 13, 2018
85094d0
fix(toolbar): Remove unused padding value for icon mixin
williamernest Feb 14, 2018
e902e26
docs(toolbar): Avoid demo page jumping when clicking toolbar icons
Feb 2, 2018
845974b
WIP More fixes to ripple styles and add JS
Feb 2, 2018
3f06825
WIP Toolbar JS ripple fixes / demo
Feb 2, 2018
8dff673
fix(toolbar): Update padding
williamernest Feb 21, 2018
d504bd7
fix(toolbar): Add height/width to icons
williamernest Feb 21, 2018
8f93f0d
Merge remote-tracking branch 'origin/master' into fix/toolbar-padding
Feb 21, 2018
b844f44
WIP fix merge goofs
Feb 21, 2018
5c60e88
Merge branch 'master' into fix/toolbar-padding
kfranqueiro Feb 21, 2018
855689e
fix(toolbar): Fix lint issues
williamernest Feb 22, 2018
1fd7b4c
Merge branch 'master' into fix/toolbar-padding
kfranqueiro Feb 22, 2018
d10152f
Merge branch 'master' into fix/toolbar-padding
williamernest Feb 22, 2018
d894899
Merge branch 'master' into fix/toolbar-padding
williamernest Feb 22, 2018
25e8c1d
fix(toolbar): Update package.json
williamernest Feb 23, 2018
caba441
Merge branch 'master' into fix/toolbar-padding
kfranqueiro Feb 23, 2018
5a04b69
WIP Remove old style from earlier on this branch
Feb 23, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions demos/toolbar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ <h2 class="demo-toolbar-example-heading">
</section>
</main>

<script src="/assets/material-components-web.js" async></script>
<script src="/assets/common.js" async></script>
<script>
[].forEach.call(document.querySelectorAll('.examples button'), function(button) {
Expand All @@ -197,6 +198,10 @@ <h2 class="demo-toolbar-example-heading">
iframeMainEl.setAttribute('dir', iframeMainEl.getAttribute('dir') === 'rtl' ? 'ltr' : 'rtl');
});
});

demoReady(function() {
mdc.toolbar.MDCToolbar.attachTo(document.querySelector('.hero .mdc-toolbar'));
});
</script>
</body>
</html>
1 change: 1 addition & 0 deletions demos/toolbar/toolbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@import "../../packages/mdc-button/mdc-button";
@import "../../packages/mdc-list/mdc-list";
@import "../../packages/mdc-menu/mdc-menu";
@import "../../packages/mdc-ripple/mdc-ripple";
@import "../../packages/mdc-theme/color-palette";

.demo-toolbar-example-heading {
Expand Down
18 changes: 16 additions & 2 deletions packages/mdc-toolbar/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@
@mixin mdc-toolbar-fill-color-accessible($color) {
@include mdc-toolbar-fill-color($color);
@include mdc-toolbar-ink-color(mdc-theme-accessible-ink-color($color));

.mdc-toolbar__icon {
@include mdc-toolbar-icon-ink-color(mdc-theme-accessible-ink-color($color));
}
}

@mixin mdc-toolbar-icon-ink-color($color) {
@include mdc-theme-prop(color, $color);
@include mdc-states($color);
}

//
Expand All @@ -46,11 +51,20 @@
// Both .mdc-toolbar__icon and .mdc-toolbar__menu-icon share all styles except for
// horizontal padding.
@mixin mdc-toolbar-icon_() {
@include mdc-ripple-surface;
@include mdc-ripple-radius-unbounded;

// mdc-states is included within the mdc-toolbar-icon-ink-color mixin

display: flex;
align-items: center;
position: relative;
align-items: start;
justify-content: center;
padding: $mdc-toolbar-element-vertical-padding;
width: $mdc-toolbar-icon-size;
height: $mdc-toolbar-icon-size;
padding: $mdc-toolbar-icon-padding;
border: none;
outline: none;
background-color: transparent;
color: inherit;
text-decoration: none;
Expand Down
10 changes: 9 additions & 1 deletion packages/mdc-toolbar/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ $mdc-toolbar-row-height: 64px;
$mdc-toolbar-mobile-row-height: 56px;
$mdc-toolbar-mobile-landscape-row-height: 48px;

$mdc-toolbar-element-vertical-padding: 16px;
$mdc-toolbar-element-section-padding: 8px;
$mdc-toolbar-element-mobile-section-padding: 4px;

$mdc-toolbar-element-horizontal-padding-desktop: 24px;
$mdc-toolbar-element-horizontal-padding-mobile: 16px;
$mdc-toolbar-title-margin-to-menu-icon-desktop: 8px;
Expand All @@ -28,3 +30,9 @@ $mdc-toolbar-ratio-to-extend-flexible: 4 !default;

$mdc-toolbar-mobile-landscape-width-breakpoint: 959px;
$mdc-toolbar-mobile-breakpoint: 599px;

$mdc-toolbar-icon-padding: 12px;
$mdc-toolbar-section-horizontal-padding: 12px;
$mdc-toolbar-mobile-section-horizontal-padding: 4px;

$mdc-toolbar-icon-size: 24px;
1 change: 1 addition & 0 deletions packages/mdc-toolbar/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const cssClasses = {

export const strings = {
TITLE_SELECTOR: '.mdc-toolbar__title',
ICON_SELECTOR: '.mdc-toolbar__icon',
FIRST_ROW_SELECTOR: '.mdc-toolbar__row:first-child',
CHANGE_EVENT: 'MDCToolbar:change',
};
Expand Down
17 changes: 17 additions & 0 deletions packages/mdc-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {MDCComponent} from '@material/base/index';
import {MDCRipple} from '@material/ripple/index';

import MDCToolbarFoundation from './foundation';
import * as util from './util';
Expand Down Expand Up @@ -44,6 +45,22 @@ export class MDCToolbar extends MDCComponent {
return this.fixedAdjustElement_;
}

initialize() {
this.ripples_ = [].map.call(this.root_.querySelectorAll(MDCToolbarFoundation.strings.ICON_SELECTOR), (icon) => {
const ripple = MDCRipple.attachTo(icon);
ripple.unbounded = true;
return ripple;
});
}

destroy() {
this.ripples_.forEach((ripple) => {
ripple.destroy();
});
super.destroy();
}


getDefaultFoundation() {
return new MDCToolbarFoundation({
hasClass: (className) => this.root_.classList.contains(className),
Expand Down
71 changes: 37 additions & 34 deletions packages/mdc-toolbar/mdc-toolbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//

@import "@material/elevation/mixins";
@import "@material/ripple/mixins";
@import "@material/rtl/mixins";
@import "@material/theme/mixins";
@import "@material/typography/mixins";
Expand Down Expand Up @@ -56,20 +57,53 @@
&__section {
display: inline-flex;
flex: 1;
align-items: flex-start;
align-items: start;
justify-content: center;
box-sizing: border-box;
min-width: 0;
height: 100%;
padding: $mdc-toolbar-element-section-padding;
z-index: 1;

@media (max-width: $mdc-toolbar-mobile-landscape-width-breakpoint)
and (orientation: landscape) {
padding: 0 0;
}

@media (max-width: $mdc-toolbar-mobile-breakpoint) {
padding: $mdc-toolbar-element-mobile-section-padding 0;
}

&--align-start {
@include mdc-rtl-reflexive-box(padding, "left", $mdc-toolbar-section-horizontal-padding);

justify-content: flex-start;
order: -1;

@media (max-width: $mdc-toolbar-mobile-landscape-width-breakpoint)
and (orientation: landscape) {
@include mdc-rtl-reflexive-box(padding, "left", $mdc-toolbar-mobile-section-horizontal-padding);
}

@media (max-width: $mdc-toolbar-mobile-breakpoint) {
@include mdc-rtl-reflexive-box(padding, "left", $mdc-toolbar-mobile-section-horizontal-padding);
}
}

&--align-end {
@include mdc-rtl-reflexive-box(padding, "right", $mdc-toolbar-section-horizontal-padding);

justify-content: flex-end;
order: 1;

@media (max-width: $mdc-toolbar-mobile-landscape-width-breakpoint)
and (orientation: landscape) {
@include mdc-rtl-reflexive-box(padding, "right", $mdc-toolbar-mobile-section-horizontal-padding);
}

@media (max-width: $mdc-toolbar-mobile-breakpoint) {
@include mdc-rtl-reflexive-box(padding, "right", $mdc-toolbar-mobile-section-horizontal-padding);
}
}
}

Expand All @@ -79,27 +113,14 @@
@include mdc-rtl-reflexive-box(margin, left, $mdc-toolbar-element-horizontal-padding-desktop);

align-self: center;
padding: $mdc-toolbar-element-vertical-padding 0;
padding: 12px 0;
line-height: 1.5rem;
z-index: 1;
}

&__icon {
@include mdc-toolbar-icon_;

padding-right: $mdc-toolbar-element-horizontal-padding-desktop / 2;
padding-left: $mdc-toolbar-element-horizontal-padding-desktop / 2;
}

&__icon:last-of-type {
@include mdc-rtl-reflexive-property(padding, $mdc-toolbar-element-horizontal-padding-desktop / 2, $mdc-toolbar-element-horizontal-padding-desktop);
}

&__icon,
&__menu-icon {
@include mdc-toolbar-icon_;

padding-right: $mdc-toolbar-element-horizontal-padding-desktop;
padding-left: $mdc-toolbar-element-horizontal-padding-desktop;
}
}

Expand All @@ -111,24 +132,6 @@
.mdc-toolbar__title {
@include mdc-rtl-reflexive-box(margin, left, $mdc-toolbar-element-horizontal-padding-mobile);
}

.mdc-toolbar__icon {
padding-right: $mdc-toolbar-element-horizontal-padding-mobile / 2;
padding-left: $mdc-toolbar-element-horizontal-padding-mobile / 2;
}

.mdc-toolbar__icon:last-of-type {
@include mdc-rtl-reflexive-property(padding, $mdc-toolbar-element-horizontal-padding-mobile / 2, $mdc-toolbar-element-horizontal-padding-mobile);
}

.mdc-toolbar__menu-icon {
padding-right: $mdc-toolbar-element-horizontal-padding-mobile;
padding-left: $mdc-toolbar-element-horizontal-padding-mobile;
}

.mdc-toolbar__menu-icon + .mdc-toolbar__title {
@include mdc-rtl-reflexive-box(margin, left, $mdc-toolbar-title-margin-to-menu-icon-mobile);
}
}

.mdc-toolbar--fixed {
Expand Down
1 change: 1 addition & 0 deletions packages/mdc-toolbar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dependencies": {
"@material/base": "^0.29.0",
"@material/elevation": "^0.28.0",
"@material/ripple": "^0.31.0",
"@material/rtl": "^0.30.0",
"@material/theme": "^0.30.0",
"@material/typography": "^0.28.0"
Expand Down