Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Overlay component #2644

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣


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
}
1 change: 0 additions & 1 deletion spec/features/admin/page_editing_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@

it "is not possible to edit the attribute", :aggregate_failures do
visit alchemy.configure_admin_page_path(readonly_page)
puts page.body
readonly_page.fixed_attributes.all.each do |attribute, _v|
expect(page).to have_selector("#page_#{attribute}[disabled]")
end
Expand Down
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")
})
})
Loading