material-web/demos/menu.html
Daniel Freedman 2182d6478a Make demos easy to publish
- Minor changes to demo pages for rollup compat
2018-05-08 11:23:01 -07:00

83 lines
2.7 KiB
HTML

<!doctype html>
<!--
@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.
-->
<html>
<head>
<title>menu demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
<script type="module" src="../node_modules/@material/mwc-button/mwc-button.js"></script>
<script type="module" src="../node_modules/@material/mwc-menu/mwc-menu.js"></script>
<script type="module" src="../node_modules/@material/mwc-list/mwc-list-item.js"></script>
<script type="module" src="../node_modules/@material/mwc-list/mwc-list-item-separator.js"></script>
<script type="module" src="../node_modules/@material/mwc-icon/mwc-icon.js"></script>
<link rel="stylesheet" href="demo-component.css">
<style>
body {
min-height: calc(100vh - 4em);
}
.demo-mdc-menu-anchor {
display: inline-block;
position: relative;
overflow: visible;
}
.demo-log {
margin: 8px;
}
</style>
</head>
<body class="unresolved">
<header>
<a href="index.html"><mwc-icon>arrow_back</mwc-icon>
<span>Menu</span></a>
</header>
<main>
<div class="demo-mdc-menu-anchor">
<mwc-button id="button" raised ripple label="Go"></mwc-button>
<mwc-menu id="menu">
<mwc-list-item label="one"></mwc-list-item>
<mwc-list-item label="two"></mwc-list-item>
<mwc-list-item label="three"></mwc-list-item>
<mwc-list-item disabled label="four"></mwc-list-item>
<mwc-list-item-separator></mwc-list-item-separator>
<mwc-list-item label="aaa"></mwc-list-item>
<mwc-list-item label="bbb"></mwc-list-item>
</mwc-menu>
</div>
<div class="demo-log" id="log"></div>
</main>
<script>
button.addEventListener('click', (e) => {
menu.setAnchorCorner(menu.Corner.BOTTOM_START);
menu.open = !menu.open;
})
menu.addEventListener('MDCMenu:selected', function(evt) {
var detail = evt.detail;
log.textContent = `selected: ${detail.index}, ${detail.item.label}`;
});
addEventListener('load', () => document.body.classList.remove('unresolved'));
</script>
</body>
</html>