Work on Portal Style (#4003)

* Reduce Portal size and close on click outside

* PR Grumbles
This commit is contained in:
Nicolas Gotchac 2016-12-31 14:28:16 +01:00 committed by Gav Wood
parent c93d3c1580
commit 0c6a9ebbb9
2 changed files with 48 additions and 12 deletions

View File

@ -15,6 +15,32 @@
/* along with Parity. If not, see <http://www.gnu.org/licenses/>. /* along with Parity. If not, see <http://www.gnu.org/licenses/>.
*/ */
$left: 1.5em;
$right: $left;
$bottom: $left;
$top: 20vh;
.backOverlay {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(255, 255, 255, 0.25);
z-index: -10;
opacity: 0;
transform-origin: 100% 0;
transition-property: opacity, z-index;
transition-duration: 0.25s;
transition-timing-function: ease-out;
&.expanded {
opacity: 1;
z-index: 2500;
}
}
.parityBackground { .parityBackground {
position: absolute; position: absolute;
top: 0; top: 0;
@ -28,10 +54,10 @@
.overlay { .overlay {
display: flex; display: flex;
position: fixed; position: fixed;
top: 0; top: $top;
left: 0; left: $left;
width: 100vw; width: calc(100vw - $left - $right);
height: 100vh; height: calc(100vh - $top - $bottom);
transform-origin: 100% 0; transform-origin: 100% 0;
transition-property: opacity, z-index; transition-property: opacity, z-index;
@ -48,7 +74,7 @@
&.expanded { &.expanded {
opacity: 1; opacity: 1;
z-index: 9999; z-index: 3500;
} }
} }

View File

@ -59,15 +59,19 @@ export default class Portal extends Component {
const { children, className } = this.props; const { children, className } = this.props;
const classes = [ styles.overlay, className ]; const classes = [ styles.overlay, className ];
const backClasses = [ styles.backOverlay ];
if (expanded) { if (expanded) {
classes.push(styles.expanded); classes.push(styles.expanded);
backClasses.push(styles.expanded);
} }
return ( return (
<ReactPortal isOpened onClose={ this.handleClose }> <ReactPortal isOpened onClose={ this.handleClose }>
<div className={ backClasses.join(' ') } onClick={ this.handleClose }>
<div <div
className={ classes.join(' ') } className={ classes.join(' ') }
onClick={ this.stopEvent }
onKeyDown={ this.handleKeyDown } onKeyDown={ this.handleKeyDown }
> >
<ParityBackground className={ styles.parityBackground } /> <ParityBackground className={ styles.parityBackground } />
@ -75,6 +79,7 @@ export default class Portal extends Component {
{ this.renderCloseIcon() } { this.renderCloseIcon() }
{ children } { children }
</div> </div>
</div>
</ReactPortal> </ReactPortal>
); );
} }
@ -93,6 +98,11 @@ export default class Portal extends Component {
); );
} }
stopEvent = (event) => {
event.preventDefault();
event.stopPropagation();
}
handleClose = () => { handleClose = () => {
this.props.onClose(); this.props.onClose();
} }