Skip to content

Commit

Permalink
fix: ui improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Feb 26, 2024
1 parent 0b2450c commit 8443a52
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 70 deletions.
2 changes: 2 additions & 0 deletions demo/starter/slides.md
Expand Up @@ -176,6 +176,8 @@ Notes can also sync with clicks
[click:3] Last click (skip two clicks)
-->

---
level: 2
---

# Shiki Magic Move
Expand Down
6 changes: 4 additions & 2 deletions packages/client/composables/useClicks.ts
Expand Up @@ -69,7 +69,9 @@ export function usePrimaryClicks(route: RouteRecordRaw | undefined): ClicksConte
const thisPath = +(route?.path ?? CLICKS_MAX)
const current = computed({
get() {
const currentPath = +(currentRoute.value?.path ?? CLICKS_MAX)
const currentPath = +(currentRoute.value?.path ?? Number.NaN)
if (!currentPath || Number.isNaN(currentPath))
return 0
if (currentPath === thisPath)
return queryClicks.value
else if (currentPath > thisPath)
Expand All @@ -78,7 +80,7 @@ export function usePrimaryClicks(route: RouteRecordRaw | undefined): ClicksConte
return 0
},
set(v) {
const currentPath = +(currentRoute.value?.path ?? CLICKS_MAX)
const currentPath = +(currentRoute.value?.path ?? Number.NaN)
if (currentPath === thisPath)
queryClicks.value = v
},
Expand Down
4 changes: 2 additions & 2 deletions packages/client/internals/Controls.vue
Expand Up @@ -2,7 +2,7 @@
import { shallowRef } from 'vue'
import { showInfoDialog, showOverview, showRecordingDialog } from '../state'
import { configs } from '../env'
import SlidesOverview from './SlidesOverview.vue'
import QuickOverview from './QuickOverview.vue'
import InfoDialog from './InfoDialog.vue'
import Goto from './Goto.vue'
Expand All @@ -15,7 +15,7 @@ if (__SLIDEV_FEATURE_RECORD__) {
</script>

<template>
<SlidesOverview v-model="showOverview" />
<QuickOverview v-model="showOverview" />
<Goto />
<WebCamera v-if="WebCamera" />
<RecordingDialog v-if="RecordingDialog" v-model="showRecordingDialog" />
Expand Down
5 changes: 3 additions & 2 deletions packages/client/internals/IconButton.vue
Expand Up @@ -2,14 +2,15 @@
defineProps<{
title: string
icon?: string
as?: string
}>()
</script>

<template>
<button class="slidev-icon-btn" :title="title" v-bind="$attrs">
<component :is="as || 'button'" class="slidev-icon-btn" :title="title" v-bind="$attrs">
<span class="sr-only">{{ title }}</span>
<slot>
<div :class="icon" />
</slot>
</button>
</component>
</template>
4 changes: 2 additions & 2 deletions packages/client/internals/NavControls.vue
Expand Up @@ -114,13 +114,13 @@ if (__SLIDEV_FEATURE_DRAWINGS__)
<IconButton
v-if="__DEV__ && __SLIDEV_FEATURE_EDITOR__"
:title="showEditor ? 'Hide editor' : 'Show editor'"
class="<md:hidden"
class="lt-md:hidden"
@click="showEditor = !showEditor"
>
<carbon:text-annotation-toggle />
</IconButton>

<IconButton v-if="isPresenter" title="Toggle Presenter Layout" @click="togglePresenterLayout">
<IconButton v-if="isPresenter" title="Toggle Presenter Layout" class="aspect-ratio-initial" @click="togglePresenterLayout">
<carbon:template />
{{ presenterLayout }}
</IconButton>
Expand Down
10 changes: 8 additions & 2 deletions packages/client/internals/NoteDisplay.vue
Expand Up @@ -129,18 +129,24 @@ onMounted(() => {
/>
<div
v-else-if="note"
class="prose overflow-auto outline-none"
class="prose overflow-auto outline-none slidev-note"
:class="props.class"
@click="$emit('click')"
>
<p v-text="note" />
</div>
<div
v-else
class="prose overflow-auto outline-none opacity-50 italic select-none"
class="prose overflow-auto outline-none opacity-50 italic select-none slidev-note"
:class="props.class"
@click="$emit('click')"
>
<p v-text="props.placeholder || 'No notes.'" />
</div>
</template>

<style>
.slidev-note :first-child {
margin-top: 0;
}
</style>
11 changes: 4 additions & 7 deletions packages/client/internals/NoteEditor.vue
Expand Up @@ -83,24 +83,22 @@ function calculateHeight() {
}
const inputHeight = ref<number | null>()
watchEffect(() => {
calculateHeight()
})
watch(
note,
() => {
nextTick(() => {
calculateHeight()
})
},
{ flush: 'post' },
{ flush: 'post', immediate: true },
)
</script>

<template>
<NoteDisplay
v-if="!editing"
class="my--4 border-transparent border-2"
class="border-transparent border-2"
:class="[props.class, note ? '' : 'opacity-25 italic select-none']"
:style="props.style"
:note="note || placeholder"
Expand All @@ -117,7 +115,6 @@ watch(
:style="[props.style, inputHeight != null ? { height: `${inputHeight}px` } : {}]"
:class="props.class"
:placeholder="placeholder"
@keydown.esc=" editing = false"
@focus="editing = true"
@keydown.esc="editing = false"
/>
</template>
Expand Up @@ -164,18 +164,19 @@ watchEffect(() => {
</div>
</div>
</Transition>
<div v-if="value" class="fixed top-4 right-4 text-gray-400 flex items-center gap-4">
<RouterLink
v-if="__DEV__"
<div v-if="value" class="fixed top-4 right-4 text-gray-400 flex flex-col items-center gap-2">
<IconButton title="Close" class="text-2xl" @click="close">
<carbon:close />
</IconButton>
<IconButton
as="a"
title="Slides Overview"
target="_blank"
to="/overview"
href="/overview"
tab-index="-1"
class="border-main border px3 py1 rounded hover:bg-gray/5 hover:text-primary"
class="text-2xl"
>
List overview
</RouterLink>
<IconButton title="Close" class="text-2xl" @click="close">
<carbon:close />
<carbon:list-boxes />
</IconButton>
</div>
</template>
2 changes: 1 addition & 1 deletion packages/client/internals/RecordingControls.vue
Expand Up @@ -54,7 +54,7 @@ onMounted(() => {
</IconButton>
<MenuButton :disabled="recording">
<template #button>
<IconButton title="Select recording device" class="h-full !text-sm !px-0">
<IconButton title="Select recording device" class="h-full !text-sm !px-0 aspect-initial">
<carbon:chevron-up class="opacity-50" />
</IconButton>
</template>
Expand Down
5 changes: 3 additions & 2 deletions packages/client/pages/overview.vue
Expand Up @@ -3,7 +3,7 @@ import { computed, nextTick, onMounted, reactive, ref } from 'vue'
import { useHead } from '@unhead/vue'
import type { RouteRecordRaw } from 'vue-router'
import type { ClicksContext } from 'packages/types'
import { themeVars } from '../env'
import { configs, themeVars } from '../env'
import { openInEditor, rawRoutes } from '../logic/nav'
import { useFixedClicks } from '../composables/useClicks'
import { isColorSchemaConfigured, isDark, toggleDark } from '../logic/dark'
Expand All @@ -18,8 +18,9 @@ import { CLICKS_MAX } from '../constants'
const cardWidth = 450
const slideTitle = configs.titleTemplate.replace('%s', configs.title || 'Slidev')
useHead({
title: 'List Overview',
title: `Overview - ${slideTitle}`,
})
const blocks: Map<number, HTMLElement> = reactive(new Map())
Expand Down
76 changes: 35 additions & 41 deletions packages/client/pages/presenter.vue
Expand Up @@ -14,7 +14,7 @@ import { useFixedClicks } from '../composables/useClicks'
import SlideWrapper from '../internals/SlideWrapper'
import SlideContainer from '../internals/SlideContainer.vue'
import NavControls from '../internals/NavControls.vue'
import SlidesOverview from '../internals/SlidesOverview.vue'
import QuickOverview from '../internals/QuickOverview.vue'
import NoteEditor from '../internals/NoteEditor.vue'
import NoteStatic from '../internals/NoteStatic.vue'
import Goto from '../internals/Goto.vue'
Expand Down Expand Up @@ -45,12 +45,19 @@ const nextFrame = computed(() => {
else
return null
})
const nextFrameClicksCtx = computed(() => {
return nextFrame.value && clicksCtxMap[+nextFrame.value[0].path - 1]
})
watch([currentRoute, queryClicks], () => {
nextFrameClicksCtx.value && (nextFrameClicksCtx.value.current = nextFrame.value![1])
}, { immediate: true })
watch(
[currentRoute, queryClicks],
() => {
if (nextFrameClicksCtx.value)
nextFrameClicksCtx.value.current = nextFrame.value![1]
},
{ immediate: true },
)
const SideEditor = shallowRef<any>()
if (__DEV__ && __SLIDEV_FEATURE_EDITOR__)
Expand Down Expand Up @@ -86,21 +93,6 @@ onMounted(() => {
<template>
<div class="bg-main h-full slidev-presenter">
<div class="grid-container" :class="`layout${presenterLayout}`">
<div class="grid-section top flex">
<img src="../assets/logo-title-horizontal.png" class="ml-2 my-auto h-10 py-1 lg:h-14 lg:py-2" style="height: 3.5rem;" alt="Slidev logo">
<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 tabular-nums">
{{ timer }}
</div>
</div>
<div ref="main" class="relative grid-section main flex flex-col p-2 lg:p-4" :style="themeVars">
<SlideContainer
key="main"
Expand All @@ -110,8 +102,8 @@ onMounted(() => {
<SlidesShow render-context="presenter" />
</template>
</SlideContainer>
<div class="context">
current
<div class="absolute left-0 top-0 bg-main border-b border-r border-main px2 py1 op50 text-sm">
Current
</div>
</div>
<div class="relative grid-section next flex flex-col p-2 lg:p-4" :style="themeVars">
Expand All @@ -129,8 +121,8 @@ onMounted(() => {
render-context="previewNext"
/>
</SlideContainer>
<div class="context">
next
<div class="absolute left-0 top-0 bg-main border-b border-r border-main px2 py1 op50 text-sm">
Next
</div>
</div>
<!-- Notes -->
Expand All @@ -141,9 +133,9 @@ onMounted(() => {
<NoteEditor
v-if="__DEV__"
:key="`edit-${currentSlideId}`"
v-model:editing="notesEditing"
:no="currentSlideId"
class="w-full max-w-full h-full overflow-auto p-2 lg:p-4"
:editing="notesEditing"
:clicks-context="clicksContext"
:style="{ fontSize: `${presenterNotesFontSize}em` }"
/>
Expand Down Expand Up @@ -171,8 +163,20 @@ onMounted(() => {
</IconButton>
</div>
</div>
<div class="grid-section bottom">
<div class="grid-section bottom flex">
<NavControls :persist="true" />
<div 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 tabular-nums">
{{ timer }}
</div>
</div>
<DrawingControls v-if="__SLIDEV_FEATURE_DRAWINGS__" />
</div>
Expand All @@ -184,7 +188,7 @@ onMounted(() => {
</div>
</div>
<Goto />
<SlidesOverview v-model="showOverview" />
<QuickOverview v-model="showOverview" />
</template>

<style scoped>
Expand All @@ -204,7 +208,7 @@ onMounted(() => {
}
.grid-container {
--uno: bg-active;
--uno: bg-gray/20;
height: 100%;
width: 100%;
display: grid;
Expand All @@ -213,19 +217,17 @@ onMounted(() => {
.grid-container.layout1 {
grid-template-columns: 1fr 1fr;
grid-template-rows: min-content 2fr 1fr min-content;
grid-template-rows: 2fr 1fr min-content;
grid-template-areas:
'top top'
'main main'
'note next'
'bottom bottom';
}
.grid-container.layout2 {
grid-template-columns: 3fr 2fr;
grid-template-rows: min-content 2fr 1fr min-content;
grid-template-rows: 2fr 1fr min-content;
grid-template-areas:
'top top'
'note main'
'note next'
'bottom bottom';
Expand All @@ -234,9 +236,8 @@ onMounted(() => {
@media (max-aspect-ratio: 3/5) {
.grid-container.layout1 {
grid-template-columns: 1fr;
grid-template-rows: min-content 1fr 1fr 1fr min-content;
grid-template-rows: 1fr 1fr 1fr min-content;
grid-template-areas:
'top'
'main'
'note'
'next'
Expand All @@ -247,9 +248,8 @@ onMounted(() => {
@media (min-aspect-ratio: 1/1) {
.grid-container.layout1 {
grid-template-columns: 1fr 1.1fr 0.9fr;
grid-template-rows: min-content 1fr 2fr min-content;
grid-template-rows: 1fr 2fr min-content;
grid-template-areas:
'top top top'
'main main next'
'main main note'
'bottom bottom bottom';
Expand Down Expand Up @@ -279,10 +279,4 @@ onMounted(() => {
.grid-section.bottom {
grid-area: bottom;
}
.context {
position: absolute;
top: 0;
left: 0;
--uno: px-1 text-xs bg-gray-400 bg-opacity-50 opacity-75 rounded-br-md;
}
</style>

0 comments on commit 8443a52

Please sign in to comment.