feat(alert): add destructive role to alert buttons (#21269)

This commit is contained in:
Manu MA
2020-05-22 21:32:12 +02:00
committed by GitHub
parent 4af54a2fea
commit e53f0241e2
4 changed files with 21 additions and 1 deletions

View File

@ -301,3 +301,12 @@
.alert-button.ion-activated { .alert-button.ion-activated {
background-color: $alert-ios-button-background-color-activated; background-color: $alert-ios-button-background-color-activated;
} }
// iOS Action Sheet Button: Destructive
// ---------------------------------------------------
.alert-button-role-destructive,
.alert-button-role-destructive.ion-activated,
.alert-button-role-destructive.ion-focused {
color: $alert-ios-button-destructive-text-color;
}

View File

@ -145,6 +145,9 @@ $alert-ios-button-font-size: 17px !default;
/// @prop - Color of the text in the alert button /// @prop - Color of the text in the alert button
$alert-ios-button-text-color: ion-color(primary, base) !default; $alert-ios-button-text-color: ion-color(primary, base) !default;
/// @prop - Destructive text color of the alert button
$alert-ios-button-destructive-text-color: ion-color(danger, base) !default;
/// @prop - Background color of the alert button /// @prop - Background color of the alert button
$alert-ios-button-background-color: transparent !default; $alert-ios-button-background-color: transparent !default;

View File

@ -505,6 +505,7 @@ const buttonClass = (button: AlertButton): CssClassMap => {
'alert-button': true, 'alert-button': true,
'ion-focusable': true, 'ion-focusable': true,
'ion-activatable': true, 'ion-activatable': true,
[`alert-button-role-${button.role}`]: button.role !== undefined,
...getClassMap(button.cssClass) ...getClassMap(button.cssClass)
}; };
}; };

View File

@ -75,7 +75,14 @@
header: 'Alert', header: 'Alert',
subHeader: 'Subtitle', subHeader: 'Subtitle',
message: 'This is an alert message.', message: 'This is an alert message.',
buttons: ['Cancel', 'Open Modal', 'Delete'] buttons: [
'Open Modal',
{
text: 'Delete',
role: 'destructive',
},
'Cancel',
]
}); });
} }