kamrify commited on
Commit
4189cd9
·
1 Parent(s): 86ba969

Add option to change the stage background

Browse files
Files changed (3) hide show
  1. readme.md +3 -1
  2. src/core/stage.js +1 -0
  3. src/index.js +10 -4
readme.md CHANGED
@@ -156,6 +156,7 @@ const driver = new Driver({
156
  allowClose: true, // Whether the click on overlay should close or not
157
  doneBtnText: 'Done', // Text on the final button
158
  closeBtnText: 'Close', // Text on the close button for this step
 
159
  nextBtnText: 'Next', // Next button text for this step
160
  prevBtnText: 'Previous', // Previous button text for this step
161
  showButtons: false, // Do not show control buttons in footer
@@ -174,6 +175,7 @@ Here are the set of options that you can pass while defining steps `defineSteps`
174
  ```javascript
175
  const stepDefinition = {
176
  element: '#some-item', // Query selector for the item to be highlighted
 
177
  popover: { // There will be no popover if empty or not given
178
  title: 'Title', // Title on the popover
179
  description: 'Description', // Body of the popover
@@ -255,7 +257,7 @@ activeElement.showPopover(); // Show the popover
255
  activeElement.getNode(); // Gets the DOM Element behind this element
256
  ```
257
 
258
- *Note –* Do not forget to add `e.stopPropagation()` to the `click` binding that triggers driver
259
 
260
  ![](./demo/images/split.png)
261
 
 
156
  allowClose: true, // Whether the click on overlay should close or not
157
  doneBtnText: 'Done', // Text on the final button
158
  closeBtnText: 'Close', // Text on the close button for this step
159
+ stageBackground: '#ffffff', // Background color for the staged behind highlighted element
160
  nextBtnText: 'Next', // Next button text for this step
161
  prevBtnText: 'Previous', // Previous button text for this step
162
  showButtons: false, // Do not show control buttons in footer
 
175
  ```javascript
176
  const stepDefinition = {
177
  element: '#some-item', // Query selector for the item to be highlighted
178
+ stageBackground: '#ffffff', // This will override the one set in driver
179
  popover: { // There will be no popover if empty or not given
180
  title: 'Title', // Title on the popover
181
  description: 'Description', // Body of the popover
 
257
  activeElement.getNode(); // Gets the DOM Element behind this element
258
  ```
259
 
260
+ **Note –** Do not forget to add `e.stopPropagation()` to the `click` binding that triggers driver
261
 
262
  ![](./demo/images/split.png)
263
 
src/core/stage.js CHANGED
@@ -85,6 +85,7 @@ export default class Stage extends Element {
85
  this.node.style.height = `${height}px`;
86
  this.node.style.top = `${position.top - (requiredPadding / 2)}px`;
87
  this.node.style.left = `${position.left - (requiredPadding / 2)}px`;
 
88
  }
89
  }
90
 
 
85
  this.node.style.height = `${height}px`;
86
  this.node.style.top = `${position.top - (requiredPadding / 2)}px`;
87
  this.node.style.left = `${position.left - (requiredPadding / 2)}px`;
88
+ this.node.style.backgroundColor = this.options.stageBackground;
89
  }
90
  }
91
 
src/index.js CHANGED
@@ -26,11 +26,12 @@ export default class Driver {
26
  */
27
  constructor(options = {}) {
28
  this.options = {
29
- animate: SHOULD_ANIMATE_OVERLAY, // Whether to animate or not
30
- opacity: OVERLAY_OPACITY, // Overlay opacity
31
- padding: OVERLAY_PADDING, // Spacing around the element from the overlay
32
  scrollIntoViewOptions: null, // Options to be passed to `scrollIntoView`
33
  allowClose: SHOULD_OUTSIDE_CLICK_CLOSE, // Whether to close overlay on click outside the element
 
34
  onHighlightStarted: () => { // When element is about to be highlighted
35
  },
36
  onHighlighted: () => { // When element has been highlighted
@@ -280,7 +281,12 @@ export default class Driver {
280
  popover = new Popover(popoverOptions, this.window, this.document);
281
  }
282
 
283
- const stage = new Stage(this.options, this.window, this.document);
 
 
 
 
 
284
 
285
  return new Element({
286
  node: domElement,
 
26
  */
27
  constructor(options = {}) {
28
  this.options = {
29
+ animate: SHOULD_ANIMATE_OVERLAY, // Whether to animate or not
30
+ opacity: OVERLAY_OPACITY, // Overlay opacity
31
+ padding: OVERLAY_PADDING, // Spacing around the element from the overlay
32
  scrollIntoViewOptions: null, // Options to be passed to `scrollIntoView`
33
  allowClose: SHOULD_OUTSIDE_CLICK_CLOSE, // Whether to close overlay on click outside the element
34
+ stageBackground: '#ffffff', // Background color for the stage
35
  onHighlightStarted: () => { // When element is about to be highlighted
36
  },
37
  onHighlighted: () => { // When element has been highlighted
 
281
  popover = new Popover(popoverOptions, this.window, this.document);
282
  }
283
 
284
+ const stageOptions = {
285
+ ...this.options,
286
+ ...elementOptions,
287
+ };
288
+
289
+ const stage = new Stage(stageOptions, this.window, this.document);
290
 
291
  return new Element({
292
  node: domElement,