c3856480b8
* parentb3c3efcec9
author Laksh Singla <lakshsingla@gmail.com> 1549106083 +0530 committer Cassie Tarakajian <ctarakajian@gmail.com> 1560540243 -0400 parentb3c3efcec9
author Laksh Singla <lakshsingla@gmail.com> 1549106083 +0530 committer Cassie Tarakajian <ctarakajian@gmail.com> 1560540198 -0400 parentb3c3efcec9
author Laksh Singla <lakshsingla@gmail.com> 1549106083 +0530 committer Cassie Tarakajian <ctarakajian@gmail.com> 1560539667 -0400 Created initial html structure and styling for new SketchList design Final styling of ActionDialogueBox commplete Dropdown menu disappearing while clicking anywhere on the table Fixed linting issues and renamed variables Minor tweaks in the SketchList dropdown dialogue UI Themifyed the dropdown Made changes in the dropdown: Arrow positioned slightly updwards, Removed blank space and added box-shadow in dropdown, themifyed dropdowns dashed border color Added Delete and Share functionality to Dialog box Added Duplicate functionality to Dialog box Added download functionality to Dialog box SketchList does not open a sketch if dialogue box is opened SketchList Rename initial UI completed Enter key handled for rename project option [WIP] Updating rename functionality Download option now working for all the sketches Duplicate functionality extended for non opened sketches too Modified overlay behaviour to close only the last overlay Share modal can now display different projects Dropdown closes when Share and Delete are closing for a more natural UX fix broken files from rebasing Created initial html structure and styling for new SketchList design Final styling of ActionDialogueBox commplete Added Delete and Share functionality to Dialog box Added Duplicate functionality to Dialog box [WIP] Updating rename functionality Duplicate functionality extended for non opened sketches too Modified overlay behaviour to close only the last overlay Share modal can now display different projects Final styling of ActionDialogueBox commplete Fixed linting issues and renamed variables Minor tweaks in the SketchList dropdown dialogue UI Themifyed the dropdown Added Delete and Share functionality to Dialog box [WIP] Updating rename functionality Modified overlay behaviour to close only the last overlay Share modal can now display different projects Dropdown closes when Share and Delete are closing for a more natural UX fix broken files from rebasing Final styling of ActionDialogueBox commplete Minor tweaks in the SketchList dropdown dialogue UI Themifyed the dropdown [WIP] Updating rename functionality Duplicate functionality extended for non opened sketches too Modified overlay behaviour to close only the last overlay Share modal can now display different projects Dropdown closes when Share and Delete are closing for a more natural UX * fix bugs in merge commit * move sketch list dialogue to ul/li * update sketch option dropdown to use dropdown placeholder, remove unused css * major refactor of sketchlist component, fix showShareModal action, minor updates ot icon sizing * fix broken links on asset list * remove unused image, fix options for different users in sketch list
108 lines
2.6 KiB
JavaScript
108 lines
2.6 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React from 'react';
|
|
import InlineSVG from 'react-inlinesvg';
|
|
import { browserHistory } from 'react-router';
|
|
|
|
const exitUrl = require('../../../images/exit.svg');
|
|
|
|
class Overlay extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.close = this.close.bind(this);
|
|
this.handleClick = this.handleClick.bind(this);
|
|
this.handleClickOutside = this.handleClickOutside.bind(this);
|
|
this.keyPressHandle = this.keyPressHandle.bind(this);
|
|
}
|
|
|
|
componentWillMount() {
|
|
document.addEventListener('mousedown', this.handleClick, false);
|
|
document.addEventListener('keydown', this.keyPressHandle);
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.node.focus();
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
document.removeEventListener('mousedown', this.handleClick, false);
|
|
document.removeEventListener('keydown', this.keyPressHandle);
|
|
}
|
|
|
|
handleClick(e) {
|
|
if (this.node.contains(e.target)) {
|
|
return;
|
|
}
|
|
|
|
this.handleClickOutside(e);
|
|
}
|
|
|
|
handleClickOutside() {
|
|
this.close();
|
|
}
|
|
|
|
keyPressHandle(e) {
|
|
// escape key code = 27.
|
|
// So here we are checking if the key pressed was Escape key.
|
|
if (e.keyCode === 27) {
|
|
this.close();
|
|
}
|
|
}
|
|
|
|
close() {
|
|
// Only close if it is the last (and therefore the topmost overlay)
|
|
const overlays = document.getElementsByClassName('overlay');
|
|
if (this.node.parentElement.parentElement !== overlays[overlays.length - 1]) return;
|
|
|
|
if (!this.props.closeOverlay) {
|
|
browserHistory.push(this.props.previousPath);
|
|
} else {
|
|
this.props.closeOverlay();
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const {
|
|
ariaLabel,
|
|
title,
|
|
children
|
|
} = this.props;
|
|
return (
|
|
<div className="overlay">
|
|
<div className="overlay__content">
|
|
<section
|
|
role="main"
|
|
aria-label={ariaLabel}
|
|
ref={(node) => { this.node = node; }}
|
|
className="overlay__body"
|
|
>
|
|
<header className="overlay__header">
|
|
<h2 className="overlay__title">{title}</h2>
|
|
<button className="overlay__close-button" onClick={this.close} >
|
|
<InlineSVG src={exitUrl} alt="close overlay" />
|
|
</button>
|
|
</header>
|
|
{children}
|
|
</section>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
Overlay.propTypes = {
|
|
children: PropTypes.element,
|
|
closeOverlay: PropTypes.func,
|
|
title: PropTypes.string,
|
|
ariaLabel: PropTypes.string,
|
|
previousPath: PropTypes.string
|
|
};
|
|
|
|
Overlay.defaultProps = {
|
|
children: null,
|
|
title: 'Modal',
|
|
closeOverlay: null,
|
|
ariaLabel: 'modal',
|
|
previousPath: '/'
|
|
};
|
|
|
|
export default Overlay;
|