-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(top-app-bar): Baseline top app bar component (#2225)
- Loading branch information
1 parent
f89cd10
commit 0ad69c4
Showing
22 changed files
with
981 additions
and
1 deletion.
There are no files selected for viewing
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,143 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Copyright 2016 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> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>MDC Top App Bar Demo</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/top-app-bar.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 id="demo-top-app-bar" class="mdc-top-app-bar"> | ||
<div class="mdc-top-app-bar__row"> | ||
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start"> | ||
<a href="#" class="material-icons mdc-top-app-bar__menu-icon">menu</a> | ||
<span class="mdc-top-app-bar__title">Title</span> | ||
</section> | ||
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end" role="top-app-bar"> | ||
<a href="#" class="material-icons mdc-top-app-bar__icon" aria-label="Download" alt="Download">file_download</a> | ||
<a href="#" class="material-icons mdc-top-app-bar__icon" aria-label="Print this page" alt="Print this page">print</a> | ||
<a href="#" class="material-icons mdc-top-app-bar__icon" aria-label="Bookmark this page" alt="Bookmark this page">bookmark</a> | ||
</section> | ||
</div> | ||
</header> | ||
|
||
<aside class="mdc-drawer mdc-drawer--temporary"> | ||
<nav class="mdc-drawer__drawer"> | ||
<header class="mdc-drawer__header"> | ||
<div class="mdc-drawer__header-content mdc-theme--text-primary-on-primary mdc-theme--primary-bg"> | ||
Header here | ||
</div> | ||
</header> | ||
<nav class="mdc-drawer__content mdc-list-group"> | ||
<div class="mdc-list"> | ||
<a href="/" class="mdc-list-item "> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true"></i>Back | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">star</i>Star | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">send</i>Sent Mail | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">drafts</i>Drafts | ||
</a> | ||
</div> | ||
|
||
<hr class="mdc-list-divider"> | ||
|
||
<div class="mdc-list"> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">email</i>All Mail | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">delete</i>Trash | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">report</i>Spam | ||
</a> | ||
</div> | ||
</nav> | ||
</nav> | ||
</aside> | ||
|
||
<main> | ||
<div> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
<p class="demo-paragraph"> | ||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. | ||
</p> | ||
</div> | ||
</main> | ||
|
||
<script src="/assets/common.js" async></script> | ||
<script src="/assets/material-components-web.js" async></script> | ||
<script type="text/javascript"> | ||
demoReady(function() { | ||
var appBarEl = document.getElementById('demo-top-app-bar'); | ||
var appBar = mdc.topAppBar.MDCTopAppBar.attachTo(appBarEl); | ||
|
||
var drawerEl = document.querySelector('.mdc-drawer'); | ||
var MDCTemporaryDrawer = mdc.drawer.MDCTemporaryDrawer; | ||
var drawer = new MDCTemporaryDrawer(drawerEl); | ||
|
||
appBarEl.addEventListener('MDCTopAppBar:nav', function() { | ||
drawer.open = true; | ||
}); | ||
|
||
}); | ||
</script> | ||
</body> | ||
</html> |
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,31 @@ | ||
// | ||
// Copyright 2017 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-top-app-bar/mdc-top-app-bar"; | ||
@import "../packages/mdc-drawer/mdc-drawer"; | ||
@import "../packages/mdc-list/mdc-list"; | ||
|
||
.demo-paragraph { | ||
margin: 0; | ||
padding: 20px 28px; | ||
} | ||
|
||
@media (max-width: $mdc-top-app-bar-mobile-breakpoint) { | ||
.demo-paragraph { | ||
padding: 16px; | ||
} | ||
} |
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,103 @@ | ||
# Top App Bar | ||
|
||
MDC Top App Bar acts as a container for items such as application title, navigation menu, and action items, among other | ||
things. Top app bars scroll with content by default. | ||
|
||
## Design & API Documentation | ||
|
||
<ul class="icon-list"> | ||
<li class="icon-list-item icon-list-item--spec"> | ||
<a href="https://material.io/guidelines/components/toolbars.html">Material Design guidelines: Toolbars</a> | ||
</li> | ||
<li class="icon-list-item icon-list-item--link"> | ||
<a href="https://material-components-web.appspot.com/top-app-bar.html">Demo</a> | ||
</li> | ||
</ul> | ||
|
||
## Installation | ||
|
||
``` | ||
npm install --save @material/top-app-bar | ||
``` | ||
|
||
## Usage | ||
|
||
### HTML Structure | ||
|
||
```html | ||
<header class="mdc-top-app-bar"> | ||
<div class="mdc-top-app-bar__row"> | ||
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start"> | ||
<a href="#" class="material-icons mdc-top-app-bar__menu-icon">menu</a> | ||
<span class="mdc-top-app-bar__title">Title</span> | ||
</section> | ||
</div> | ||
</header> | ||
``` | ||
|
||
Top app bars can accommodate multiple icons on the right: | ||
|
||
```html | ||
<header class="mdc-top-app-bar"> | ||
<div class="mdc-top-app-bar__row"> | ||
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start"> | ||
<a href="#" class="material-icons mdc-top-app-bar__menu-icon">menu</a> | ||
<span class="mdc-top-app-bar__title">Title</span> | ||
</section> | ||
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end" role="top-app-bar"> | ||
<a href="#" class="material-icons mdc-top-app-bar__icon" aria-label="Download" alt="Download">file_download</a> | ||
<a href="#" class="material-icons mdc-top-app-bar__icon" aria-label="Print this page" alt="Print this page">print</a> | ||
<a href="#" class="material-icons mdc-top-app-bar__icon" aria-label="Bookmark this page" alt="Bookmark this page">bookmark</a> | ||
</section> | ||
</div> | ||
</header> | ||
``` | ||
|
||
### JavaScript | ||
|
||
```js | ||
// Instantiation | ||
var topAppBarElement = document.querySelector('#topAppBar'); | ||
var topAppBar = mdc.topAppBar.MDCTopAppBar.attachTo(topAppBarElement); | ||
|
||
// Listen for navigation icon events | ||
topAppBarElement.addEventListener('MDCTopAppBar:nav', function () { | ||
// do something | ||
}); | ||
``` | ||
|
||
### CSS Classes | ||
|
||
Class | Description | ||
--- | --- | ||
`mdc-top-app-bar` | Mandatory | ||
|
||
### Sass Mixins | ||
|
||
Mixin | Description | ||
--- | --- | ||
`mdc-top-app-bar-ink-color($color)` | Sets the ink color of the top app bar | ||
`mdc-top-app-bar-icon-ink-color($color)` | Sets the ink color of the top app bar icons | ||
`mdc-top-app-bar-fill-color($color)` | Sets the fill color of the top app bar | ||
`mdc-top-app-bar-fill-color-accessible($color)` | Sets the fill color of the top app bar and automatically sets a high-contrast ink color | ||
|
||
### `MDCTopAppBar` | ||
|
||
See [Importing the JS component](../../docs/importing-js.md) for more information on how to import JavaScript. | ||
|
||
#### `MDCTopAppBarAdapter` | ||
|
||
Method Signature | Description | ||
--- | --- | ||
`hasClass(className: string) => boolean` | Checks if the root element of the component has the given className. | ||
`addClass(className: string) => void` | Adds a class to the root element of the component. | ||
`removeClass(className: string) => void` | Removes a class from the root element of the component. | ||
`registerNavigationIconInteractionHandler(evtType: string, handler: EventListener) => void` | Registers an event listener on the native navigation icon element for a given event. | ||
`deregisterNavigationIconInteractionHandler(evtType: string, handler: EventListener) => void` | Deregisters an event listener on the native navigation icon element for a given event. | ||
`notifyNavigationIconClicked() => void` | Emits a custom event `MDCTopAppBar:nav` when the navigation icon is clicked. | ||
|
||
### Events | ||
|
||
Event Name | Event Data Structure | Description | ||
--- | --- | --- | ||
`MDCTopAppBar:nav` | None | Emits when the navigation icon is clicked. |
Oops, something went wrong.