From ead2ba36acad1c24b8dc1ad6f76a0b4160c14a8b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 27 May 2016 20:34:01 -0700 Subject: [PATCH] More UI tweaks --- src/components/ha-view-tabs.html | 25 ++++++++++++++ src/components/ha-view-tabs.js | 50 +++++++++++++++++++++++++++ src/layouts/partial-base.html | 4 +++ src/layouts/partial-base.js | 2 +- src/layouts/partial-cards.html | 33 ++++++------------ src/layouts/partial-cards.js | 33 +++--------------- src/layouts/partial-dev-template.html | 1 + src/layouts/partial-map.html | 4 +++ src/layouts/partial-map.js | 2 +- 9 files changed, 102 insertions(+), 52 deletions(-) create mode 100644 src/components/ha-view-tabs.html create mode 100644 src/components/ha-view-tabs.js 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; + }