Add option to configure opacity

This commit is contained in:
Kamran Ahmed
2023-05-11 00:36:22 +01:00
parent 4c98241ac4
commit e3d3debcb5
3 changed files with 24 additions and 1 deletions
+20
View File
@@ -81,6 +81,8 @@
<button id="simple-highlight-btn">Simple Highlight</button>
<button id="transition-highlight-btn">Multiple Highlight Calls</button>
<button id="disallow-close">Disallow Close</button>
<button id="dark-highlight-btn">Super Dark Highlight</button>
<button id="dim-highlight-btn">Super Dim Highlight</button>
<button id="tour-btn">Start Tour</button>
<button id="destroy-btn">Destroy</button>
</div>
@@ -105,6 +107,24 @@
driver({ animate: false }).highlight({ element: "ul" });
});
document
.getElementById("dark-highlight-btn")
.addEventListener("click", () => {
driver({
animate: true,
opacity: 0.9,
}).highlight({ element: "ul" });
});
document
.getElementById("dim-highlight-btn")
.addEventListener("click", () => {
driver({
animate: true,
opacity: 0.2,
}).highlight({ element: ".buttons" });
});
document
.getElementById("transition-highlight-btn")
.addEventListener("click", () => {
+2
View File
@@ -1,6 +1,7 @@
export type Config = {
animate?: boolean;
allowClose?: boolean;
opacity?: number;
};
let currentConfig: Config = {};
@@ -9,6 +10,7 @@ export function configure(config: Config = {}) {
currentConfig = {
animate: true,
allowClose: true,
opacity: 0.7,
...config,
};
}
+2 -1
View File
@@ -1,6 +1,7 @@
import { easeInOutQuad } from "./math";
import { onDriverClick } from "./events";
import { trigger } from "./hooks";
import { getConfig } from "./config";
export type StageDefinition = {
x: number;
@@ -158,7 +159,7 @@ function createStageSvg(stage: StageDefinition): SVGSVGElement {
cutoutPath.setAttribute("d", generateSvgCutoutPathString(stage));
cutoutPath.style.fill = "rgb(0,0,0)";
cutoutPath.style.opacity = `0.7`;
cutoutPath.style.opacity = `${getConfig("opacity")}`;
cutoutPath.style.pointerEvents = "auto";
cutoutPath.style.cursor = "auto";