mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(button): update from core
This commit is contained in:
@@ -70,6 +70,8 @@ import { CssClassObject } from '../../util/interfaces';
|
||||
}
|
||||
})
|
||||
export class Button {
|
||||
$el: HTMLElement;
|
||||
|
||||
@Prop() itemButton: boolean = false;
|
||||
|
||||
@Prop() href: string;
|
||||
@@ -162,8 +164,10 @@ export class Button {
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* Get the classes based on the button type
|
||||
* e.g. alert-button, action-sheet-button
|
||||
*/
|
||||
getElementClassList(buttonType: string, mode: string): string[] {
|
||||
getButtonClassList(buttonType: string, mode: string): string[] {
|
||||
if (!buttonType) {
|
||||
return [];
|
||||
}
|
||||
@@ -176,6 +180,8 @@ export class Button {
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* Get the classes based on the type
|
||||
* e.g. block, full, round, large
|
||||
*/
|
||||
getClassList(buttonType: string, type: string, mode: string): string[] {
|
||||
if (!type) {
|
||||
@@ -190,6 +196,7 @@ export class Button {
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* Get the classes for the color
|
||||
*/
|
||||
getColorClassList(color: string, buttonType: string, style: string, mode: string): string[] {
|
||||
style = (buttonType !== 'bar-button' && style === 'solid') ? 'default' : style;
|
||||
@@ -216,6 +223,8 @@ export class Button {
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* Get the classes for the style
|
||||
* e.g. outline, clear, solid
|
||||
*/
|
||||
getStyleClassList(buttonType: string): string[] {
|
||||
let classList = [].concat(
|
||||
@@ -233,7 +242,7 @@ export class Button {
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* Whether or not to add the item-button class
|
||||
* Get the item classes for the button
|
||||
*/
|
||||
getItemClassList(size: string) {
|
||||
let classList = [].concat(
|
||||
@@ -243,6 +252,18 @@ export class Button {
|
||||
return classList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* Get the element classes to add to the child element
|
||||
*/
|
||||
getElementClassList() {
|
||||
let classList = [].concat(
|
||||
this.$el.className.length ? this.$el.className.split(' ') : []
|
||||
);
|
||||
|
||||
return classList;
|
||||
}
|
||||
|
||||
render() {
|
||||
const size =
|
||||
(this.large ? 'large' : null) ||
|
||||
@@ -259,13 +280,14 @@ export class Button {
|
||||
|
||||
const buttonClasses: CssClassObject = []
|
||||
.concat(
|
||||
this.getElementClassList(this.buttonType, this.mode),
|
||||
this.getButtonClassList(this.buttonType, this.mode),
|
||||
this.getClassList(this.buttonType, shape, this.mode),
|
||||
this.getClassList(this.buttonType, display, this.mode),
|
||||
this.getClassList(this.buttonType, size, this.mode),
|
||||
this.getClassList(this.buttonType, decorator, this.mode),
|
||||
this.getStyleClassList(this.buttonType),
|
||||
this.getItemClassList(size)
|
||||
this.getItemClassList(size),
|
||||
this.getElementClassList()
|
||||
)
|
||||
.reduce((prevValue, cssClass) => {
|
||||
prevValue[cssClass] = true;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
<style>
|
||||
button {
|
||||
ion-button {
|
||||
display: block !important;
|
||||
margin: 8px auto !important;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user