-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Presenter.vue
212 lines (193 loc) · 5.26 KB
/
Presenter.vue
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
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
210
211
212
<script setup lang="ts">
import { useHead } from '@vueuse/head'
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { useMouse, useWindowFocus } from '@vueuse/core'
import { clicks, clicksTotal, currentPage, currentRoute, hasNext, nextRoute, total, useSwipeControls } from '../logic/nav'
import { showOverview, showPresenterCursor } from '../state'
import { configs, themeVars } from '../env'
import { sharedState } from '../state/shared'
import { registerShortcuts } from '../logic/shortcuts'
import { getSlideClass } from '../utils'
import { useTimer } from '../logic/utils'
import { isDrawing } from '../logic/drawings'
import SlideContainer from './SlideContainer.vue'
import NavControls from './NavControls.vue'
import SlidesOverview from './SlidesOverview.vue'
import NoteEditor from './NoteEditor.vue'
import Goto from './Goto.vue'
import SlidesShow from './SlidesShow.vue'
import SlideWrapper from './SlideWrapper'
import DrawingControls from './DrawingControls.vue'
const main = ref<HTMLDivElement>()
registerShortcuts()
useSwipeControls(main)
const slideTitle = configs.titleTemplate.replace('%s', configs.title || 'Slidev')
useHead({
title: `Presenter - ${slideTitle}`,
})
const { timer, resetTimer } = useTimer()
const nextTabElements = ref([])
const nextSlide = computed(() => {
if (clicks.value < clicksTotal.value) {
return {
route: currentRoute.value,
clicks: clicks.value + 1,
}
}
else {
if (hasNext.value) {
return {
route: nextRoute.value,
clicks: 0,
}
}
else {
return null
}
}
})
// sync presenter cusor
onMounted(() => {
const slidesContainer = main.value!.querySelector('#slide-content')!
const mouse = reactive(useMouse())
const focus = useWindowFocus()
watch(
() => {
if (!focus.value || isDrawing.value || !showPresenterCursor.value)
return undefined
const rect = slidesContainer.getBoundingClientRect()
const x = (mouse.x - rect.left) / rect.width * 100
const y = (mouse.y - rect.top) / rect.height * 100
if (x < 0 || x > 100 || y < 0 || y > 100)
return undefined
return { x, y }
},
(pos) => {
sharedState.cursor = pos
},
)
})
</script>
<template>
<div class="bg-main h-full slidev-presenter">
<div class="grid-container">
<div class="grid-section top flex">
<img src="../assets/logo-title-horizontal.png" class="h-14 ml-2 py-2 my-auto">
<div class="flex-auto" />
<div
class="timer-btn my-auto relative w-22px h-22px cursor-pointer text-lg"
opacity="50 hover:100"
@click="resetTimer"
>
<carbon:time class="absolute" />
<carbon:renew class="absolute opacity-0" />
</div>
<div class="text-2xl pl-2 pr-6 my-auto">
{{ timer }}
</div>
</div>
<div ref="main" class="grid-section main flex flex-col p-4" :style="themeVars">
<SlideContainer
key="main"
class="h-full w-full"
>
<template #>
<SlidesShow context="presenter" />
</template>
</SlideContainer>
</div>
<div class="grid-section next flex flex-col p-4">
<SlideContainer
v-if="nextSlide"
key="next"
class="h-full w-full"
>
<SlideWrapper
:is="nextSlide.route?.component"
v-model:clicks-elements="nextTabElements"
:clicks="nextSlide.clicks"
:clicks-disabled="false"
:class="getSlideClass(nextSlide.route)"
:route="nextSlide.route"
context="previewNext"
/>
</SlideContainer>
</div>
<div class="grid-section note overflow-auto">
<NoteEditor class="w-full h-full p-4 overflow-auto" />
</div>
<div class="grid-section bottom">
<NavControls :persist="true" />
</div>
<DrawingControls v-if="__SLIDEV_FEATURE_DRAWINGS__" />
</div>
<div class="progress-bar">
<div
class="progress h-2px bg-primary transition-all"
:style="{ width: `${(currentPage - 1) / (total - 1) * 100}%` }"
/>
</div>
</div>
<Goto />
<SlidesOverview v-model="showOverview" />
</template>
<style lang="postcss" scoped>
.slidev-presenter {
--slidev-controls-foreground: current;
}
.timer-btn:hover {
& > :first-child {
@apply opacity-0;
}
& > :last-child {
@apply opacity-100;
}
}
.section-title {
@apply px-4 py-2 text-xl;
}
.grid-container {
@apply h-full w-full bg-gray-400 bg-opacity-15;
display: grid;
gap: 1px 1px;
grid-template-columns: 1fr 1fr;
grid-template-rows: min-content 2fr 1fr min-content;
grid-template-areas:
"top top"
"main main"
"note next"
"bottom bottom";
}
@screen md {
.grid-container {
grid-template-columns: 1fr 1.1fr 0.9fr;
grid-template-rows: min-content 1fr 2fr min-content;
grid-template-areas:
"top top top"
"main main next"
"main main note"
"bottom bottom bottom";
}
}
.progress-bar {
@apply fixed left-0 right-0 bottom-0;
}
.grid-section {
@apply bg-main;
&.top {
grid-area: top;
}
&.main {
grid-area: main;
}
&.next {
grid-area: next;
}
&.note {
grid-area: note;
}
&.bottom {
grid-area: bottom;
}
}
</style>