Commit 14f2a60a4a
Unsigned
Layout: unified · split
docs/.vitepress/post/1. retro-archives-and-blogs.md added +5
| @@ -0,0 +1,5 @@ | |||
| 1 | --- | ||
| 2 | type: section | ||
| 3 | title: Retro Archives & Blogs | ||
| 4 | link: /misc?t=retro-archives-blogs | ||
| 5 | --- | ||
docs/.vitepress/post/10. live-action.md added +6
| @@ -0,0 +1,6 @@ | |||
| 1 | --- | ||
| 2 | type: section | ||
| 3 | title: Live Action | ||
| 4 | link: /websites#live-action | ||
| 5 | --- | ||
| 6 | |||
docs/.vitepress/post/2. url-search.md added +9
| @@ -0,0 +1,9 @@ | |||
| 1 | --- | ||
| 2 | type: component | ||
| 3 | title: URL Search | ||
| 4 | --- | ||
| 5 | |||
| 6 | You can now directly search urls in the wiki. Directly clicking on the URL will open it on new tab, clicking on the card will take you to the section. Click on the search settings and select URL search mode. | ||
| 7 | |||
| 8 | <video src="/post/searchurl/vid1.webm" controls muted playsinline></video> | ||
| 9 | |||
docs/.vitepress/post/3. home-cards.md added +20
| @@ -0,0 +1,20 @@ | |||
| 1 | --- | ||
| 2 | type: component | ||
| 3 | title: Home Cards | ||
| 4 | --- | ||
| 5 | |||
| 6 | The homepage cards are now customizable. You can now select whichever cards you really want and how many; every page in the wiki or none at all. | ||
| 7 | |||
| 8 | <video src="/post/homefeature/vid1.webm" controls muted playsinline></video> | ||
| 9 | |||
| 10 | <hr> | ||
| 11 | |||
| 12 | You can shuffle them however you want. You can even select a specific page from a folder, instead of having the whole thing. | ||
| 13 | |||
| 14 | <video src="/post/homefeature/vid2.webm" controls muted playsinline></video> | ||
| 15 | |||
| 16 | <hr> | ||
| 17 | |||
| 18 | There is also mini layout which saves spaces and you have to scroll less in phone layout. | ||
| 19 | |||
| 20 | <video src="/post/homefeature/vid3.webm" controls muted playsinline></video>\ No newline at end of file | ||
docs/.vitepress/post/4. accent-color.md added +8
| @@ -0,0 +1,8 @@ | |||
| 1 | --- | ||
| 2 | type: component | ||
| 3 | title: Accent Color | ||
| 4 | --- | ||
| 5 | |||
| 6 | You can now select different accent color and accent color based background. | ||
| 7 | |||
| 8 |  | ||
docs/.vitepress/post/5. bookmarks.md added +14
| @@ -0,0 +1,14 @@ | |||
| 1 | --- | ||
| 2 | type: component | ||
| 3 | title: Bookmarks | ||
| 4 | --- | ||
| 5 | |||
| 6 | Now you can bookmark any header 2 and find them all in the bookmarks menu, grouped by page. In PC layout, hover over the ToC and click the bookmark icon. | ||
| 7 | |||
| 8 | <video src="/post/bookmark/vid1.webm" controls muted playsinline></video> | ||
| 9 | |||
| 10 | <hr> | ||
| 11 | |||
| 12 | In phone layout, click the ToC button and then the bookmark button. | ||
| 13 | |||
| 14 | <video src="/post/bookmark/vid2.webm" controls muted playsinline></video>\ No newline at end of file | ||
docs/.vitepress/post/6. pagination-and-excerpts.md added +12
| @@ -0,0 +1,12 @@ | |||
| 1 | --- | ||
| 2 | type: improvement | ||
| 3 | title: Search improvements | ||
| 4 | --- | ||
| 5 | |||
| 6 | Search now has quite a few improvements. | ||
| 7 | - Better search optimization | ||
| 8 | - Proper pagination | ||
| 9 | - Excerpts preload configeration | ||
| 10 | - History support | ||
| 11 | |||
| 12 | \ No newline at end of file | ||
docs/.vitepress/post/7. tab-and-collapsible-link.md added +10
| @@ -0,0 +1,10 @@ | |||
| 1 | --- | ||
| 2 | type: improvement | ||
| 3 | title: Tabs & Collapsible Links | ||
| 4 | --- | ||
| 5 | |||
| 6 | You can now share a speicific tab or collapsible. Example: | ||
| 7 | |||
| 8 | - `https://wotaku.wiki/misc?t=stats-more` | ||
| 9 | - `https://wotaku.wiki/misc?c=related-resources` | ||
| 10 | - `https://wotaku.wiki/misc?t=scanlation&c=related-resources-1`\ No newline at end of file | ||
docs/.vitepress/post/8. extension-repo.md added +8
| @@ -0,0 +1,8 @@ | |||
| 1 | --- | ||
| 2 | type: component | ||
| 3 | title: Extension Repos | ||
| 4 | --- | ||
| 5 | |||
| 6 | We now have a dedicated extension repo component, instead of using default markdown table. It should give you cleaner expereince. You can look through every repo and filter them based on language, types and other tags (based on source repo maintainer). | ||
| 7 | |||
| 8 | \ No newline at end of file | ||
docs/.vitepress/post/9. favicons.md added +8
| @@ -0,0 +1,8 @@ | |||
| 1 | --- | ||
| 2 | type: improvement | ||
| 3 | title: Favicons | ||
| 4 | --- | ||
| 5 | |||
| 6 | You can now have website favicons beside the URLs, if you want the URLs to have more disctinctive look. You can turn it on in the settings. | ||
| 7 | |||
| 8 | \ No newline at end of file | ||
docs/.vitepress/theme/announcements.data.ts added +69
| @@ -0,0 +1,69 @@ | |||
| 1 | import { readdirSync, readFileSync } from 'node:fs' | ||
| 2 | import { dirname, join } from 'node:path' | ||
| 3 | import { fileURLToPath } from 'node:url' | ||
| 4 | import matter from 'gray-matter' | ||
| 5 | import MarkdownIt from 'markdown-it' | ||
| 6 | |||
| 7 | export type AnnouncementType = 'section' | 'component' | 'improvement' | ||
| 8 | |||
| 9 | export interface Announcement { | ||
| 10 | id: string | ||
| 11 | type: AnnouncementType | ||
| 12 | title: string | ||
| 13 | html: string | ||
| 14 | link?: string // section type only | ||
| 15 | } | ||
| 16 | |||
| 17 | const THEME_DIR = dirname(fileURLToPath(import.meta.url)) | ||
| 18 | const POST_DIR = join(THEME_DIR, '../post') | ||
| 19 | |||
| 20 | const VALID_TYPES: AnnouncementType[] = ['section', 'component', 'improvement'] | ||
| 21 | |||
| 22 | const md = MarkdownIt({ html: true, linkify: true, breaks: false }) | ||
| 23 | |||
| 24 | function orderOf(id: string): number { | ||
| 25 | const m = id.match(/^(\d+)/) | ||
| 26 | return m ? parseInt(m[1], 10) : 0 | ||
| 27 | } | ||
| 28 | |||
| 29 | function normalizeType(raw: unknown): AnnouncementType { | ||
| 30 | const value = String(raw ?? '').toLowerCase() | ||
| 31 | return (VALID_TYPES as string[]).includes(value) | ||
| 32 | ? (value as AnnouncementType) | ||
| 33 | : 'improvement' | ||
| 34 | } | ||
| 35 | |||
| 36 | function loadAnnouncements(): Announcement[] { | ||
| 37 | let files: string[] = [] | ||
| 38 | try { | ||
| 39 | files = readdirSync(POST_DIR).filter((f) => f.endsWith('.md')) | ||
| 40 | } catch { | ||
| 41 | return [] | ||
| 42 | } | ||
| 43 | |||
| 44 | // highest number first (files numbered "1. name.md" with 1 = oldest) | ||
| 45 | files.sort((a, b) => orderOf(b) - orderOf(a)) | ||
| 46 | |||
| 47 | return files.map((file) => { | ||
| 48 | const raw = readFileSync(join(POST_DIR, file), 'utf-8') | ||
| 49 | const { data, content } = matter(raw) | ||
| 50 | // strip the "N. " prefix so read-state survives renumbering | ||
| 51 | const id = file.replace(/\.md$/, '').replace(/^\d+\.\s*/, '') | ||
| 52 | return { | ||
| 53 | id, | ||
| 54 | type: normalizeType(data.type), | ||
| 55 | title: String(data.title ?? id), | ||
| 56 | html: md.render(content), | ||
| 57 | link: data.link ? String(data.link) : undefined | ||
| 58 | } | ||
| 59 | }) | ||
| 60 | } | ||
| 61 | |||
| 62 | export declare const data: Announcement[] | ||
| 63 | |||
| 64 | export default { | ||
| 65 | watch: ['../post/*.md'], | ||
| 66 | load(): Announcement[] { | ||
| 67 | return loadAnnouncements() | ||
| 68 | } | ||
| 69 | } | ||
docs/.vitepress/theme/components/AnnouncementTypeSelect.vue added +278
| @@ -0,0 +1,278 @@ | |||
| 1 | <script setup lang="ts"> | ||
| 2 | import { NuInputHighlight, NuVerticalTransition } from '@nolebase/ui' | ||
| 3 | import { onMounted, onUnmounted, ref } from 'vue' | ||
| 4 | import type { AnnouncementType } from '../composables/useAnnouncements' | ||
| 5 | import MenuHelp from './settings/MenuHelp.vue' | ||
| 6 | import MenuTitle from './settings/MenuTitle.vue' | ||
| 7 | |||
| 8 | defineProps<{ | ||
| 9 | modelValue: string | ||
| 10 | }>() | ||
| 11 | |||
| 12 | const emit = defineEmits<{ | ||
| 13 | 'update:modelValue': [value: string] | ||
| 14 | }>() | ||
| 15 | |||
| 16 | const OPTIONS: { value: AnnouncementType; label: string }[] = [ | ||
| 17 | { value: 'section', label: 'Section' }, | ||
| 18 | { value: 'component', label: 'Component' }, | ||
| 19 | { value: 'improvement', label: 'Improvement' } | ||
| 20 | ] | ||
| 21 | |||
| 22 | function labelFor(value: string): string { | ||
| 23 | return OPTIONS.find((o) => o.value === value)?.label ?? 'All types' | ||
| 24 | } | ||
| 25 | |||
| 26 | const rootRef = ref<HTMLElement>() | ||
| 27 | const open = ref(false) | ||
| 28 | const menuTitleElementRef = ref<HTMLDivElement>() | ||
| 29 | const isMenuHelpPoppedUp = ref(false) | ||
| 30 | |||
| 31 | function select(value: string) { | ||
| 32 | emit('update:modelValue', value) | ||
| 33 | open.value = false | ||
| 34 | } | ||
| 35 | |||
| 36 | function onDocClick(e: MouseEvent) { | ||
| 37 | if (rootRef.value && !rootRef.value.contains(e.target as Node)) open.value = false | ||
| 38 | } | ||
| 39 | |||
| 40 | onMounted(() => document.addEventListener('click', onDocClick, true)) | ||
| 41 | onUnmounted(() => document.removeEventListener('click', onDocClick, true)) | ||
| 42 | </script> | ||
| 43 | |||
| 44 | <template> | ||
| 45 | <div ref="rootRef" class="ann-type-select" :class="{ 'ann-type-select--open': open }"> | ||
| 46 | <div ref="menuTitleElementRef" relative flex items-center mb-2> | ||
| 47 | <MenuTitle title="Type" aria-label="Type" flex="1" pr-4> | ||
| 48 | <template #icon> | ||
| 49 | <span i-lucide:tags mr-1 aria-hidden="true" /> | ||
| 50 | </template> | ||
| 51 | </MenuTitle> | ||
| 52 | <MenuHelp | ||
| 53 | v-model:is-popped-up="isMenuHelpPoppedUp" | ||
| 54 | :menu-title-element-ref="menuTitleElementRef" | ||
| 55 | > | ||
| 56 | <h4 class="sh-title"> | ||
| 57 | <span class="i-lucide:tags sh-title-icon" /> | ||
| 58 | Type | ||
| 59 | </h4> | ||
| 60 | <p class="sh-desc">Filters announcements by type.</p> | ||
| 61 | <div class="sh-options"> | ||
| 62 | <div class="sh-option"> | ||
| 63 | <strong> | ||
| 64 | <span class="i-lucide:panel-top sh-opt-icon" /> | ||
| 65 | Section | ||
| 66 | </strong> | ||
| 67 | <span>Jumps straight to a page section or tab</span> | ||
| 68 | </div> | ||
| 69 | <div class="sh-option"> | ||
| 70 | <strong> | ||
| 71 | <span class="i-lucide:box sh-opt-icon" /> | ||
| 72 | Component | ||
| 73 | </strong> | ||
| 74 | <span>A new interactive feature or widget</span> | ||
| 75 | </div> | ||
| 76 | <div class="sh-option"> | ||
| 77 | <strong> | ||
| 78 | <span class="i-lucide:sparkles sh-opt-icon" /> | ||
| 79 | Improvement | ||
| 80 | </strong> | ||
| 81 | <span>An enhancement to something existing</span> | ||
| 82 | </div> | ||
| 83 | </div> | ||
| 84 | </MenuHelp> | ||
| 85 | </div> | ||
| 86 | <NuInputHighlight :active="isMenuHelpPoppedUp" class="rounded-md"> | ||
| 87 | <button | ||
| 88 | type="button" | ||
| 89 | class="ann-type-trigger" | ||
| 90 | aria-haspopup="listbox" | ||
| 91 | :aria-expanded="open" | ||
| 92 | @click="open = !open" | ||
| 93 | > | ||
| 94 | <span class="ann-type-label">{{ labelFor(modelValue) }}</span> | ||
| 95 | <span class="ann-type-chevron i-lucide:chevron-down" :class="{ 'ann-type-chevron--open': open }" /> | ||
| 96 | </button> | ||
| 97 | |||
| 98 | <NuVerticalTransition :duration="200"> | ||
| 99 | <div v-show="open" class="ann-type-options" role="listbox"> | ||
| 100 | <button | ||
| 101 | type="button" | ||
| 102 | role="option" | ||
| 103 | class="ann-type-option" | ||
| 104 | :class="{ 'ann-type-option--selected': modelValue === '' }" | ||
| 105 | :aria-selected="modelValue === ''" | ||
| 106 | @click="select('')" | ||
| 107 | > | ||
| 108 | <span class="ann-type-option-label">All types</span> | ||
| 109 | </button> | ||
| 110 | <button | ||
| 111 | v-for="opt in OPTIONS" | ||
| 112 | :key="opt.value" | ||
| 113 | type="button" | ||
| 114 | role="option" | ||
| 115 | class="ann-type-option" | ||
| 116 | :class="{ 'ann-type-option--selected': modelValue === opt.value }" | ||
| 117 | :aria-selected="modelValue === opt.value" | ||
| 118 | @click="select(opt.value)" | ||
| 119 | > | ||
| 120 | <span class="ann-type-option-label">{{ opt.label }}</span> | ||
| 121 | </button> | ||
| 122 | </div> | ||
| 123 | </NuVerticalTransition> | ||
| 124 | </NuInputHighlight> | ||
| 125 | </div> | ||
| 126 | </template> | ||
| 127 | |||
| 128 | <style scoped> | ||
| 129 | .ann-type-select { | ||
| 130 | position: relative; | ||
| 131 | } | ||
| 132 | |||
| 133 | .ann-type-trigger { | ||
| 134 | display: flex; | ||
| 135 | align-items: center; | ||
| 136 | gap: 8px; | ||
| 137 | width: 100%; | ||
| 138 | min-height: 44px; | ||
| 139 | padding: 7px 10px; | ||
| 140 | border-radius: 8px; | ||
| 141 | border: 2px solid var(--vp-c-divider); | ||
| 142 | background: var(--wk-c-menu-bg); | ||
| 143 | color: var(--vp-c-text-1); | ||
| 144 | font-size: 13px; | ||
| 145 | cursor: pointer; | ||
| 146 | transition: border-color 0.15s, background-color 0.15s; | ||
| 147 | } | ||
| 148 | |||
| 149 | .ann-type-trigger:hover, | ||
| 150 | .ann-type-select--open .ann-type-trigger { | ||
| 151 | border-color: var(--vp-c-brand-1); | ||
| 152 | } | ||
| 153 | |||
| 154 | .ann-type-label { | ||
| 155 | flex: 1; | ||
| 156 | text-align: left; | ||
| 157 | } | ||
| 158 | |||
| 159 | .ann-type-chevron { | ||
| 160 | flex-shrink: 0; | ||
| 161 | color: var(--vp-c-text-2); | ||
| 162 | transition: transform 0.2s ease; | ||
| 163 | } | ||
| 164 | |||
| 165 | .ann-type-chevron--open { | ||
| 166 | transform: rotate(180deg); | ||
| 167 | } | ||
| 168 | |||
| 169 | .ann-type-options { | ||
| 170 | margin-top: 6px; | ||
| 171 | max-height: 240px; | ||
| 172 | overflow-y: auto; | ||
| 173 | overscroll-behavior: contain; | ||
| 174 | display: flex; | ||
| 175 | flex-direction: column; | ||
| 176 | gap: 2px; | ||
| 177 | padding: 4px; | ||
| 178 | border-radius: 8px; | ||
| 179 | border: 1px solid var(--vp-c-divider); | ||
| 180 | background: var(--vp-c-bg-elv); | ||
| 181 | box-shadow: var(--vp-shadow-2, 0 4px 16px rgba(0, 0, 0, 0.2)); | ||
| 182 | } | ||
| 183 | |||
| 184 | .ann-type-option { | ||
| 185 | display: flex; | ||
| 186 | align-items: center; | ||
| 187 | gap: 8px; | ||
| 188 | padding: 5px 8px; | ||
| 189 | border-radius: 8px; | ||
| 190 | border: none; | ||
| 191 | background: transparent; | ||
| 192 | cursor: pointer; | ||
| 193 | color: var(--vp-c-text-1); | ||
| 194 | font-size: 13px; | ||
| 195 | text-align: left; | ||
| 196 | width: 100%; | ||
| 197 | transition: background-color 0.15s; | ||
| 198 | } | ||
| 199 | |||
| 200 | .ann-type-option-label { | ||
| 201 | flex: 1; | ||
| 202 | min-width: 0; | ||
| 203 | } | ||
| 204 | |||
| 205 | .ann-type-option:hover { | ||
| 206 | background-color: var(--vp-c-bg-soft); | ||
| 207 | } | ||
| 208 | |||
| 209 | .ann-type-option--selected { | ||
| 210 | background-color: var(--vp-c-brand-soft); | ||
| 211 | font-weight: 600; | ||
| 212 | } | ||
| 213 | |||
| 214 | .ann-type-option--selected:hover { | ||
| 215 | background-color: var(--vp-c-brand-soft); | ||
| 216 | } | ||
| 217 | |||
| 218 | /* Help popup */ | ||
| 219 | .sh-title { | ||
| 220 | display: flex; | ||
| 221 | align-items: center; | ||
| 222 | gap: 6px; | ||
| 223 | font-size: 1rem; | ||
| 224 | font-weight: 600; | ||
| 225 | color: var(--vp-c-text-1); | ||
| 226 | margin: 0 0 4px; | ||
| 227 | } | ||
| 228 | |||
| 229 | .sh-title-icon { | ||
| 230 | flex-shrink: 0; | ||
| 231 | opacity: 0.8; | ||
| 232 | width: 16px; | ||
| 233 | height: 16px; | ||
| 234 | } | ||
| 235 | |||
| 236 | .sh-desc { | ||
| 237 | font-size: 0.875rem; | ||
| 238 | color: var(--vp-c-text-2); | ||
| 239 | margin: 0 0 6px; | ||
| 240 | line-height: 1.5; | ||
| 241 | } | ||
| 242 | |||
| 243 | .sh-options { | ||
| 244 | display: flex; | ||
| 245 | flex-direction: column; | ||
| 246 | gap: 5px; | ||
| 247 | } | ||
| 248 | |||
| 249 | .sh-option { | ||
| 250 | display: flex; | ||
| 251 | flex-direction: column; | ||
| 252 | gap: 4px; | ||
| 253 | background: var(--wk-c-menu-bg); | ||
| 254 | border-radius: 12px; | ||
| 255 | padding: 10px 12px; | ||
| 256 | } | ||
| 257 | |||
| 258 | .sh-option strong { | ||
| 259 | display: flex; | ||
| 260 | align-items: center; | ||
| 261 | gap: 4px; | ||
| 262 | font-size: 0.875rem; | ||
| 263 | font-weight: 600; | ||
| 264 | color: var(--vp-c-text-1); | ||
| 265 | } | ||
| 266 | |||
| 267 | .sh-opt-icon { | ||
| 268 | flex-shrink: 0; | ||
| 269 | width: 14px; | ||
| 270 | height: 14px; | ||
| 271 | } | ||
| 272 | |||
| 273 | .sh-option span { | ||
| 274 | font-size: 0.875rem; | ||
| 275 | color: var(--vp-c-text-2); | ||
| 276 | line-height: 1.4; | ||
| 277 | } | ||
| 278 | </style> | ||
docs/.vitepress/theme/components/AnnouncementsPanel.vue added +801
| @@ -0,0 +1,801 @@ | |||
| 1 | <script setup lang="ts"> | ||
| 2 | import { onClickOutside, useEventListener, useMounted } from '@vueuse/core' | ||
| 3 | import { ArrowLeft, CheckCheck, ChevronRight, Megaphone } from 'lucide-vue-next' | ||
| 4 | import { inBrowser, useRouter } from 'vitepress' | ||
| 5 | import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue' | ||
| 6 | import type { Announcement, AnnouncementType } from '../composables/useAnnouncements' | ||
| 7 | import { useAnnouncements } from '../composables/useAnnouncements' | ||
| 8 | import AnnouncementTypeSelect from './AnnouncementTypeSelect.vue' | ||
| 9 | |||
| 10 | const ICON_SIZE = 18 | ||
| 11 | const ICON_STROKE = 2 | ||
| 12 | |||
| 13 | const { | ||
| 14 | announcements, | ||
| 15 | enabled, | ||
| 16 | isRead, | ||
| 17 | markRead, | ||
| 18 | markAllRead, | ||
| 19 | hasUnread, | ||
| 20 | unreadCount | ||
| 21 | } = useAnnouncements() | ||
| 22 | |||
| 23 | const router = useRouter() | ||
| 24 | const mounted = useMounted() | ||
| 25 | |||
| 26 | const TYPE_META: Record<AnnouncementType, { label: string; icon: string }> = { | ||
| 27 | section: { label: 'Section', icon: 'i-lucide:panel-top' }, | ||
| 28 | component: { label: 'Component', icon: 'i-lucide:box' }, | ||
| 29 | improvement: { label: 'Improvement', icon: 'i-lucide:sparkles' } | ||
| 30 | } | ||
| 31 | |||
| 32 | /* Panel open/close & positioning */ | ||
| 33 | const isOpen = ref(false) | ||
| 34 | const wrapperRef = ref<HTMLElement>() | ||
| 35 | const buttonRef = ref<HTMLElement>() | ||
| 36 | const panelRef = ref<HTMLElement>() | ||
| 37 | const scrollRef = ref<HTMLElement>() | ||
| 38 | const showFade = ref(true) | ||
| 39 | const panelStyle = ref<Record<string, string>>({}) | ||
| 40 | |||
| 41 | onClickOutside(wrapperRef, () => { | ||
| 42 | // keep panel open while the filter menu is up | ||
| 43 | if (!filterOpen.value) isOpen.value = false | ||
| 44 | }) | ||
| 45 | |||
| 46 | function onScroll() { | ||
| 47 | if (!scrollRef.value) return | ||
| 48 | const { scrollTop, scrollHeight, clientHeight } = scrollRef.value | ||
| 49 | showFade.value = scrollTop + clientHeight < scrollHeight - 4 | ||
| 50 | } | ||
| 51 | |||
| 52 | function updatePanelPosition() { | ||
| 53 | const wrapper = wrapperRef.value | ||
| 54 | const button = buttonRef.value | ||
| 55 | const panel = panelRef.value | ||
| 56 | if (!wrapper || !button || !panel) return | ||
| 57 | |||
| 58 | if (!inBrowser || window.innerWidth <= 767) { | ||
| 59 | panelStyle.value = {} | ||
| 60 | return | ||
| 61 | } | ||
| 62 | |||
| 63 | const viewportMargin = 12 | ||
| 64 | const wrapperRect = wrapper.getBoundingClientRect() | ||
| 65 | const buttonRect = button.getBoundingClientRect() | ||
| 66 | const panelWidth = panel.offsetWidth | ||
| 67 | const centeredLeft = buttonRect.left + buttonRect.width / 2 - panelWidth / 2 | ||
| 68 | const maxLeft = Math.max( | ||
| 69 | viewportMargin, | ||
| 70 | window.innerWidth - viewportMargin - panelWidth | ||
| 71 | ) | ||
| 72 | const viewportLeft = Math.min(Math.max(centeredLeft, viewportMargin), maxLeft) | ||
| 73 | |||
| 74 | panelStyle.value = { | ||
| 75 | '--ann-panel-left': `${viewportLeft - wrapperRect.left}px` | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | watch(isOpen, async (open) => { | ||
| 80 | if (!open) { | ||
| 81 | filterOpen.value = false | ||
| 82 | return | ||
| 83 | } | ||
| 84 | await nextTick() | ||
| 85 | updatePanelPosition() | ||
| 86 | onScroll() | ||
| 87 | }) | ||
| 88 | |||
| 89 | useEventListener(inBrowser ? window : undefined, 'resize', () => { | ||
| 90 | if (isOpen.value) updatePanelPosition() | ||
| 91 | if (filterOpen.value) updateFilterPosition() | ||
| 92 | }) | ||
| 93 | |||
| 94 | /* Type filter (gear menu) */ | ||
| 95 | // '' = all types | ||
| 96 | const typeFilter = ref('') | ||
| 97 | const filterOpen = ref(false) | ||
| 98 | const filterBtnRef = ref<HTMLElement>() | ||
| 99 | const filterMenuRef = ref<HTMLElement>() | ||
| 100 | const filterStyle = ref<Record<string, string>>({}) | ||
| 101 | |||
| 102 | function updateFilterPosition() { | ||
| 103 | const btn = filterBtnRef.value | ||
| 104 | if (!btn) return | ||
| 105 | const viewportMargin = 12 | ||
| 106 | const menuWidth = filterMenuRef.value?.offsetWidth ?? 200 | ||
| 107 | const rect = btn.getBoundingClientRect() | ||
| 108 | const maxLeft = Math.max(viewportMargin, window.innerWidth - viewportMargin - menuWidth) | ||
| 109 | const left = Math.min(Math.max(rect.right - menuWidth, viewportMargin), maxLeft) | ||
| 110 | filterStyle.value = { top: `${rect.bottom + 6}px`, left: `${left}px` } | ||
| 111 | } | ||
| 112 | |||
| 113 | function toggleFilter() { | ||
| 114 | filterOpen.value = !filterOpen.value | ||
| 115 | if (filterOpen.value) void nextTick(updateFilterPosition) | ||
| 116 | } | ||
| 117 | |||
| 118 | function onFilterDocClick(e: MouseEvent) { | ||
| 119 | const target = e.target as Node | ||
| 120 | if ( | ||
| 121 | filterBtnRef.value && !filterBtnRef.value.contains(target) | ||
| 122 | && filterMenuRef.value && !filterMenuRef.value.contains(target) | ||
| 123 | ) { | ||
| 124 | filterOpen.value = false | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | const filtered = computed(() => | ||
| 129 | typeFilter.value | ||
| 130 | ? announcements.filter((a) => a.type === typeFilter.value) | ||
| 131 | : announcements | ||
| 132 | ) | ||
| 133 | |||
| 134 | /* Detail popup */ | ||
| 135 | const activePost = ref<Announcement | null>(null) | ||
| 136 | |||
| 137 | function openPost(post: Announcement) { | ||
| 138 | markRead(post.id) | ||
| 139 | if (post.type === 'section') { | ||
| 140 | isOpen.value = false | ||
| 141 | if (post.link) router.go(post.link) | ||
| 142 | return | ||
| 143 | } | ||
| 144 | activePost.value = post | ||
| 145 | } | ||
| 146 | |||
| 147 | function closePost() { | ||
| 148 | activePost.value = null | ||
| 149 | } | ||
| 150 | |||
| 151 | function onMarkAllRead() { | ||
| 152 | markAllRead() | ||
| 153 | } | ||
| 154 | |||
| 155 | watch(activePost, (post) => { | ||
| 156 | if (typeof document !== 'undefined') { | ||
| 157 | document.body.style.overflow = post ? 'hidden' : '' | ||
| 158 | } | ||
| 159 | }) | ||
| 160 | |||
| 161 | function onKeydown(e: KeyboardEvent) { | ||
| 162 | if (e.key !== 'Escape') return | ||
| 163 | if (activePost.value) closePost() | ||
| 164 | else if (filterOpen.value) filterOpen.value = false | ||
| 165 | else if (isOpen.value) isOpen.value = false | ||
| 166 | } | ||
| 167 | |||
| 168 | onMounted(() => { | ||
| 169 | document.addEventListener('click', onFilterDocClick, true) | ||
| 170 | document.addEventListener('keydown', onKeydown) | ||
| 171 | }) | ||
| 172 | |||
| 173 | onUnmounted(() => { | ||
| 174 | document.removeEventListener('click', onFilterDocClick, true) | ||
| 175 | document.removeEventListener('keydown', onKeydown) | ||
| 176 | if (typeof document !== 'undefined') document.body.style.overflow = '' | ||
| 177 | }) | ||
| 178 | </script> | ||
| 179 | |||
| 180 | <template> | ||
| 181 | <div v-if="enabled" ref="wrapperRef" class="ann-wrapper"> | ||
| 182 | <button | ||
| 183 | ref="buttonRef" | ||
| 184 | type="button" | ||
| 185 | class="ann-btn" | ||
| 186 | aria-label="Announcements" | ||
| 187 | :aria-expanded="isOpen" | ||
| 188 | @click="isOpen = !isOpen" | ||
| 189 | > | ||
| 190 | <Megaphone :size="ICON_SIZE" :stroke-width="ICON_STROKE" /> | ||
| 191 | <span v-if="mounted && hasUnread" class="ann-dot" aria-hidden="true" /> | ||
| 192 | </button> | ||
| 193 | |||
| 194 | <Transition name="ann-panel"> | ||
| 195 | <div | ||
| 196 | v-if="isOpen" | ||
| 197 | ref="panelRef" | ||
| 198 | class="ann-panel" | ||
| 199 | :style="panelStyle" | ||
| 200 | role="dialog" | ||
| 201 | aria-label="Announcements" | ||
| 202 | > | ||
| 203 | <div class="ann-header"> | ||
| 204 | <button type="button" class="ann-mobile-back" aria-label="Back" @click="isOpen = false"> | ||
| 205 | <ArrowLeft :size="18" :stroke-width="2" /> | ||
| 206 | </button> | ||
| 207 | <span class="ann-header-title">Announcements</span> | ||
| 208 | <div class="ann-header-actions"> | ||
| 209 | <button | ||
| 210 | type="button" | ||
| 211 | class="ann-header-btn" | ||
| 212 | aria-label="Mark all as read" | ||
| 213 | :disabled="unreadCount === 0" | ||
| 214 | @click="onMarkAllRead" | ||
| 215 | > | ||
| 216 | <CheckCheck :size="16" :stroke-width="2" /> | ||
| 217 | </button> | ||
| 218 | <button | ||
| 219 | type="button" | ||
| 220 | class="ann-settings-btn" | ||
| 221 | :class="{ 'is-active': filterOpen }" | ||
| 222 | aria-label="Filter by type" | ||
| 223 | :aria-expanded="filterOpen" | ||
| 224 | ref="filterBtnRef" | ||
| 225 | @click="toggleFilter" | ||
| 226 | > | ||
| 227 | <span class="i-lucide:settings" /> | ||
| 228 | </button> | ||
| 229 | </div> | ||
| 230 | </div> | ||
| 231 | |||
| 232 | <div ref="scrollRef" class="ann-scroll" @scroll.passive="onScroll"> | ||
| 233 | <div v-if="filtered.length === 0" class="ann-empty"> | ||
| 234 | <span class="ann-empty-kaomoji">(´・ω・`)</span> | ||
| 235 | <p class="ann-empty-hint">No announcements to show.</p> | ||
| 236 | </div> | ||
| 237 | <ul v-else class="ann-list"> | ||
| 238 | <li v-for="post in filtered" :key="post.id" class="ann-item"> | ||
| 239 | <button | ||
| 240 | type="button" | ||
| 241 | class="ann-item-btn" | ||
| 242 | :class="{ 'is-unread': !isRead(post.id) }" | ||
| 243 | :aria-label="`${TYPE_META[post.type].label}: ${post.title}`" | ||
| 244 | @click="openPost(post)" | ||
| 245 | > | ||
| 246 | <span class="ann-item-typeicon" :class="TYPE_META[post.type].icon" /> | ||
| 247 | <span class="ann-item-title">{{ post.title }}</span> | ||
| 248 | <ChevronRight :size="15" :stroke-width="2" class="ann-item-chevron" /> | ||
| 249 | </button> | ||
| 250 | </li> | ||
| 251 | </ul> | ||
| 252 | </div> | ||
| 253 | |||
| 254 | <Transition name="ann-fade"> | ||
| 255 | <div v-if="showFade && filtered.length > 0" class="ann-fade-overlay" /> | ||
| 256 | </Transition> | ||
| 257 | </div> | ||
| 258 | </Transition> | ||
| 259 | |||
| 260 | <!-- Type filter menu --> | ||
| 261 | <Teleport to="body"> | ||
| 262 | <div | ||
| 263 | v-show="filterOpen" | ||
| 264 | ref="filterMenuRef" | ||
| 265 | class="ann-filter-menu VPMenu" | ||
| 266 | :style="filterStyle" | ||
| 267 | role="menu" | ||
| 268 | aria-label="Filter announcements by type" | ||
| 269 | > | ||
| 270 | <AnnouncementTypeSelect v-model="typeFilter" /> | ||
| 271 | </div> | ||
| 272 | </Teleport> | ||
| 273 | |||
| 274 | <!-- detail popup --> | ||
| 275 | <Teleport to="body"> | ||
| 276 | <Transition name="ann-detail-fade"> | ||
| 277 | <div v-if="activePost" class="ann-backdrop" @click.self="closePost"> | ||
| 278 | <Transition name="ann-detail-slide" appear> | ||
| 279 | <div v-if="activePost" class="ann-detail" role="dialog" aria-modal="true" :aria-label="activePost.title"> | ||
| 280 | <div class="ann-detail-head"> | ||
| 281 | <button class="ann-detail-back" aria-label="Back" @click="closePost"> | ||
| 282 | <ArrowLeft :size="18" :stroke-width="2" /> | ||
| 283 | </button> | ||
| 284 | <span class="ann-detail-title">{{ activePost.title }}</span> | ||
| 285 | <button class="ann-detail-close" aria-label="Close" @click="closePost"> | ||
| 286 | <span class="i-lucide:x" /> | ||
| 287 | </button> | ||
| 288 | </div> | ||
| 289 | <div class="ann-detail-body"> | ||
| 290 | <div class="ann-detail-content vp-doc" v-html="activePost.html" /> | ||
| 291 | </div> | ||
| 292 | </div> | ||
| 293 | </Transition> | ||
| 294 | </div> | ||
| 295 | </Transition> | ||
| 296 | </Teleport> | ||
| 297 | </div> | ||
| 298 | </template> | ||
| 299 | |||
| 300 | <style scoped> | ||
| 301 | .ann-wrapper { | ||
| 302 | position: relative; | ||
| 303 | width: 100%; | ||
| 304 | height: 100%; | ||
| 305 | display: flex; | ||
| 306 | align-items: center; | ||
| 307 | justify-content: center; | ||
| 308 | } | ||
| 309 | |||
| 310 | .ann-btn { | ||
| 311 | position: relative; | ||
| 312 | display: flex; | ||
| 313 | align-items: center; | ||
| 314 | justify-content: center; | ||
| 315 | width: 100%; | ||
| 316 | height: 100%; | ||
| 317 | color: var(--vp-c-text-1); | ||
| 318 | opacity: 0.55; | ||
| 319 | transition: | ||
| 320 | opacity 0.25s, | ||
| 321 | transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); | ||
| 322 | } | ||
| 323 | |||
| 324 | .ann-btn:hover { opacity: 1; } | ||
| 325 | .ann-btn:active { transform: scale(0.94); } | ||
| 326 | |||
| 327 | /* unread dot, brand colour */ | ||
| 328 | .ann-dot { | ||
| 329 | position: absolute; | ||
| 330 | top: calc(50% - 11px); | ||
| 331 | right: calc(50% - 11px); | ||
| 332 | width: 7px; | ||
| 333 | height: 7px; | ||
| 334 | border-radius: 50%; | ||
| 335 | background: var(--vp-c-brand-1); | ||
| 336 | box-shadow: 0 0 0 2px var(--nav-pill-bg, var(--vp-c-bg)); | ||
| 337 | } | ||
| 338 | |||
| 339 | .ann-panel { | ||
| 340 | position: absolute; | ||
| 341 | top: calc(var(--vp-nav-height) / 2 + 20px); | ||
| 342 | left: var(--ann-panel-left, 50%); | ||
| 343 | z-index: 100; | ||
| 344 | width: 320px; | ||
| 345 | max-width: calc(100vw - 24px); | ||
| 346 | --ann-panel-bg: var(--vp-c-bg-elv); | ||
| 347 | background-color: var(--ann-panel-bg); | ||
| 348 | border: 1px solid var(--vp-c-divider); | ||
| 349 | border-radius: 12px; | ||
| 350 | box-shadow: var(--vp-shadow-3); | ||
| 351 | transition: background-color 0.5s; | ||
| 352 | transform: translateX(-50%); | ||
| 353 | transform-origin: top center; | ||
| 354 | overflow: hidden; | ||
| 355 | display: flex; | ||
| 356 | flex-direction: column; | ||
| 357 | } | ||
| 358 | |||
| 359 | .ann-panel[style*="--ann-panel-left"] { | ||
| 360 | transform: none; | ||
| 361 | } | ||
| 362 | |||
| 363 | .ann-header { | ||
| 364 | display: flex; | ||
| 365 | align-items: center; | ||
| 366 | gap: 8px; | ||
| 367 | flex-shrink: 0; | ||
| 368 | padding: 12px 12px 8px 16px; | ||
| 369 | } | ||
| 370 | |||
| 371 | .ann-header-title { | ||
| 372 | flex: 1; | ||
| 373 | font-size: 15px; | ||
| 374 | font-weight: 600; | ||
| 375 | color: var(--vp-c-text-1); | ||
| 376 | min-width: 0; | ||
| 377 | overflow: hidden; | ||
| 378 | white-space: nowrap; | ||
| 379 | text-overflow: ellipsis; | ||
| 380 | } | ||
| 381 | |||
| 382 | .ann-header-actions { | ||
| 383 | display: flex; | ||
| 384 | align-items: center; | ||
| 385 | gap: 2px; | ||
| 386 | flex-shrink: 0; | ||
| 387 | } | ||
| 388 | |||
| 389 | /* header buttons, extrepo gear style */ | ||
| 390 | .ann-header-btn, | ||
| 391 | .ann-settings-btn { | ||
| 392 | display: flex; | ||
| 393 | align-items: center; | ||
| 394 | justify-content: center; | ||
| 395 | width: 30px; | ||
| 396 | height: 30px; | ||
| 397 | padding: 0; | ||
| 398 | border: none; | ||
| 399 | border-radius: 0; | ||
| 400 | background: transparent; | ||
| 401 | color: var(--vp-c-text-1); | ||
| 402 | opacity: 0.55; | ||
| 403 | cursor: pointer; | ||
| 404 | transition: opacity 0.25s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); | ||
| 405 | } | ||
| 406 | |||
| 407 | .ann-settings-btn span { | ||
| 408 | font-size: 15px; | ||
| 409 | } | ||
| 410 | |||
| 411 | .ann-header-btn:hover, | ||
| 412 | .ann-settings-btn:hover, | ||
| 413 | .ann-settings-btn.is-active { | ||
| 414 | color: var(--vp-c-text-1); | ||
| 415 | opacity: 1; | ||
| 416 | background: transparent; | ||
| 417 | } | ||
| 418 | |||
| 419 | .ann-header-btn:active, | ||
| 420 | .ann-settings-btn:active { | ||
| 421 | transform: scale(0.94); | ||
| 422 | } | ||
| 423 | |||
| 424 | .ann-header-btn:disabled { | ||
| 425 | opacity: 0.25; | ||
| 426 | cursor: default; | ||
| 427 | } | ||
| 428 | |||
| 429 | .ann-header-btn:disabled:active { | ||
| 430 | transform: none; | ||
| 431 | } | ||
| 432 | |||
| 433 | html.effects-disabled .ann-settings-btn, | ||
| 434 | html.effects-disabled .ann-header-btn { | ||
| 435 | transition: none; | ||
| 436 | } | ||
| 437 | |||
| 438 | html.effects-disabled .ann-settings-btn:active, | ||
| 439 | html.effects-disabled .ann-header-btn:active { | ||
| 440 | transform: none; | ||
| 441 | } | ||
| 442 | |||
| 443 | .ann-mobile-back { | ||
| 444 | display: none; | ||
| 445 | align-items: center; | ||
| 446 | justify-content: center; | ||
| 447 | padding: 8px; | ||
| 448 | border: none; | ||
| 449 | background: transparent; | ||
| 450 | color: var(--vp-c-text-1); | ||
| 451 | cursor: pointer; | ||
| 452 | transition: color 0.15s; | ||
| 453 | } | ||
| 454 | |||
| 455 | .ann-mobile-back:hover { | ||
| 456 | color: var(--vp-c-brand-1); | ||
| 457 | } | ||
| 458 | |||
| 459 | .ann-scroll { | ||
| 460 | height: 400px; | ||
| 461 | overflow-y: auto; | ||
| 462 | overflow-x: hidden; | ||
| 463 | overscroll-behavior: contain; | ||
| 464 | padding: 0 8px 12px; | ||
| 465 | scrollbar-width: none; | ||
| 466 | -ms-overflow-style: none; | ||
| 467 | } | ||
| 468 | |||
| 469 | .ann-scroll::-webkit-scrollbar { | ||
| 470 | display: none; | ||
| 471 | } | ||
| 472 | |||
| 473 | .ann-fade-overlay { | ||
| 474 | position: absolute; | ||
| 475 | bottom: 0; | ||
| 476 | left: 0; | ||
| 477 | right: 0; | ||
| 478 | height: 48px; | ||
| 479 | pointer-events: none; | ||
| 480 | background: linear-gradient(to bottom, transparent, var(--ann-panel-bg)); | ||
| 481 | border-radius: 0 0 12px 12px; | ||
| 482 | } | ||
| 483 | |||
| 484 | .ann-empty { | ||
| 485 | display: flex; | ||
| 486 | flex-direction: column; | ||
| 487 | align-items: center; | ||
| 488 | justify-content: center; | ||
| 489 | min-height: 340px; | ||
| 490 | gap: 10px; | ||
| 491 | text-align: center; | ||
| 492 | } | ||
| 493 | |||
| 494 | .ann-empty-kaomoji { | ||
| 495 | font-size: 26px; | ||
| 496 | color: var(--vp-c-text-3); | ||
| 497 | line-height: 1; | ||
| 498 | user-select: none; | ||
| 499 | } | ||
| 500 | |||
| 501 | .ann-empty-hint { | ||
| 502 | font-size: 13px; | ||
| 503 | color: var(--vp-c-text-2); | ||
| 504 | margin: 0; | ||
| 505 | } | ||
| 506 | |||
| 507 | .ann-list { | ||
| 508 | list-style: none; | ||
| 509 | padding: 0; | ||
| 510 | margin: 0; | ||
| 511 | display: flex; | ||
| 512 | flex-direction: column; | ||
| 513 | gap: 2px; | ||
| 514 | } | ||
| 515 | |||
| 516 | .ann-item-btn { | ||
| 517 | display: flex; | ||
| 518 | align-items: center; | ||
| 519 | gap: 10px; | ||
| 520 | width: 100%; | ||
| 521 | padding: 9px 8px; | ||
| 522 | border: none; | ||
| 523 | background: transparent; | ||
| 524 | border-radius: 8px; | ||
| 525 | cursor: pointer; | ||
| 526 | text-align: left; | ||
| 527 | transition: background 0.15s, opacity 0.15s; | ||
| 528 | } | ||
| 529 | |||
| 530 | .ann-item-btn:hover { | ||
| 531 | background: var(--vp-c-default-soft); | ||
| 532 | } | ||
| 533 | |||
| 534 | .ann-item-typeicon { | ||
| 535 | flex-shrink: 0; | ||
| 536 | font-size: 18px; | ||
| 537 | color: var(--vp-c-text-2); | ||
| 538 | } | ||
| 539 | |||
| 540 | .ann-item-title { | ||
| 541 | flex: 1; | ||
| 542 | font-size: 13.5px; | ||
| 543 | font-weight: 500; | ||
| 544 | color: var(--vp-c-text-1); | ||
| 545 | overflow: hidden; | ||
| 546 | white-space: nowrap; | ||
| 547 | text-overflow: ellipsis; | ||
| 548 | min-width: 0; | ||
| 549 | } | ||
| 550 | |||
| 551 | /* dim read items */ | ||
| 552 | .ann-item-btn:not(.is-unread) { | ||
| 553 | opacity: 0.5; | ||
| 554 | } | ||
| 555 | |||
| 556 | .ann-item-btn:not(.is-unread):hover { | ||
| 557 | opacity: 1; | ||
| 558 | } | ||
| 559 | |||
| 560 | .ann-item-btn:not(.is-unread) .ann-item-title { | ||
| 561 | font-weight: 400; | ||
| 562 | } | ||
| 563 | |||
| 564 | .ann-item-chevron { | ||
| 565 | flex-shrink: 0; | ||
| 566 | color: var(--vp-c-text-3); | ||
| 567 | } | ||
| 568 | |||
| 569 | /* Filter menu */ | ||
| 570 | .ann-filter-menu { | ||
| 571 | position: fixed; | ||
| 572 | z-index: 120; | ||
| 573 | width: 260px; | ||
| 574 | max-width: calc(100vw - 24px); | ||
| 575 | max-height: calc(100vh - 24px); | ||
| 576 | overflow-y: auto; | ||
| 577 | padding: 12px; | ||
| 578 | border-radius: 12px; | ||
| 579 | border: 1px solid var(--vp-c-divider); | ||
| 580 | background-color: var(--vp-c-bg-elv); | ||
| 581 | box-shadow: var(--vp-shadow-3, 0 4px 16px rgba(0, 0, 0, 0.3)); | ||
| 582 | } | ||
| 583 | |||
| 584 | /* Detail popup */ | ||
| 585 | .ann-backdrop { | ||
| 586 | position: fixed; | ||
| 587 | inset: 0; | ||
| 588 | z-index: 200; | ||
| 589 | display: flex; | ||
| 590 | align-items: center; | ||
| 591 | justify-content: center; | ||
| 592 | background: rgba(0, 0, 0, 0.5); | ||
| 593 | backdrop-filter: blur(4px); | ||
| 594 | overscroll-behavior: none; | ||
| 595 | } | ||
| 596 | |||
| 597 | .ann-detail { | ||
| 598 | width: min(640px, calc(100vw - 32px)); | ||
| 599 | max-height: 85vh; | ||
| 600 | display: flex; | ||
| 601 | flex-direction: column; | ||
| 602 | border-radius: 16px; | ||
| 603 | border: 1px solid var(--vp-c-divider); | ||
| 604 | background: var(--vp-c-bg); | ||
| 605 | overflow: hidden; | ||
| 606 | } | ||
| 607 | |||
| 608 | .ann-detail-head { | ||
| 609 | display: flex; | ||
| 610 | align-items: center; | ||
| 611 | justify-content: space-between; | ||
| 612 | gap: 8px; | ||
| 613 | padding: 10px 12px 10px 16px; | ||
| 614 | border-bottom: 1px solid var(--vp-c-divider); | ||
| 615 | flex-shrink: 0; | ||
| 616 | } | ||
| 617 | |||
| 618 | .ann-detail-title { | ||
| 619 | flex: 1; | ||
| 620 | font-size: 15px; | ||
| 621 | font-weight: 600; | ||
| 622 | color: var(--vp-c-text-1); | ||
| 623 | overflow: hidden; | ||
| 624 | white-space: nowrap; | ||
| 625 | text-overflow: ellipsis; | ||
| 626 | min-width: 0; | ||
| 627 | } | ||
| 628 | |||
| 629 | .ann-detail-back { | ||
| 630 | display: none; | ||
| 631 | align-items: center; | ||
| 632 | justify-content: center; | ||
| 633 | padding: 8px; | ||
| 634 | border: none; | ||
| 635 | background: transparent; | ||
| 636 | color: var(--vp-c-text-1); | ||
| 637 | cursor: pointer; | ||
| 638 | transition: color 0.15s; | ||
| 639 | } | ||
| 640 | |||
| 641 | .ann-detail-back:hover { | ||
| 642 | color: var(--vp-c-brand-1); | ||
| 643 | } | ||
| 644 | |||
| 645 | .ann-detail-close { | ||
| 646 | display: flex; | ||
| 647 | align-items: center; | ||
| 648 | justify-content: center; | ||
| 649 | width: 28px; | ||
| 650 | height: 28px; | ||
| 651 | border-radius: 6px; | ||
| 652 | border: none; | ||
| 653 | background: transparent; | ||
| 654 | color: var(--vp-c-text-2); | ||
| 655 | font-size: 16px; | ||
| 656 | cursor: pointer; | ||
| 657 | flex-shrink: 0; | ||
| 658 | transition: color 0.15s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); | ||
| 659 | } | ||
| 660 | |||
| 661 | .ann-detail-close:hover { | ||
| 662 | color: var(--vp-c-text-1); | ||
| 663 | } | ||
| 664 | |||
| 665 | .ann-detail-close:active { | ||
| 666 | transform: scale(0.94); | ||
| 667 | } | ||
| 668 | |||
| 669 | .ann-detail-body { | ||
| 670 | overflow-y: auto; | ||
| 671 | min-height: 0; | ||
| 672 | padding: 20px 24px 28px; | ||
| 673 | overscroll-behavior: contain; | ||
| 674 | } | ||
| 675 | |||
| 676 | .ann-detail-content :deep(:first-child) { | ||
| 677 | margin-top: 0; | ||
| 678 | } | ||
| 679 | |||
| 680 | /* Transitions */ | ||
| 681 | .ann-panel-enter-active, | ||
| 682 | .ann-panel-leave-active { | ||
| 683 | transition: opacity 0.15s, transform 0.15s cubic-bezier(0.16, 1, 0.3, 1); | ||
| 684 | } | ||
| 685 | |||
| 686 | .ann-panel-enter-from, | ||
| 687 | .ann-panel-leave-to { | ||
| 688 | opacity: 0; | ||
| 689 | transform: translateX(-50%) scale(0.95) translateY(-4px); | ||
| 690 | } | ||
| 691 | |||
| 692 | .ann-panel[style*="--ann-panel-left"].ann-panel-enter-from, | ||
| 693 | .ann-panel[style*="--ann-panel-left"].ann-panel-leave-to { | ||
| 694 | transform: scale(0.95) translateY(-4px); | ||
| 695 | } | ||
| 696 | |||
| 697 | .ann-fade-enter-active, | ||
| 698 | .ann-fade-leave-active { | ||
| 699 | transition: opacity 0.2s; | ||
| 700 | } | ||
| 701 | |||
| 702 | .ann-fade-enter-from, | ||
| 703 | .ann-fade-leave-to { | ||
| 704 | opacity: 0; | ||
| 705 | } | ||
| 706 | |||
| 707 | .ann-detail-fade-enter-active, | ||
| 708 | .ann-detail-fade-leave-active { transition: opacity 0.2s ease; } | ||
| 709 | .ann-detail-fade-enter-from, | ||
| 710 | .ann-detail-fade-leave-to { opacity: 0; } | ||
| 711 | |||
| 712 | .ann-detail-slide-enter-active { transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease; } | ||
| 713 | .ann-detail-slide-leave-active { transition: transform 0.2s ease, opacity 0.15s ease; } | ||
| 714 | .ann-detail-slide-enter-from { transform: translateY(20px); opacity: 0; } | ||
| 715 | .ann-detail-slide-leave-to { transform: translateY(10px); opacity: 0; } | ||
| 716 | |||
| 717 | html.effects-disabled .ann-btn, | ||
| 718 | html.effects-disabled .ann-header-btn, | ||
| 719 | html.effects-disabled .ann-detail-close { | ||
| 720 | transition: none; | ||
| 721 | } | ||
| 722 | |||
| 723 | html.effects-disabled .ann-btn:active, | ||
| 724 | html.effects-disabled .ann-header-btn:active, | ||
| 725 | html.effects-disabled .ann-detail-close:active { | ||
| 726 | transform: none; | ||
| 727 | } | ||
| 728 | |||
| 729 | /* Phone: full-screen panel */ | ||
| 730 | @media (max-width: 767px) { | ||
| 731 | .ann-panel { | ||
| 732 | position: fixed; | ||
| 733 | top: 0; | ||
| 734 | left: 0; | ||
| 735 | right: 0; | ||
| 736 | bottom: 0; | ||
| 737 | width: 100%; | ||
| 738 | max-width: none; | ||
| 739 | height: 100%; | ||
| 740 | border-radius: 0; | ||
| 741 | border: none; | ||
| 742 | z-index: 9999; | ||
| 743 | transform: none; | ||
| 744 | --ann-panel-bg: var(--vp-c-bg); | ||
| 745 | } | ||
| 746 | |||
| 747 | .ann-header { | ||
| 748 | height: 49px; | ||
| 749 | padding: 6px 8px; | ||
| 750 | border-bottom: 1px solid var(--wk-fs-header-divider); | ||
| 751 | } | ||
| 752 | |||
| 753 | .ann-mobile-back { | ||
| 754 | display: flex; | ||
| 755 | } | ||
| 756 | |||
| 757 | .ann-header-title { | ||
| 758 | font-size: 16px; | ||
| 759 | } | ||
| 760 | |||
| 761 | .ann-scroll { | ||
| 762 | flex: 1; | ||
| 763 | height: auto; | ||
| 764 | min-height: 0; | ||
| 765 | } | ||
| 766 | |||
| 767 | .ann-panel-enter-from, | ||
| 768 | .ann-panel-leave-to { | ||
| 769 | opacity: 0; | ||
| 770 | transform: translateY(8px); | ||
| 771 | } | ||
| 772 | |||
| 773 | .ann-backdrop { | ||
| 774 | align-items: stretch; | ||
| 775 | } | ||
| 776 | |||
| 777 | .ann-detail { | ||
| 778 | width: 100vw; | ||
| 779 | height: 100vh; | ||
| 780 | height: 100dvh; | ||
| 781 | max-height: none; | ||
| 782 | border-radius: 0; | ||
| 783 | border: none; | ||
| 784 | } | ||
| 785 | |||
| 786 | .ann-detail-head { | ||
| 787 | height: 49px; | ||
| 788 | padding: 6px 8px; | ||
| 789 | justify-content: flex-start; | ||
| 790 | border-bottom-color: var(--wk-fs-header-divider); | ||
| 791 | } | ||
| 792 | |||
| 793 | .ann-detail-back { | ||
| 794 | display: flex; | ||
| 795 | } | ||
| 796 | |||
| 797 | .ann-detail-close { | ||
| 798 | display: none; | ||
| 799 | } | ||
| 800 | } | ||
| 801 | </style> | ||
docs/.vitepress/theme/components/NavActions.vue +7
| @@ -10,6 +10,7 @@ import { openSearch } from '../searchState' | |||
| 10 | import { openSettings } from '../settingsState' | 10 | import { openSettings } from '../settingsState' |
| 11 | import NolebaseEnhancedReadabilitiesMenu from './settings/Menu.vue' | 11 | import NolebaseEnhancedReadabilitiesMenu from './settings/Menu.vue' |
| 12 | import BookmarksPanel from './BookmarksPanel.vue' | 12 | import BookmarksPanel from './BookmarksPanel.vue' |
| 13 | import AnnouncementsPanel from './AnnouncementsPanel.vue' | ||
| 13 | import SettingsPanel from './SettingsPanel.vue' | 14 | import SettingsPanel from './SettingsPanel.vue' |
| 14 | 15 | ||
| 15 | const ICON_SIZE = 18 | 16 | const ICON_SIZE = 18 |
| @@ -68,6 +69,7 @@ const toggleAppearance = inject<() => void>('toggle-appearance', () => { | |||
| 68 | </button> | 69 | </button> |
| 69 | </template> | 70 | </template> |
| 70 | <BookmarksPanel v-else-if="action.type === 'bookmarks'" /> | 71 | <BookmarksPanel v-else-if="action.type === 'bookmarks'" /> |
| 72 | <AnnouncementsPanel v-else-if="action.type === 'announcement'" /> | ||
| 71 | </div> | 73 | </div> |
| 72 | </template> | 74 | </template> |
| 73 | </div> | 75 | </div> |
| @@ -104,6 +106,11 @@ const toggleAppearance = inject<() => void>('toggle-appearance', () => { | |||
| 104 | justify-content: center; | 106 | justify-content: center; |
| 105 | } | 107 | } |
| 106 | 108 | ||
| 109 | /* collapse the slot when announcements are disabled */ | ||
| 110 | .nav-action--announcement:empty { | ||
| 111 | display: none; | ||
| 112 | } | ||
| 113 | |||
| 107 | /* Social links move to the full-screen menu on phones. */ | 114 | /* Social links move to the full-screen menu on phones. */ |
| 108 | .nav-action--link { | 115 | .nav-action--link { |
| 109 | display: none; | 116 | display: none; |
docs/.vitepress/theme/components/settings/Announcements.vue added +61
| @@ -0,0 +1,61 @@ | |||
| 1 | <script setup lang="ts"> | ||
| 2 | import { NuInputHighlight, NuInputHorizontalRadioGroup } from '@nolebase/ui' | ||
| 3 | import { useStorage } from '@vueuse/core' | ||
| 4 | import { computed, ref } from 'vue' | ||
| 5 | |||
| 6 | import MenuHelp from './MenuHelp.vue' | ||
| 7 | import MenuTitle from './MenuTitle.vue' | ||
| 8 | |||
| 9 | import { AnnouncementsEnabledKey } from '../../constants' | ||
| 10 | |||
| 11 | const menuTitleElementRef = ref<HTMLDivElement>() | ||
| 12 | const isMenuHelpPoppedUp = ref(false) | ||
| 13 | |||
| 14 | const announcements = useStorage(AnnouncementsEnabledKey, 'on') | ||
| 15 | |||
| 16 | const fieldOptions = computed(() => [ | ||
| 17 | { | ||
| 18 | value: 'on', | ||
| 19 | title: 'On', | ||
| 20 | ariaLabel: 'On', | ||
| 21 | text: 'ON', | ||
| 22 | name: 'Announcements' | ||
| 23 | }, | ||
| 24 | { | ||
| 25 | value: 'off', | ||
| 26 | title: 'Off', | ||
| 27 | ariaLabel: 'Off', | ||
| 28 | text: 'OFF', | ||
| 29 | name: 'Announcements' | ||
| 30 | } | ||
| 31 | ]) | ||
| 32 | </script> | ||
| 33 | |||
| 34 | <template> | ||
| 35 | <div space-y-2 role="radiogroup"> | ||
| 36 | <div ref="menuTitleElementRef" relative flex items-center> | ||
| 37 | <MenuTitle title="Announcements" aria-label="Announcements" flex="1" pr-4> | ||
| 38 | <template #icon> | ||
| 39 | <span i-lucide:megaphone mr-1 aria-hidden="true" /> | ||
| 40 | </template> | ||
| 41 | </MenuTitle> | ||
| 42 | <MenuHelp | ||
| 43 | v-model:is-popped-up="isMenuHelpPoppedUp" | ||
| 44 | :menu-title-element-ref="menuTitleElementRef" | ||
| 45 | > | ||
| 46 | <h4 text-md mb-1 font-semibold>Announcements</h4> | ||
| 47 | <p text="sm" mb-2 max-w-100> | ||
| 48 | Shows the megaphone in the navbar with news about new sections, components, and improvements. | ||
| 49 | </p> | ||
| 50 | </MenuHelp> | ||
| 51 | </div> | ||
| 52 | <NuInputHighlight :active="isMenuHelpPoppedUp" class="rounded-md"> | ||
| 53 | <NuInputHorizontalRadioGroup | ||
| 54 | v-model="announcements" | ||
| 55 | bg="$vp-nolebase-enhanced-readabilities-menu-background-color" | ||
| 56 | text="sm $vp-nolebase-enhanced-readabilities-menu-text-color" | ||
| 57 | :options="fieldOptions" | ||
| 58 | /> | ||
| 59 | </NuInputHighlight> | ||
| 60 | </div> | ||
| 61 | </template> | ||
docs/.vitepress/theme/components/settings/Menu.vue +2
| @@ -3,6 +3,7 @@ import { useMounted } from '@vueuse/core' | |||
| 3 | 3 | ||
| 4 | import AccentBackground from './AccentBackground.vue' | 4 | import AccentBackground from './AccentBackground.vue' |
| 5 | import AccentColor from './AccentColor.vue' | 5 | import AccentColor from './AccentColor.vue' |
| 6 | import Announcements from './Announcements.vue' | ||
| 6 | import Effects from './Effects.vue' | 7 | import Effects from './Effects.vue' |
| 7 | import Favicons from './Favicons.vue' | 8 | import Favicons from './Favicons.vue' |
| 8 | import SettingsFlyout from './SettingsFlyout.vue' | 9 | import SettingsFlyout from './SettingsFlyout.vue' |
| @@ -23,6 +24,7 @@ const mounted = useMounted() | |||
| 23 | <AccentBackground /> | 24 | <AccentBackground /> |
| 24 | <Effects /> | 25 | <Effects /> |
| 25 | <Favicons /> | 26 | <Favicons /> |
| 27 | <Announcements /> | ||
| 26 | </div> | 28 | </div> |
| 27 | </SettingsFlyout> | 29 | </SettingsFlyout> |
| 28 | </template> | 30 | </template> |
docs/.vitepress/theme/components/settings/ScreenMenu.vue +2
| @@ -5,6 +5,7 @@ import VPSocialLinks from 'vitepress/dist/client/theme-default/components/VPSoci | |||
| 5 | 5 | ||
| 6 | import AccentBackground from './AccentBackground.vue' | 6 | import AccentBackground from './AccentBackground.vue' |
| 7 | import AccentColor from './AccentColor.vue' | 7 | import AccentColor from './AccentColor.vue' |
| 8 | import Announcements from './Announcements.vue' | ||
| 8 | import Effects from './Effects.vue' | 9 | import Effects from './Effects.vue' |
| 9 | import Favicons from './Favicons.vue' | 10 | import Favicons from './Favicons.vue' |
| 10 | 11 | ||
| @@ -18,6 +19,7 @@ const { theme } = useData() | |||
| 18 | <AccentBackground /> | 19 | <AccentBackground /> |
| 19 | <Effects /> | 20 | <Effects /> |
| 20 | <Favicons /> | 21 | <Favicons /> |
| 22 | <Announcements /> | ||
| 21 | <VPSocialLinks | 23 | <VPSocialLinks |
| 22 | v-if="theme.socialLinks" | 24 | v-if="theme.socialLinks" |
| 23 | :links="theme.socialLinks" | 25 | :links="theme.socialLinks" |
docs/.vitepress/theme/composables/useAnnouncements.ts added +44
| @@ -0,0 +1,44 @@ | |||
| 1 | import { useStorage } from '@vueuse/core' | ||
| 2 | import { computed } from 'vue' | ||
| 3 | |||
| 4 | import { data as announcements } from '../announcements.data' | ||
| 5 | import { AnnouncementsEnabledKey, AnnouncementsReadKey } from '../constants' | ||
| 6 | |||
| 7 | export type { Announcement, AnnouncementType } from '../announcements.data' | ||
| 8 | |||
| 9 | export function useAnnouncements() { | ||
| 10 | // on by default | ||
| 11 | const enabledPref = useStorage(AnnouncementsEnabledKey, 'on') | ||
| 12 | const enabled = computed(() => enabledPref.value !== 'off') | ||
| 13 | |||
| 14 | const readIds = useStorage<string[]>(AnnouncementsReadKey, []) | ||
| 15 | const readSet = computed(() => new Set(readIds.value)) | ||
| 16 | |||
| 17 | function isRead(id: string): boolean { | ||
| 18 | return readSet.value.has(id) | ||
| 19 | } | ||
| 20 | |||
| 21 | function markRead(id: string): void { | ||
| 22 | if (!readSet.value.has(id)) readIds.value = [...readIds.value, id] | ||
| 23 | } | ||
| 24 | |||
| 25 | function markAllRead(): void { | ||
| 26 | readIds.value = announcements.map((a) => a.id) | ||
| 27 | } | ||
| 28 | |||
| 29 | const unreadCount = computed( | ||
| 30 | () => announcements.filter((a) => !readSet.value.has(a.id)).length | ||
| 31 | ) | ||
| 32 | const hasUnread = computed(() => enabled.value && unreadCount.value > 0) | ||
| 33 | |||
| 34 | return { | ||
| 35 | announcements, | ||
| 36 | enabledPref, | ||
| 37 | enabled, | ||
| 38 | isRead, | ||
| 39 | markRead, | ||
| 40 | markAllRead, | ||
| 41 | unreadCount, | ||
| 42 | hasUnread | ||
| 43 | } | ||
| 44 | } | ||
docs/.vitepress/theme/constants.ts +4
| @@ -4,3 +4,7 @@ export const AccentColorStorageKey = 'preference-accent-color' | |||
| 4 | export const AccentBgStorageKey = 'preference-accent-bg' | 4 | export const AccentBgStorageKey = 'preference-accent-bg' |
| 5 | /** Accent background tint strength, 0–100. */ | 5 | /** Accent background tint strength, 0–100. */ |
| 6 | export const AccentBgStrengthStorageKey = 'preference-accent-bg-strength' | 6 | export const AccentBgStrengthStorageKey = 'preference-accent-bg-strength' |
| 7 | // announcements on/off toggle | ||
| 8 | export const AnnouncementsEnabledKey = 'preference-announcements' | ||
| 9 | // ids marked read | ||
| 10 | export const AnnouncementsReadKey = 'wotaku-announcements-read' | ||
docs/.vitepress/theme/navActions.ts +6
| @@ -20,6 +20,10 @@ export interface NavBookmarksAction extends NavActionBase { | |||
| 20 | type: 'bookmarks' | 20 | type: 'bookmarks' |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | export interface NavAnnouncementAction extends NavActionBase { | ||
| 24 | type: 'announcement' | ||
| 25 | } | ||
| 26 | |||
| 23 | export interface NavLinkAction extends NavActionBase { | 27 | export interface NavLinkAction extends NavActionBase { |
| 24 | type: 'link' | 28 | type: 'link' |
| 25 | icon: string | 29 | icon: string |
| @@ -32,12 +36,14 @@ export type NavAction = | |||
| 32 | | NavAppearanceAction | 36 | | NavAppearanceAction |
| 33 | | NavSettingsAction | 37 | | NavSettingsAction |
| 34 | | NavBookmarksAction | 38 | | NavBookmarksAction |
| 39 | | NavAnnouncementAction | ||
| 35 | | NavLinkAction | 40 | | NavLinkAction |
| 36 | 41 | ||
| 37 | export const navActions: NavAction[] = [ | 42 | export const navActions: NavAction[] = [ |
| 38 | { type: 'appearance' }, | 43 | { type: 'appearance' }, |
| 39 | { type: 'search' }, | 44 | { type: 'search' }, |
| 40 | { type: 'bookmarks' }, | 45 | { type: 'bookmarks' }, |
| 46 | { type: 'announcement' }, | ||
| 41 | { type: 'settings' }, | 47 | { type: 'settings' }, |
| 42 | { | 48 | { |
| 43 | type: 'link', | 49 | type: 'link', |
docs/public/post/accent/img1.png added
Binary file not shown.
docs/public/post/bookmark/vid1.webm added
Binary file not shown.
docs/public/post/bookmark/vid2.webm added
Binary file not shown.
docs/public/post/extrepo/img1.png added
Binary file not shown.
docs/public/post/fav/img1.png added
Binary file not shown.
docs/public/post/homefeature/vid1.webm added
Binary file not shown.
docs/public/post/homefeature/vid2.webm added
Binary file not shown.
docs/public/post/homefeature/vid3.webm added
Binary file not shown.
docs/public/post/searchimp/img1.png added
Binary file not shown.
docs/public/post/searchurl/vid1.webm added
Binary file not shown.
docs/public/post/searchurl/vid2.webm added
Binary file not shown.