Skip to content

Commit 5a504bd

Browse files
committed
Close #32
1 parent 30798d5 commit 5a504bd

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

public/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ small {
422422
dialog::backdrop {
423423
background-color: black;
424424
opacity: 50%;
425+
opacity: var(--dialog-backdrop-opacity); /* for programmatic modification */
425426
}
426427
.simple-popup-button-div {
427428
display: flex;

src/ts/changelogs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ export const versionChangelogs: Changelog[] = [
238238
"A button in Options to toggle auto-saving (#29)",
239239
"GitHub issues in changelogs work as hyperlinks, like this one: #13",
240240
"A \"removed\" section in changelogs",
241+
"Advanced popups now have options (#32)",
241242
"The white background is now visible by default."
242243
],
243244
changed: [

src/ts/mods.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class Mod extends SaveProvider {
3838
// -------------------
3939
// Actual mod stuff
4040
// -------------------
41+
/** See #61 for how this will be used */
4142
public readonly METADATA: ModMetadata;
4243

4344
/** Mod namespace used for saving */

src/ts/popup.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,36 @@ export class SimplePopup {
8181
}
8282
}
8383

84+
export interface AdvancedPopupOptions {
85+
/** The `opacity` percentage of the dialog backdrop. Default: 50 */
86+
filterLevel?: number;
87+
/** The padding to apply to the popup HTML, in `px` */
88+
innerPadding?: number;
89+
}
90+
const defaultValues: Required<AdvancedPopupOptions> = {
91+
filterLevel: 50,
92+
innerPadding: 0
93+
}
94+
8495
export class AdvancedPopup {
8596
html: HTMLDialogElement
8697

87-
constructor(x: number, y: number, html: string) { // todo: possibly add HTMLElement to html instead of just string?
98+
constructor(x: number, y: number, html: string, options: AdvancedPopupOptions=undefined) { // todo: possibly add HTMLElement to html instead of just string?
8899
this.html = document.createElement("dialog");
89100
this.html.className = "popup";
90101
this.html.style.display = "flex";
91102
this.html.style.width = `${x}px`;
92103
this.html.style.height = `${y}px`;
93104

94105
this.html.innerHTML = html;
106+
107+
const filledOptions = {
108+
...defaultValues,
109+
...options
110+
};
111+
112+
this.html.style.padding = filledOptions.innerPadding+"px";
113+
this.html.style.setProperty("--dialog-backdrop-opacity", filledOptions.filterLevel+"%");
95114

96115
document.body.appendChild(this.html);
97116

0 commit comments

Comments
 (0)