From d788a8eac6ea8e60b1147be3d6119cd448a845db Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 14 May 2019 12:04:41 -0400 Subject: [PATCH] fix(tab-button): apply background-focused when tabbing into tab button (#17502) fixes #17042 --- core/src/components/tab-bar/tab-bar.ios.scss | 5 +- core/src/components/tab-bar/tab-bar.md.scss | 4 - core/src/components/tab-bar/tab-bar.scss | 25 +- .../src/components/tab-bar/test/custom/e2e.ts | 16 +- .../components/tab-bar/test/custom/index.html | 6 + .../tab-bar/test/translucent/index.html | 351 +++++++++--------- .../tab-button/tab-button.ios.vars.scss | 2 +- .../src/components/tab-button/tab-button.scss | 4 +- core/src/components/tab-button/tab-button.tsx | 19 +- 9 files changed, 240 insertions(+), 192 deletions(-) diff --git a/core/src/components/tab-bar/tab-bar.ios.scss b/core/src/components/tab-bar/tab-bar.ios.scss index 6cf90179d2..006df07de4 100644 --- a/core/src/components/tab-bar/tab-bar.ios.scss +++ b/core/src/components/tab-bar/tab-bar.ios.scss @@ -28,7 +28,6 @@ background: #{current-color(base, $tab-bar-ios-translucent-background-color-alpha)}; } -// iOS Translucent Tab bar button -:host(.tab-bar-translucent) ::slotted(ion-tab-button) { - background: transparent; +:host(.tab-bar-translucent) ::slotted(ion-tab-button.ion-focused) { + background: rgba($background-color-rgb, .6); } \ No newline at end of file diff --git a/core/src/components/tab-bar/tab-bar.md.scss b/core/src/components/tab-bar/tab-bar.md.scss index 0a198f1678..4363520fad 100644 --- a/core/src/components/tab-bar/tab-bar.md.scss +++ b/core/src/components/tab-bar/tab-bar.md.scss @@ -11,8 +11,4 @@ --color-selected: #{$tabbar-md-color-activated}; height: 56px; -} - -:host(.tab-bar-translucent) ::slotted(ion-tab-button) { - background: transparent; } \ No newline at end of file diff --git a/core/src/components/tab-bar/tab-bar.scss b/core/src/components/tab-bar/tab-bar.scss index 05f6e76f6a..ee703639fb 100644 --- a/core/src/components/tab-bar/tab-bar.scss +++ b/core/src/components/tab-bar/tab-bar.scss @@ -33,19 +33,32 @@ box-sizing: content-box !important; } +:host(.ion-color) ::slotted(ion-tab-button) { + --background-focused: #{current-color(shade)}; + --color-selected: #{current-color(contrast)}; +} + +:host(.ion-color) ::slotted(.tab-selected) { + color: #{current-color(contrast)};; +} + :host(.ion-color), :host(.ion-color) ::slotted(ion-tab-button) { - background: #{current-color(base)}; color: #{current-color(contrast, .7)}; } +:host(.ion-color), :host(.ion-color) ::slotted(ion-tab-button) { - --background-focused: #{current-color(shade)}; - --color-selected: #{current-color(contrast)}; + background: #{current-color(base)}; } -:host(.ion-color) ::slotted(.tab-selected) { - color: #{current-color(contrast)};; +:host(.ion-color) ::slotted(ion-tab-button.ion-focused), +:host(.tab-bar-translucent) ::slotted(ion-tab-button.ion-focused) { + background: var(--background-focused) +} + +:host(.tab-bar-translucent) ::slotted(ion-tab-button) { + background: transparent; } :host([slot="top"]) { @@ -58,4 +71,4 @@ :host(.tab-bar-hidden) { /* stylelint-disable-next-line declaration-no-important */ display: none !important; -} +} \ No newline at end of file diff --git a/core/src/components/tab-bar/test/custom/e2e.ts b/core/src/components/tab-bar/test/custom/e2e.ts index 6ca6a6f4aa..0c3d211519 100644 --- a/core/src/components/tab-bar/test/custom/e2e.ts +++ b/core/src/components/tab-bar/test/custom/e2e.ts @@ -5,6 +5,18 @@ test('tab-bar: custom', async () => { url: '/src/components/tab-bar/test/custom?ionic:_testing=true' }); - const compare = await page.compareScreenshot(); - expect(compare).toMatchScreenshot(); + const screenshotCompares = []; + + const tabBar = await page.find('ion-tab-bar'); + await tabBar.waitForVisible(); + + screenshotCompares.push(await page.compareScreenshot('tab-bar: custom default')); + + await page.keyboard.press('Tab'); + + screenshotCompares.push(await page.compareScreenshot('tab-bar: custom tabbed')); + await page.waitFor(10000); + for (const screenshotCompare of screenshotCompares) { + expect(screenshotCompare).toMatchScreenshot(); + } }); diff --git a/core/src/components/tab-bar/test/custom/index.html b/core/src/components/tab-bar/test/custom/index.html index 3263a2b5d1..a6f0c0b707 100644 --- a/core/src/components/tab-bar/test/custom/index.html +++ b/core/src/components/tab-bar/test/custom/index.html @@ -16,6 +16,12 @@ + + + + Recents + + Recents diff --git a/core/src/components/tab-bar/test/translucent/index.html b/core/src/components/tab-bar/test/translucent/index.html index 04dc027816..6915eb2dd3 100644 --- a/core/src/components/tab-bar/test/translucent/index.html +++ b/core/src/components/tab-bar/test/translucent/index.html @@ -12,182 +12,187 @@ + + + + + + Recents + + + + Favorites + 6 + + + + Settings + + + + + + + + + Item One Max + + + + + + + + + + 88 + + + + + 888+ + + + + + + + + + + + Item One Max + + + + + + 88 + + + + + 888+ + + + + + + + + + + + + + + + + + + + + + + + + + Item One Max + 88 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - Recents - - - - Favorites - 6 - - - - Settings - - - - - - - - - Item One Max - - - - - - - - - - 88 - - - - - 888+ - - - - - - - - - - - Item One Max - - - - - - 88 - - - - - 888+ - - - - - - - - - - - - - - - - - - - - - - - - - Item One Max - 88 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +