diff --git a/core/api.txt b/core/api.txt index e9c4c71ad3..2f6d0387b1 100644 --- a/core/api.txt +++ b/core/api.txt @@ -89,8 +89,12 @@ ion-back-button,prop,icon,null | string | undefined,undefined,false,false ion-back-button,prop,mode,"ios" | "md",undefined,false,false ion-back-button,prop,text,null | string | undefined,undefined,false,false ion-back-button,css-prop,--background +ion-back-button,css-prop,--background-focused +ion-back-button,css-prop,--background-hover ion-back-button,css-prop,--border-radius ion-back-button,css-prop,--color +ion-back-button,css-prop,--color-focused +ion-back-button,css-prop,--color-hover ion-back-button,css-prop,--icon-font-size ion-back-button,css-prop,--icon-font-weight ion-back-button,css-prop,--icon-margin-bottom diff --git a/core/src/components/back-button/back-button.ios.scss b/core/src/components/back-button/back-button.ios.scss index 28328b0334..ac383fb9fb 100644 --- a/core/src/components/back-button/back-button.ios.scss +++ b/core/src/components/back-button/back-button.ios.scss @@ -5,26 +5,13 @@ // -------------------------------------------------- :host { + --background-focused: #{ion-color(primary, base, .1)}; + --border-radius: 10px; --color: #{$back-button-ios-color}; - --margin-top: 0; - --margin-end: 0; - --margin-bottom: 0; - --margin-start: 0; - --padding-top: 0; - --padding-end: 0; - --padding-bottom: 0; - --padding-start: 0; - --min-height: 32px; - --min-width: auto; - --icon-padding-top: 0; - --icon-padding-end: 0; - --icon-padding-bottom: 0; - --icon-padding-start: 0; - --icon-margin-top: 0; --icon-margin-end: -5px; - --icon-margin-bottom: 0; --icon-margin-start: -4px; --icon-font-size: 1.85em; + --min-height: 32px; font-size: 17px; } @@ -41,4 +28,19 @@ :host(.activated) .button-native { opacity: .4; -} \ No newline at end of file +} + +@media (any-hover: hover) { + :host(:hover) { + --opacity: #{$button-ios-clear-opacity-hover}; + } +} + + + +// Back Button Color: Focused +// -------------------------------------------------- + +:host(.ion-color.ion-focused) .button-native { + background: #{current-color(base, .1)}; +} diff --git a/core/src/components/back-button/back-button.ios.vars.scss b/core/src/components/back-button/back-button.ios.vars.scss index 8793d741f2..02fb7648f3 100644 --- a/core/src/components/back-button/back-button.ios.vars.scss +++ b/core/src/components/back-button/back-button.ios.vars.scss @@ -1,5 +1,9 @@ @import "../../themes/ionic.globals.ios"; +// TODO this is needed for the ios vars to import +@import "../button/button.vars"; +@import "../button/button.ios.vars"; + // iOS Back Button // -------------------------------------------------- diff --git a/core/src/components/back-button/back-button.md.scss b/core/src/components/back-button/back-button.md.scss index 6e1adbde25..47bf84cb5e 100644 --- a/core/src/components/back-button/back-button.md.scss +++ b/core/src/components/back-button/back-button.md.scss @@ -5,27 +5,18 @@ // -------------------------------------------------- :host { + --border-radius: 4px; + --background-focused: rgba(66, 66, 66, 0.24); + --background-hover: rgba(66, 66, 66, 0.08); --color: #{$back-button-md-color}; - --margin-top: 0; - --margin-end: 0; - --margin-bottom: 0; - --margin-start: 0; - --padding-top: 0; - --padding-end: 0; - --padding-bottom: 0; - --padding-start: 0; - --min-height: 32px; - --min-width: 44px; - --icon-padding-top: 0; - --icon-padding-end: 0; - --icon-padding-start: 0; - --icon-padding-bottom: 0; - --icon-margin-top: 0; --icon-margin-end: 0; - --icon-margin-bottom: 0; --icon-margin-start: 0; --icon-font-size: 24px; --icon-font-weight: normal; + --min-height: 32px; + --min-width: 44px; + --padding-start: 12px; + --padding-end: 12px; font-size: 14px; font-weight: 500; @@ -33,15 +24,41 @@ text-transform: uppercase; } -.button-native { - width: 48px; - height: 48px; +:host(.back-button-has-icon-only) { + --border-radius: 50%; + min-width: 48px; + height: 48px; +} + +.button-native { box-shadow: none; } +.button-text { + @include padding(0, 4px); +} + ion-icon { line-height: .67; text-align: start; } + + +// Back Button Color: Hover +// -------------------------------------------------- + +@media (any-hover: hover) { + :host(.ion-color:hover) .button-native { + background: #{current-color(base, .08)}; + } +} + + +// Back Button Color: Focused +// -------------------------------------------------- + +:host(.ion-color.ion-focused) .button-native { + background: #{current-color(base, .24)}; +} diff --git a/core/src/components/back-button/back-button.scss b/core/src/components/back-button/back-button.scss index 2c1ca5c920..c9f7d0e001 100644 --- a/core/src/components/back-button/back-button.scss +++ b/core/src/components/back-button/back-button.scss @@ -6,8 +6,12 @@ :host { /** * @prop --background: Background of the button + * @prop --background-focused: Background of the button when focused + * @prop --background-hover: Background of the button when hover * * @prop --color: Text color of the button + * @prop --color-focused: Text color of the button when focused + * @prop --color-hover: Text color of the button when hover * * @prop --min-width: Minimum width of the button * @prop --min-height: Minimum height of the button @@ -44,12 +48,33 @@ * @prop --icon-font-weight: Font weight of the button icon */ --background: transparent; + --color-focused: var(--color); + --color-hover: var(--color); + --icon-margin-top: 0; + --icon-margin-bottom: 0; + --icon-padding-top: 0; + --icon-padding-end: 0; + --icon-padding-bottom: 0; + --icon-padding-start: 0; + --margin-top: 0; + --margin-end: 0; + --margin-bottom: 0; + --margin-start: 0; + --min-width: auto; + --min-height: auto; + --padding-top: 0; + --padding-end: 0; + --padding-bottom: 0; + --padding-start: 0; + --opacity: 1; --ripple-color: currentColor; --transition: background-color, opacity 100ms linear; - --opacity: 1; display: none; + min-width: var(--min-width); + min-height: var(--min-height); + color: var(--color); font-family: $font-family-base; @@ -96,8 +121,10 @@ display: block; position: relative; - min-width: var(--min-width); - min-height: var(--min-height); + width: 100%; + height: 100%; + + min-height: inherit; transition: var(--transition); @@ -145,6 +172,44 @@ ion-icon { pointer-events: none; } + +// Back Button: Hover +// -------------------------------------------------- + +@media (any-hover: hover) { + :host(:hover) .button-native { + background: var(--background-hover); + color: var(--color-hover); + } +} + +// Back Button: Focused +// -------------------------------------------------- + +:host(.ion-focused) .button-native { + background: var(--background-focused); + color: var(--color-focused); +} + + +// Back Button Color: Hover +// -------------------------------------------------- + +@media (any-hover: hover) { + :host(.ion-color:hover) .button-native { + color: #{current-color(base)}; + } +} + + +// Back Button Color: Focused +// -------------------------------------------------- + +:host(.ion-color.ion-focused) .button-native { + color: #{current-color(base)}; +} + + // Back Button in Toolbar: Global Theming // -------------------------------------------------- diff --git a/core/src/components/back-button/back-button.tsx b/core/src/components/back-button/back-button.tsx index 704497c598..b56484702b 100644 --- a/core/src/components/back-button/back-button.tsx +++ b/core/src/components/back-button/back-button.tsx @@ -56,6 +56,29 @@ export class BackButton implements ComponentInterface { return openURL(this.win, this.defaultHref, ev, 'back'); } + private get backButtonIcon() { + return this.icon != null ? this.icon : this.config.get('backButtonIcon', 'arrow-back'); + } + + private get backButtonText() { + const defaultBackButtonText = this.mode === 'ios' ? 'Back' : null; + return this.text != null ? this.text : this.config.get('backButtonText', defaultBackButtonText); + } + + private get hasIconOnly() { + return this.backButtonIcon && !this.backButtonText; + } + + private get rippleType() { + // If the button only has an icon we use the unbounded + // "circular" ripple effect + if (this.hasIconOnly) { + return 'unbounded'; + } + + return 'bounded'; + } + hostData() { const showBackButton = this.defaultHref !== undefined; @@ -65,16 +88,16 @@ export class BackButton implements ComponentInterface { [`${this.mode}`]: true, 'button': true, // ion-buttons target .button + 'back-button-has-icon-only': this.hasIconOnly, 'ion-activatable': true, + 'ion-focusable': true, 'show-back-button': showBackButton } }; } render() { - const defaultBackButtonText = this.mode === 'ios' ? 'Back' : null; - const backButtonIcon = this.icon != null ? this.icon : this.config.get('backButtonIcon', 'arrow-back'); - const backButtonText = this.text != null ? this.text : this.config.get('backButtonText', defaultBackButtonText); + const { backButtonIcon, backButtonText } = this; return ( ); } diff --git a/core/src/components/back-button/readme.md b/core/src/components/back-button/readme.md index ee7a3808ac..397664520b 100644 --- a/core/src/components/back-button/readme.md +++ b/core/src/components/back-button/readme.md @@ -250,34 +250,38 @@ export default Example; ## CSS Custom Properties -| Name | Description | -| ----------------------- | --------------------------------- | -| `--background` | Background of the button | -| `--border-radius` | Border radius of the button | -| `--color` | Text color of the button | -| `--icon-font-size` | Font size of the button icon | -| `--icon-font-weight` | Font weight of the button icon | -| `--icon-margin-bottom` | Margin bottom of the button icon | -| `--icon-margin-end` | Margin end of the button icon | -| `--icon-margin-start` | Margin start of the button icon | -| `--icon-margin-top` | Margin top of the button icon | -| `--icon-padding-bottom` | Padding bottom of the button icon | -| `--icon-padding-end` | Padding end of the button icon | -| `--icon-padding-start` | Padding start of the button icon | -| `--icon-padding-top` | Padding top of the button icon | -| `--margin-bottom` | Margin bottom of the button | -| `--margin-end` | Margin end of the button | -| `--margin-start` | Margin start of the button | -| `--margin-top` | Margin top of the button | -| `--min-height` | Minimum height of the button | -| `--min-width` | Minimum width of the button | -| `--opacity` | Opacity of the button | -| `--padding-bottom` | Padding bottom of the button | -| `--padding-end` | Padding end of the button | -| `--padding-start` | Padding start of the button | -| `--padding-top` | Padding top of the button | -| `--ripple-color` | Color of the button ripple effect | -| `--transition` | Transition of the button | +| Name | Description | +| ----------------------- | ------------------------------------- | +| `--background` | Background of the button | +| `--background-focused` | Background of the button when focused | +| `--background-hover` | Background of the button when hover | +| `--border-radius` | Border radius of the button | +| `--color` | Text color of the button | +| `--color-focused` | Text color of the button when focused | +| `--color-hover` | Text color of the button when hover | +| `--icon-font-size` | Font size of the button icon | +| `--icon-font-weight` | Font weight of the button icon | +| `--icon-margin-bottom` | Margin bottom of the button icon | +| `--icon-margin-end` | Margin end of the button icon | +| `--icon-margin-start` | Margin start of the button icon | +| `--icon-margin-top` | Margin top of the button icon | +| `--icon-padding-bottom` | Padding bottom of the button icon | +| `--icon-padding-end` | Padding end of the button icon | +| `--icon-padding-start` | Padding start of the button icon | +| `--icon-padding-top` | Padding top of the button icon | +| `--margin-bottom` | Margin bottom of the button | +| `--margin-end` | Margin end of the button | +| `--margin-start` | Margin start of the button | +| `--margin-top` | Margin top of the button | +| `--min-height` | Minimum height of the button | +| `--min-width` | Minimum width of the button | +| `--opacity` | Opacity of the button | +| `--padding-bottom` | Padding bottom of the button | +| `--padding-end` | Padding end of the button | +| `--padding-start` | Padding start of the button | +| `--padding-top` | Padding top of the button | +| `--ripple-color` | Color of the button ripple effect | +| `--transition` | Transition of the button | ---------------------------------------------- diff --git a/core/src/components/back-button/test/basic/e2e.ts b/core/src/components/back-button/test/basic/e2e.ts new file mode 100644 index 0000000000..5b813c6da8 --- /dev/null +++ b/core/src/components/back-button/test/basic/e2e.ts @@ -0,0 +1,10 @@ +import { newE2EPage } from '@stencil/core/testing'; + +test('back-button: basic', async () => { + const page = await newE2EPage({ + url: '/src/components/back-button/test/basic?ionic:_testing=true' + }); + + const compare = await page.compareScreenshot(); + expect(compare).toMatchScreenshot(); +}); diff --git a/core/src/components/back-button/test/basic/index.html b/core/src/components/back-button/test/basic/index.html index b8b671b063..a41ef7d711 100644 --- a/core/src/components/back-button/test/basic/index.html +++ b/core/src/components/back-button/test/basic/index.html @@ -3,129 +3,144 @@ - Back Button - + Back Button - Basic + - + - + +

Default

+

+ + + + + +

+

+ + + + + +

+ +

Colors

+

+ + + + + + + + + +

+

+ + + + + + + + + +

+ +

Custom

+ + +

+ + + + +

+

+ + + + +

+ + +

+ + +

+ +

+ + +

+
+ + + + - - diff --git a/core/src/components/back-button/test/navigation/index.html b/core/src/components/back-button/test/navigation/index.html new file mode 100644 index 0000000000..dd91303014 --- /dev/null +++ b/core/src/components/back-button/test/navigation/index.html @@ -0,0 +1,131 @@ + + + + + + Back Button - Navigation + + + + + + + + + + + + + + + + diff --git a/core/src/components/back-button/test/standalone/e2e.ts b/core/src/components/back-button/test/standalone/e2e.ts new file mode 100644 index 0000000000..93f1bdf46f --- /dev/null +++ b/core/src/components/back-button/test/standalone/e2e.ts @@ -0,0 +1,10 @@ +import { newE2EPage } from '@stencil/core/testing'; + +test('back-button: standalone', async () => { + const page = await newE2EPage({ + url: '/src/components/back-button/test/standalone?ionic:_testing=true' + }); + + const compare = await page.compareScreenshot(); + expect(compare).toMatchScreenshot(); +}); diff --git a/core/src/components/back-button/test/standalone/index.html b/core/src/components/back-button/test/standalone/index.html index 55fbc5eef1..b557645f6a 100644 --- a/core/src/components/back-button/test/standalone/index.html +++ b/core/src/components/back-button/test/standalone/index.html @@ -3,7 +3,7 @@ - Back Button + Back Button - Standalone diff --git a/core/src/components/back-button/test/toolbar/e2e.ts b/core/src/components/back-button/test/toolbar/e2e.ts new file mode 100644 index 0000000000..5b813c6da8 --- /dev/null +++ b/core/src/components/back-button/test/toolbar/e2e.ts @@ -0,0 +1,10 @@ +import { newE2EPage } from '@stencil/core/testing'; + +test('back-button: basic', async () => { + const page = await newE2EPage({ + url: '/src/components/back-button/test/basic?ionic:_testing=true' + }); + + const compare = await page.compareScreenshot(); + expect(compare).toMatchScreenshot(); +}); diff --git a/core/src/components/back-button/test/toolbar/index.html b/core/src/components/back-button/test/toolbar/index.html new file mode 100644 index 0000000000..ef01e9a2eb --- /dev/null +++ b/core/src/components/back-button/test/toolbar/index.html @@ -0,0 +1,125 @@ + + + + + + Back Button - Toolbar + + + + + + + + + + + + + + + + Default + + + + + + + + Custom + + + + + + + + Secondary + + + + + + + + Light + + + + + + + + + Danger + + + + + + + + + + + Dark + + + + + + + + Tertiary + + + + + + + + Primary + + + + + + + + Success + + + + + + + + + + diff --git a/core/src/components/button/button.scss b/core/src/components/button/button.scss index ef5bcda76a..1f7bc23d0b 100644 --- a/core/src/components/button/button.scss +++ b/core/src/components/button/button.scss @@ -238,11 +238,6 @@ border: 0; } - -// .button > .button-container:hover { -// opacity: var(--opacity-hover); -// } - .button-inner { display: flex; diff --git a/core/src/components/buttons/buttons.ios.scss b/core/src/components/buttons/buttons.ios.scss index c64b5209bc..e06ac95bcc 100644 --- a/core/src/components/buttons/buttons.ios.scss +++ b/core/src/components/buttons/buttons.ios.scss @@ -29,7 +29,8 @@ :host-context(.ion-color)::slotted(*) .button { --color: initial; --border-color: initial; - --color-activated: initial; + --background-focused: #{current-color(contrast, .1)}; + } :host-context(.ion-color)::slotted(*) .button-solid { diff --git a/core/src/components/buttons/buttons.md.scss b/core/src/components/buttons/buttons.md.scss index 84f0f8521b..e104ea28af 100644 --- a/core/src/components/buttons/buttons.md.scss +++ b/core/src/components/buttons/buttons.md.scss @@ -29,8 +29,8 @@ :host-context(.ion-color)::slotted(*) .button { --color: initial; - --color-activated: initial; - --color-focused: initial; + --color-focused: #{current-color(contrast)}; + --color-hover: #{current-color(contrast)}; --background-hover: #{current-color(contrast, .08)}; --background-focused: #{current-color(contrast, .24)}; } @@ -39,8 +39,10 @@ --background: #{current-color(contrast)}; --background-activated: #{current-color(contrast)}; --background-focused: #{current-color(contrast, .9)}; + --background-hover: #{current-color(contrast, .92)}; --color: #{current-color(base)}; --color-focused: #{current-color(base)}; + --color-hover: #{current-color(base)}; } :host-context(.ion-color)::slotted(*) .button-outline { @@ -48,15 +50,6 @@ } -// Material Design Toolbar Default Button -// -------------------------------------------------- - -::slotted(*) .button { - --color-focused: #{$toolbar-md-color}; - --background-focused: rgba(66, 66, 66, 0.1); -} - - // Material Design Toolbar Icon Only Clear Button // -------------------------------------------------- @@ -74,16 +67,20 @@ } +::slotted(*) .button { + --background-hover: rgba(66, 66, 66, 0.08); +} + // Material Design Toolbar Solid Button // -------------------------------------------------- ::slotted(*) .button-solid { --color: #{$toolbar-md-background}; --color-activated: #{$toolbar-md-background}; - --color-focused: #{$toolbar-md-background}; --background: #{$toolbar-md-color}; --background-activated: #{$toolbar-md-color}; --background-focused: #{$toolbar-md-color-activated}; + --background-hover: rgba(66, 66, 66, 0.92); } @@ -106,8 +103,10 @@ ::slotted(*) .button-clear { --color: initial; + --color-focused: #{$toolbar-md-color}; --color-activated: currentColor; --background: transparent; + --background-focused: rgba(66, 66, 66, 0.1); } diff --git a/core/src/components/menu-button/menu-button.md.scss b/core/src/components/menu-button/menu-button.md.scss index 46de1679bc..bc1645a9f6 100644 --- a/core/src/components/menu-button/menu-button.md.scss +++ b/core/src/components/menu-button/menu-button.md.scss @@ -32,7 +32,6 @@ ion-icon { // Menu Button Color: Focused // -------------------------------------------------- - :host(.ion-color.ion-focused) .button-native { background: #{current-color(base, .24)}; color: #{current-color(base)};