-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: update menu-bar to use vaadin-menu-bar-list-box (#5354)
- Loading branch information
1 parent
a6edd66
commit 1f47047
Showing
11 changed files
with
106 additions
and
12 deletions.
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
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,81 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2019 - 2023 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js'; | ||
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js'; | ||
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js'; | ||
import { ListMixin } from '@vaadin/component-base/src/list-mixin.js'; | ||
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
|
||
/** | ||
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately. | ||
* | ||
* @extends HTMLElement | ||
* @mixes ControllerMixin | ||
* @mixes DirMixin | ||
* @mixes ListMixin | ||
* @mixes ThemableMixin | ||
* @protected | ||
*/ | ||
class MenuBarListBox extends ListMixin(ThemableMixin(DirMixin(ControllerMixin(PolymerElement)))) { | ||
static get is() { | ||
return 'vaadin-menu-bar-list-box'; | ||
} | ||
|
||
static get template() { | ||
return html` | ||
<style> | ||
:host { | ||
display: flex; | ||
} | ||
:host([hidden]) { | ||
display: none !important; | ||
} | ||
[part='items'] { | ||
height: 100%; | ||
width: 100%; | ||
overflow-y: auto; | ||
-webkit-overflow-scrolling: touch; | ||
} | ||
</style> | ||
<div part="items"> | ||
<slot></slot> | ||
</div> | ||
`; | ||
} | ||
|
||
static get properties() { | ||
return { | ||
// We don't need to define this property since super default is vertical, | ||
// but we don't want it to be modified, or be shown in the API docs. | ||
/** @private */ | ||
orientation: { | ||
readOnly: true, | ||
}, | ||
}; | ||
} | ||
|
||
/** | ||
* @return {!HTMLElement} | ||
* @protected | ||
* @override | ||
*/ | ||
get _scrollerElement() { | ||
return this.shadowRoot.querySelector('[part="items"]'); | ||
} | ||
|
||
/** @protected */ | ||
ready() { | ||
super.ready(); | ||
|
||
this.setAttribute('role', 'menu'); | ||
} | ||
} | ||
|
||
customElements.define(MenuBarListBox.is, MenuBarListBox); | ||
|
||
export { MenuBarListBox }; |
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
5 changes: 5 additions & 0 deletions
5
packages/menu-bar/theme/lumo/vaadin-menu-bar-list-box-styles.js
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,5 @@ | ||
import { contextMenuListBox } from '@vaadin/context-menu/theme/lumo/vaadin-context-menu-list-box-styles.js'; | ||
import { listBox } from '@vaadin/list-box/theme/lumo/vaadin-list-box-styles.js'; | ||
import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
|
||
registerStyles('vaadin-menu-bar-list-box', [listBox, contextMenuListBox], { moduleId: 'lumo-menu-bar-list-box' }); |
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
5 changes: 5 additions & 0 deletions
5
packages/menu-bar/theme/material/vaadin-menu-bar-list-box-styles.js
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,5 @@ | ||
import { contextMenuListBox } from '@vaadin/context-menu/theme/material/vaadin-context-menu-list-box-styles.js'; | ||
import { listBox } from '@vaadin/list-box/theme/material/vaadin-list-box-styles.js'; | ||
import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
|
||
registerStyles('vaadin-menu-bar-list-box', [listBox, contextMenuListBox], { moduleId: 'material-menu-bar-list-box' }); |
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