mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 16:16:41 +08:00
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:
@ -20,6 +20,6 @@
|
||||
box-shadow: $card-ios-box-shadow;
|
||||
}
|
||||
|
||||
:host(.activated) {
|
||||
:host(.ion-activated) {
|
||||
transform: #{$card-ios-transform-activated};
|
||||
}
|
||||
@ -40,9 +40,9 @@ sub-components to reflect this. Please see `ion-card-content`,
|
||||
</ion-card>
|
||||
|
||||
<ion-card>
|
||||
<ion-item href="#" class="activated">
|
||||
<ion-item href="#" class="ion-activated">
|
||||
<ion-icon name="wifi" slot="start"></ion-icon>
|
||||
<ion-label>Card Link Item 1 .activated</ion-label>
|
||||
<ion-label>Card Link Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item href="#">
|
||||
@ -50,9 +50,9 @@ sub-components to reflect this. Please see `ion-card-content`,
|
||||
<ion-label>Card Link Item 2</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item class="activated">
|
||||
<ion-item class="ion-activated">
|
||||
<ion-icon name="warning" slot="start"></ion-icon>
|
||||
<ion-label>Card Button Item 1 .activated</ion-label>
|
||||
<ion-label>Card Button Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
@ -97,9 +97,9 @@ export const CardExample: React.FC = () => (
|
||||
</IonCard>
|
||||
|
||||
<IonCard>
|
||||
<IonItem href="#" class="activated">
|
||||
<IonItem href="#" class="ion-activated">
|
||||
<IonIcon name="wifi" slot="start" />
|
||||
<IonLabel>Card Link Item 1 .activated</IonLabel>
|
||||
<IonLabel>Card Link Item 1 activated</IonLabel>
|
||||
</IonItem>
|
||||
|
||||
<IonItem href="#">
|
||||
@ -107,9 +107,9 @@ export const CardExample: React.FC = () => (
|
||||
<IonLabel>Card Link Item 2</IonLabel>
|
||||
</IonItem>
|
||||
|
||||
<IonItem class="activated">
|
||||
<IonItem class="ion-activated">
|
||||
<IonIcon name="warning" slot="start" />
|
||||
<IonLabel>Card Button Item 1 .activated</IonLabel>
|
||||
<IonLabel>Card Button Item 1 activated</IonLabel>
|
||||
</IonItem>
|
||||
|
||||
<IonItem>
|
||||
@ -152,9 +152,9 @@ export const CardExample: React.FC = () => (
|
||||
</ion-card>
|
||||
|
||||
<ion-card>
|
||||
<ion-item href="#" class="activated">
|
||||
<ion-item href="#" class="ion-activated">
|
||||
<ion-icon name="wifi" slot="start"></ion-icon>
|
||||
<ion-label>Card Link Item 1 .activated</ion-label>
|
||||
<ion-label>Card Link Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item href="#">
|
||||
@ -162,9 +162,9 @@ export const CardExample: React.FC = () => (
|
||||
<ion-label>Card Link Item 2</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item class="activated">
|
||||
<ion-item class="ion-activated">
|
||||
<ion-icon name="warning" slot="start"></ion-icon>
|
||||
<ion-label>Card Button Item 1 .activated</ion-label>
|
||||
<ion-label>Card Button Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
|
||||
@ -85,9 +85,9 @@
|
||||
|
||||
<ion-card>
|
||||
<ion-list lines="none">
|
||||
<ion-item href="#" class="activated">
|
||||
<ion-item href="#" class="ion-activated">
|
||||
<ion-icon name="wifi" slot="start"></ion-icon>
|
||||
<ion-label>Link Item .activated</ion-label>
|
||||
<ion-label>Link Item activated</ion-label>
|
||||
<ion-note>More</ion-note>
|
||||
</ion-item>
|
||||
|
||||
@ -97,9 +97,9 @@
|
||||
<ion-note>More</ion-note>
|
||||
</ion-item>
|
||||
|
||||
<ion-item button class="activated">
|
||||
<ion-item button class="ion-activated">
|
||||
<ion-icon name="warning" slot="start"></ion-icon>
|
||||
<ion-label>Button Item .activated</ion-label>
|
||||
<ion-label>Button Item activated</ion-label>
|
||||
<ion-note>More</ion-note>
|
||||
</ion-item>
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@
|
||||
</ion-button>
|
||||
</ion-col>
|
||||
<ion-col class="ion-no-padding ion-text-right">
|
||||
<ion-button fill="clear" size="small" class="activated">
|
||||
<ion-button fill="clear" size="small" class="ion-activated">
|
||||
<ion-icon slot="start" name="share"></ion-icon>
|
||||
Activated
|
||||
</ion-button>
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
</ion-card>
|
||||
|
||||
<ion-card>
|
||||
<ion-item href="#" class="activated">
|
||||
<ion-item href="#" class="ion-activated">
|
||||
<ion-icon name="wifi" slot="start"></ion-icon>
|
||||
<ion-label>Card Link Item 1 .activated</ion-label>
|
||||
<ion-label>Card Link Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item href="#">
|
||||
@ -35,9 +35,9 @@
|
||||
<ion-label>Card Link Item 2</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item class="activated">
|
||||
<ion-item class="ion-activated">
|
||||
<ion-icon name="warning" slot="start"></ion-icon>
|
||||
<ion-label>Card Button Item 1 .activated</ion-label>
|
||||
<ion-label>Card Button Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
</ion-card>
|
||||
|
||||
<ion-card>
|
||||
<ion-item href="#" class="activated">
|
||||
<ion-item href="#" class="ion-activated">
|
||||
<ion-icon name="wifi" slot="start"></ion-icon>
|
||||
<ion-label>Card Link Item 1 .activated</ion-label>
|
||||
<ion-label>Card Link Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item href="#">
|
||||
@ -35,9 +35,9 @@
|
||||
<ion-label>Card Link Item 2</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item class="activated">
|
||||
<ion-item class="ion-activated">
|
||||
<ion-icon name="warning" slot="start"></ion-icon>
|
||||
<ion-label>Card Button Item 1 .activated</ion-label>
|
||||
<ion-label>Card Button Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
|
||||
@ -30,9 +30,9 @@ export const CardExample: React.FC = () => (
|
||||
</IonCard>
|
||||
|
||||
<IonCard>
|
||||
<IonItem href="#" class="activated">
|
||||
<IonItem href="#" class="ion-activated">
|
||||
<IonIcon name="wifi" slot="start" />
|
||||
<IonLabel>Card Link Item 1 .activated</IonLabel>
|
||||
<IonLabel>Card Link Item 1 activated</IonLabel>
|
||||
</IonItem>
|
||||
|
||||
<IonItem href="#">
|
||||
@ -40,9 +40,9 @@ export const CardExample: React.FC = () => (
|
||||
<IonLabel>Card Link Item 2</IonLabel>
|
||||
</IonItem>
|
||||
|
||||
<IonItem class="activated">
|
||||
<IonItem class="ion-activated">
|
||||
<IonIcon name="warning" slot="start" />
|
||||
<IonLabel>Card Button Item 1 .activated</IonLabel>
|
||||
<IonLabel>Card Button Item 1 activated</IonLabel>
|
||||
</IonItem>
|
||||
|
||||
<IonItem>
|
||||
|
||||
@ -26,9 +26,9 @@
|
||||
</ion-card>
|
||||
|
||||
<ion-card>
|
||||
<ion-item href="#" class="activated">
|
||||
<ion-item href="#" class="ion-activated">
|
||||
<ion-icon name="wifi" slot="start"></ion-icon>
|
||||
<ion-label>Card Link Item 1 .activated</ion-label>
|
||||
<ion-label>Card Link Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item href="#">
|
||||
@ -36,9 +36,9 @@
|
||||
<ion-label>Card Link Item 2</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item class="activated">
|
||||
<ion-item class="ion-activated">
|
||||
<ion-icon name="warning" slot="start"></ion-icon>
|
||||
<ion-label>Card Button Item 1 .activated</ion-label>
|
||||
<ion-label>Card Button Item 1 activated</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
|
||||
Reference in New Issue
Block a user