-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The overlay is now a web component and a bit easier to use. The API is still the same, but the component is using the same mechanic as the Spinner.
- Loading branch information
1 parent
7b7e564
commit b10fbe0
Showing
5 changed files
with
62 additions
and
19 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
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,22 @@ | ||
import { AlchemyHTMLElement } from "./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> | ||
</div> | ||
` | ||
} | ||
} | ||
|
||
customElements.define("alchemy-overlay", Overlay) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import "../../../../app/javascript/alchemy_admin/components/overlay" | ||
|
||
describe("alchemy-overlay", () => { | ||
/** | ||
* @type {HTMLElement | undefined} | ||
*/ | ||
let overlay = undefined | ||
let overlayText = undefined | ||
|
||
const renderComponent = (html = `<alchemy-overlay></alchemy-overlay>`) => { | ||
document.body.innerHTML = html | ||
overlay = document.querySelector("alchemy-overlay") | ||
overlayText = document.getElementById("overlay_text") | ||
} | ||
|
||
it("should render the overlay", () => { | ||
renderComponent() | ||
expect(overlayText).toBeTruthy() | ||
}) | ||
|
||
it("should be hidden", () => { | ||
renderComponent() | ||
expect(overlay.style.getPropertyValue("display")).toBe("none") | ||
}) | ||
|
||
it("should have a given text", () => { | ||
renderComponent(`<alchemy-overlay text="Foo Bar"></alchemy-overlay>`) | ||
expect(overlayText.textContent).toBe("Foo Bar") | ||
}) | ||
|
||
it("should be visible", () => { | ||
renderComponent(`<alchemy-overlay show="true"></alchemy-overlay>`) | ||
expect(overlay.style.getPropertyValue("display")).toBe("block") | ||
}) | ||
}) |