Add example code on homepage
Browse files
docs/src/components/CodeSample.tsx
CHANGED
@@ -15,14 +15,14 @@ type CodeSampleProps = {
|
|
15 |
buttonText?: string;
|
16 |
};
|
17 |
|
18 |
-
function removeDummyElement() {
|
19 |
const el = document.querySelector(".dynamic-el");
|
20 |
if (el) {
|
21 |
el.remove();
|
22 |
}
|
23 |
}
|
24 |
|
25 |
-
function mountDummyElement() {
|
26 |
const newDiv = (document.querySelector(".dynamic-el") || document.createElement("div")) as HTMLElement;
|
27 |
|
28 |
newDiv.innerHTML = "This is a new Element";
|
|
|
15 |
buttonText?: string;
|
16 |
};
|
17 |
|
18 |
+
export function removeDummyElement() {
|
19 |
const el = document.querySelector(".dynamic-el");
|
20 |
if (el) {
|
21 |
el.remove();
|
22 |
}
|
23 |
}
|
24 |
|
25 |
+
export function mountDummyElement() {
|
26 |
const newDiv = (document.querySelector(".dynamic-el") || document.createElement("div")) as HTMLElement;
|
27 |
|
28 |
newDiv.innerHTML = "This is a new Element";
|
docs/src/components/examples/ExampleButton.tsx
CHANGED
@@ -1,13 +1,15 @@
|
|
1 |
type ExampleButtonProps = {
|
|
|
2 |
onClick: () => void;
|
3 |
text: string;
|
4 |
};
|
5 |
|
6 |
export function ExampleButton(props: ExampleButtonProps) {
|
7 |
-
const { onClick, text } = props;
|
8 |
|
9 |
return (
|
10 |
<button
|
|
|
11 |
onClick={onClick}
|
12 |
className="bg-transparent rounded-xl py-2 px-4 font-medium text-black border-2 border-black text-lg hover:bg-yellow-300 hover:text-black transition-colors duration-100">
|
13 |
{ text }
|
|
|
1 |
type ExampleButtonProps = {
|
2 |
+
id: string;
|
3 |
onClick: () => void;
|
4 |
text: string;
|
5 |
};
|
6 |
|
7 |
export function ExampleButton(props: ExampleButtonProps) {
|
8 |
+
const { id, onClick, text } = props;
|
9 |
|
10 |
return (
|
11 |
<button
|
12 |
+
id={id}
|
13 |
onClick={onClick}
|
14 |
className="bg-transparent rounded-xl py-2 px-4 font-medium text-black border-2 border-black text-lg hover:bg-yellow-300 hover:text-black transition-colors duration-100">
|
15 |
{ text }
|
docs/src/pages/index.astro
CHANGED
@@ -38,19 +38,19 @@ const starCount = getFormattedStars('kamranahmedse/driver.js');
|
|
38 |
|
39 |
<div class="py-24 bg-white text-black">
|
40 |
<Container>
|
41 |
-
<h2 class="text-6xl font-bold mb-6">Examples</h2>
|
42 |
-
<p class="text-2xl text-black mb-12">Here are just a few examples; find more <a
|
43 |
class="text-black underline underline-offset-4" href="/docs/installation">in the documentation</a>.</p>
|
44 |
|
45 |
<div class="flex flex-wrap gap-3" data-example-btns>
|
46 |
-
<ExampleButton text="Animated Tour" />
|
47 |
-
<ExampleButton text="Non-Animated Tour" />
|
48 |
-
<ExampleButton text="Asynchronous Tour" />
|
49 |
-
<ExampleButton text="Confirm on Exit" />
|
50 |
-
<ExampleButton text="Show Progress" />
|
51 |
-
<ExampleButton text="Simple Element Highlight" />
|
52 |
-
<ExampleButton text="
|
53 |
-
<ExampleButton text="
|
54 |
<ExampleButton text="Overlay Color" />
|
55 |
<ExampleButton text="Popover Positioning" />
|
56 |
<ExampleButton text="Customizing Popover" />
|
@@ -98,12 +98,12 @@ const starCount = getFormattedStars('kamranahmedse/driver.js');
|
|
98 |
<a href="https://github.com/kamranahmedse/driver.js"
|
99 |
data-github-link
|
100 |
target="_blank"
|
101 |
-
class="flex items-center font-
|
102 |
<span class="mr-3 inline-flex items-center"><img src="/star.svg" alt="Hero Image" class="h-7 mr-2" /> { starCount }</span>
|
103 |
GitHub Stars
|
104 |
</a>
|
105 |
<a href="/docs/installation"
|
106 |
-
class="bg-black text-white flex items-center font-
|
107 |
Start Using Driver.js
|
108 |
</a>
|
109 |
</div>
|
@@ -135,89 +135,404 @@ const starCount = getFormattedStars('kamranahmedse/driver.js');
|
|
135 |
<script>
|
136 |
import { driver } from "driver.js";
|
137 |
import "driver.js/dist/driver.css";
|
|
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
}
|
206 |
},
|
207 |
-
{
|
208 |
-
|
209 |
-
description: "<img style='width: 270px; height: 206.65px; margin-bottom: 10px; border-radius: 5px;' src='https://i.imgur.com/3WpTnyA.gif' />That's it for now, make sure to visit the docs for more examples and use-cases.",
|
210 |
-
side: "bottom",
|
211 |
-
align: "start",
|
212 |
-
showButtons: [],
|
213 |
-
popoverClass: "default-theme"
|
214 |
-
}
|
215 |
}
|
216 |
-
|
|
|
|
|
217 |
});
|
218 |
|
219 |
-
const
|
220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
driverObj.drive();
|
222 |
});
|
223 |
</script>
|
|
|
38 |
|
39 |
<div class="py-24 bg-white text-black">
|
40 |
<Container>
|
41 |
+
<h2 class="text-6xl font-bold mb-6" data-examples-heading>Examples</h2>
|
42 |
+
<p class="text-2xl text-black mb-12" data-examples-tagline>Here are just a few examples; find more <a
|
43 |
class="text-black underline underline-offset-4" href="/docs/installation">in the documentation</a>.</p>
|
44 |
|
45 |
<div class="flex flex-wrap gap-3" data-example-btns>
|
46 |
+
<ExampleButton id="animated-tour" text="Animated Tour" />
|
47 |
+
<ExampleButton id="static-tour" text="Non-Animated Tour" />
|
48 |
+
<ExampleButton id="async-tour" text="Asynchronous Tour" />
|
49 |
+
<ExampleButton id="confirm-on-exit" text="Confirm on Exit" />
|
50 |
+
<ExampleButton id="show-progress" text="Show Progress" />
|
51 |
+
<ExampleButton id="simple-element-highlight" text="Simple Element Highlight" />
|
52 |
+
<ExampleButton id="simple-element-highlight-popover" text="Simple Highlight with Popover" />
|
53 |
+
<ExampleButton id="prevent-close" text="Prevent Tour from Closing" />
|
54 |
<ExampleButton text="Overlay Color" />
|
55 |
<ExampleButton text="Popover Positioning" />
|
56 |
<ExampleButton text="Customizing Popover" />
|
|
|
98 |
<a href="https://github.com/kamranahmedse/driver.js"
|
99 |
data-github-link
|
100 |
target="_blank"
|
101 |
+
class="flex items-center font-medium text-2xl rounded-xl py-3 px-5 bg-yellow-300 border-black hover:bg-yellow-400">
|
102 |
<span class="mr-3 inline-flex items-center"><img src="/star.svg" alt="Hero Image" class="h-7 mr-2" /> { starCount }</span>
|
103 |
GitHub Stars
|
104 |
</a>
|
105 |
<a href="/docs/installation"
|
106 |
+
class="bg-black text-white flex items-center font-medium text-2xl border-4 border-black rounded-xl py-3 px-5 hover:bg-gray-800">
|
107 |
Start Using Driver.js
|
108 |
</a>
|
109 |
</div>
|
|
|
135 |
<script>
|
136 |
import { driver } from "driver.js";
|
137 |
import "driver.js/dist/driver.css";
|
138 |
+
import { mountDummyElement, removeDummyElement } from "../components/CodeSample";
|
139 |
|
140 |
+
function markDone(btn) {
|
141 |
+
btn.classList.add("bg-gray-300", "hover:bg-gray-200", "line-through");
|
142 |
+
}
|
143 |
+
|
144 |
+
const demoTourButton = document.querySelector("[data-demo-tour]");
|
145 |
+
demoTourButton.addEventListener("click", () => {
|
146 |
+
const driverObj = driver({
|
147 |
+
popoverClass: "driverjs-theme",
|
148 |
+
showButtons: ["next", "previous"],
|
149 |
+
steps: [
|
150 |
+
{
|
151 |
+
element: "[data-hero-text]",
|
152 |
+
popover: {
|
153 |
+
title: "Before we start",
|
154 |
+
description: "This is just one use-case, make sure to look at the docs for more use-cases and examples.",
|
155 |
+
nextBtnText: "Okay, start!",
|
156 |
+
side: "bottom",
|
157 |
+
align: "start"
|
158 |
+
}
|
159 |
+
},
|
160 |
+
{
|
161 |
+
element: "[data-driver-tagline]",
|
162 |
+
popover: {
|
163 |
+
title: "Focus Anything",
|
164 |
+
description: "You can use it to highlight literally anything, images, text, svg, div, span, li etc.",
|
165 |
+
side: "bottom",
|
166 |
+
align: "start"
|
167 |
+
}
|
168 |
+
},
|
169 |
+
{
|
170 |
+
element: "[data-driver-name]",
|
171 |
+
popover: {
|
172 |
+
title: "Why Driver.js",
|
173 |
+
description: "It's lightweight, has no dependencies, is MIT licensed, is highly customizable, and is super easy to use.",
|
174 |
+
side: "bottom",
|
175 |
+
align: "start"
|
176 |
+
}
|
177 |
+
},
|
178 |
+
{
|
179 |
+
element: "[data-docs-link]",
|
180 |
+
popover: {
|
181 |
+
title: "More Powerful than Ever",
|
182 |
+
description: "Driver.js has been completely rewritten from scratch and is now more powerful than ever.",
|
183 |
+
side: "bottom",
|
184 |
+
align: "start"
|
185 |
+
}
|
186 |
+
},
|
187 |
+
{
|
188 |
+
element: "[data-example-btns]",
|
189 |
+
popover: {
|
190 |
+
title: "Examples",
|
191 |
+
description: "Here are some examples to give you a rough idea.",
|
192 |
+
side: "bottom",
|
193 |
+
align: "start"
|
194 |
+
}
|
195 |
+
},
|
196 |
+
{
|
197 |
+
element: "[data-example-btns] a:last-child",
|
198 |
+
popover: {
|
199 |
+
title: "Visit Docs",
|
200 |
+
description: "Make sure to visit the docs for more examples and use-cases.",
|
201 |
+
side: "top",
|
202 |
+
align: "start"
|
203 |
+
}
|
204 |
+
},
|
205 |
+
{
|
206 |
+
element: "[data-github-link]",
|
207 |
+
popover: {
|
208 |
+
title: "MIT Licensed",
|
209 |
+
description: "Driver.js is MIT licensed and is used by thousands of companies around the world.",
|
210 |
+
side: "top",
|
211 |
+
align: "start"
|
212 |
+
}
|
213 |
+
},
|
214 |
+
{
|
215 |
+
popover: {
|
216 |
+
description: "<img style='width: 270px; height: 206.65px; margin-bottom: 10px; border-radius: 5px;' src='https://i.imgur.com/3WpTnyA.gif' />That's it for now, make sure to visit the docs for more examples and use-cases.",
|
217 |
+
side: "bottom",
|
218 |
+
align: "start",
|
219 |
+
showButtons: [],
|
220 |
+
popoverClass: "default-theme"
|
221 |
+
}
|
222 |
}
|
223 |
+
]
|
224 |
+
});
|
225 |
+
|
226 |
+
driverObj.drive();
|
227 |
+
});
|
228 |
+
|
229 |
+
const animatedTourBtn = document.getElementById('animated-tour');
|
230 |
+
animatedTourBtn.addEventListener("click", () => {
|
231 |
+
const driverObj = driver({
|
232 |
+
popoverClass: "driverjs-theme",
|
233 |
+
showButtons: ["next", "previous"],
|
234 |
+
steps: [
|
235 |
+
{
|
236 |
+
element: "[data-examples-heading]",
|
237 |
+
popover: {
|
238 |
+
title: "Animated Tour",
|
239 |
+
description: "Animated tour can simply be achieved by setting `animate` option true.",
|
240 |
+
side: "bottom",
|
241 |
+
align: "start"
|
242 |
+
}
|
243 |
+
},
|
244 |
+
{
|
245 |
+
element: "[data-examples-tagline]",
|
246 |
+
popover: {
|
247 |
+
title: "Just an Example",
|
248 |
+
description: "We don't have many steps in this example, but you can have as many as you want.",
|
249 |
+
side: "bottom",
|
250 |
+
align: "start"
|
251 |
+
}
|
252 |
+
},
|
253 |
+
{
|
254 |
+
element: "[data-examples-tagline] a",
|
255 |
+
popover: {
|
256 |
+
title: "That's it for now",
|
257 |
+
description: "Make sure to visit the docs for more examples and use-cases.",
|
258 |
+
side: "bottom",
|
259 |
+
align: "start"
|
260 |
+
}
|
261 |
+
},
|
262 |
+
],
|
263 |
+
onDestroyed: () => {
|
264 |
+
markDone(animatedTourBtn);
|
265 |
+
}
|
266 |
+
});
|
267 |
+
|
268 |
+
driverObj.drive();
|
269 |
+
});
|
270 |
+
|
271 |
+
const staticTourBtn = document.getElementById('static-tour');
|
272 |
+
staticTourBtn.addEventListener("click", () => {
|
273 |
+
const driverObj = driver({
|
274 |
+
animate: false,
|
275 |
+
popoverClass: "driverjs-theme",
|
276 |
+
showButtons: ["next", "previous"],
|
277 |
+
steps: [
|
278 |
+
{
|
279 |
+
element: "[data-examples-heading]",
|
280 |
+
popover: {
|
281 |
+
title: "Static Tour",
|
282 |
+
description: "This is a static tour, which means that it won't be animated.",
|
283 |
+
side: "bottom",
|
284 |
+
align: "start"
|
285 |
+
}
|
286 |
+
},
|
287 |
+
{
|
288 |
+
element: "[data-examples-tagline]",
|
289 |
+
popover: {
|
290 |
+
title: "Just an Example",
|
291 |
+
description: "We don't have many steps in this example, but you can have as many as you want.",
|
292 |
+
side: "bottom",
|
293 |
+
align: "start"
|
294 |
+
}
|
295 |
+
},
|
296 |
+
{
|
297 |
+
element: "[data-examples-tagline] a",
|
298 |
+
popover: {
|
299 |
+
title: "That's it for now",
|
300 |
+
description: "Make sure to visit the docs for more examples and use-cases.",
|
301 |
+
side: "bottom",
|
302 |
+
align: "start"
|
303 |
+
}
|
304 |
+
},
|
305 |
+
],
|
306 |
+
onDestroyed: () => {
|
307 |
+
markDone(staticTourBtn);
|
308 |
+
}
|
309 |
+
});
|
310 |
+
|
311 |
+
driverObj.drive();
|
312 |
+
});
|
313 |
+
|
314 |
+
const asyncTourBtn = document.getElementById('async-tour');
|
315 |
+
asyncTourBtn.addEventListener("click", () => {
|
316 |
+
const driverObj = driver({
|
317 |
+
animate: true,
|
318 |
+
popoverClass: "driverjs-theme",
|
319 |
+
showButtons: ["next", "previous"],
|
320 |
+
steps: [
|
321 |
+
{
|
322 |
+
popover: {
|
323 |
+
title: "Async Tour",
|
324 |
+
description: "You can also use Driver.js to create async tours. Element for the next step doesn't exist -- we will create before moving next.",
|
325 |
+
side: "bottom",
|
326 |
+
align: "start",
|
327 |
+
onNextClick: () => {
|
328 |
+
mountDummyElement();
|
329 |
+
driverObj.moveNext();
|
330 |
+
}
|
331 |
+
}
|
332 |
+
},
|
333 |
+
{
|
334 |
+
element: '.dynamic-el',
|
335 |
+
popover: {
|
336 |
+
title: "New Element",
|
337 |
+
description: "This element was created after the first step and will be destroyed after this step.",
|
338 |
+
side: "bottom",
|
339 |
+
align: "start",
|
340 |
+
onPrevClick: () => {
|
341 |
+
removeDummyElement();
|
342 |
+
driverObj.movePrevious();
|
343 |
+
},
|
344 |
+
onNextClick: () => {
|
345 |
+
removeDummyElement();
|
346 |
+
driverObj.moveNext();
|
347 |
+
}
|
348 |
+
}
|
349 |
+
},
|
350 |
+
{
|
351 |
+
popover: {
|
352 |
+
title: "More in Docs",
|
353 |
+
description: "There is a detailed guide on <a href='/docs/async-tour/' target='_blank' class='underline font-bold'>how to create async</a> tours in the documentation.",
|
354 |
+
side: "bottom",
|
355 |
+
align: "start",
|
356 |
+
onPrevClick: () => {
|
357 |
+
mountDummyElement();
|
358 |
+
driverObj.movePrevious();
|
359 |
+
}
|
360 |
+
}
|
361 |
+
},
|
362 |
+
],
|
363 |
+
onDestroyed: () => {
|
364 |
+
markDone(asyncTourBtn);
|
365 |
+
}
|
366 |
+
});
|
367 |
+
|
368 |
+
driverObj.drive();
|
369 |
+
});
|
370 |
+
|
371 |
+
const exitConfirm = document.getElementById('confirm-on-exit');
|
372 |
+
exitConfirm.addEventListener("click", () => {
|
373 |
+
const driverObj = driver({
|
374 |
+
animate: true,
|
375 |
+
popoverClass: "driverjs-theme",
|
376 |
+
showButtons: ["next", "previous"],
|
377 |
+
steps: [
|
378 |
+
{
|
379 |
+
element: "[data-examples-heading]",
|
380 |
+
popover: {
|
381 |
+
title: "Confirm on Exit",
|
382 |
+
description: "You can also ask for confirmation before exiting the tour.",
|
383 |
+
side: "bottom",
|
384 |
+
align: "start"
|
385 |
+
}
|
386 |
+
},
|
387 |
+
{
|
388 |
+
element: "[data-examples-tagline]",
|
389 |
+
popover: {
|
390 |
+
title: "Just an Example",
|
391 |
+
description: "We don't have many steps in this example, but you can have as many as you want.",
|
392 |
+
side: "bottom",
|
393 |
+
align: "start"
|
394 |
+
}
|
395 |
+
},
|
396 |
+
{
|
397 |
+
element: "[data-examples-tagline] a",
|
398 |
+
popover: {
|
399 |
+
title: "That's it for now",
|
400 |
+
description: "Make sure to visit the docs for more examples and use-cases.",
|
401 |
+
side: "bottom",
|
402 |
+
align: "start"
|
403 |
+
}
|
404 |
+
},
|
405 |
+
],
|
406 |
+
onDestroyStarted: () => {
|
407 |
+
if (!driverObj.hasNextStep() || confirm("Are you sure?")) {
|
408 |
+
driverObj.destroy();
|
409 |
}
|
410 |
},
|
411 |
+
onDestroyed: () => {
|
412 |
+
markDone(exitConfirm);
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
}
|
414 |
+
});
|
415 |
+
|
416 |
+
driverObj.drive();
|
417 |
});
|
418 |
|
419 |
+
const showProgressBtn = document.getElementById('show-progress');
|
420 |
+
showProgressBtn.addEventListener('click', () => {
|
421 |
+
const driverObj = driver({
|
422 |
+
animate: true,
|
423 |
+
showProgress: true,
|
424 |
+
showButtons: ["next", "previous"],
|
425 |
+
steps: [
|
426 |
+
{
|
427 |
+
element: "[data-examples-heading]",
|
428 |
+
popover: {
|
429 |
+
title: "Show Progress",
|
430 |
+
description: "You can set `showProgress` to `true` and progress will be shown in the footer.",
|
431 |
+
side: "bottom",
|
432 |
+
align: "start"
|
433 |
+
}
|
434 |
+
},
|
435 |
+
{
|
436 |
+
element: "[data-examples-tagline]",
|
437 |
+
popover: {
|
438 |
+
title: "Just an Example",
|
439 |
+
description: "We don't have many steps in this example, but you can have as many as you want.",
|
440 |
+
side: "bottom",
|
441 |
+
align: "start"
|
442 |
+
}
|
443 |
+
},
|
444 |
+
{
|
445 |
+
element: "[data-examples-tagline] a",
|
446 |
+
popover: {
|
447 |
+
title: "That's it for now",
|
448 |
+
description: "Make sure to visit the docs for more examples and use-cases.",
|
449 |
+
side: "bottom",
|
450 |
+
align: "start"
|
451 |
+
}
|
452 |
+
},
|
453 |
+
],
|
454 |
+
onDestroyed: () => {
|
455 |
+
markDone(showProgressBtn);
|
456 |
+
}
|
457 |
+
});
|
458 |
+
|
459 |
+
driverObj.drive();
|
460 |
+
});
|
461 |
+
|
462 |
+
const simpleHighlightBtn = document.getElementById('simple-element-highlight');
|
463 |
+
simpleHighlightBtn.addEventListener('click', () => {
|
464 |
+
const driverObj = driver({
|
465 |
+
popoverClass: 'driverjs-theme',
|
466 |
+
onDestroyed: () => {
|
467 |
+
markDone(simpleHighlightBtn);
|
468 |
+
}
|
469 |
+
});
|
470 |
+
|
471 |
+
driverObj.highlight({
|
472 |
+
element: '[data-example-btns]'
|
473 |
+
})
|
474 |
+
});
|
475 |
+
|
476 |
+
const simpleHighlightPopoverBtn = document.getElementById('simple-element-highlight-popover');
|
477 |
+
simpleHighlightPopoverBtn.addEventListener('click', () => {
|
478 |
+
const driverObj = driver({
|
479 |
+
popoverClass: 'driverjs-theme',
|
480 |
+
onDestroyed: () => {
|
481 |
+
markDone(simpleHighlightPopoverBtn);
|
482 |
+
}
|
483 |
+
});
|
484 |
+
|
485 |
+
driverObj.highlight({
|
486 |
+
element: '[data-example-btns]',
|
487 |
+
popover: {
|
488 |
+
title: "Popover Highlight",
|
489 |
+
description: "You can also highlight an element with a popover.",
|
490 |
+
side: 'top'
|
491 |
+
}
|
492 |
+
});
|
493 |
+
});
|
494 |
+
|
495 |
+
const preventCloseBtn = document.getElementById('prevent-close');
|
496 |
+
preventCloseBtn.addEventListener('click', () => {
|
497 |
+
const driverObj = driver({
|
498 |
+
animate: true,
|
499 |
+
allowClose: false,
|
500 |
+
showProgress: true,
|
501 |
+
showButtons: ["next", "previous"],
|
502 |
+
steps: [
|
503 |
+
{
|
504 |
+
element: "[data-examples-heading]",
|
505 |
+
popover: {
|
506 |
+
title: "Show Progress",
|
507 |
+
description: "You can set `showProgress` to `true` and progress will be shown in the footer.",
|
508 |
+
side: "bottom",
|
509 |
+
align: "start"
|
510 |
+
}
|
511 |
+
},
|
512 |
+
{
|
513 |
+
element: "[data-examples-tagline]",
|
514 |
+
popover: {
|
515 |
+
title: "Just an Example",
|
516 |
+
description: "We don't have many steps in this example, but you can have as many as you want.",
|
517 |
+
side: "bottom",
|
518 |
+
align: "start"
|
519 |
+
}
|
520 |
+
},
|
521 |
+
{
|
522 |
+
element: "[data-examples-tagline] a",
|
523 |
+
popover: {
|
524 |
+
title: "That's it for now",
|
525 |
+
description: "Make sure to visit the docs for more examples and use-cases.",
|
526 |
+
side: "bottom",
|
527 |
+
align: "start"
|
528 |
+
}
|
529 |
+
},
|
530 |
+
],
|
531 |
+
onDestroyed: () => {
|
532 |
+
markDone(preventCloseBtn);
|
533 |
+
}
|
534 |
+
});
|
535 |
+
|
536 |
driverObj.drive();
|
537 |
});
|
538 |
</script>
|