11<script setup lang="ts">
2+ import type { Ref } from ' vue'
23import { computed , nextTick , onMounted , reactive , ref } from ' vue'
34import { useHead } from ' @unhead/vue'
45import type { RouteRecordRaw } from ' vue-router'
56import type { ClicksContext } from ' packages/types'
67import { themeVars } from ' ../env'
78import { rawRoutes } from ' ../logic/nav'
8- import { useClicksContextBase } from ' ../composables/useClicks'
9+ import { useFixedClicks } from ' ../composables/useClicks'
910import { isColorSchemaConfigured , isDark , toggleDark } from ' ../logic/dark'
1011import { getSlideClass } from ' ../utils'
1112import SlideContainer from ' ../internals/SlideContainer.vue'
1213import SlideWrapper from ' ../internals/SlideWrapper'
1314import DrawingPreview from ' ../internals/DrawingPreview.vue'
1415import IconButton from ' ../internals/IconButton.vue'
1516import NoteEditor from ' ../internals/NoteEditor.vue'
17+ import OverviewClicksSlider from ' ../internals/OverviewClicksSlider.vue'
1618
1719const cardWidth = 450
1820
@@ -27,16 +29,16 @@ const wordCounts = computed(() => rawRoutes.map(route => wordCount(route.meta?.s
2729const totalWords = computed (() => wordCounts .value .reduce ((a , b ) => a + b , 0 ))
2830const totalClicks = computed (() => rawRoutes .map (route => getSlideClicks (route )).reduce ((a , b ) => a + b , 0 ))
2931
30- const clicksContextMap = new WeakMap <RouteRecordRaw , ClicksContext >()
32+ const clicksContextMap = new WeakMap <RouteRecordRaw , [ Ref < number >, ClicksContext ] >()
3133function getClickContext(route : RouteRecordRaw ) {
3234 // We create a local clicks context to calculate the total clicks of the slide
3335 if (! clicksContextMap .has (route ))
34- clicksContextMap .set (route , useClicksContextBase (() => 999999 , route ?. meta ?. clicks ))
36+ clicksContextMap .set (route , useFixedClicks ( route , 9999 ))
3537 return clicksContextMap .get (route )!
3638}
3739
3840function getSlideClicks(route : RouteRecordRaw ) {
39- return route .meta ?.clicks || getClickContext (route )?.total
41+ return route .meta ?.clicks || getClickContext (route )?.[ 1 ]?. total
4042}
4143
4244function wordCount(str : string ) {
@@ -133,36 +135,36 @@ onMounted(() => {
133135 <div class =" text-3xl op20 mb2" >
134136 {{ idx + 1 }}
135137 </div >
138+ </div >
139+ <div class =" flex flex-col gap-2 my5" >
136140 <div
137- v-if = " getSlideClicks(route) "
138- class = " flex gap-0.5 op50 items-center justify-end "
139- :title = " `Clicks in this slide: ${getSlideClicks (route)}` "
141+ class = " border rounded border-main overflow-hidden bg-main select-none h-max "
142+ :style = " themeVars "
143+ @dblclick = " openSlideInNewTab (route.path) "
140144 >
141- <carbon:cursor-1 text-sm />
142- {{ getSlideClicks(route) }}
145+ <SlideContainer
146+ :key =" route.path"
147+ :width =" cardWidth"
148+ :clicks-disabled =" true"
149+ class =" pointer-events-none important:[& _*]:select-none"
150+ >
151+ <SlideWrapper
152+ :is =" route.component"
153+ v-if =" route?.component"
154+ :clicks-context =" getClickContext(route)[1]"
155+ :class =" getSlideClass(route)"
156+ :route =" route"
157+ render-context =" overview"
158+ />
159+ <DrawingPreview :page =" +route.path" />
160+ </SlideContainer >
143161 </div >
144- </div >
145- <div
146- class =" border rounded border-main overflow-hidden bg-main my5 select-none h-max"
147- :style =" themeVars"
148- @dblclick =" openSlideInNewTab(route.path)"
149- >
150- <SlideContainer
151- :key =" route.path"
152- :width =" cardWidth"
153- :clicks-disabled =" true"
154- class =" pointer-events-none important:[& _*]:select-none"
155- >
156- <SlideWrapper
157- :is =" route.component"
158- v-if =" route?.component"
159- :clicks-context =" getClickContext(route)"
160- :class =" getSlideClass(route)"
161- :route =" route"
162- render-context =" overview"
163- />
164- <DrawingPreview :page =" +route.path" />
165- </SlideContainer >
162+ <OverviewClicksSlider
163+ v-if =" getSlideClicks(route)"
164+ mt-2
165+ :click-context =" getClickContext(route)"
166+ class =" w-full"
167+ />
166168 </div >
167169 <div class =" py3 mt-0.5 mr--8 ml--4 op0 transition group-hover:op100" >
168170 <IconButton
0 commit comments