This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4523 from gratipay/extract-modal
Extract a modal component
- Loading branch information
Showing
11 changed files
with
183 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
Gratipay.confirm = function(message, yes, no) { | ||
var $m = $('.modal'); | ||
var $m = $('.confirmation-modal'); | ||
$m.show(); | ||
$('.confirmation-message', $m).html(message); | ||
$('.yes', $m).off('click').click(function() { yes(); Gratipay.confirm.close(); }); | ||
$('.no', $m).off('click').click(function() { no(); Gratipay.confirm.close(); }); | ||
}; | ||
|
||
Gratipay.confirm.close = function() { | ||
$('.modal').hide(); | ||
$('.confirmation-modal').hide(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Gratipay.modal = {} | ||
|
||
Gratipay.modal.open = function(modalWrapper) { | ||
$(modalWrapper).show().focus(); | ||
|
||
var closeModal = function() { | ||
Gratipay.modal.close(modalWrapper); | ||
}; | ||
$(modalWrapper).on('click', function (e) { | ||
if (e.target === this) { | ||
closeModal(); | ||
} else { | ||
return; // Don't close modal if the click was on descendants | ||
} | ||
}); | ||
$(modalWrapper).find('button.close-modal').click(closeModal); | ||
}; | ||
|
||
Gratipay.modal.close = function(modalWrapper) { | ||
$(modalWrapper).hide(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.confirmation-modal { | ||
display: none; | ||
position: fixed; | ||
left: 50%; | ||
top: 30%; | ||
margin-top: 24px; | ||
margin-left: -144px; | ||
width: 288px; | ||
font: normal 14px/18px $Ideal; | ||
padding: 24px; | ||
background: $white; | ||
border: 2px solid $black; | ||
@include border-radius(5px); | ||
box-shadow: 0px 0px 32px 16px rgba($black, 0.5); | ||
z-index: 3; | ||
|
||
.continue { | ||
text-align: right; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,110 @@ | ||
.modal { | ||
display: none; | ||
/* | ||
* ======= MARKUP ======= | ||
* | ||
* <div class="modal-wrapper"> | ||
* <div class="modal"> | ||
* <header> | ||
* <h2>Title!</h2> | ||
* <button class="close-modal"> | ||
* X | ||
* </button> | ||
* </header> | ||
* <section> | ||
* Your content here. | ||
* </section> | ||
* </div> | ||
* </div> | ||
* | ||
* ======= VISUAL EXPLANATION ======= | ||
* | ||
* div.modal-wrapper (full-screen) | ||
* | ||
* div.modal (horizontally centered) | ||
* ---------------------------- | ||
* | header (button) [x] | | ||
* |____________________________| | ||
* | section | | ||
* | | | ||
* | | | ||
* | | | ||
* | | | ||
* ---------------------------- | ||
* | ||
* ======= NOTES ======= | ||
* | ||
* - The modal width is not fixed. Set width on .modal directly, or it'll | ||
* be decided by child content | ||
* - To open/close, show/hide the .modal-wrapper div. Hidden by default. | ||
*/ | ||
|
||
.modal-wrapper { | ||
width: 100vw; | ||
height: 100vh; | ||
position: fixed; | ||
left: 50%; | ||
top: 30%; | ||
margin-top: 24px; | ||
margin-left: -144px; | ||
width: 288px; | ||
font: normal 14px/18px $Ideal; | ||
padding: 24px; | ||
background: $white; | ||
border: 2px solid $black; | ||
@include border-radius(5px); | ||
box-shadow: 0px 0px 32px 16px rgba($black, 0.5); | ||
z-index: 3; | ||
|
||
.continue { | ||
text-align: right; | ||
top: 0; | ||
left: 0; | ||
text-align: center; | ||
display: none; | ||
background: transparentize($black, 0.3); | ||
} | ||
|
||
.modal { | ||
$border-radius: 5px; | ||
$header-height: 55px; | ||
|
||
display: inline-block; | ||
position: relative; | ||
@include border-radius($border-radius); | ||
@include box-shadow(0, 0, 50px, $black); | ||
|
||
margin-top: 15vh; | ||
|
||
header { | ||
text-align: left; | ||
width: 100%; | ||
height: $header-height; | ||
border: 1px solid $darker-black; | ||
background: white; | ||
@include border-radius($border-radius $border-radius 0 0); | ||
|
||
h2 { | ||
margin: 0; | ||
font-size: 20px; | ||
padding: 0px 20px 0px 20px; | ||
line-height: $header-height; | ||
vertical-align: middle; | ||
text-transform: none; | ||
} | ||
|
||
button { | ||
border-top: 1px solid $darker-black; | ||
border-right: 1px solid $darker-black; | ||
border-bottom: 1px solid $darker-black; | ||
color: $darker-black; | ||
vertical-align: middle; | ||
position: absolute; | ||
top: 0px; | ||
right: 0px; | ||
height: $header-height; | ||
width: $header-height; | ||
background: none; | ||
@include border-radius(0 $border-radius 0 0); | ||
|
||
&:hover { | ||
background-color: $light-brown; | ||
} | ||
} | ||
} | ||
|
||
section { | ||
border-right: 1px solid $darker-black; | ||
border-left: 1px solid $darker-black; | ||
border-bottom: 1px solid $darker-black; | ||
text-align: left; | ||
overflow: auto; | ||
max-height: 70vh; | ||
z-index: 0; | ||
background: $lightest-gray; | ||
@include border-radius(0 0 $border-radius $border-radius); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters