From 4272111ce7da4293bff7d11cf08e172651e7b3b1 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 21 Sep 2017 17:34:19 +0200 Subject: Make sidebars collapsible --- src/components/sidebars/Sidebar.js | 40 +++++++++++++++++----- src/components/sidebars/Sidebar.sass | 31 +++++++++++++++++ .../sidebars/simulation/TaskComponent.js | 10 ++++-- 3 files changed, 70 insertions(+), 11 deletions(-) (limited to 'src/components') diff --git a/src/components/sidebars/Sidebar.js b/src/components/sidebars/Sidebar.js index ce743b17..00e3607a 100644 --- a/src/components/sidebars/Sidebar.js +++ b/src/components/sidebars/Sidebar.js @@ -2,13 +2,37 @@ import classNames from "classnames"; import React from "react"; import "./Sidebar.css"; -const Sidebar = ({isRight, children}) => ( -
e.stopPropagation()} - > - {children} -
-); +class Sidebar extends React.Component { + state = { + collapsed: false + }; + + render() { + const collapseButton = ( +
this.setState({collapsed: !this.state.collapsed})} + > + {(this.state.collapsed && this.props.isRight) || (!this.state.collapsed && !this.props.isRight) ? + : + + } +
+ ); + + if (this.state.collapsed) { + return collapseButton; + } + return ( +
e.stopPropagation()} + > + {this.props.children} + {collapseButton} +
+ ); + } +} export default Sidebar; diff --git a/src/components/sidebars/Sidebar.sass b/src/components/sidebars/Sidebar.sass index c3796d59..b987ef07 100644 --- a/src/components/sidebars/Sidebar.sass +++ b/src/components/sidebars/Sidebar.sass @@ -1,4 +1,27 @@ @import ../../style-globals/_variables.sass +@import ../../style-globals/_mixins.sass + +.sidebar-collapse-button + position: absolute + left: 5px + top: 5px + padding: 5px 7px + + background: white + border: solid 1px $gray-semi-light + z-index: 99 + + +clickable + +border-radius(5px) + +transition(background, 200ms) + + &.sidebar-collapse-button-right + left: auto + right: 5px + top: 5px + + &:hover + background: #eeeeee .sidebar position: absolute @@ -11,9 +34,17 @@ border-right: $gray-semi-dark 1px solid + .sidebar-collapse-button + left: auto + right: -25px + .sidebar-right left: auto right: 0 border-left: $gray-semi-dark 1px solid border-right: none + + .sidebar-collapse-button-right + left: -25px + right: auto diff --git a/src/components/sidebars/simulation/TaskComponent.js b/src/components/sidebars/simulation/TaskComponent.js index c02d0a4b..09608b99 100644 --- a/src/components/sidebars/simulation/TaskComponent.js +++ b/src/components/sidebars/simulation/TaskComponent.js @@ -5,7 +5,9 @@ const TaskComponent = ({task, flopsLeft}) => { let stateInfo; if (flopsLeft === task.totalFlopCount) { - stateInfo =

Waiting

; + stateInfo = ( +

Waiting

+ ); } else if (flopsLeft > 0) { stateInfo = (

@@ -14,14 +16,16 @@ const TaskComponent = ({task, flopsLeft}) => {

); } else { - stateInfo =

Completed

; + stateInfo = ( +

Completed

+ ); } return (
  • {task.totalFlopCount} FLOPS
    - Starts: {convertSecondsToFormattedTime(task.startTick)} + Starts at {convertSecondsToFormattedTime(task.startTick)}
    {stateInfo}
  • -- cgit v1.2.3