From da566191fa1329c0e729f67c51d63e86abfb8536 Mon Sep 17 00:00:00 2001 From: aprigogin <17075403+aprigogin@users.noreply.github.com> Date: Fri, 5 Jan 2018 17:13:16 -0800 Subject: [PATCH] feat(menu): Add new anchor positioning functionality (#1691) Resolves #1688 BREAKING CHANGE: Removes 5 adapter methods and adds a new setMaxHeight adapter method; adds anchor positioning API to menu foundation; see README for details. --- demos/simple-menu.html | 294 ++++++++++-- packages/mdc-menu/README.md | 28 +- packages/mdc-menu/index.js | 4 +- packages/mdc-menu/simple/adapter.js | 30 +- packages/mdc-menu/simple/constants.js | 58 ++- packages/mdc-menu/simple/foundation.js | 384 +++++++++------- packages/mdc-menu/simple/index.js | 36 +- packages/mdc-menu/simple/mdc-simple-menu.scss | 66 +-- packages/mdc-select/foundation.js | 11 +- test/unit/mdc-menu/mdc-simple-menu.test.js | 56 +-- test/unit/mdc-menu/simple.foundation.test.js | 420 ++++++++++++------ .../unit/mdc-select/foundation-events.test.js | 13 + 12 files changed, 922 insertions(+), 478 deletions(-) diff --git a/demos/simple-menu.html b/demos/simple-menu.html index 12a1fd57be7..6bbea52b85b 100644 --- a/demos/simple-menu.html +++ b/demos/simple-menu.html @@ -28,33 +28,32 @@ html, body, main { - display: flex; + position: relative; flex-direction: column; - height: 100%; } - .demo-header-toolbar { - z-index: 10; + .hero .mdc-simple-menu { + z-index: initial; } .demo-content { position: relative; - flex: 1; - padding: 16px; + top: 64px; } .demo-controls-container { - height: 100%; width: 100%; + height: calc(100vh - 80px); } .demo-controls { margin-left: auto; margin-right: auto; - width: 320px; + width: 360px; } .mdc-menu-anchor { + position: absolute; margin: 16px; } @@ -63,8 +62,41 @@ color: #ddd; } - .mdc-menu-anchor { - position: absolute; + .margin-inputs input { + width: 2em; + } + + .left-column-controls { + display: inline-block; + vertical-align: top; + } + + .right-column-controls { + display: inline-block; + margin-left: 2em; + vertical-align: top; + } + + .demo-button__normal-text, + .demo-button__long-text { + display: none; + } + + .demo-button--normal .demo-button__normal-text, + .demo-button--long .demo-button__normal-text, + .demo-button--long .demo-button__long-text { + display: inline; + } + + .demo-menu__long-items, + .demo-menu__extra-long-items { + display: none; + } + + .demo-menu--long .demo-menu__long-items, + .demo-menu--extra-long .demo-menu__long-items, + .demo-menu--extra-long .demo-menu__extra-long-items { + display: inline; } @@ -94,45 +126,126 @@ -