File size: 4,066 Bytes
aa3b624
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8ff0f16
 
aa3b624
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8ff0f16
 
 
 
 
4c98241
 
8ff0f16
 
 
 
 
 
 
 
 
 
aa3b624
 
 
 
 
 
 
8ff0f16
4c98241
 
 
 
e3d3deb
 
8ff0f16
66a740c
8ff0f16
 
aa3b624
 
 
 
 
 
 
 
 
 
4c98241
 
66a740c
aa3b624
4c98241
 
 
 
 
 
e3d3deb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c98241
 
 
 
 
 
 
 
 
 
8ff0f16
 
4c98241
 
 
 
 
 
 
 
8ff0f16
66a740c
8ff0f16
4c98241
66a740c
 
4c98241
66a740c
aa3b624
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite App</title>

    <style>
      * {
        margin: 0;
        padding: 0;
      }

      body {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
        font-size: 14px;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
      }

      .container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100vh;
        max-width: 1200px;
        margin: 0 auto;
      }

      h1 {
        margin: 40px 0 10px;
        font-size: 48px;
        font-weight: 600;
        text-align: center;
      }

      h1 sup {
        font-size: 18px;
        font-weight: 400;
      }

      ul {
        list-style: none;
        padding: 0;
        margin: 20px 10px 0;
        line-height: 1.5;
      }

      ul li:before {
        content: "•";
        margin-right: 10px;
      }

      .buttons {
        display: flex;
        margin-top: 20px;
        gap: 10px;
        max-width: 500px;
        flex-wrap: wrap;
      }

      button {
        all: unset;
        border: 1px solid #ccc;
        padding: 5px 15px;
        border-radius: 5px;
        display: block;
        cursor: pointer;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <h1>driver.js <sup>next</sup></h1>
      <p>Rewritten and enhanced version of driver.js</p>

      <div class="buttons">
        <button id="highlight-btn">Animated Highlight</button>
        <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>

      <ul>
        <li>Written in TypeScript</li>
        <li>Lightweight — only 5kb gzipped</li>
        <li>No dependencies</li>
        <li>MIT Licensed</li>
      </ul>
    </div>
    <script type="module">
      import { driver } from "./src/driver.ts";

      document.getElementById("highlight-btn").addEventListener("click", () => {
        driver({ animate: true }).highlight({ element: "h1" });
      });

      document
        .getElementById("simple-highlight-btn")
        .addEventListener("click", () => {
          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", () => {
          const driverObj = driver({ animate: true });

          driverObj.highlight({ element: "h1" });

          window.setTimeout(() => {
            driverObj.highlight({ element: ".buttons" });
          }, 1000);
        });

      document
        .getElementById("disallow-close")
        .addEventListener("click", () => {
          const driverObj = driver({
            animate: true,
            allowClose: false,
          });

          driverObj.highlight({
            element: ".buttons",
          });
        });

      document.getElementById("destroy-btn").addEventListener("click", () => {
        driver().destroy();
      });
    </script>
  </body>
</html>