From 036c36933360f3b1e5716c48b996bdcfa3e629cb Mon Sep 17 00:00:00 2001 From: Samuel Meuli Date: Fri, 26 Oct 2018 15:42:06 +0200 Subject: [PATCH] make SiteSwitcher work on touch devices (#164) --- assets/src/js/components/SiteSwitcher.js | 30 +++++++++++++++++++++++- assets/src/sass/styles.scss | 8 +++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/assets/src/js/components/SiteSwitcher.js b/assets/src/js/components/SiteSwitcher.js index 506f610..b61ec38 100644 --- a/assets/src/js/components/SiteSwitcher.js +++ b/assets/src/js/components/SiteSwitcher.js @@ -4,6 +4,13 @@ import { h, Component } from 'preact'; import { bind } from 'decko'; class SiteSwitcher extends Component { + constructor() { + super(); + this.state = { + isExpanded: false + }; + } + @bind selectSite(evt) { let itemId = evt.target.getAttribute("data-id") @@ -22,6 +29,27 @@ class SiteSwitcher extends Component { this.props.onAdd({ id: 1, name: "New site", unsaved: true }) } + @bind + expand() { + this.setState({ + isExpanded: true + }); + } + + @bind + collapse() { + this.setState({ + isExpanded: false + }); + } + + @bind + toggleExpanded() { + this.setState({ + isExpanded: !this.state.isExpanded + }); + } + render(props, state) { // show nothing if there is only 1 site and no option to add additional sites if(!props.showAdd && props.sites.length == 1) { @@ -30,7 +58,7 @@ class SiteSwitcher extends Component { // otherwise, render list of sites + add button return ( -
  • +
  • {props.selectedSite.name}