Skip to content

Commit d73d174

Browse files
authored
Merge pull request #26 from ezeaniiandrew/feat/add-overlay-color-option
Feat: add `overlayColor` option to Boarding class
2 parents 4712af8 + 461b11d commit d73d174

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,11 @@ <h4>Boarding Definition</h4>
642642
<pre><code class="javascript">const boarding = new Boarding({
643643
className: 'scoped-class', // className to wrap boarding.js popover
644644
animate: true, // Animate while changing highlighted element
645-
opacity: 0.75, // Background opacity (0 means only popovers and without overlay)
645+
opacity: 0.75, // Overlay opacity (0 means only popovers and without overlay)
646646
padding: 10, // Distance of element from around the edges
647647
allowClose: true, // Whether clicking on overlay should close or not
648648
overlayClickNext: false, // Should it move to next step on overlay click
649+
overlayColor: 'rgb(0,0,0)', // Fill color for the overlay
649650
doneBtnText: 'Done', // Text on the final button
650651
closeBtnText: 'Close', // Text on the close button for this step
651652
nextBtnText: 'Next', // Next button text for this step

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,11 @@ Here are the options that Boarding understands:
260260
const boarding = new Boarding({
261261
className: "scoped-class", // className to wrap boarding.js popover
262262
animate: true, // Whether to animate or not
263-
opacity: 0.75, // Background opacity (0 means only popovers and without overlay)
263+
opacity: 0.75, // Overlay opacity (0 means only popovers and without overlay)
264264
padding: 10, // Distance of element from around the edges
265265
allowClose: true, // Whether the click on overlay should close or not
266266
overlayClickNext: false, // Whether the click on overlay should move next
267+
overlayColor: "rgb(0,0,0)", // Fill color for the overlay
267268
doneBtnText: "Done", // Text on the final button
268269
closeBtnText: "Close", // Text on the close button for this step
269270
nextBtnText: "Next", // Next button text for this step

src/lib/boarding.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class Boarding {
104104
radius: this.options.radius,
105105
onReset: this.options.onReset,
106106
opacity: this.options.opacity,
107+
overlayColor: this.options.overlayColor,
107108
onOverlayClick: () => {
108109
// Perform the 'Next' operation when clicked outside the highlighted element
109110
if (this.options.overlayClickNext) {

src/lib/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const OVERLAY_OPACITY = 0.75;
2+
export const OVERLAY_FILL_COLOR = "rgb(0,0,0)";
23
export const OVERLAY_RADIUS = 5;
34
export const OVERLAY_PADDING = 10;
45
export const POPOVER_OFFSET = 10;

src/lib/core/overlay.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BoardingSharedOptions } from "../boarding-types";
2-
import { OVERLAY_OPACITY } from "../common/constants";
2+
import { OVERLAY_FILL_COLOR, OVERLAY_OPACITY } from "../common/constants";
33
import {
44
assertVarIsNotFalsy,
55
attachHighPrioClick,
@@ -37,6 +37,11 @@ export interface OverlayTopLevelOptions {
3737
* @default 0.75
3838
*/
3939
opacity?: number;
40+
/**
41+
* Fill color for the overlay
42+
* @default rgb(0,0,0)
43+
*/
44+
overlayColor?: string;
4045
}
4146

4247
interface OverlayOptions
@@ -69,9 +74,14 @@ class Overlay {
6974

7075
constructor(options: OverlayOptions) {
7176
this.options = {
72-
// padding: Padding default will come from outside, as it affects more then just the overlay
73-
opacity: OVERLAY_OPACITY,
7477
...options,
78+
opacity:
79+
options.opacity === undefined ? OVERLAY_OPACITY : options.opacity,
80+
overlayColor:
81+
options.overlayColor === undefined
82+
? OVERLAY_FILL_COLOR
83+
: options.overlayColor,
84+
// padding: Padding default will come from outside, as it affects more then just the overlay
7585
};
7686
}
7787

@@ -377,6 +387,7 @@ class Overlay {
377387
opacity: this.options.opacity,
378388
radius: definition.radius,
379389
animated: this.options.animate,
390+
fillColor: this.options.overlayColor,
380391
};
381392

382393
// mount svg if its not mounted already

0 commit comments

Comments
 (0)