@hanology/cham-browser 0.4.65 → 0.4.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/src/App.vue +16 -1
- package/template/src/components/PartBlock.vue +18 -5
- package/template/src/components/ReadingToolbar.vue +5 -5
- package/template/src/components/SideNav.vue +5 -5
- package/template/src/composables/useAnnotationRenderer.ts +0 -4
- package/template/src/styles/main.css +3 -1
- package/template/src/views/AuthorView.vue +2 -2
- package/template/src/views/PieceView.vue +8 -8
package/package.json
CHANGED
package/template/src/App.vue
CHANGED
|
@@ -56,7 +56,9 @@ function onKey(event: KeyboardEvent) {
|
|
|
56
56
|
<Suspense :key="route.fullPath">
|
|
57
57
|
<component :is="Component" />
|
|
58
58
|
<template #fallback>
|
|
59
|
-
<div class="route-loading"
|
|
59
|
+
<div class="route-loading">
|
|
60
|
+
<div class="route-loading-seal">文</div>
|
|
61
|
+
</div>
|
|
60
62
|
</template>
|
|
61
63
|
</Suspense>
|
|
62
64
|
</Transition>
|
|
@@ -175,4 +177,17 @@ function onKey(event: KeyboardEvent) {
|
|
|
175
177
|
justify-content: center;
|
|
176
178
|
min-height: 100vh;
|
|
177
179
|
}
|
|
180
|
+
.route-loading-seal {
|
|
181
|
+
width: 56px; height: 56px;
|
|
182
|
+
border: 2px solid var(--vermillion);
|
|
183
|
+
border-radius: 4px;
|
|
184
|
+
display: flex; align-items: center; justify-content: center;
|
|
185
|
+
font-size: 28px; font-weight: 900;
|
|
186
|
+
color: var(--vermillion);
|
|
187
|
+
animation: pulse 1.2s ease-in-out infinite;
|
|
188
|
+
}
|
|
189
|
+
@keyframes pulse {
|
|
190
|
+
0%, 100% { opacity: 0.6; transform: scale(0.96); }
|
|
191
|
+
50% { opacity: 1; transform: scale(1); }
|
|
192
|
+
}
|
|
178
193
|
</style>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
2
3
|
import type { Annotation, VerseLine, PieceSource } from '../types'
|
|
3
|
-
import { buildVerseAnnotations, renderAnnotatedText, resolveHoveredAnnotations
|
|
4
|
+
import { buildVerseAnnotations, renderAnnotatedText, resolveHoveredAnnotations } from '../composables/useAnnotationRenderer'
|
|
4
5
|
|
|
5
6
|
const props = defineProps<{
|
|
6
7
|
num: number
|
|
@@ -17,12 +18,24 @@ const emit = defineEmits<{
|
|
|
17
18
|
annotationTap: [event: MouseEvent, annotations: Annotation[]]
|
|
18
19
|
}>()
|
|
19
20
|
|
|
21
|
+
const allVerseSpans = computed(() =>
|
|
22
|
+
props.verses.map((_, i) => buildVerseAnnotations(props.annotations, i))
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const verseOffsets = computed(() => {
|
|
26
|
+
const offsets: number[] = []
|
|
27
|
+
let acc = 0
|
|
28
|
+
for (const spans of allVerseSpans.value) {
|
|
29
|
+
offsets.push(acc)
|
|
30
|
+
acc += spans.length
|
|
31
|
+
}
|
|
32
|
+
return offsets
|
|
33
|
+
})
|
|
34
|
+
|
|
20
35
|
function verseHtml(index: number): string {
|
|
21
36
|
const useRuby = props.vertical
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const spans = buildVerseAnnotations(props.annotations, index)
|
|
25
|
-
return renderAnnotatedText(props.verses[index].text, spans, useRuby, offset)
|
|
37
|
+
const spans = allVerseSpans.value[index]
|
|
38
|
+
return renderAnnotatedText(props.verses[index].text, spans, useRuby, verseOffsets.value[index])
|
|
26
39
|
}
|
|
27
40
|
|
|
28
41
|
function onHover(event: MouseEvent) {
|
|
@@ -68,12 +68,12 @@ function close() { open.value = false }
|
|
|
68
68
|
<div class="rt-label">{{ t('settings.theme') }}</div>
|
|
69
69
|
<div class="rt-options">
|
|
70
70
|
<button
|
|
71
|
-
v-for="
|
|
72
|
-
:key="
|
|
71
|
+
v-for="th in THEMES"
|
|
72
|
+
:key="th"
|
|
73
73
|
class="rt-opt rt-theme"
|
|
74
|
-
:class="{ active: theme ===
|
|
75
|
-
@click="setTheme(
|
|
76
|
-
>{{ t('theme.' +
|
|
74
|
+
:class="{ active: theme === th, ['theme-' + th]: true }"
|
|
75
|
+
@click="setTheme(th)"
|
|
76
|
+
>{{ t('theme.' + th) }}</button>
|
|
77
77
|
</div>
|
|
78
78
|
</div>
|
|
79
79
|
<div class="rt-group">
|
|
@@ -78,12 +78,12 @@ function toggleSettings() { settingsOpen.value = !settingsOpen.value }
|
|
|
78
78
|
<div class="ss-label">{{ t('settings.theme') }}</div>
|
|
79
79
|
<div class="ss-options">
|
|
80
80
|
<button
|
|
81
|
-
v-for="
|
|
82
|
-
:key="
|
|
81
|
+
v-for="th in THEMES"
|
|
82
|
+
:key="th"
|
|
83
83
|
class="ss-opt"
|
|
84
|
-
:class="{ active: theme ===
|
|
85
|
-
@click="setTheme(
|
|
86
|
-
>{{ t('theme.' +
|
|
84
|
+
:class="{ active: theme === th }"
|
|
85
|
+
@click="setTheme(th)"
|
|
86
|
+
>{{ t('theme.' + th) }}</button>
|
|
87
87
|
</div>
|
|
88
88
|
</div>
|
|
89
89
|
<div class="ss-group">
|
|
@@ -51,10 +51,6 @@ export function buildVerseAnnotations(annotations: Annotation[], verseIndex: num
|
|
|
51
51
|
return segments
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export function countVerseSpans(annotations: Annotation[], verseIndex: number): number {
|
|
55
|
-
return buildVerseAnnotations(annotations, verseIndex).length
|
|
56
|
-
}
|
|
57
|
-
|
|
58
54
|
export function renderAnnotatedText(text: string, spans: AnnSpan[], useRuby = false, startNum = 0): string {
|
|
59
55
|
if (!spans.length) return esc(text)
|
|
60
56
|
|
|
@@ -132,6 +132,7 @@
|
|
|
132
132
|
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
|
|
133
133
|
html {
|
|
134
134
|
scroll-behavior: smooth;
|
|
135
|
+
scroll-padding-top: 56px;
|
|
135
136
|
-webkit-font-smoothing: antialiased;
|
|
136
137
|
-moz-osx-font-smoothing: grayscale;
|
|
137
138
|
text-rendering: optimizeLegibility;
|
|
@@ -144,6 +145,7 @@ body {
|
|
|
144
145
|
line-height: 1.8;
|
|
145
146
|
min-height: 100vh;
|
|
146
147
|
overflow-x: hidden;
|
|
148
|
+
overscroll-behavior-y: contain;
|
|
147
149
|
}
|
|
148
150
|
::selection { background: var(--vermillion); color: var(--selection-text); }
|
|
149
151
|
::-webkit-scrollbar { width: 6px; height: 6px; }
|
|
@@ -321,7 +323,7 @@ button:focus-visible {
|
|
|
321
323
|
/* ===== DARK MODE VERTICAL WARMTH ===== */
|
|
322
324
|
[data-theme="dark"] .v-scroll,
|
|
323
325
|
[data-theme="oled"] .v-scroll {
|
|
324
|
-
box-shadow: 0 0 40px
|
|
326
|
+
box-shadow: 0 0 40px color-mix(in srgb, var(--vermillion) 3%, transparent), 0 4px 16px rgba(var(--shadow-rgb), 0.2);
|
|
325
327
|
}
|
|
326
328
|
|
|
327
329
|
[data-theme="dark"] .sb-vertical,
|
|
@@ -151,7 +151,7 @@ function goHome() { router.push('/') }
|
|
|
151
151
|
flex-direction: row-reverse;
|
|
152
152
|
overflow-x: auto;
|
|
153
153
|
overflow-y: hidden;
|
|
154
|
-
margin-right: var(--nav-width, 56px);
|
|
154
|
+
margin-right: calc(var(--nav-width, 56px) + env(safe-area-inset-right, 0px));
|
|
155
155
|
padding: 0 32px;
|
|
156
156
|
background: var(--paper);
|
|
157
157
|
scrollbar-width: thin;
|
|
@@ -349,6 +349,6 @@ function goHome() { router.push('/') }
|
|
|
349
349
|
.h-hero { flex-direction: column; text-align: center; padding: 24px; }
|
|
350
350
|
.h-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
|
|
351
351
|
.h-content { padding: 30px 20px; }
|
|
352
|
-
.v-page { padding: 0 16px; }
|
|
352
|
+
.v-page { padding: 0 16px; margin-right: calc(var(--nav-width, 44px) + env(safe-area-inset-right, 0px)); }
|
|
353
353
|
}
|
|
354
354
|
</style>
|
|
@@ -364,13 +364,13 @@ function tcy(n: number): string {
|
|
|
364
364
|
<template v-if="piece.contributors && piece.contributors.length > 1">
|
|
365
365
|
<div v-for="group in contributorGroups" :key="group.title" class="v-author-group">
|
|
366
366
|
<span class="v-author-role">{{ group.title }}</span>
|
|
367
|
-
<span v-for="name in group.names" :key="name" class="v-poem-author" @click="openAuthorPane(piece.contributors!.find(c => c.name === name)?.id)">{{ name }}</span>
|
|
367
|
+
<span v-for="name in group.names" :key="name" class="v-poem-author" role="button" tabindex="0" @click="openAuthorPane(piece.contributors!.find(c => c.name === name)?.id)" @keydown.enter="openAuthorPane(piece.contributors!.find(c => c.name === name)?.id)">{{ name }}</span>
|
|
368
368
|
</div>
|
|
369
369
|
</template>
|
|
370
|
-
<span v-else class="v-poem-author" @click="openAuthorPane">{{ piece.author }}</span>
|
|
371
|
-
<
|
|
370
|
+
<span v-else class="v-poem-author" role="button" tabindex="0" @click="openAuthorPane" @keydown.enter="openAuthorPane">{{ piece.author }}</span>
|
|
371
|
+
<router-link v-if="piece.source?.textRef" :to="`/${piece.source.textRef}`" class="v-source-link">
|
|
372
372
|
← {{ meta?.title }}
|
|
373
|
-
</
|
|
373
|
+
</router-link>
|
|
374
374
|
<div class="v-poem-meta">
|
|
375
375
|
<template v-if="isMultiPart">
|
|
376
376
|
<span class="v-meta-item" v-html="tcy(piece.parts!.length) + ' ' + t('piece.stanzas')" />
|
|
@@ -543,9 +543,9 @@ function tcy(n: number): string {
|
|
|
543
543
|
<div class="h-nav-title-row">
|
|
544
544
|
<span v-if="piece.era" class="h-era">{{ piece.era }}</span>
|
|
545
545
|
<span class="h-breadcrumb">
|
|
546
|
-
<
|
|
546
|
+
<router-link v-if="piece.source?.textRef" :to="`/${piece.source.textRef}`" class="h-source-link">
|
|
547
547
|
{{ meta?.title }} →
|
|
548
|
-
</
|
|
548
|
+
</router-link>
|
|
549
549
|
<span class="h-sep">{{ piece.num }}.</span>
|
|
550
550
|
{{ piece.title }}
|
|
551
551
|
</span>
|
|
@@ -553,10 +553,10 @@ function tcy(n: number): string {
|
|
|
553
553
|
<template v-for="(group, gi) in contributorGroups" :key="group.title">
|
|
554
554
|
<span v-if="gi > 0" class="h-sep">|</span>
|
|
555
555
|
<span class="h-author-role">{{ group.title }}</span>
|
|
556
|
-
<span v-for="name in group.names" :key="name" class="h-author-link" @click="openAuthorPane(piece.contributors!.find(c => c.name === name)?.id)">{{ name }}</span>
|
|
556
|
+
<span v-for="name in group.names" :key="name" class="h-author-link" role="button" tabindex="0" @click="openAuthorPane(piece.contributors!.find(c => c.name === name)?.id)" @keydown.enter="openAuthorPane(piece.contributors!.find(c => c.name === name)?.id)">{{ name }}</span>
|
|
557
557
|
</template>
|
|
558
558
|
</template>
|
|
559
|
-
<span v-else class="h-author-link" @click="openAuthorPane">{{ piece.author }}</span>
|
|
559
|
+
<span v-else class="h-author-link" role="button" tabindex="0" @click="openAuthorPane" @keydown.enter="openAuthorPane">{{ piece.author }}</span>
|
|
560
560
|
</div>
|
|
561
561
|
<div class="h-controls">
|
|
562
562
|
<span class="h-tag h-tag-pager">{{ piece.num }} / {{ pieces.length }}</span>
|