Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

feat(tab): Add tab indicator #2461

Merged
merged 68 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1b3bac3
WIP start of mdc-tab
patrickrodee Mar 10, 2018
8bd43c0
WIP updated with "hasClass" on foundation
patrickrodee Mar 10, 2018
9d33e3b
WIP testing
patrickrodee Mar 12, 2018
0bbfe73
WIP added tests; updated styles for custom indicator
patrickrodee Mar 13, 2018
d531675
WIP adding demo
patrickrodee Mar 13, 2018
8753c18
WIP more progess
patrickrodee Mar 14, 2018
7fe42d5
WIP demo
patrickrodee Mar 14, 2018
9f1053c
WIP added material-icons because i'm a fool
patrickrodee Mar 14, 2018
2205fcb
WIP got ripples and custom theme working; need to update layout and RTL
patrickrodee Mar 15, 2018
dbb6a3d
WIP made mdc-tab private
patrickrodee Mar 15, 2018
0feb3ab
WIP added readme; fixed up demo to look nice
patrickrodee Mar 16, 2018
f1c3097
WIP added ripple exposure from MDCTab
patrickrodee Mar 16, 2018
52187c1
WIP fixed spelling of "event"
patrickrodee Mar 16, 2018
3cc11f3
WIP added ripple foundation back to checkbox
patrickrodee Mar 16, 2018
0f2e7fa
WIP updated all the tests...
patrickrodee Mar 16, 2018
2cc6387
WIP merged master
patrickrodee Mar 20, 2018
b6b7380
WIP cleaned up tab mixins file
patrickrodee Mar 20, 2018
d130f43
WIP rewrote ripple test
patrickrodee Mar 20, 2018
22a5656
WIP re-rewrote ripple test
patrickrodee Mar 20, 2018
047a45f
WIP re-re-rewrote ripple test and implementation
patrickrodee Mar 20, 2018
a016ecf
WIP changed ripple import order
patrickrodee Mar 20, 2018
3744249
WIP moved getters/setters
patrickrodee Mar 20, 2018
f15e991
WIP changed static method order
patrickrodee Mar 20, 2018
1c0d1cc
WIP upgraded tab to 0.33.0; upgraded ripple in tab to 0.33.0
patrickrodee Mar 20, 2018
fa5be74
Merge branch 'master' into feat/tabs/tab
patrickrodee Mar 20, 2018
5fa0260
WIP starting
patrickrodee Mar 20, 2018
dab80ce
WIP merge master
patrickrodee Mar 20, 2018
dd8554e
WIP progress
patrickrodee Mar 21, 2018
55d9f5e
WIP progress
patrickrodee Mar 22, 2018
88dae47
WIP progress
patrickrodee Mar 23, 2018
d1a7de3
WIP progress again
patrickrodee Mar 23, 2018
f63bfea
WIP removed tab-indicator package
patrickrodee Mar 26, 2018
2e0f946
WIP added tests
patrickrodee Mar 26, 2018
352bc66
WIP removed tab ripple
patrickrodee Mar 26, 2018
3820453
WIP fixed tests and typing
patrickrodee Mar 26, 2018
6239108
WIP added ripple test
patrickrodee Mar 26, 2018
80bb55d
WIP set transform origin for IE testing [skip-ci]
patrickrodee Mar 26, 2018
915e572
Merge branch 'master' into feat/tabs/tab-indicator
patrickrodee Mar 27, 2018
06093c7
WIP updated demo and event handler registration naming scheme
patrickrodee Mar 27, 2018
394d115
Merge branch 'feat/tabs/tab-indicator' of github.com:material-compone…
patrickrodee Mar 27, 2018
4a27603
WIP fixed some stylelint issues i should've caught
patrickrodee Mar 27, 2018
0c52e85
WIP readme progress; mdc-tab commenting [ci skip]
patrickrodee Mar 27, 2018
d9739ef
WIP updated demos and tests
patrickrodee Mar 27, 2018
3a65619
WIP adding moar tests
patrickrodee Mar 28, 2018
c80c9f5
WIP progress; need to fix outstanding closure issues
patrickrodee Mar 29, 2018
d42b3ad
WIP added a whole bunch; time for an updated PR
patrickrodee Mar 29, 2018
56aebed
WIP reset all tab changes so this PR is just tab-indicator
patrickrodee Mar 29, 2018
35ba5d2
Merge branch 'master' into feat/tabs/tab-indicator
patrickrodee Mar 29, 2018
961f84b
WIP removed package-lock.json
patrickrodee Mar 29, 2018
6aaf004
Merge branch 'feat/tabs/tab-indicator' of github.com:material-compone…
patrickrodee Mar 29, 2018
6ba4fbe
WIP got tests passing
patrickrodee Mar 30, 2018
8603321
WIP added demo for tab indicator
patrickrodee Mar 30, 2018
1ba59fc
WIP updated demo; reworked icon visual centering
patrickrodee Mar 30, 2018
e015586
WIP adding appendChild/removeChild to gBCR test
patrickrodee Mar 30, 2018
00af9db
Merge branch 'master' into feat/tabs/tab-indicator
patrickrodee Mar 30, 2018
5841b72
WIP removed overrides from icon foundation
patrickrodee Mar 30, 2018
38c868f
WIP updated from review
patrickrodee Apr 2, 2018
164089a
WIP separating content from animation
patrickrodee Apr 3, 2018
8a41020
Merge branch 'feat/tabs/tabs' into feat/tabs/tab-indicator
patrickrodee Apr 3, 2018
6b563c2
Merge branch 'feat/tabs/tab-indicator' of github.com:material-compone…
patrickrodee Apr 3, 2018
e4d6b76
WIP updated from review
patrickrodee Apr 3, 2018
6e1b1a4
WIP set travis to run for merges to feat/tabs/tabs
patrickrodee Apr 3, 2018
66b550f
WIP DONE
patrickrodee Apr 6, 2018
058998e
WIP saved the day
patrickrodee Apr 7, 2018
7aa0362
WIP party time ✨
patrickrodee Apr 7, 2018
c5ca744
WIP updated from review ✌️
patrickrodee Apr 9, 2018
60463e4
WIP renamed "bar" to "underline"
patrickrodee Apr 9, 2018
ad27e5c
WIP updated test names
patrickrodee Apr 9, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js
branches:
only:
- master
- feat/tabs/tabs
matrix:
include:
- node_js: 8
Expand Down
221 changes: 221 additions & 0 deletions demos/tab-indicator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
<!DOCTYPE html>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This demo page needs some restructure

  • don't put so much in the "hero" section. You can just put two tabs there showing hte default behavior and call it done
  • Add some sections, with titles, below the hero section. I'm thinking: bar x sliding indicator, icon x fading indicator, bar x fading indicator, icon x sliding indicator (same icon on each tab)
  • Also add sections for the customization: color, height, and corner radius

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

<!--
Copyright 2018 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License
-->
<html>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add more cases where the tabs are different widths. And remove the fading bar demo.

<head>
<meta charset="utf-8">
<title>Tab Indicator - Material Components Catalog</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png">
<link rel="stylesheet" href="/assets/tab-indicator.css">
<script src="/ready.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>

<body class="mdc-typography">
<header class="mdc-toolbar mdc-toolbar--fixed">
<div class="mdc-toolbar__row">
<section class="mdc-toolbar__section mdc-toolbar__section--align-start">
<span class="catalog-back">
<a href="/" class="mdc-toolbar__menu-icon"><i class="material-icons">&#xE5C4;</i></a>
</span>
<span class="mdc-toolbar__title catalog-title">Tab Indicator</span>
</section>
</div>
</header>

<main class="mdc-toolbar-fixed-adjust">
<section class="hero">
<div class="demo">
<div class="demo-item hero-demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--bar mdc-tab-indicator--active"></span>
</div>
<div class="demo-item demo-item--wide hero-demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--bar"></span>
</div>
<div class="demo-item demo-item--narrow hero-demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--bar"></span>
</div>
</div>
</section>

<section class="example">
<h2>Sliding Bar Indicator</h2>
<div class="demo">
<div class="demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--bar mdc-tab-indicator--active demo-indicator custom-sliding-bar"></span>
</div>
<div class="demo-item demo-item--narrow">
<span class="mdc-tab-indicator mdc-tab-indicator--bar custom-sliding-bar"></span>
</div>
<div class="demo-item demo-item--wide">
<span class="mdc-tab-indicator mdc-tab-indicator--bar custom-sliding-bar"></span>
</div>
</div>

<br>

<h4>Custom Color</h4>
<div class="demo">
<div class="demo-item demo-item--narrow">
<span class="mdc-tab-indicator mdc-tab-indicator--bar mdc-tab-indicator--active custom-color-bar"></span>
</div>
<div class="demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--bar custom-color-bar"></span>
</div>
<div class="demo-item demo-item--wide">
<span class="mdc-tab-indicator mdc-tab-indicator--bar custom-color-bar"></span>
</div>
</div>

<br>

<h4>Custom Height</h4>
<div class="demo">
<div class="demo-item demo-item--narrow">
<span class="mdc-tab-indicator mdc-tab-indicator--bar mdc-tab-indicator--active custom-height-bar"></span>
</div>
<div class="demo-item demo-item--wide">
<span class="mdc-tab-indicator mdc-tab-indicator--bar custom-height-bar"></span>
</div>
<div class="demo-item demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--bar custom-height-bar"></span>
</div>
</div>

<br>

<h4>Custom Border Radius</h4>
<div class="demo">
<div class="demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--bar mdc-tab-indicator--active custom-border-radius"></span>
</div>
<div class="demo-item demo-item--narrow">
<span class="mdc-tab-indicator mdc-tab-indicator--bar custom-border-radius"></span>
</div>
<div class="demo-item demo-item--wide">
<span class="mdc-tab-indicator mdc-tab-indicator--bar custom-border-radius"></span>
</div>
</div>
</section>

<section class="example">
<h2>Fading Icon Indicator</h2>
<div class="demo">
<div class="demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--icon mdc-tab-indicator--fade mdc-tab-indicator--active material-icons">favorite</span>
</div>
<div class="demo-item demo-item--wide">
<span class="mdc-tab-indicator mdc-tab-indicator--icon mdc-tab-indicator--fade material-icons">star</span>
</div>
<div class="demo-item demo-item--narrow">
<span class="mdc-tab-indicator mdc-tab-indicator--icon mdc-tab-indicator--fade material-icons">lens</span>
</div>
</div>

<br>

<h4>Custom Color</h4>
<div class="demo">
<div class="demo-item demo-item--wide">
<span class="mdc-tab-indicator mdc-tab-indicator--icon mdc-tab-indicator--fade mdc-tab-indicator--active custom-color-icon material-icons">favorite</span>
</div>
<div class="demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--icon mdc-tab-indicator--fade custom-color-icon material-icons">star</span>
</div>
<div class="demo-item demo-item--narrow">
<span class="mdc-tab-indicator mdc-tab-indicator--icon mdc-tab-indicator--fade custom-color-icon material-icons">lens</span>
</div>
</div>

<br>

<h4>Custom Height</h4>
<div class="demo">
<div class="demo-item demo-item--narrow">
<span class="mdc-tab-indicator mdc-tab-indicator--icon mdc-tab-indicator--fade mdc-tab-indicator--active custom-height-icon material-icons">favorite</span>
</div>
<div class="demo-item demo-item--wide">
<span class="mdc-tab-indicator mdc-tab-indicator--icon mdc-tab-indicator--fade custom-height-icon material-icons">star</span>
</div>
<div class="demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--icon mdc-tab-indicator--fade custom-height-icon material-icons">lens</span>
</div>
</div>
</section>

<section class="example">
<h2>Mix and Match</h2>
<p>This demo shows how to use a sliding indicator with custom SVG icon content.</p>
<div class="demo">
<div class="demo-item">
<span class="mdc-tab-indicator mdc-tab-indicator--icon mdc-tab-indicator--active custom-sliding-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="custom-icon">
<path d="M12 7.77L18.39 18H5.61L12 7.77M12 4L2 20h20L12 4z"/>
<path fill="none" d="M0 0h24v24H0V0z"/>
</svg>
</span>
</div>
<div class="demo-item demo-item--narrow">
<span class="mdc-tab-indicator mdc-tab-indicator--icon custom-sliding-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="custom-icon">
<path d="M12 7.77L18.39 18H5.61L12 7.77M12 4L2 20h20L12 4z"/>
<path fill="none" d="M0 0h24v24H0V0z"/>
</svg>
</span>
</div>
<div class="demo-item demo-item--wide">
<span class="mdc-tab-indicator mdc-tab-indicator--icon custom-sliding-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="custom-icon">
<path d="M12 7.77L18.39 18H5.61L12 7.77M12 4L2 20h20L12 4z"/>
<path fill="none" d="M0 0h24v24H0V0z"/>
</svg>
</span>
</div>
</div>
</section>
</main>

<script src="/assets/material-components-web.js" async></script>
<script>
demoReady(function() {

function initDemo(demoRoot) {
var demoItems = demoRoot.querySelectorAll('.demo-item');
var activeIndicator;
[].forEach.call(demoItems, function (demoItem) {
var indicatorEl = demoItem.querySelector('.mdc-tab-indicator');
var indicator = new mdc.tabIndicator.MDCTabIndicator(indicatorEl);
if (indicatorEl.classList.contains('mdc-tab-indicator--active')) {
activeIndicator = indicator;
}

demoItem.addEventListener('click', function() {
activeIndicator.deactivate();
indicator.activate(activeIndicator.computeClientRect());
activeIndicator = indicator;
});
});
}

var demos = document.querySelectorAll('.demo');
[].forEach.call(demos, initDemo);
});
</script>
</body>
</html>
85 changes: 85 additions & 0 deletions demos/tab-indicator.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
@import "./common";
@import "../packages/mdc-tab-indicator/mixins";
@import "../packages/mdc-tab-indicator/mdc-tab-indicator";
@import "../packages/mdc-elevation/mixins";
@import "../packages/mdc-theme/color-palette";

.hero {
flex-direction: column;
}

.demo {
@include mdc-elevation(1);

display: flex;
width: 400px;
height: 50px;
margin: 2rem 0;
}

.demo-item {
@include mdc-tab-indicator-surface;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so will this mdc-tab-indicator-surface go on mdc-tab?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly


flex: 2 0 auto;
height: inherit;
background-color: $material-color-grey-50;
cursor: pointer;
}

.demo-item--narrow {
flex: 1 0 auto;
}

.demo-item--wide {
flex: 3 0 auto;
}

.demo-item:hover {
background-color: white;
}

.demo > .demo-item:nth-child(n + 2) {
border-left: 1px solid $material-color-grey-300;
}

.demo-label {
position: relative;
z-index: 2;
}

.custom-color-bar {
@include mdc-tab-indicator-bar-color($material-color-orange-a400);
}

.custom-color-icon {
@include mdc-tab-indicator-icon-color($material-color-orange-a400);
}

.custom-height-bar {
@include mdc-tab-indicator-bar-height(8px);
}

.custom-height-icon {
@include mdc-tab-indicator-icon-height(44px);
}

.custom-border-radius {
@include mdc-tab-indicator-bar-height(5px);
@include mdc-tab-indicator-bar-top-corner-radius(5px);
}

.custom-fading-bar {
@include mdc-tab-indicator-bar-height(4px);
@include mdc-tab-indicator-bar-color($material-color-green-a400);
@include mdc-tab-indicator-bar-top-corner-radius(4px);
}

.custom-sliding-icon {
@include mdc-tab-indicator-icon-height(30px);
@include mdc-tab-indicator-icon-color($material-color-pink-a400);
}

.custom-icon {
height: inherit;
fill: currentColor;
}
Loading