|
2 | 2 | <div class="page-contents">
|
3 | 3 | <Navbar :show-back-button="true">
|
4 | 4 | <template #right>
|
5 |
| - <div class="inline-flex items-center gap-1"> |
6 |
| - <label for="toggleScrollInSync" class="select-none" |
7 |
| - >Scroll in sync</label |
8 |
| - > |
9 |
| - <input |
10 |
| - id="toggleScrollInSync" |
11 |
| - type="checkbox" |
12 |
| - :checked="scrollInSync" |
13 |
| - class="form-checkbox filter mix-blend-luminosity" |
14 |
| - @click="toggleInSyncScroll" |
15 |
| - /> |
16 |
| - </div> |
17 | 5 | <button
|
18 | 6 | type="button"
|
19 | 7 | class="inline-flex justify-center px-4 py-2 transition-transform transform rounded-md shadow outline-none copy-uri-button align-center focus:ring-4 active:scale-y-75"
|
|
62 | 50 | </template>
|
63 | 51 | </Navbar>
|
64 | 52 | <main>
|
| 53 | + <section class="flex items-center gap-4 py-4"> |
| 54 | + <div |
| 55 | + class="inline-flex items-center gap-1" |
| 56 | + id="toggleScrollInSyncSection" |
| 57 | + > |
| 58 | + <label |
| 59 | + for="toggleScrollInSync" |
| 60 | + class="text-gray-800 select-none dark:text-gray-50" |
| 61 | + > |
| 62 | + Scroll in sync |
| 63 | + </label> |
| 64 | + <input |
| 65 | + id="toggleScrollInSync" |
| 66 | + type="checkbox" |
| 67 | + :checked="isSrollInSyncEnabled" |
| 68 | + class="form-checkbox" |
| 69 | + @click="toggleInSyncScroll" |
| 70 | + /> |
| 71 | + </div> |
| 72 | + </section> |
65 | 73 | <section
|
66 | 74 | class="flex items-stretch w-full gap-4 font-mono text-gray-800 dark:text-gray-50"
|
67 | 75 | >
|
|
72 | 80 | <div
|
73 | 81 | class="relative flex-1 px-4 py-2 border-2 rounded-md dark:border-gray-500 line-number-gutter min-h-80"
|
74 | 82 | :class="{
|
75 |
| - 'overflow-y-auto max-h-screen--nav': !scrollInSync, |
| 83 | + 'overflow-y-auto max-h-screen--nav': !isSrollInSyncEnabled, |
76 | 84 | }"
|
77 | 85 | >
|
78 | 86 | <RTStickyCopyButton
|
|
97 | 105 | <div
|
98 | 106 | class="relative flex-1 px-4 py-2 border-2 rounded-md dark:border-gray-500 line-number-gutter min-h-80"
|
99 | 107 | :class="{
|
100 |
| - 'overflow-y-auto max-h-screen--nav': !scrollInSync, |
| 108 | + 'overflow-y-auto max-h-screen--nav': !isSrollInSyncEnabled, |
101 | 109 | }"
|
102 | 110 | >
|
103 | 111 | <RTStickyCopyButton
|
@@ -133,17 +141,19 @@ export default {
|
133 | 141 | rhsLabel: this.rhsLabel,
|
134 | 142 | lhsLabel: this.lhsLabel,
|
135 | 143 | copied: false,
|
136 |
| - scrollInSync: this.scrollInSync, |
| 144 | + isSrollInSyncEnabled: this.isSrollInSyncEnabled, |
| 145 | + isDarkMode: this.$isDarkMode, |
| 146 | + isSkipScrollInSyncTutorial: this.$isSkipScrollInSyncTutorial, |
137 | 147 | }
|
138 | 148 | },
|
139 |
| - mounted() { |
| 149 | + async mounted() { |
140 | 150 | const _diff = this.$route.hash
|
141 | 151 | const gunzip = pako.ungzip(Buffer.from(undoUrlSafeBase64(_diff), 'base64'))
|
142 | 152 | const diffData = JSON.parse(Buffer.from(gunzip).toString('utf8'))
|
143 | 153 | const { diff, lhsLabel, rhsLabel } = diffData
|
144 | 154 | this.lhsLabel = lhsLabel
|
145 | 155 | this.rhsLabel = rhsLabel
|
146 |
| - this.scrollInSync = true |
| 156 | + this.isSrollInSyncEnabled = true |
147 | 157 | this.lhsDiff = diff
|
148 | 158 | .map((item) => {
|
149 | 159 | const hunkState = item[0]
|
@@ -182,6 +192,32 @@ export default {
|
182 | 192 | '--max-line-number-characher',
|
183 | 193 | `${`${maxLineCount}`.split('').length}ch`
|
184 | 194 | )
|
| 195 | + const { default: Driver } = await import('driver.js') |
| 196 | + const driver = new Driver({ |
| 197 | + // ...driverJSConfig(this.$isDarkMode), |
| 198 | + closeBtnText: 'Skip', |
| 199 | + className: 'dark:filter dark:invert', |
| 200 | + stageBackground: this.isDarkMode |
| 201 | + ? 'hsl(221deg 50% 90% / 0.5)' |
| 202 | + : '#ffffff', |
| 203 | + onReset: () => { |
| 204 | + document.cookie = |
| 205 | + 'isSkipScrollInSyncTutorial=true; max-age=31536000; path=/;' |
| 206 | + }, |
| 207 | + }) |
| 208 | + // Define the steps for introduction |
| 209 | + if (!this.isSkipScrollInSyncTutorial) { |
| 210 | + driver.defineSteps([ |
| 211 | + { |
| 212 | + element: '#toggleScrollInSyncSection', |
| 213 | + popover: { |
| 214 | + title: 'Scroll In Sync', |
| 215 | + description: 'Now you can choose to scroll both sides in sync.', |
| 216 | + }, |
| 217 | + }, |
| 218 | + ]) |
| 219 | + driver.start() |
| 220 | + } |
185 | 221 | },
|
186 | 222 | methods: {
|
187 | 223 | putToClipboard(textToPut, toastContent) {
|
@@ -224,7 +260,7 @@ export default {
|
224 | 260 | )
|
225 | 261 | },
|
226 | 262 | toggleInSyncScroll() {
|
227 |
| - this.scrollInSync = !this.scrollInSync |
| 263 | + this.isSrollInSyncEnabled = !this.isSrollInSyncEnabled |
228 | 264 | },
|
229 | 265 | },
|
230 | 266 | }
|
|
0 commit comments