This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(tab-bar): Add tab bar #3229
Merged
Merged
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
c6076e1
feat(ripple): Call layout on each activation (#2567)
kfranqueiro 5ba7e27
chore(dialog): Remove ripple layout & layoutFooterRipples adapter API…
kfranqueiro 68c08f7
fix(select): Float label on focus/blur (#2560)
afd9e11
chore(text-field): Remove layout calls from text field (#2569)
kfranqueiro 40c11ae
chore(package): update google-closure-compiler to version 20180402.0.…
acdvorak 60c0204
docs(auto-init): Clarify "component's class name" (#2576)
acdvorak 30710a4
fix(checkbox): Implement component/adapter APIs to sync aria-checked …
kfranqueiro 6f97632
docs(button): Add aria-hidden="true" to icon elements (#2582)
kfranqueiro e6e05b7
docs(text-field): Add aria-describedby referencing helper text (#2581)
kfranqueiro 099fdf8
docs(dialog): Remove mention of layoutFooterRipples adapter API (#2586)
kfranqueiro f71d905
fix(select): Override floating label properties in select box (#2574)
williamernest 3d16d78
WIP start of tab bar
patrickrodee ef3d946
feat(tab-bar): Add tab bar
patrickrodee af9b0fc
feat(tab-bar): First commit
patrickrodee 93a5bc5
feat(tab-bar): Create tab bar
patrickrodee 8bcad80
feat(tab-bar): Basic usecase is working
patrickrodee 5fc6332
feat(tab-bar): Basic LTR scrolling and navigation works
patrickrodee c9d25e8
feat(tab-bar): Re-order activateTab functions
patrickrodee 5072399
Merge branch 'feat/tabs/tabs' into feat/tabs/tab-bar1
patrickrodee 5d8dd7d
feat(tab-bar): RTL TAB BAR IS WORKING ✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨
patrickrodee 106ed74
feat(tab-bar): Renamed rtl keyboard navigation handler
patrickrodee 84e5ae8
Merge feat/tabs/tabs
patrickrodee 5505f98
feat(tab-bar): Refactored scrollIntoView logic
patrickrodee 8cb0642
feat(tab-bar): Progress on tests
patrickrodee e0401f5
feat(tab-bar): Finished tests; updated tab and tab scroller styles
patrickrodee afe5938
feat(tab-bar): Update scroller tests
patrickrodee 376ae15
Merge branch 'feat/tabs/tabs' into feat/tabs/tab-bar1
patrickrodee b70fb62
Merge branch 'feat/tabs/tabs' into feat/tabs/tab-bar1
patrickrodee 0f1030b
fix(tab): Clean up duplicate rules
patrickrodee 26e6fee
fix(tab-bar): Clean-up unnecessary changes
patrickrodee f4e9e00
feat(tab-bar): Add readme
patrickrodee 6153d62
feat(tab-bar): Added annotations
patrickrodee 84af175
fix(tab-bar): Fix keyboard navigation for keyCode browsers
patrickrodee 2067704
Merge branch 'feat/tabs/tabs' into feat/tabs/tab-bar1
patrickrodee 2a84535
feat(tab-bar): Update from feedback
patrickrodee a0cd324
fix(tab-bar): Update tests to pass
patrickrodee 74c0c8a
fix(tab-bar): Manually initialize ACCEPTABLE_KEYS and KEYCODE_MAP
patrickrodee 87925f6
feat(tab-bar): Emit event when a tab is activated
patrickrodee 7ee952e
Merge branch 'feat/tabs/tabs' into feat/tabs/tab-bar1
patrickrodee f121fa6
Merge branch 'feat/tabs/tab-bar1' of github.com:material-components/m…
patrickrodee ea11d8f
feat(tab-bar): Emit event when tab is activated
patrickrodee 1a98d7c
Merge branch 'feat/tabs/tabs' into feat/tabs/tab-bar1
patrickrodee d1857c6
Merge feat/tabs/tabs
patrickrodee f769977
feat(tab-bar): Add mixin; FInalize demo; Update readme
patrickrodee 1edecd0
fix(tab-bar): Update autoinit names from review
patrickrodee 8cbcfc7
WIP
patrickrodee da10d84
feat(tab-bar): Debugging failing iOS test
patrickrodee 9bf7b60
fix(tab-bar): Hacking on iOS
patrickrodee 1f016cd
WIP
patrickrodee 0e23d78
WIP remove debugger
patrickrodee 5975ae9
WIP
patrickrodee f3174f1
WIP remove clock cleanup from other tests
patrickrodee b933372
WIP test loosening
patrickrodee 5fe2fbd
WIP README fixes
8d15570
feat(tab-bar): Remove active check in activateTab
patrickrodee cb25074
WIP Release preparations
26eab8e
feat(tab-bar): Update tab activation notification logic; Add a test
patrickrodee 7869fdd
fix(tab-scroller): Update tests
patrickrodee 0c7f132
WIP super minor demo fixes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// 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 | ||
// | ||
// http://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. | ||
// | ||
|
||
@import "./common"; | ||
@import "../packages/mdc-tab/mdc-tab"; | ||
@import "../packages/mdc-tab/mixins"; | ||
@import "../packages/mdc-tab-indicator/mdc-tab-indicator"; | ||
@import "../packages/mdc-tab-indicator/mixins"; | ||
@import "../packages/mdc-tab-scroller/mdc-tab-scroller"; | ||
@import "../packages/mdc-tab-bar/mdc-tab-bar"; | ||
@import "../packages/mdc-tab-bar/mixins"; | ||
@import "../packages/mdc-elevation/mixins"; | ||
@import "../packages/mdc-ripple/mixins"; | ||
@import "../packages/mdc-theme/color-palette"; | ||
|
||
.demo { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.hero-demo-tab-bar { | ||
@include mdc-tab-bar-width(420px); | ||
} | ||
|
||
.custom-demo-tab-bar { | ||
.mdc-tab { | ||
@include mdc-typography(subtitle1); | ||
@include mdc-tab-fixed-width(120px); | ||
@include mdc-tab-text-label-color($material-color-blue-600); | ||
@include mdc-tab-icon-color($material-color-blue-600); | ||
} | ||
|
||
.mdc-tab__ripple { | ||
@include mdc-states($material-color-yellow-700); | ||
} | ||
|
||
.mdc-tab--active { | ||
@include mdc-tab-text-label-color($material-color-blue-900); | ||
@include mdc-tab-icon-color($material-color-blue-900); | ||
} | ||
|
||
.mdc-tab-indicator { | ||
@include mdc-tab-indicator-underline-height(5px); | ||
@include mdc-tab-indicator-underline-color($material-color-yellow-700); | ||
} | ||
} | ||
|
||
.demo-controls { | ||
padding: 0 16px; | ||
} | ||
|
||
.rtl-container { | ||
margin: 24px; | ||
padding: 24px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<!--docs: | ||
title: "Tab Bar" | ||
layout: detail | ||
section: components | ||
excerpt: "Manages a set of Tabs." | ||
iconId: tabs | ||
path: /catalog/tabs/tab-bar/ | ||
--> | ||
|
||
# Tab Bar | ||
|
||
Tabs organize and allow navigation between groups of content that are related and at the same level of hierarchy. | ||
The Tab Bar contains the Tab Scroller and Tab components. | ||
|
||
## Design & API Documentation | ||
|
||
<ul class="icon-list"> | ||
<li class="icon-list-item icon-list-item--spec"> | ||
<a href="https://material.io/go/design-tabs">Material Design guidelines: Tabs</a> | ||
</li> | ||
<li class="icon-list-item icon-list-item--link"> | ||
<a href="https://material-components.github.io/material-components-web-catalog/#/component/tabs">Demo</a> | ||
</li> | ||
</ul> | ||
|
||
## Installation | ||
|
||
``` | ||
npm install @material/tab-bar | ||
``` | ||
|
||
## Basic Usage | ||
|
||
### HTML Structure | ||
|
||
```html | ||
<div class="mdc-tab-bar" role="tablist"> | ||
<div class="mdc-tab-scroller"> | ||
<div class="mdc-tab-scroller__scroll-area"> | ||
<div class="mdc-tab-scroller__scroll-content"> | ||
<button class="mdc-tab mdc-tab--active" role="tab" aria-selected="true" tabindex="0"> | ||
<div class="mdc-tab__content"> | ||
<span class="mdc-tab__icon">heart</div> | ||
<span class="mdc-tab__text-label">Favorites</div> | ||
</div> | ||
<span class="mdc-tab-indicator mdc-tab-indicator--active"> | ||
<span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span> | ||
</span> | ||
<div class="mdc-tab__ripple"></div> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</button> | ||
``` | ||
|
||
### Styles | ||
|
||
```scss | ||
@import "@material/tab-bar/mdc-tab-bar"; | ||
@import "@material/tab-scroller/mdc-tab-scroller"; | ||
@import "@material/tab-indicator/mdc-tab-indicator"; | ||
@import "@material/tab/mdc-tab"; | ||
``` | ||
|
||
### JavaScript Instantiation | ||
|
||
```js | ||
import {MDCTabBar} from '@material/tab-bar'; | ||
|
||
const tabBar = new MDCTabBar(document.querySelector('.mdc-tab-bar')); | ||
``` | ||
|
||
> See [Importing the JS component](../../docs/importing-js.md) for more information on how to import JavaScript. | ||
|
||
## Style Customization | ||
|
||
### CSS Classes | ||
|
||
CSS Class | Description | ||
--- | --- | ||
`mdc-tab-bar` | Mandatory. | ||
|
||
### Sass Mixins | ||
|
||
To customize the width of the tab bar, use the following mixin. | ||
|
||
Mixin | Description | ||
--- | --- | ||
`mdc-tab-bar-width($width)` | Customizes the width of the tab bar. | ||
|
||
## `MDCTabBar` Properties and Methods | ||
|
||
Method Signature | Description | ||
--- | --- | ||
`activateTab(index: number) => void` | Activates the tab at the given index. | ||
`scrollIntoView(index: number) => void` | Scrolls the tab at the given index into view. | ||
|
||
Event Name | Event Data Structure | Description | ||
--- | --- | --- | ||
`MDCTabBar:activated` | `{"detail": {"index": number}}` | Emitted when a Tab is activated with the index of the activated Tab. Listen for this to update content when a Tab becomes active. | ||
|
||
## Usage within Web Frameworks | ||
|
||
If you are using a JavaScript framework, such as React or Angular, you can create a Tab Bar for your framework. Depending on your needs, you can use the _Simple Approach: Wrapping MDC Web Vanilla Components_, or the _Advanced Approach: Using Foundations and Adapters_. Please follow the instructions [here](../../docs/integrating-into-frameworks.md). | ||
|
||
### `MDCTabBarAdapter` | ||
|
||
Method Signature | Description | ||
--- | --- | ||
`scrollTo(scrollX: number) => void` | Scrolls the Tab Scroller to the given position. | ||
`incrementScroll(scrollXIncrement: number) => void` | Increments the Tab Scroller by the given value. | ||
`getScrollPosition() => number` | Returns the scroll position of the Tab Scroller. | ||
`getScrollContentWidth() => number` | Returns the width of the Tab Scroller's scroll content element. | ||
`getOffsetWidth() => number` | Returns the offsetWidth of the root element. | ||
`isRTL() => boolean` | Returns if the text direction is RTL. | ||
`activateTabAtIndex(index: number, clientRect: ClientRect) => void` | Activates the Tab at the given index with the given clientRect. | ||
`deactivateTabAtIndex(index) => void` | Deactivates the Tab at the given index. | ||
`getTabIndicatorClientRectAtIndex(index: number) => ClientRect` | Returns the client rect of the Tab at the given index. | ||
`getTabDimensionsAtIndex(index) => MDCTabDimensions` | Returns the dimensions of the Tab at the given index. | ||
`getTabListLength() => number` | Returns the number of child Tab components. | ||
`getActiveTabIndex() => number` | Returns the index of the active Tab. | ||
`getIndexOfTab(tab: MDCTab) => number` | Returns the index of the given Tab instance. | ||
`notifyTabActivated(index: number) => void` | Emits the `MDCTabBar:activated` event. | ||
|
||
### `MDCTabBarFoundation` | ||
|
||
Method Signature | Description | ||
--- | --- | ||
`activateTab(index: number) => void` | Activates the Tab at the given index. | ||
`handleKeyDown(evt: Event) => void` | Handles the logic for the `"keydown"` event. | ||
`handleTabInteraction(evt: Event) => void` | Handles the logic for the `"MDCTab:interacted"` event. | ||
`scrollIntoView(index: number) => void` | Scrolls the Tab at the given index into view. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @license | ||
* 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 | ||
* | ||
* http://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. | ||
*/ | ||
|
||
@mixin mdc-tab-bar-width($width) { | ||
width: $width; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include the other 3 tab component imports here