Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d237715

Browse files
committedJul 31, 2020
fix(tabs): align theming with spec updates
- by default, use the accent color for the selected tab's text instead of the primary color. It should match the ink bar. - add support for white/black (contrast color) ink bar with `md-primary` background - non-selected tabs are now colored with the palette's contrast color at 70% opacity - remove padding around `md-tabs` in Dynamic Tabs demo - add theming docs for `md-tabs` - fix theming issues with pagination buttons - default `md-accent` and `md-warn` tab background colors to the 500 hue Fixes #7685
1 parent 3400321 commit d237715

File tree

8 files changed

+80
-33
lines changed

8 files changed

+80
-33
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>This demo shows how you can horizontally center tabs and use the primary color as your tab background.</p>
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<p>
22
The Dynamic Height demo shows how tabs can be used to display content with varying heights.
33
</p>
4-
5-
<p>
6-
<i>
4+
<blockquote>
5+
<p>
76
<b>Note:</b> If you are using the Tabs component for page-level navigation, please take a look
8-
at the <a href="./demo/navBar">NavBar component</a> instead as it can handle this case a bit
9-
more natively.
10-
</i>
11-
</p>
7+
at the <a href="./demo/navBar">NavBar component</a> instead. It has better support for navigation
8+
and can performantly handle tabs with larger, more rich content.
9+
</p>
10+
</blockquote>

‎src/components/tabs/demoDynamicTabs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div ng-controller="AppCtrl" layout="column" ng-cloak>
2-
<md-content class="md-padding">
2+
<md-content>
33
<md-tabs md-selected="selectedIndex" md-border-bottom md-autoselect md-swipe-content>
44
<md-tab ng-repeat="tab in tabs"
55
ng-disabled="tab.disabled"
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<p>The Dynamic Tabs demo shows how internal tab views can be easily used.</p>
1+
<p>The Dynamic Tabs demo shows how internal tab views can be used.</p>

‎src/components/tabs/demoStaticTabs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div ng-controller="AppCtrl" ng-cloak>
22
<md-content class="md-padding">
3-
<md-tabs class="md-primary" md-selected="data.selectedIndex"
3+
<md-tabs class="md-primary md-no-ink-bar-color" md-selected="data.selectedIndex"
44
md-align-tabs="{{data.bottom ? 'bottom' : 'top'}}">
55
<md-tab id="tab1" md-tab-class="example-selector-tab1">
66
<md-tab-label>Item One</md-tab-label>
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<p>The Static Tabs demo shows how to disable and bottom-align tabs:</p>
1+
<p>
2+
The Static Tabs demo shows how to disable and bottom-align tabs. Additionally, it demonstrates
3+
the <code>md-no-ink-bar-color</code> class.
4+
</p>

‎src/components/tabs/js/tabsDirective.js

+22-7
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,36 @@
3131
* **Tabs-only** support is useful when tab buttons are used for custom navigation regardless of any
3232
* other components, content, or views.
3333
*
34-
* <i><b>Note:</b> If you are using the Tabs component for page-level navigation, please use
35-
* the <a ng-href="./api/directive/mdNavBar">NavBar component</a> instead. It handles this
36-
* case a more natively and more performantly.</i>
34+
* <blockquote><b>Note:</b> If you are using the Tabs component for page-level navigation, please
35+
* use the <a ng-href="./api/directive/mdNavBar">NavBar component</a> instead. It handles this
36+
* case a more natively and more performantly.</blockquote>
3737
*
3838
* **Tabs with internal views** are the traditional usage where each tab has associated view
3939
* content and the view switching is managed internally by the Tabs component.
4040
*
4141
* **Tabs with external view content** is often useful when content associated with each tab is
4242
* independently managed and data-binding notifications announce tab selection changes.
4343
*
44-
* Additional features also include:
44+
* Additional features include:
4545
*
4646
* * Content can include any markup.
4747
* * If a tab is disabled while active/selected, then the next tab will be auto-selected.
4848
*
49+
* ### Theming
50+
*
51+
* By default, tabs use your app's accent color for the selected tab's text and ink bar.
52+
*
53+
* You can use the theming classes to change the color of the `md-tabs` background:
54+
* * Applying `class="md-primary"` will use your app's primary color for the background, your
55+
* accent color for the ink bar, and your primary palette's contrast color for the text of the
56+
* selected tab.
57+
* * When using the `md-primary` class, you can add the `md-no-ink-bar-color` class to make the
58+
* ink bar use your theme's primary contrast color instead of the accent color.
59+
* * Applying `class="md-accent"` will use your app's accent color for the background and your
60+
* accent palette's contrast color for the text and ink bar of the selected tab.
61+
* * Applying `class="md-warn"` will use your app's warn color for the background and your
62+
* warn palette's contrast color for the text and ink bar of the selected tab.
63+
*
4964
* ### Explanation of tab stretching
5065
*
5166
* Initially, tabs will have an inherent size. This size will either be defined by how much space
@@ -96,16 +111,16 @@
96111
*
97112
* @usage
98113
* <hljs lang="html">
99-
* <md-tabs md-selected="selectedIndex" >
100-
* <img ng-src="img/angular.png" class="centered">
114+
* <md-tabs md-selected="selectedIndex">
115+
* <img ng-src="img/angular.png" class="centered" alt="Angular icon">
101116
* <md-tab
102117
* ng-repeat="tab in tabs | orderBy:predicate:reversed"
103118
* md-on-select="onTabSelected(tab)"
104119
* md-on-deselect="announceDeselected(tab)"
105120
* ng-disabled="tab.disabled">
106121
* <md-tab-label>
107122
* {{tab.title}}
108-
* <img src="img/removeTab.png" ng-click="removeTab(tab)" class="delete">
123+
* <img src="img/removeTab.png" ng-click="removeTab(tab)" class="delete" alt="Remove tab">
109124
* </md-tab-label>
110125
* <md-tab-body>
111126
* {{tab.content}}

‎src/components/tabs/tabs-theme.scss

+44-15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
@mixin md-tab-primary {
22
> md-tabs-wrapper {
33
background-color: '{{primary-color}}';
4+
5+
md-prev-button md-icon,
6+
md-next-button md-icon {
7+
color: '{{primary-contrast}}';
8+
}
49
> md-tabs-canvas {
510
> md-pagination-wrapper {
611
> md-tab-item:not([disabled]) {
712
&, md-icon {
8-
color: '{{primary-100}}';
13+
color: '{{primary-contrast-0.7}}';
914
}
1015
&.md-active, &.md-focused {
1116
&, md-icon {
@@ -16,66 +21,90 @@
1621
background: '{{primary-contrast-0.1}}';
1722
}
1823
}
24+
> md-ink-bar {
25+
color: '{{accent-color}}';
26+
background: '{{accent-color}}';
27+
}
1928
}
2029
}
2130
}
31+
&.md-no-ink-bar-color {
32+
&>md-tabs-wrapper>md-tabs-canvas>md-pagination-wrapper>md-ink-bar {
33+
color: '{{primary-contrast}}';
34+
background: '{{primary-contrast}}';
35+
}
36+
}
2237
}
2338
@mixin md-tab-warn {
2439
> md-tabs-wrapper {
25-
background-color: '{{warn-color}}';
40+
background-color: '{{warn-500}}';
41+
42+
md-prev-button md-icon,
43+
md-next-button md-icon {
44+
color: '{{warn-500-contrast}}';
45+
}
2646
> md-tabs-canvas {
2747
> md-pagination-wrapper {
2848
> md-tab-item:not([disabled]) {
2949
&, md-icon {
30-
color: '{{warn-100}}';
50+
color: '{{warn-500-contrast-0.7}}';
3151
}
3252
&.md-active, &.md-focused {
3353
&, md-icon {
34-
color: '{{warn-contrast}}';
54+
color: '{{warn-500-contrast-1}}';
3555
}
3656
}
3757
&.md-focused {
38-
background: '{{warn-contrast-0.1}}';
58+
background: '{{warn-500-contrast-0.1}}';
3959
}
4060
}
61+
> md-ink-bar {
62+
color: '{{warn-500-contrast}}';
63+
background: '{{warn-500-contrast}}';
64+
}
4165
}
4266
}
4367
}
4468
}
4569
@mixin md-tab-accent {
4670
> md-tabs-wrapper {
47-
background-color: '{{accent-color}}';
71+
background-color: '{{accent-500}}';
72+
73+
md-prev-button md-icon,
74+
md-next-button md-icon {
75+
color: '{{accent-500-contrast-0.7}}';
76+
}
4877
> md-tabs-canvas {
4978
> md-pagination-wrapper {
5079
> md-tab-item:not([disabled]) {
5180
&, md-icon {
52-
color: '{{accent-A100}}';
81+
color: '{{accent-500-contrast-0.7}}';
5382
}
5483
&.md-active, &.md-focused {
5584
&, md-icon {
56-
color: '{{accent-contrast}}';
85+
color: '{{accent-500-contrast-1}}';
5786
}
5887
}
5988
&.md-focused {
60-
background: '{{accent-contrast-0.1}}';
89+
background: '{{accent-500-contrast-0.1}}';
6190
}
6291
}
6392
> md-ink-bar {
64-
color: '{{primary-600-1}}';
65-
background: '{{primary-600-1}}';
93+
color: '{{accent-500-contrast}}';
94+
background: '{{accent-500-contrast}}';
6695
}
6796
}
6897
}
6998
}
70-
7199
}
72100
md-tabs.md-THEME_NAME-theme {
73101
md-tabs-wrapper {
74102
background-color: transparent;
75103
border-color: '{{foreground-4}}';
76104
}
77-
.md-paginator md-icon {
78-
color: '{{primary-color}}';
105+
md-prev-button md-icon,
106+
md-next-button md-icon {
107+
color: '{{foreground-2}}';
79108
}
80109

81110
md-ink-bar {
@@ -92,7 +121,7 @@ md-tabs.md-THEME_NAME-theme {
92121
}
93122
&.md-active, &.md-focused {
94123
&, md-icon {
95-
color: '{{primary-color}}';
124+
color: '{{accent-color}}';
96125
}
97126
}
98127
&.md-focused {

0 commit comments

Comments
 (0)
Failed to load comments.