Add theming guide
Browse files- docs/src/content/guides/theming.mdx +82 -3
- src/driver.css +2 -2
- src/overlay.ts +1 -1
docs/src/content/guides/theming.mdx
CHANGED
@@ -4,7 +4,77 @@ groupTitle: "Introduction"
|
|
4 |
sort: 3
|
5 |
---
|
6 |
|
7 |
-
You can customize the look and feel of the driver by applying CSS to
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
```css
|
10 |
/* Applied to the `body` when the driver: */
|
@@ -13,7 +83,16 @@ You can customize the look and feel of the driver by applying CSS to following c
|
|
13 |
.driver-simple {} /* is not animated */
|
14 |
```
|
15 |
|
16 |
-
Following classes are applied to the overlay
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
```css
|
19 |
-
.driver-
|
|
|
|
4 |
sort: 3
|
5 |
---
|
6 |
|
7 |
+
You can customize the look and feel of the driver by adding custom class to popover or applying CSS to different classes used by driver.js.
|
8 |
+
|
9 |
+
## Styling Popover
|
10 |
+
|
11 |
+
You can set the `popoverClass` option globally in the driver configuration or at the step level to apply custom class to the popover and then use CSS to apply styles.
|
12 |
+
|
13 |
+
```js
|
14 |
+
const driverObj = driver({
|
15 |
+
popoverClass: 'my-custom-popover-class'
|
16 |
+
});
|
17 |
+
|
18 |
+
// or you can also have different classes for different steps
|
19 |
+
const driverObj2 = driver({
|
20 |
+
steps: [
|
21 |
+
{
|
22 |
+
element: '#some-element',
|
23 |
+
popover: {
|
24 |
+
title: 'Title',
|
25 |
+
description: 'Description',
|
26 |
+
popoverClass: 'my-custom-popover-class'
|
27 |
+
}
|
28 |
+
}
|
29 |
+
],
|
30 |
+
})
|
31 |
+
```
|
32 |
+
|
33 |
+
Here is the list of classes applied to the popover which you can use in conjunction with `popoverClass` option to apply custom styles on the popover.
|
34 |
+
|
35 |
+
```css
|
36 |
+
/* Class assigned to popover wrapper */
|
37 |
+
.driver-popover {}
|
38 |
+
|
39 |
+
/* Arrow pointing towards the highlighted element */
|
40 |
+
.driver-popover-arrow {}
|
41 |
+
|
42 |
+
/* Title and description */
|
43 |
+
.driver-popover-title {}
|
44 |
+
.driver-popover-description {}
|
45 |
+
|
46 |
+
/* Close button displayed on the top right corner */
|
47 |
+
.driver-popover-close-btn {}
|
48 |
+
|
49 |
+
/* Footer of the popover displaying progress and navigation buttons */
|
50 |
+
.driver-popover-footer {}
|
51 |
+
.driver-popover-progress-text {}
|
52 |
+
.driver-popover-prev-btn {}
|
53 |
+
.driver-popover-next-btn {}
|
54 |
+
```
|
55 |
+
|
56 |
+
Alternatively, you can also use the `onPopoverRendered` hook to modify the popover DOM before it is displayed. The hook is called with the popover DOM as the first argument.
|
57 |
+
|
58 |
+
```typescript
|
59 |
+
type PopoverDOM = {
|
60 |
+
wrapper: HTMLElement;
|
61 |
+
arrow: HTMLElement;
|
62 |
+
title: HTMLElement;
|
63 |
+
description: HTMLElement;
|
64 |
+
footer: HTMLElement;
|
65 |
+
progress: HTMLElement;
|
66 |
+
previousButton: HTMLElement;
|
67 |
+
nextButton: HTMLElement;
|
68 |
+
closeButton: HTMLElement;
|
69 |
+
footerButtons: HTMLElement;
|
70 |
+
};
|
71 |
+
|
72 |
+
onPopoverRendered?: (popover: PopoverDOM) => void;
|
73 |
+
```
|
74 |
+
|
75 |
+
## Styling Page
|
76 |
+
|
77 |
+
Following classes are applied to the page when the driver is active.
|
78 |
|
79 |
```css
|
80 |
/* Applied to the `body` when the driver: */
|
|
|
83 |
.driver-simple {} /* is not animated */
|
84 |
```
|
85 |
|
86 |
+
Following classes are applied to the overlay i.e. the lightbox displayed over the page.
|
87 |
+
|
88 |
+
```css
|
89 |
+
.driver-overlay {}
|
90 |
+
```
|
91 |
+
|
92 |
+
## Styling Highlighted Element
|
93 |
+
|
94 |
+
Following classes are applied to the highlighted element which can be used to apply custom styles depending on the state of the driver.
|
95 |
|
96 |
```css
|
97 |
+
.driver-active-element {}
|
98 |
+
```
|
src/driver.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
.driver-active .driver-
|
2 |
pointer-events: none;
|
3 |
}
|
4 |
|
@@ -23,7 +23,7 @@
|
|
23 |
}
|
24 |
}
|
25 |
|
26 |
-
.driver-fade .driver-
|
27 |
animation: animate-fade-in 200ms ease-in-out;
|
28 |
}
|
29 |
|
|
|
1 |
+
.driver-active .driver-overlay {
|
2 |
pointer-events: none;
|
3 |
}
|
4 |
|
|
|
23 |
}
|
24 |
}
|
25 |
|
26 |
+
.driver-fade .driver-overlay {
|
27 |
animation: animate-fade-in 200ms ease-in-out;
|
28 |
}
|
29 |
|
src/overlay.ts
CHANGED
@@ -112,7 +112,7 @@ function createOverlaySvg(stage: StageDefinition): SVGSVGElement {
|
|
112 |
const windowY = window.innerHeight;
|
113 |
|
114 |
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
115 |
-
svg.classList.add("driver-
|
116 |
|
117 |
svg.setAttribute("viewBox", `0 0 ${windowX} ${windowY}`);
|
118 |
svg.setAttribute("xmlSpace", "preserve");
|
|
|
112 |
const windowY = window.innerHeight;
|
113 |
|
114 |
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
115 |
+
svg.classList.add("driver-overlay", "driver-overlay-animated");
|
116 |
|
117 |
svg.setAttribute("viewBox", `0 0 ${windowX} ${windowY}`);
|
118 |
svg.setAttribute("xmlSpace", "preserve");
|