diff --git a/client/constants.js b/client/constants.js index 459fe4f5..fdedc38b 100644 --- a/client/constants.js +++ b/client/constants.js @@ -69,6 +69,8 @@ export const OPEN_PROJECT_OPTIONS = 'OPEN_PROJECT_OPTIONS'; export const CLOSE_PROJECT_OPTIONS = 'CLOSE_PROJECT_OPTIONS'; export const SHOW_NEW_FOLDER_MODAL = 'SHOW_NEW_FOLDER_MODAL'; export const CLOSE_NEW_FOLDER_MODAL = 'CLOSE_NEW_FOLDER_MODAL'; +export const SHOW_FOLDER_CHILDREN = 'SHOW_FOLDER_CHILDREN'; +export const HIDE_FOLDER_CHILDREN = 'HIDE_FOLDER_CHILDREN'; // eventually, handle errors more specifically and better export const ERROR = 'ERROR'; diff --git a/client/images/triangle-arrow-down.svg b/client/images/triangle-arrow-down.svg new file mode 100644 index 00000000..fec407e0 --- /dev/null +++ b/client/images/triangle-arrow-down.svg @@ -0,0 +1,14 @@ + + + + Triangle 3 + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/client/images/folder-triangle.svg b/client/images/triangle-arrow-right.svg similarity index 70% rename from client/images/folder-triangle.svg rename to client/images/triangle-arrow-right.svg index 1843a73e..8261d814 100644 --- a/client/images/folder-triangle.svg +++ b/client/images/triangle-arrow-right.svg @@ -1,11 +1,11 @@ - + Triangle 3 Created with Sketch. - + diff --git a/client/modules/IDE/actions/files.js b/client/modules/IDE/actions/files.js index 17b5cf1c..6c75fa59 100644 --- a/client/modules/IDE/actions/files.js +++ b/client/modules/IDE/actions/files.js @@ -247,3 +247,17 @@ export function deleteFile(id, parentId) { } }; } + +export function showFolderChildren(id) { + return { + type: ActionTypes.SHOW_FOLDER_CHILDREN, + id + }; +} + +export function hideFolderChildren(id) { + return { + type: ActionTypes.HIDE_FOLDER_CHILDREN, + id + }; +} diff --git a/client/modules/IDE/components/FileNode.js b/client/modules/IDE/components/FileNode.js index c68dda89..ed481706 100644 --- a/client/modules/IDE/components/FileNode.js +++ b/client/modules/IDE/components/FileNode.js @@ -5,6 +5,8 @@ import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import InlineSVG from 'react-inlinesvg'; const downArrowUrl = require('../../../images/down-arrow.svg'); +const folderRightUrl = require('../../../images/triangle-arrow-right.svg'); +const folderDownUrl = require('../../../images/triangle-arrow-down.svg'); const fileUrl = require('../../../images/file.svg'); import classNames from 'classnames'; @@ -60,7 +62,8 @@ export class FileNode extends React.Component { 'sidebar__file-item': this.props.name !== 'root', 'sidebar__file-item--selected': this.props.isSelected, 'sidebar__file-item--open': this.props.isOptionsOpen, - 'sidebar__file-item--editing': this.props.isEditingName + 'sidebar__file-item--editing': this.props.isEditingName, + 'sidebar__file-item--closed': this.props.isFolderClosed }); return (
); + } else if (this.props.isFolderClosed) { + return ( + this.props.showFolderChildren(this.props.id)} + > + + + ); } + return ( + this.props.hideFolderChildren(this.props.id)} + > + + + ); })()} {this.props.name} { } return Object.assign({}, file, { isSelected: false }); }); + case ActionTypes.SHOW_FOLDER_CHILDREN: + return state.map(file => { + if (file.id === action.id) { + return Object.assign({}, file, { isFolderClosed: false }); + } + return file; + }); + case ActionTypes.HIDE_FOLDER_CHILDREN: + return state.map(file => { + if (file.id === action.id) { + return Object.assign({}, file, { isFolderClosed: true }); + } + return file; + }); default: return state; } diff --git a/client/styles/components/_sidebar.scss b/client/styles/components/_sidebar.scss index 14ef3eaf..030d4034 100644 --- a/client/styles/components/_sidebar.scss +++ b/client/styles/components/_sidebar.scss @@ -177,3 +177,7 @@ padding: #{8 / $base-font-size}rem; width: #{110 / $base-font-size}rem; } + +.sidebar__file-item--closed .file-item__children { + display: none; +}