feat(components): improve button states and add new css properties (#19440)

Before users had to know the exact opacity that the MD/iOS spec called for in order to change the hover or focused background color. This allows them to change the background without having to know the opacity. 

- changes apply to Action Sheet (Buttons), Back Button, Button, FAB Button, Item, Menu Button, Segment Button, Tab Button
- greatly reduces the requirement by users to set the background hover, focused states for dark modes and custom themes, also eliminates the need to know what the hover opacity is for each based on the spec
- updates the MD dark theme per their spec
- adds a component guide for internal use changing Ionic components

references #18279 fixes #20213 fixes #19965

BREAKING CHANGE:

*Activated Class*

The `activated` class that is automatically added to buttons on press has been renamed to `ion-activated`. This will be more consistent with our `ion-focused` class we add and also will reduce conflicts with user's CSS.

*CSS Variables*

The `--background-hover`, `--background-focused` and `--background-activated` CSS variables on components that render native buttons will now have an opacity automatically set. If you are setting any of these like the following:

```
--background-hover: rgba(44, 44, 44, 0.08);
```

You will likely not see a hover state anymore. It should be updated to only set the desired color:

```
--background-hover: rgba(44, 44, 44);
```

If the opacity desired is something other than what the spec asks for, use:

```
--background-hover: rgba(44, 44, 44);
--background-hover-opacity: 1;
```
This commit is contained in:
Brandy Carney
2020-01-23 16:57:47 -05:00
committed by GitHub
parent 445f129e2d
commit 94159291b2
114 changed files with 3641 additions and 1487 deletions

View File

@ -70,6 +70,15 @@ export class Segment implements ComponentInterface {
@Watch('disabled')
disabledChanged() {
this.gestureChanged();
const buttons = this.getButtons();
for (const button of buttons) {
button.disabled = this.disabled;
}
}
private gestureChanged() {
if (this.gesture && !this.scrollable) {
this.gesture.enable(!this.disabled);
}
@ -97,7 +106,11 @@ export class Segment implements ComponentInterface {
onEnd: ev => this.onEnd(ev),
});
this.gesture.enable(!this.scrollable);
this.disabledChanged();
this.gestureChanged();
if (this.disabled) {
this.disabledChanged();
}
this.didInit = true;
}