diff --git a/assets/src/js/components/SiteSwitcher.js b/assets/src/js/components/SiteSwitcher.js index 506f6104..b61ec384 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}