diff --git a/src/components/badge/badge.ios.scss b/src/components/badge/badge.ios.scss index bcc0ebf8ce..4bb667076c 100644 --- a/src/components/badge/badge.ios.scss +++ b/src/components/badge/badge.ios.scss @@ -16,9 +16,11 @@ $badge-ios-text-color: color-contrast($colors-ios, $badge-ios-background .badge-ios { - border-radius: $badge-ios-border-radius; - color: $badge-ios-text-color; - background-color: $badge-ios-background-color; + @include host-context() { + border-radius: $badge-ios-border-radius; + color: $badge-ios-text-color; + background-color: $badge-ios-background-color; + } } @@ -28,8 +30,10 @@ $badge-ios-text-color: color-contrast($colors-ios, $badge-ios-background @each $color-name, $color-base, $color-contrast in get-colors($colors-ios) { .badge-ios-#{$color-name} { - color: $color-contrast; - background-color: $color-base; + @include host-context() { + color: $color-contrast; + background-color: $color-base; + } } } diff --git a/src/components/badge/badge.md.scss b/src/components/badge/badge.md.scss index ac9680a815..ded2fd56f7 100644 --- a/src/components/badge/badge.md.scss +++ b/src/components/badge/badge.md.scss @@ -16,9 +16,20 @@ $badge-md-text-color: color-contrast($colors-md, $badge-md-backgro .badge-md { - border-radius: $badge-md-border-radius; - color: $badge-md-text-color; - background-color: $badge-md-background-color; + @include host-context() { + border-radius: $badge-md-border-radius; + color: $badge-md-text-color; + background-color: $badge-md-background-color; + } +} + + +.badge-md { + @include host-context() { + border-radius: $badge-md-border-radius; + color: $badge-md-text-color; + background-color: $badge-md-background-color; + } } @@ -28,8 +39,10 @@ $badge-md-text-color: color-contrast($colors-md, $badge-md-backgro @each $color-name, $color-base, $color-contrast in get-colors($colors-md) { .badge-md-#{$color-name} { - color: $color-contrast; - background-color: $color-base; + @include host-context() { + color: $color-contrast; + background-color: $color-base; + } } } diff --git a/src/components/badge/badge.scss b/src/components/badge/badge.scss index 5503a6e397..1684f3749f 100644 --- a/src/components/badge/badge.scss +++ b/src/components/badge/badge.scss @@ -11,28 +11,32 @@ $badge-font-size: 1.3rem !default; $badge-font-weight: bold !default; -ion-badge, -:host { - display: inline-block; - visibility: inherit !important; - contain: content; +ion-badge { + @include host() { + display: inline-block; + visibility: inherit !important; + contain: content; + } } .badge { - padding: 3px 8px; + @include host() { + padding: 3px 8px; - min-width: 10px; + min-width: 10px; - font-size: $badge-font-size; - font-weight: $badge-font-weight; - line-height: 1; + font-size: $badge-font-size; + font-weight: $badge-font-weight; + line-height: 1; - text-align: center; - white-space: nowrap; - vertical-align: baseline; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + } } -ion-badge:empty, -:host(:empty) { - display: none; -} +ion-badge:empty { + @include host(':empty') { + display: none; + } +} \ No newline at end of file diff --git a/src/components/badge/badge.wp.scss b/src/components/badge/badge.wp.scss index b860dc5a87..87ab16a215 100644 --- a/src/components/badge/badge.wp.scss +++ b/src/components/badge/badge.wp.scss @@ -16,9 +16,11 @@ $badge-wp-text-color: color-contrast($colors-wp, $badge-wp-backgro .badge-wp { - border-radius: $badge-wp-border-radius; - color: $badge-wp-text-color; - background-color: $badge-wp-background-color; + @include host-context() { + border-radius: $badge-wp-border-radius; + color: $badge-wp-text-color; + background-color: $badge-wp-background-color; + } } @@ -28,8 +30,10 @@ $badge-wp-text-color: color-contrast($colors-wp, $badge-wp-backgro @each $color-name, $color-base, $color-contrast in get-colors($colors-wp) { .badge-wp-#{$color-name} { - color: $color-contrast; - background-color: $color-base; + @include host-context() { + color: $color-contrast; + background-color: $color-base; + } } } diff --git a/src/components/button/button.ios.scss b/src/components/button/button.ios.scss index 9c0d5ac72b..3a70f7eb3f 100644 --- a/src/components/button/button.ios.scss +++ b/src/components/button/button.ios.scss @@ -1,5 +1,6 @@ @import "../../themes/ionic.globals.ios"; @import "./button"; +@import "./toolbar-button"; // iOS Button // -------------------------------------------------- diff --git a/src/components/button/button.md.scss b/src/components/button/button.md.scss index 2075666909..a13471c347 100644 --- a/src/components/button/button.md.scss +++ b/src/components/button/button.md.scss @@ -1,5 +1,6 @@ @import "../../themes/ionic.globals.md"; @import "./button"; +@import "./toolbar-button"; // Material Design Button // -------------------------------------------------- diff --git a/src/components/button/button.ts b/src/components/button/button.ts index b80070aa4c..9dc01a0e93 100644 --- a/src/components/button/button.ts +++ b/src/components/button/button.ts @@ -76,7 +76,7 @@ export class Button { * @Prop {boolean} If true, activates the large button size. * Type: size */ - @Prop() role: string = 'button'; + @Prop() buttonType: string = 'button'; /** * @Prop {boolean} If true, activates the large button size. @@ -161,13 +161,13 @@ export class Button { /** * @hidden */ - getElementClassList(role: string, mode: string): string[] { - if (!role) { + getElementClassList(buttonType: string, mode: string): string[] { + if (!buttonType) { return []; } return [ - role, - `${role}-${mode}` + buttonType, + `${buttonType}-${mode}` ]; } @@ -175,24 +175,24 @@ export class Button { /** * @hidden */ - getClassList(role: string, type: string, mode: string): string[] { + getClassList(buttonType: string, type: string, mode: string): string[] { if (!type) { return []; } type = type.toLocaleLowerCase(); return [ - `${role}-${type}`, - `${role}-${type}-${mode}` + `${buttonType}-${type}`, + `${buttonType}-${type}-${mode}` ]; } /** * @hidden */ - getColorClassList(color: string, role: string, style: string, mode: string): string[] { - style = (role !== 'bar-button' && style === 'solid') ? 'default' : style; + getColorClassList(color: string, buttonType: string, style: string, mode: string): string[] { + style = (buttonType !== 'bar-button' && style === 'solid') ? 'default' : style; let className = - role + + buttonType + ((style && style !== 'default') ? '-' + style.toLowerCase() : ''); @@ -203,15 +203,15 @@ export class Button { ); } - getStyleClassList(role: string): string[] { + getStyleClassList(buttonType: string): string[] { var classList = [].concat( - this.outline ? this.getColorClassList(this.color, role, 'outline', this.mode) : [], - this.clear ? this.getColorClassList(this.color, role, 'clear', this.mode) : [], - this.solid ? this.getColorClassList(this.color, role, 'solid', this.mode) : [] + this.outline ? this.getColorClassList(this.color, buttonType, 'outline', this.mode) : [], + this.clear ? this.getColorClassList(this.color, buttonType, 'clear', this.mode) : [], + this.solid ? this.getColorClassList(this.color, buttonType, 'solid', this.mode) : [] ); if (classList.length === 0) { - classList = [this.getColorClassList(this.color, role, 'default', this.mode)]; + classList = [this.getColorClassList(this.color, buttonType, 'default', this.mode)]; } return classList; @@ -233,12 +233,12 @@ export class Button { var buttonClasses: CssClassObject = [] .concat( - this.getElementClassList(this.role, this.mode), - this.getClassList(this.role, shape, this.mode), - this.getClassList(this.role, display, this.mode), - this.getClassList(this.role, size, this.mode), - this.getClassList(this.role, decorator, this.mode), - this.getStyleClassList(this.role) + this.getElementClassList(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) ) .reduce((prevValue, cssClass) => { prevValue[cssClass] = true; diff --git a/src/components/button/button.wp.scss b/src/components/button/button.wp.scss index cf6d76e8b9..57ddac3b85 100644 --- a/src/components/button/button.wp.scss +++ b/src/components/button/button.wp.scss @@ -1,5 +1,6 @@ @import "../../themes/ionic.globals.wp"; @import "./button"; +@import "./toolbar-button"; // Windows Button // -------------------------------------------------- diff --git a/src/components/button/toolbar-button.scss b/src/components/button/toolbar-button.scss new file mode 100644 index 0000000000..b134731fe0 --- /dev/null +++ b/src/components/button/toolbar-button.scss @@ -0,0 +1,67 @@ +@import "../../themes/ionic.globals"; + +// Toolbar Buttons +// -------------------------------------------------- + +.bar-button { + @include text-align(center); + @include appearance(none); + + border: 0; + position: relative; + display: inline-block; + + margin: 0; + padding: 0; + + line-height: 1; + text-overflow: ellipsis; + text-transform: none; + white-space: nowrap; + + cursor: pointer; + + vertical-align: top; // the better option for most scenarios + vertical-align: -webkit-baseline-middle; // the best for those that support it + + user-select: none; +} + +.bar-button::after { + // used to make the button's hit area larger + position: absolute; + top: -7px; + right: -2px; + bottom: -6px; + left: -2px; + + content: ""; +} + + +// Menu Toggle +// -------------------------------------------------- + +.bar-button-menutoggle { + display: flex; + + align-items: center; +} + + +// Back Button +// -------------------------------------------------- + +.back-button { + display: none; +} + +.back-button.show-back-button { + display: inline-block; +} + +.back-button-text { + display: flex; + + align-items: center; +} diff --git a/src/themes/ionic.mixins.scss b/src/themes/ionic.mixins.scss index c3a5fc1e91..e712475f1e 100644 --- a/src/themes/ionic.mixins.scss +++ b/src/themes/ionic.mixins.scss @@ -155,4 +155,34 @@ } @else { @content; } +} + + +// Based on a selector, apply the content to that selector and the :host +@mixin host($selector: null) { + @debug $selector; + @at-root { + @if ($selector) { + :host(#{$selector}), + #{&} { + @content; + } + } @else { + :host, + #{&} { + @content; + } + } + } +} + + +// Based on a selector, apply the content to that selector and the :host-context +@mixin host-context() { + @at-root { + :host-context(#{&}), + #{&} { + @content; + } + } } \ No newline at end of file