fix(toolbar): update md toolbar button spacing and padding to match spec (#17537)

- Removes the padding from the main toolbar and individually style the components inside of it
- Adds a `has-icon-only` class to button, this is used to switch between `unbounded` and `bounded` ripples on buttons in a toolbar. If the button is clear and only has an icon, we use the unbounded "circular" ripple effect, otherwise still use the bounded one. This matches the MD spec, without making the other buttons look off.
- Using the class above, style the button differently to match the MD spec
- Updates the back button and menu button to use the proper size / icon size
- Removes the opacity on an activated back button, it should use the ripple for activated
- Moves the margin to the slots in a toolbar by grabbing the "first" and "last" slot and applying a class to them
- Makes the segment in a toolbar use the min height from the toolbar
- Updates the back button so that it matches the MD spec
- Updates the header box shadow to use the old v3 datauri 

fixes #16950 fixes #14444
This commit is contained in:
Brandy Carney
2019-05-17 14:54:21 -04:00
committed by GitHub
parent a8f9dfe0e1
commit fa87e35a05
23 changed files with 511 additions and 132 deletions

View File

@ -130,6 +130,30 @@ export class Button implements ComponentInterface {
}
}
private get hasLabel() {
return this.el.textContent !== null && this.el.textContent.trim() !== '';
}
private get hasIcon() {
return !!this.el.querySelector('ion-icon');
}
private get hasIconOnly() {
return this.hasIcon && !this.hasLabel;
}
private get rippleType() {
const hasClearFill = this.fill === undefined || this.fill === 'clear';
// If the button is in a toolbar, has a clear fill (which is the default)
// and only has an icon we use the unbounded "circular" ripple effect
if (hasClearFill && this.hasIconOnly && this.inToolbar) {
return 'unbounded';
}
return 'bounded';
}
private onFocus = () => {
this.ionFocus.emit();
}
@ -139,7 +163,7 @@ export class Button implements ComponentInterface {
}
hostData() {
const { buttonType, disabled, color, expand, shape, size, strong } = this;
const { buttonType, disabled, color, expand, hasIconOnly, shape, size, strong } = this;
let fill = this.fill;
if (fill === undefined) {
fill = this.inToolbar ? 'clear' : 'solid';
@ -156,6 +180,7 @@ export class Button implements ComponentInterface {
[`${buttonType}-${fill}`]: true,
[`${buttonType}-strong`]: strong,
'button-has-icon-only': hasIconOnly,
'button-disabled': disabled,
'ion-activatable': true,
'ion-focusable': true,
@ -183,7 +208,7 @@ export class Button implements ComponentInterface {
<slot></slot>
<slot name="end"></slot>
</span>
{this.mode === 'md' && <ion-ripple-effect type={this.inToolbar ? 'unbounded' : 'bounded'}></ion-ripple-effect>}
{this.mode === 'md' && <ion-ripple-effect type={this.rippleType}></ion-ripple-effect>}
</TagType>
);
}