diff --git a/src/components/ha-view-tabs.html b/src/components/ha-view-tabs.html new file mode 100644 index 0000000000..a1b54dfa08 --- /dev/null +++ b/src/components/ha-view-tabs.html @@ -0,0 +1,25 @@ + + + + + + diff --git a/src/components/ha-view-tabs.js b/src/components/ha-view-tabs.js new file mode 100644 index 0000000000..930036b12f --- /dev/null +++ b/src/components/ha-view-tabs.js @@ -0,0 +1,50 @@ +import hass from '../util/home-assistant-js-instance'; + +import Polymer from '../polymer'; +import nuclearObserver from '../util/bound-nuclear-behavior'; + +const { + configGetters, + viewActions, + viewGetters, +} = hass; + +export default new Polymer({ + is: 'ha-view-tabs', + + behaviors: [nuclearObserver], + + properties: { + locationName: { + type: String, + bindNuclear: configGetters.locationName, + }, + + currentView: { + type: String, + bindNuclear: [ + viewGetters.currentView, + view => view || '', + ], + }, + + views: { + type: Array, + bindNuclear: [ + viewGetters.views, + views => views.valueSeq() + .sortBy(view => view.attributes.order) + .toArray(), + ], + }, + }, + + viewSelected(ev) { + const view = ev.detail.item.getAttribute('data-entity') || null; + const current = this.currentView || null; + this.expectChange = true; + if (view !== current) { + this.async(() => viewActions.selectView(view), 0); + } + }, +}); diff --git a/src/layouts/partial-base.html b/src/layouts/partial-base.html index 426a92b477..3ac41bd550 100644 --- a/src/layouts/partial-base.html +++ b/src/layouts/partial-base.html @@ -13,6 +13,10 @@ -webkit-user-select: none; -moz-user-select: none; } + + .menu-icon { + margin-right: 24px; + }