Skip to content

Commit

Permalink
Added support for adding overlays to a container (other than the body).
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyjb committed Aug 12, 2018
1 parent 20d7aaf commit f1990fd
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
5 changes: 3 additions & 2 deletions module/ui/image-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ export class ImageEditor extends Overlay {
imageURL,
cropAspectRatio=1.0,
fixCropAspectRatio=false,
maxPreviewSize=[600, 600]
maxPreviewSize=[600, 600],
container=null
) {
super()
super(container)

// The URL of the image being edited (typically a working draft
// version of the image to keep load times optimal).
Expand Down
4 changes: 2 additions & 2 deletions module/ui/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ MetaProp.css = {
*/
export class Metadata extends Overlay {

constructor(props) {
super()
constructor(props, container=null) {
super(container)

// A list meta properties to present, the format of the list should be
// as follows:
Expand Down
7 changes: 4 additions & 3 deletions module/ui/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as $ from 'manhattan-essentials'

export class Overlay {

constructor() {
constructor(container=null) {

// Flag indicating if the overlay is transitioning between hidden and
// visible state.
Expand All @@ -22,6 +22,7 @@ export class Overlay {
this._dom = {
'buttons': null,
'close': null,
'container': container || document.body,
'content': null,
'overlay': null
}
Expand Down Expand Up @@ -130,7 +131,7 @@ export class Overlay {

// Remove the overlay
if (this.overlay) {
document.body.removeChild(this.overlay)
this._dom.container.removeChild(this.overlay)
}

// Clear DOM references
Expand Down Expand Up @@ -180,7 +181,7 @@ export class Overlay {
this.overlay.appendChild(this._dom.buttons)

// Add the overlay to the page
document.body.appendChild(this.overlay)
this._dom.container.appendChild(this.overlay)

// Prevent the page from scrolling whilst the overlay is open
document.body.style.overflow = 'hidden'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manhattan-assets",
"version": "1.0.0-beta.7",
"version": "1.0.0-beta.8",
"description": "File and image uploads for forms.",
"engines": {
"node": ">=8.9.4"
Expand Down
15 changes: 8 additions & 7 deletions scss/ui/_acceptor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,25 @@
z-index: 1;
}

&--file-inbound {
.mh-acceptor__drop-zone {
opacity: 1;
z-index: 2;
}
}

&--disabled {
opacity: 0.5;

.mh-acceptor {
&__input {
cursor: not-allowed;
pointer-events: none;
z-index: 1;
}
}
}

&--file-inbound:not(&--disabled) {
.mh-acceptor__drop-zone {
opacity: 1;
z-index: 2;
}
}

.mh-file-field--file & {
&__drop-zone,
&__faceplate {
Expand Down
16 changes: 8 additions & 8 deletions scss/ui/_crop_tool.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,25 @@
}

&__control {
background: #f8f8f8;
border-radius: 8px;
box-shadow:
inset 0 1px 0 0 #fff,
0 1px 1px rgba(0,0,0,.15);
position: absolute;
z-index: 2;

&--c {
background: transparent;
border-radius: 0;
box-shadow: none;
bottom: 8px;
cursor: move;
left: 8px;
right: 8px;
top: 8px;
}

&:not(&--c) {
background: #f8f8f8;
border-radius: 8px;
box-shadow:
inset 0 1px 0 0 #fff,
0 1px 1px rgba(0,0,0,.15);
}

&--n,
&--s {
cursor: ns-resize;
Expand Down

0 comments on commit f1990fd

Please sign in to comment.