From df44a6223ff66aa771cb387d892fe659f16e732b Mon Sep 17 00:00:00 2001 From: Andrew Nicolaou Date: Mon, 25 Nov 2019 14:53:45 +0100 Subject: [PATCH] Remove sketch from collection via icon button --- client/modules/User/components/Collection.jsx | 169 ++---------------- client/styles/components/_collection.scss | 17 ++ 2 files changed, 28 insertions(+), 158 deletions(-) diff --git a/client/modules/User/components/Collection.jsx b/client/modules/User/components/Collection.jsx index 99f57201..59130704 100644 --- a/client/modules/User/components/Collection.jsx +++ b/client/modules/User/components/Collection.jsx @@ -23,7 +23,7 @@ import { SketchSearchbar } from '../../IDE/components/Searchbar'; 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 trashCan = require('../../../images/trash-can.svg'); const ShareURL = ({ value }) => { const [showURL, setShowURL] = React.useState(false); @@ -48,114 +48,7 @@ ShareURL.propTypes = { }; class CollectionItemRowBase extends React.Component { - constructor(props) { - super(props); - this.state = { - optionsOpen: false, - renameOpen: false, - renameValue: props.item.project.name, - isFocused: false - }; - } - - onFocusComponent = () => { - this.setState({ isFocused: true }); - } - - onBlurComponent = () => { - this.setState({ isFocused: false }); - setTimeout(() => { - if (!this.state.isFocused) { - this.closeAll(); - } - }, 200); - } - - openOptions = () => { - this.setState({ - optionsOpen: true - }); - } - - closeOptions = () => { - this.setState({ - optionsOpen: false - }); - } - - toggleOptions = () => { - if (this.state.optionsOpen) { - this.closeOptions(); - } else { - this.openOptions(); - } - } - - openRename = () => { - this.setState({ - renameOpen: true - }); - } - - closeRename = () => { - this.setState({ - renameOpen: false - }); - } - - closeAll = () => { - this.setState({ - renameOpen: false, - optionsOpen: false - }); - } - - handleRenameChange = (e) => { - this.setState({ - renameValue: e.target.value - }); - } - - handleRenameEnter = (e) => { - if (e.key === 'Enter') { - // TODO pass this func - this.props.changeProjectName(this.props.collection.id, this.state.renameValue); - this.closeAll(); - } - } - - resetSketchName = () => { - this.setState({ - renameValue: this.props.collection.name - }); - } - - handleDropdownOpen = () => { - this.closeAll(); - this.openOptions(); - } - - handleRenameOpen = () => { - this.closeAll(); - this.openRename(); - } - - handleSketchDownload = () => { - this.props.exportProjectAsZip(this.props.collection.id); - } - - handleSketchDuplicate = () => { - this.closeAll(); - this.props.cloneProject(this.props.collection.id); - } - - handleSketchShare = () => { - this.closeAll(); - this.props.showShareModal(this.props.collection.id, this.props.collection.name, this.props.username); - } - handleSketchRemove = () => { - this.closeAll(); if (window.confirm(`Are you sure you want to remove "${this.props.item.project.name}" from this collection?`)) { this.props.removeFromCollection(this.props.collection.id, this.props.item.project.id); } @@ -163,63 +56,28 @@ class CollectionItemRowBase extends React.Component { render() { const { item } = this.props; - const { renameOpen, optionsOpen, renameValue } = this.state; const sketchOwnerUsername = item.project.user.username; - const userIsOwner = this.props.user.username === sketchOwnerUsername; const sketchUrl = `/${item.project.user.username}/sketches/${item.project.id}`; - const dropdown = ( - - - {optionsOpen && - - } - - ); - return ( - {renameOpen ? '' : item.project.name} + {item.project.name} - {renameOpen - && - e.stopPropagation()} - /> - } {format(new Date(item.createdAt), 'MMM D, YYYY h:mm A')} {sketchOwnerUsername} - {dropdown} + + + ); } } @@ -235,16 +93,11 @@ CollectionItemRowBase.propTypes = { name: PropTypes.string.isRequired, }).isRequired, }).isRequired, - username: PropTypes.string.isRequired, user: PropTypes.shape({ username: PropTypes.string, authenticated: PropTypes.bool.isRequired }).isRequired, - removeFromCollection: PropTypes.func.isRequired, - showShareModal: PropTypes.func.isRequired, - cloneProject: PropTypes.func.isRequired, - exportProjectAsZip: PropTypes.func.isRequired, - changeProjectName: PropTypes.func.isRequired + removeFromCollection: PropTypes.func.isRequired }; function mapDispatchToPropsSketchListRow(dispatch) { diff --git a/client/styles/components/_collection.scss b/client/styles/components/_collection.scss index 9c5e5f95..c0df5141 100644 --- a/client/styles/components/_collection.scss +++ b/client/styles/components/_collection.scss @@ -123,3 +123,20 @@ text-align: center; font-size: #{16 / $base-font-size}rem; } + +.collection-row__action-column { + width: #{60 / $base-font-size}rem; + position: relative; +} + +.collection-row__remove-button { + @include themify() { + svg path { + fill: getThemifyVariable('table-button-background-color'); + } + + &:hover svg path { + fill: getThemifyVariable('table-button-background-hover-color'); + } + } +}