Skip to content

Commit

Permalink
fix(tab-bar): add translucent tab-bar styles back (#17376)
Browse files Browse the repository at this point in the history
- updates css to allow for translucent tab-bar
- adds translucent test
  • Loading branch information
liamdebeasi authored and brandyscarney committed Feb 6, 2019
1 parent b49257a commit 374bd77
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 4 deletions.
17 changes: 13 additions & 4 deletions core/src/components/tab-bar/tab-bar.ios.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@import "./tab-bar";
@import "../../themes/ionic.globals.ios";
@import "../tab-button/tab-button.ios.vars";
@import "./tab-bar.ios.vars";

// iOS Tabs
// --------------------------------------------------
Expand All @@ -20,6 +19,16 @@
// --------------------------------------------------

:host(.tab-bar-translucent) {
background-color: #{current-color(base, .8)};
backdrop-filter: saturate(210%) blur(20px);
--background: #{$tab-bar-ios-translucent-background-color};
backdrop-filter: $tab-bar-ios-translucent-filter;
}

// iOS Translucent Tab bar with Color
:host(.ion-color.tab-bar-translucent) {
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;
}
14 changes: 14 additions & 0 deletions core/src/components/tab-bar/tab-bar.ios.vars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import "../../themes/ionic.globals.ios";
@import "../tab-button/tab-button.ios.vars";

// iOS Tab Bar
// --------------------------------------------------

/// @prop - Alpha of translucent tab bar background color
$tab-bar-ios-translucent-background-color-alpha: .8 !default;

/// @prop - Translucent tab bar background color
$tab-bar-ios-translucent-background-color: rgba($background-color-rgb, $tab-bar-ios-translucent-background-color-alpha) !default;

/// @prop - Filter of the translucent tab bar background color
$tab-bar-ios-translucent-filter: saturate(210%) blur(20px) !default;
4 changes: 4 additions & 0 deletions core/src/components/tab-bar/tab-bar.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@

height: 56px;
}

:host(.tab-bar-translucent) ::slotted(ion-tab-button) {
background: transparent;
}
38 changes: 38 additions & 0 deletions core/src/components/tab-bar/test/spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,44 @@
<ion-icon name="calendar"></ion-icon>
</ion-tab-button>
</ion-tab-bar>

<!-- Translucent -->
<ion-tab-bar translucent>
<ion-tab-button tab="1">
<ion-icon name="heart"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="musical-note"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="today"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="4">
<ion-icon name="calendar"></ion-icon>
</ion-tab-button>
</ion-tab-bar>

<!-- Translucent / Custom Color -->
<ion-tab-bar translucent color="dark">
<ion-tab-button tab="1">
<ion-icon name="heart"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="musical-note"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="today"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="4">
<ion-icon name="calendar"></ion-icon>
</ion-tab-button>
</ion-tab-bar>

<style>
body {
Expand Down
10 changes: 10 additions & 0 deletions core/src/components/tab-bar/test/translucent/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { newE2EPage } from '@stencil/core/testing';

test('tab-bar: translucent', async () => {
const page = await newE2EPage({
url: '/src/components/tab-bar/test/translucent?ionic:_testing=true'
});

const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot();
});
213 changes: 213 additions & 0 deletions core/src/components/tab-bar/test/translucent/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
<!DOCTYPE html>
<html dir="ltr">

<head>
<meta charset="UTF-8">
<title>Tab Bar - Spec</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<script src="../../../../../scripts/testing/scripts.js"></script>
<script src="../../../../../dist/ionic.js"></script>
<link rel="stylesheet" href="../../../../../css/ionic.bundle.css">
<link rel="stylesheet" href="../../../../../scripts/testing/styles.css">
</head>

<body>
<!-- Default -->
<ion-tab-bar translucent selected-tab="1">

<ion-tab-button tab="1">
<ion-label>Recents</ion-label>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-label>Favorites</ion-label>
<ion-badge>6</ion-badge>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-label>Settings</ion-label>
</ion-tab-button>

</ion-tab-bar>

<!-- Badges -->
<ion-tab-bar translucent selected-tab="1">
<ion-tab-button tab="1">
<ion-icon name="heart"></ion-icon>
<ion-label>Item One Max</ion-label>
<ion-badge color="danger"></ion-badge>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="musical-note"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="today"></ion-icon>
<ion-badge color="danger">88</ion-badge>
</ion-tab-button>

<ion-tab-button tab="4">
<ion-icon name="calendar"></ion-icon>
<ion-badge color="danger">888+</ion-badge>
</ion-tab-button>
</ion-tab-bar>

<ion-tab-bar translucent selected-tab="1">
<ion-tab-button tab="1">
<ion-icon name="musical-note"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="2" layout="icon-bottom">
<ion-icon name="heart"></ion-icon>
<ion-label>Item One Max</ion-label>
<ion-badge color="danger"></ion-badge>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="today"></ion-icon>
<ion-badge color="danger">88</ion-badge>
</ion-tab-button>

<ion-tab-button tab="4">
<ion-icon name="calendar"></ion-icon>
<ion-badge color="danger">888+</ion-badge>
</ion-tab-button>
</ion-tab-bar>

<ion-tab-bar translucent selected-tab="1">
<ion-tab-button tab="1">
<ion-icon name="heart"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="musical-note"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="today"></ion-icon>
</ion-tab-button>
</ion-tab-bar>

<ion-tab-bar translucent selected-tab="1">
<ion-tab-button tab="1">
<ion-icon name="musical-note"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="2" layout="icon-bottom">
<ion-icon name="heart"></ion-icon>
<ion-label>Item One Max</ion-label>
<ion-badge color="danger">88</ion-badge>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="today"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="4">
<ion-icon name="calendar"></ion-icon>
</ion-tab-button>
</ion-tab-bar>

<!-- Custom Height -->
<ion-tab-bar translucent color="danger" selected-tab="3" class="custom-height">
<ion-tab-button tab="1">
<ion-icon name="heart"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="musical-note"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="today"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="4">
<ion-icon name="calendar"></ion-icon>
</ion-tab-button>
</ion-tab-bar>

<!-- Custom Height / Alignment -->
<ion-tab-bar translucent color="tertiary" selected-tab="3" class="custom-height custom-top">
<ion-tab-button tab="1">
<ion-icon name="heart"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="musical-note"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="today"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="4">
<ion-icon name="calendar"></ion-icon>
</ion-tab-button>
</ion-tab-bar>

<!-- Translucent -->
<ion-tab-bar translucent>
<ion-tab-button tab="1">
<ion-icon name="heart"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="musical-note"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="today"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="4">
<ion-icon name="calendar"></ion-icon>
</ion-tab-button>
</ion-tab-bar>

<!-- Translucent / Custom Color -->
<ion-tab-bar translucent class="custom-background">
<ion-tab-button tab="1">
<ion-icon name="heart"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="musical-note"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="today"></ion-icon>
</ion-tab-button>

<ion-tab-button tab="4">
<ion-icon name="calendar"></ion-icon>
</ion-tab-button>
</ion-tab-bar>

<style>
body {
background: linear-gradient(
to right, orange , yellow, green, cyan, blue, violet
);
}

ion-tab-bar {
margin-bottom: 5px;
}

.custom-height {
height: 80px;
}

.custom-top ion-tab-button {
justify-content: start;
}

.custom-background {
--background: rgba(124, 243, 217, 0.6);
}
</style>
</body>

</html>

0 comments on commit 374bd77

Please sign in to comment.