Skip to content

Commit

Permalink
Fix Overlay component
Browse files Browse the repository at this point in the history
The please wait - overlay was not shown correctly and didn't reacted to Alchemy.pleaseWaitOverlay() - toggle anymore.
  • Loading branch information
sascha-karnatz committed Dec 14, 2023
1 parent a51a933 commit d4511bd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
7 changes: 3 additions & 4 deletions app/assets/stylesheets/alchemy/frame.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
div#overlay {
alchemy-overlay {
display: none;
position: fixed;
left: 0px;
top: 0px;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 400000;
background-color: rgba(229, 229, 229, 0.4);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = #40E5E5E5, endColorstr = #40E5E5E5);
}

div#overlay_text_box {
Expand Down
14 changes: 5 additions & 9 deletions app/javascript/alchemy_admin/components/overlay.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import { AlchemyHTMLElement } from "alchemy_admin/components/alchemy_html_element"

class Overlay extends AlchemyHTMLElement {
static properties = {
show: { default: false },
text: { default: "" }
}

render() {
this.id = `overlay`
this.style.setProperty("display", this.show ? "block" : "none")

return `
<alchemy-spinner></alchemy-spinner>
<div id="overlay_text_box">
<span id="overlay_text">${this.text}</span>
<span id="overlay_text">${this.getAttribute("text")}</span>
</div>
`
}

set show(value) {
this.style.setProperty("display", value ? "block" : "none")
}
}

customElements.define("alchemy-overlay", Overlay)
6 changes: 3 additions & 3 deletions app/javascript/alchemy_admin/please_wait_overlay.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* To show the "Please wait" overlay.
* Pass false to hide it.
* @param {boolean,null} show
* @param {boolean} show
*/
export default function pleaseWaitOverlay(show) {
customElements.get("alchemy-overlay").show = !!show
export default function pleaseWaitOverlay(show = true) {
document.querySelector("alchemy-overlay").show = !!show
}
4 changes: 3 additions & 1 deletion spec/javascript/alchemy_admin/components/overlay.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe("alchemy-overlay", () => {

it("should be hidden", () => {
renderComponent()
overlay.show = false
expect(overlay.style.getPropertyValue("display")).toBe("none")
})

Expand All @@ -29,7 +30,8 @@ describe("alchemy-overlay", () => {
})

it("should be visible", () => {
renderComponent(`<alchemy-overlay show="true"></alchemy-overlay>`)
renderComponent()
overlay.show = true
expect(overlay.style.getPropertyValue("display")).toBe("block")
})
})

0 comments on commit d4511bd

Please sign in to comment.