Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
modal overlays: all but top overlay should have transparent background (
Browse files Browse the repository at this point in the history
#4820)

- tried several CSS-only solutions for ensuring only the top-most modal had a gray background,
  but I think using some JS is actually simpler, so that is what I did here

- keeping modalOverlay background when opening iframe w/ Coinbase widget
  (decision made w/ @bsclifton after trying alternatives)

fixes #4808
  • Loading branch information
willy-b authored and cezaraugusto committed Dec 7, 2016
1 parent 254cffb commit 2728303
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
34 changes: 33 additions & 1 deletion js/components/modalOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,39 @@ const ImmutableComponent = require('./immutableComponent')
* Represents a modal overlay
*/

var globalInstanceCounter = 0
var mountedInstances = []

class ModalOverlay extends ImmutableComponent {

componentWillMount () {
this.instanceId = globalInstanceCounter++

this.setState({last: true})

if (mountedInstances.length) {
let lastModal = mountedInstances[mountedInstances.length - 1]
lastModal.setState({last: false})
lastModal.forceUpdate()
}

mountedInstances.push(this)
}

componentWillUnmount () {
let instId = this.instanceId

mountedInstances = mountedInstances.filter(function (inst) {
return inst.instanceId !== instId
})

if (mountedInstances.length) {
let lastModal = mountedInstances[mountedInstances.length - 1]
lastModal.setState({last: true})
lastModal.forceUpdate()
}
}

get dialogContent () {
var close = null
var button = null
Expand All @@ -35,7 +67,7 @@ class ModalOverlay extends ImmutableComponent {
}

render () {
return <div className='modal fade' role='alert'>
return <div className={'modal fade' + (this.state.last ? ' last' : '') + (this.props.transparentBackground ? ' transparentBackground' : '')} role='alert'>
{this.dialogContent}
</div>
}
Expand Down
20 changes: 15 additions & 5 deletions less/modalOverlay.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@

@import "variables.less";

.modal.last + .modal.last {
background: transparent;
}

.modal {
opacity: 1;
overflow: auto;
position: fixed;
background: @black25;
background: transparent;
width: 100vw;
height: 100vh;
left: 0;
top: 0;
z-index: 8999;

&.fade {
transition: @transitionFast;
+.modal {
background: transparent;
}

&.last {
background: @black25;

&.transparentBackground {
background: transparent;
}
}

&.hidden {
Expand All @@ -25,8 +37,6 @@
}

.modal {
background: transparent;

.dialog {
left: 0;
top: 0;
Expand Down

0 comments on commit 2728303

Please sign in to comment.