From 18af6aed3ab3fd1e498c043c3413f0fdbbb11661 Mon Sep 17 00:00:00 2001 From: Andrew Nicolaou Date: Mon, 4 Nov 2019 22:04:38 +0100 Subject: [PATCH] Show add/remove/in collection icon in SketchList --- client/modules/IDE/components/SketchList.jsx | 57 ++++++++++++------ client/styles/components/_sketch-list.scss | 62 ++++++++++++++++++-- 2 files changed, 96 insertions(+), 23 deletions(-) diff --git a/client/modules/IDE/components/SketchList.jsx b/client/modules/IDE/components/SketchList.jsx index a0c14b80..40944818 100644 --- a/client/modules/IDE/components/SketchList.jsx +++ b/client/modules/IDE/components/SketchList.jsx @@ -21,11 +21,27 @@ import CollectionPopover from './CollectionPopover'; const arrowUp = require('../../../images/sort-arrow-up.svg'); const arrowDown = require('../../../images/sort-arrow-down.svg'); const downFilledTriangle = require('../../../images/down-filled-triangle.svg'); -const check = require('../../../images/check.svg'); +const check = require('../../../images/check_encircled.svg'); +const close = require('../../../images/close.svg'); -const checkIcon = ( - -); +const Icons = ({ inCollection }) => { + const classes = [ + 'sketch-list__icon', + inCollection ? 'sketch-list__icon--in-collection' : 'sketch-list__icon--not-in-collection' + ].join(' '); + + return ( +
+ + + +
+ ); +}; + +Icons.propTypes = { + inCollection: PropTypes.bool.isRequired, +}; class SketchListRowBase extends React.Component { constructor(props) { @@ -167,9 +183,8 @@ class SketchListRowBase extends React.Component { } renderViewButton = sketchURL => ( - { + View - } ) @@ -282,7 +297,7 @@ class SketchListRowBase extends React.Component { } const name = addMode ? - {inCollection ? checkIcon : null} {sketch.name} + {sketch.name} : ( @@ -308,11 +323,17 @@ class SketchListRowBase extends React.Component { key={sketch.id} onClick={this.handleRowClick} > + { + this.props.addMode && + + + + } {name} - {format(new Date(sketch.createdAt), 'MMM D, YYYY h:mm A')} - {format(new Date(sketch.updatedAt), 'MMM D, YYYY h:mm A')} + {!this.props.addMode && {format(new Date(sketch.createdAt), 'MMM D, YYYY h:mm A')}} + {!this.props.addMode && {format(new Date(sketch.updatedAt), 'MMM D, YYYY h:mm A')}} {this.renderActions(url)} ); @@ -433,14 +454,16 @@ class SketchList extends React.Component { {this._renderEmptyTable()} {this.hasSketches() && - - - {this._renderFieldHeader('name', 'Sketch')} - {this._renderFieldHeader('createdAt', 'Date Created')} - {this._renderFieldHeader('updatedAt', 'Date Updated')} - - - + {!this.props.addMode && + + + {this._renderFieldHeader('name', 'Sketch')} + {this._renderFieldHeader('createdAt', 'Date Created')} + {this._renderFieldHeader('updatedAt', 'Date Updated')} + + + + } {this.props.sketches.map(sketch => ( * { + display: none; +} + +.sketch-list__in-icon { + display: inline-block; + + & svg { + opacity: 0.3; + } +} + +.sketch-list__icon--in-collection .sketch-list__in-icon svg { + opacity: 1; +} + +.sketch-list__add-icon { + transform: rotate(45deg); +} + +.sketches-table__row:hover { + .sketch-list__in-icon { + display: none; + } + + .sketch-list__icon--in-collection { + .sketch-list__remove-icon { + display: inline-block; + } + + .sketch-list__add-icon { + display: none; + } + } + + .sketch-list__icon--not-in-collection { + .sketch-list__add-icon { + display: inline-block; + } + + .sketch-list__remove-icon { + display: none; } } }