Commit 3bfe2658a4

3bfe2658a416835956fd931b4a3827462592b2eb

parent: 462c94fdb0

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-11-03 01:08 UTC

a

Layout: unified · split

docs/.vitepress/configs/markdown/index.ts +2
@@ -31,6 +31,7 @@ import { scrapeTablePlugin } from './scrapeTablePlugin'
3131import markdownSteps from './steps'
3232import { tableMorePlugin } from './tableMore'
3333import { tabsMarkdownPlugin } from './tabs'
34import { themeRepoPlugin } from './themeRepoPlugin'
3435
3536export function configureMarkdown(md: MarkdownRenderer) {
3637 md.use(emojiRender)
@@ -57,6 +58,7 @@ export function configureMarkdown(md: MarkdownRenderer) {
5758 md.use(tableMorePlugin)
5859 md.use(scrapeTablePlugin)
5960 md.use(extRepoPlugin)
61 md.use(themeRepoPlugin)
6062 renderHighlight(md)
6163}
6264
docs/.vitepress/configs/markdown/themeRepoPlugin.ts added +96
@@ -0,0 +1,96 @@
1import type MarkdownIt from 'markdown-it'
2import type { ThemeRepoEntry } from '../../../ext/themeRepos/types'
3
4const MARKER = ':'
5const MIN_MARKERS = 3
6const NAME = 'themerepo'
7
8function parseEntries(bodyLines: string[]): ThemeRepoEntry[] {
9 const entries: ThemeRepoEntry[] = []
10 let current: ThemeRepoEntry | null = null
11
12 for (const rawLine of bodyLines) {
13 const line = rawLine.trim()
14 if (!line) continue
15
16 const headingMatch = line.match(/^==\s+(.+)$/)
17 if (headingMatch) {
18 if (current) entries.push(current)
19 current = { name: headingMatch[1].trim() }
20 continue
21 }
22
23 const fieldMatch = line.match(/^-\s*([a-zA-Z]+)\s*:\s*(.+)$/)
24 if (fieldMatch && current) {
25 const key = fieldMatch[1].toLowerCase()
26 const value = fieldMatch[2].trim()
27 if (key === 'url' || key === 'src' || key === 'raw') {
28 current[key] = value
29 }
30 }
31 }
32 if (current) entries.push(current)
33
34 return entries
35}
36
37export function themeRepoPlugin(md: MarkdownIt): void {
38 md.block.ruler.before(
39 'fence',
40 'theme_repo',
41 (state, startLine, endLine, silent) => {
42 let pos = state.bMarks[startLine] + state.tShift[startLine]
43 const max = state.eMarks[startLine]
44
45 let markerCount = 0
46 while (pos < max && state.src[pos] === MARKER) {
47 pos++
48 markerCount++
49 }
50 if (markerCount < MIN_MARKERS) return false
51
52 const params = state.src.slice(pos, max).trim()
53 if (params.split(/\s+/)[0].toLowerCase() !== NAME) return false
54
55 if (silent) return true
56
57 let nextLine = startLine + 1
58 let found = false
59 while (nextLine < endLine) {
60 let p = state.bMarks[nextLine] + state.tShift[nextLine]
61 const m = state.eMarks[nextLine]
62 if (p < m && state.sCount[nextLine] < state.blkIndent) break
63
64 let cnt = 0
65 while (p < m && state.src[p] === MARKER) {
66 p++
67 cnt++
68 }
69 if (cnt >= markerCount && state.src.slice(p, m).trim() === '') {
70 found = true
71 break
72 }
73 nextLine++
74 }
75
76 const body = state.getLines(
77 startLine + 1,
78 nextLine,
79 state.blkIndent,
80 false
81 )
82 const entries = parseEntries(body.split('\n'))
83 const attrs = entries.length
84 ? ` :themes='${JSON.stringify(entries).replace(/'/g, '&#39;')}'`
85 : ''
86
87 const token = state.push('html_block', '', 0)
88 token.map = [startLine, nextLine]
89 token.content = `<ThemeRepos${attrs} />\n`
90
91 state.line = found ? nextLine + 1 : nextLine
92 return true
93 },
94 { alt: ['paragraph', 'reference', 'blockquote', 'list'] }
95 )
96}
docs/.vitepress/theme/components/themerepo/ThemePreview.vue added +80
@@ -0,0 +1,80 @@
1<script setup lang="ts">
2import type { ManaTheme } from '../../../../ext/themeRepos/types'
3import type { Screen } from './screens'
4import ThemeScreen from './ThemeScreen.vue'
5
6defineProps<{ theme: ManaTheme; screen: Screen }>()
7defineEmits<{ prev: []; next: [] }>()
8</script>
9
10<template>
11 <div class="theme-preview">
12 <div class="theme-phone">
13 <ThemeScreen :screen="screen" :theme="theme" />
14 <button
15 type="button"
16 class="theme-arrow theme-arrow-prev"
17 aria-label="Previous screen"
18 @click="$emit('prev')"
19 >
20 <span class="i-lucide:chevron-left" />
21 </button>
22 <button
23 type="button"
24 class="theme-arrow theme-arrow-next"
25 aria-label="Next screen"
26 @click="$emit('next')"
27 >
28 <span class="i-lucide:chevron-right" />
29 </button>
30 </div>
31 <div class="theme-caption">{{ screen.title }}</div>
32 </div>
33</template>
34
35<style scoped>
36.theme-preview {
37 display: flex;
38 flex-direction: column;
39 align-items: center;
40 gap: 10px;
41}
42.theme-phone {
43 position: relative;
44 width: min(100%, var(--theme-phone-width, 250px));
45}
46.theme-arrow {
47 position: absolute;
48 top: 50%;
49 display: flex;
50 align-items: center;
51 justify-content: center;
52 width: 32px;
53 height: 32px;
54 padding: 0;
55 border: none;
56 border-radius: 50%;
57 background-color: transparent;
58 color: var(--vp-c-text-2);
59 cursor: pointer;
60 transform: translateY(-50%);
61 transition: color 0.2s, filter 0.2s;
62}
63.theme-arrow:hover {
64 color: var(--vp-c-brand-1);
65 filter: brightness(1.08);
66}
67.theme-arrow span {
68 font-size: 20px;
69}
70.theme-arrow-prev {
71 left: -33px;
72}
73.theme-arrow-next {
74 right: -33px;
75}
76.theme-caption {
77 font-size: 12px;
78 color: var(--vp-c-text-3);
79}
80</style>
docs/.vitepress/theme/components/themerepo/ThemeRepos.vue added +230
@@ -0,0 +1,230 @@
1<script setup lang="ts">
2import { useMediaQuery } from '@vueuse/core'
3import { computed, onMounted, ref } from 'vue'
4import {
5 DEFAULT_THEME,
6 resolveThemeColors
7} from '../../../../ext/themeRepos/defaults'
8import type {
9 ManaTheme,
10 ThemeRepoEntry
11} from '../../../../ext/themeRepos/types'
12import { screens } from './screens'
13import ThemePreview from './ThemePreview.vue'
14import ThemeRow from './ThemeRow.vue'
15
16type ThemeIndexEntry = {
17 name?: string
18 author?: string | { name?: string }
19 url?: string
20}
21type ThemeFile = {
22 theme?: { name?: string; colors?: { values?: Record<string, string> } }
23}
24type LoadedTheme = ManaTheme & { raw: string }
25
26const props = withDefaults(defineProps<{ themes?: ThemeRepoEntry[] }>(), {
27 themes: () => []
28})
29
30const themes = ref<LoadedTheme[]>([])
31const loading = ref(props.themes.length > 0)
32const loadFailed = ref(false)
33const selectedKey = ref<string | null>(null)
34const screenIndex = ref(0)
35const isPhone = useMediaQuery('(max-width: 767px)')
36
37const previewTheme = computed(
38 () =>
39 themes.value.find(theme => theme.raw === selectedKey.value) ??
40 DEFAULT_THEME
41)
42const screen = computed(() => screens[screenIndex.value] ?? screens[0])
43
44async function fetchJson<T>(url: string): Promise<T> {
45 const res = await fetch(url)
46 if (!res.ok) throw new Error(`${res.status} ${res.statusText}`)
47 return res.json()
48}
49
50async function loadRepo(entry: ThemeRepoEntry): Promise<LoadedTheme[]> {
51 if (!entry.raw) return []
52
53 const index = await fetchJson<{ themes?: ThemeIndexEntry[] }>(entry.raw)
54 const loaded = await Promise.all(
55 (index.themes ?? [])
56 .filter((item): item is ThemeIndexEntry & { url: string } =>
57 Boolean(item.url)
58 )
59 .map(async item => {
60 const file = await fetchJson<ThemeFile>(item.url)
61 const values = file.theme?.colors?.values
62 const name = item.name ?? file.theme?.name
63 return values && name
64 ? {
65 name,
66 author: typeof item.author === 'string'
67 ? item.author
68 : item.author?.name,
69 colors: resolveThemeColors(values),
70 raw: item.url
71 }
72 : null
73 })
74 )
75
76 return loaded.filter((theme): theme is LoadedTheme => theme !== null)
77}
78
79onMounted(async () => {
80 if (props.themes.length === 0) return
81
82 loading.value = true
83 const results = await Promise.allSettled(props.themes.map(loadRepo))
84 const unique = new Map<string, LoadedTheme>()
85 for (
86 const theme of results.flatMap(r => r.status === 'fulfilled' ? r.value : [])
87 ) {
88 unique.set(theme.raw, theme)
89 }
90 themes.value = [...unique.values()].sort((a, b) =>
91 a.name.localeCompare(b.name)
92 )
93 loadFailed.value = results.some(r => r.status === 'rejected')
94 loading.value = false
95})
96
97function showScreen(delta: number): void {
98 screenIndex.value = (screenIndex.value + delta + screens.length) %
99 screens.length
100}
101
102function toggleTheme(theme: LoadedTheme): void {
103 selectedKey.value = selectedKey.value === theme.raw ? null : theme.raw
104}
105</script>
106
107<template>
108 <div class="theme-repos">
109 <div v-if="themes.length" class="theme-showcase">
110 <div class="theme-stage">
111 <ThemePreview
112 :theme="previewTheme"
113 :screen="screen"
114 @prev="showScreen(-1)"
115 @next="showScreen(1)"
116 />
117 </div>
118
119 <div class="theme-panel">
120 <div
121 class="theme-list"
122 :class="{ 'theme-list-open': isPhone && selectedKey }"
123 >
124 <template v-for="theme in themes" :key="theme.raw">
125 <ThemeRow
126 :theme="theme"
127 :selected="theme.raw === selectedKey"
128 @select="toggleTheme(theme)"
129 />
130 <div
131 v-if="isPhone && theme.raw === selectedKey"
132 class="theme-dropdown"
133 >
134 <ThemePreview
135 :theme="theme"
136 :screen="screen"
137 @prev="showScreen(-1)"
138 @next="showScreen(1)"
139 />
140 </div>
141 </template>
142 </div>
143 </div>
144 </div>
145
146 <p v-else-if="loading" class="theme-repos-empty">Loading themes…</p>
147 <p v-else-if="loadFailed" class="theme-repos-empty">
148 Couldn't load themes from this repo.
149 </p>
150 <p v-else class="theme-repos-empty">No themes found.</p>
151 </div>
152</template>
153
154<style scoped>
155.theme-repos {
156 margin: 16px 0;
157 border: 1px solid var(--vp-c-divider);
158 border-radius: var(--radius-xl, 12px);
159 overflow: hidden;
160}
161.theme-showcase {
162 display: grid;
163 grid-template-columns: minmax(220px, 0.82fr) minmax(0, 1.18fr);
164 min-height: 100%;
165}
166.theme-stage {
167 display: flex;
168 flex-direction: column;
169 align-items: center;
170 justify-content: center;
171 gap: 10px;
172 padding: 34px;
173 background-color: var(--vp-c-bg-soft);
174 border-right: 1px solid var(--vp-c-divider);
175}
176.theme-panel {
177 position: relative;
178 min-width: 0;
179 min-height: 0;
180}
181.theme-list {
182 position: absolute;
183 inset: 0;
184 display: flex;
185 flex-direction: column;
186 justify-content: flex-start;
187 overflow-y: auto;
188}
189.theme-list > .theme-row:not(:first-child) {
190 border-top: 1px solid var(--vp-c-divider);
191}
192.theme-dropdown {
193 display: flex;
194 flex-direction: column;
195 align-items: center;
196 padding: 30px 40px 22px;
197 background-color: var(--vp-c-bg-soft);
198}
199.theme-repos-empty {
200 margin: 0;
201 padding: 16px;
202 color: var(--vp-c-text-2);
203 font-size: 14px;
204}
205
206@media (max-width: 767px) {
207 .theme-showcase {
208 grid-template-columns: minmax(0, 1fr);
209 }
210 .theme-stage {
211 display: none;
212 }
213 .theme-panel {
214 position: static;
215 }
216 .theme-list {
217 position: static;
218 max-height: 60vh;
219 overflow-y: auto;
220 overscroll-behavior: contain;
221 }
222 .theme-dropdown {
223 border-top: 1px solid var(--vp-c-divider);
224 --theme-phone-width: min(250px, calc(40vh - 64px));
225 }
226 .theme-list-open {
227 max-height: 85vh;
228 }
229}
230</style>
docs/.vitepress/theme/components/themerepo/ThemeRow.vue added +227
@@ -0,0 +1,227 @@
1<script setup lang="ts">
2import { computed } from 'vue'
3import type { ManaTheme } from '../../../../ext/themeRepos/types'
4import { useCopy } from '../extrepo/useCopy'
5
6const props = defineProps<{ theme: ManaTheme; selected: boolean }>()
7defineEmits<{ select: [] }>()
8
9const { copiedKey, copy } = useCopy()
10
11const addThemeLink = computed(() =>
12 props.theme.raw
13 ? `mana://add-theme?url=${encodeURIComponent(props.theme.raw)}`
14 : undefined
15)
16
17const swatches = computed(() =>
18 Object.entries(props.theme.colors)
19 .sort(([a], [b]) => a.localeCompare(b))
20 .map(([key, color]) => ({ key, color }))
21)
22</script>
23
24<template>
25 <div
26 class="theme-row"
27 :class="{ 'theme-row-selected': selected }"
28 @click="$emit('select')"
29 >
30 <div class="theme-row-body">
31 <div class="theme-row-text">
32 <button
33 type="button"
34 class="theme-row-name"
35 :aria-pressed="selected"
36 :title="selected
37 ? 'Show default preview'
38 : `Preview ${theme.name}`"
39 >
40 {{ theme.name }}
41 </button>
42 <span v-if="theme.author" class="theme-row-author">
43 {{ theme.author }}
44 </span>
45 </div>
46 <button
47 type="button"
48 class="theme-shades"
49 :aria-pressed="selected"
50 :aria-label="`Preview ${theme.name}`"
51 >
52 <span
53 v-for="swatch in swatches"
54 :key="swatch.key"
55 class="theme-shade"
56 :style="{ backgroundColor: swatch.color }"
57 :title="`${swatch.key}: ${swatch.color}`"
58 />
59 </button>
60 </div>
61
62 <a
63 v-if="addThemeLink"
64 class="theme-install"
65 :href="addThemeLink"
66 :aria-label="`Add ${theme.name} to Mana`"
67 :title="`Add ${theme.name} to Mana`"
68 @click.stop
69 >
70 <span class="theme-install-icon i-lucide:download" />
71 <span class="theme-install-label">Install</span>
72 </a>
73
74 <button
75 v-if="theme.raw"
76 type="button"
77 class="theme-copy"
78 :class="{ 'theme-copy-done': copiedKey === theme.raw }"
79 :aria-label="copiedKey === theme.raw
80 ? `Copied ${theme.name} URL`
81 : `Copy ${theme.name} URL`"
82 :title="copiedKey === theme.raw
83 ? 'Copied!'
84 : `Copy ${theme.name} JSON URL`"
85 @click.stop="copy(theme.raw, theme.raw)"
86 >
87 <span v-if="copiedKey === theme.raw" class="i-lucide:check" />
88 <span v-else class="i-lucide:copy" />
89 </button>
90 </div>
91</template>
92
93<style scoped>
94.theme-row {
95 display: flex;
96 align-items: center;
97 gap: 10px;
98 padding: 10px 12px;
99 border-left: 2px solid transparent;
100 cursor: pointer;
101 transition: background-color 0.15s, border-color 0.15s;
102}
103.theme-row:hover {
104 background-color: var(--vp-c-bg-soft);
105}
106.theme-row-selected {
107 border-left-color: var(--vp-c-brand-1);
108 background-color: var(--vp-c-bg-soft);
109}
110.theme-row-body {
111 flex: 1;
112 min-width: 0;
113 display: flex;
114 flex-direction: column;
115 gap: 6px;
116}
117.theme-row-text {
118 min-width: 0;
119 display: flex;
120 flex-direction: column;
121 gap: 1px;
122}
123.theme-row-name {
124 min-width: 0;
125 padding: 0;
126 border: none;
127 background: transparent;
128 font: inherit;
129 font-size: 14px;
130 font-weight: 600;
131 line-height: 1.3;
132 color: var(--vp-c-text-1);
133 text-align: left;
134 white-space: nowrap;
135 overflow: hidden;
136 text-overflow: ellipsis;
137 cursor: pointer;
138}
139.theme-row-author {
140 font-size: 12px;
141 line-height: 1.3;
142 color: var(--vp-c-text-3);
143 white-space: nowrap;
144 overflow: hidden;
145 text-overflow: ellipsis;
146}
147.theme-shades {
148 width: 100%;
149 display: flex;
150 height: 10px;
151 padding: 0;
152 border: none;
153 border-radius: 4px;
154 overflow: hidden;
155 background: transparent;
156 cursor: pointer;
157}
158.theme-shade {
159 flex: 1;
160 height: 100%;
161}
162.theme-copy {
163 flex-shrink: 0;
164 display: flex;
165 align-items: center;
166 justify-content: center;
167 width: 32px;
168 height: 32px;
169 padding: 0;
170 border-radius: 8px;
171 border: 1px solid var(--vp-c-divider);
172 background-color: var(--vp-c-bg);
173 color: var(--vp-c-text-1);
174 cursor: pointer;
175 transition: border-color 0.2s, color 0.2s;
176}
177.theme-copy:hover {
178 border-color: var(--vp-c-brand-1);
179 color: var(--vp-c-brand-1);
180}
181.theme-copy-done {
182 border-color: var(--vp-c-brand-1);
183 color: var(--vp-c-brand-1);
184}
185.theme-copy span {
186 font-size: 15px;
187}
188.theme-install {
189 flex-shrink: 0;
190 display: flex;
191 align-items: center;
192 justify-content: center;
193 gap: 5px;
194 height: 32px;
195 padding: 0 10px;
196 border-radius: 8px;
197 border: 1px solid var(--vp-button-brand-border);
198 background-color: var(--vp-button-brand-bg);
199 color: var(--vp-button-brand-text) !important;
200 font-size: 13px;
201 font-weight: 600;
202 line-height: 1;
203 text-decoration: none !important;
204 transition: filter 0.2s, border-color 0.2s;
205}
206.theme-install:hover {
207 filter: brightness(1.08);
208 border-color: var(--vp-button-brand-hover-border);
209}
210.theme-install-icon {
211 font-size: 15px;
212}
213.theme-install-label {
214 white-space: nowrap;
215}
216
217@media (max-width: 767px) {
218 .theme-install {
219 width: 32px;
220 padding: 0;
221 gap: 0;
222 }
223 .theme-install-label {
224 display: none;
225 }
226}
227</style>
docs/.vitepress/theme/components/themerepo/ThemeScreen.vue added +159
@@ -0,0 +1,159 @@
1<script setup lang="ts">
2import { useId } from 'vue'
3import type { ManaTheme } from '../../../../ext/themeRepos/types'
4import type { Screen } from './screens'
5
6defineProps<{ screen: Screen; theme: ManaTheme }>()
7
8const id = useId()
9
10function colors(theme: ManaTheme) {
11 const vars = Object.entries(theme.colors).map((
12 [key, value]
13 ) => [`--t-${key}`, value])
14 return Object.fromEntries([
15 ...vars,
16 ['--scrim', `url(#${id}-scrim)`],
17 ['--fade', `url(#${id}-fade)`]
18 ])
19}
20</script>
21
22<template>
23 <svg
24 class="screen"
25 viewBox="0 0 497 1024"
26 role="img"
27 :aria-label="`${screen.title} screen in ${theme.name}`"
28 :style="colors(theme)"
29 >
30 <defs>
31 <linearGradient :id="`${id}-scrim`" x1="0" y1="0" x2="0" y2="1">
32 <stop offset="0.55" class="stop-overlay" stop-opacity="0" />
33 <stop offset="1" class="stop-overlay" />
34 </linearGradient>
35 <linearGradient :id="`${id}-fade`" x1="0" y1="0" x2="0" y2="1">
36 <stop offset="0" class="stop-background" stop-opacity="0" />
37 <stop offset="1" class="stop-background" />
38 </linearGradient>
39 </defs>
40 <component
41 :is="shape.tag"
42 v-for="(shape, i) in screen.shapes"
43 :key="i"
44 v-bind="shape.attrs"
45 />
46 </svg>
47</template>
48
49<style scoped>
50.screen {
51 display: block;
52 width: 100%;
53 height: auto;
54 border-radius: 8%/3.9%;
55 background: var(--t-background);
56 box-shadow: 0 0 0 1px var(--vp-c-divider);
57}
58.stop-overlay {
59 stop-color: var(--t-contentTileOverlay);
60}
61.stop-background {
62 stop-color: var(--t-background);
63}
64
65.label {
66 fill: var(--t-label);
67 fill-opacity: 0.8;
68}
69.muted {
70 fill: var(--t-secondaryLabel);
71 fill-opacity: 0.7;
72}
73.chevron {
74 fill: none;
75 stroke: var(--t-secondaryLabel);
76 stroke-width: 2.4;
77 stroke-linecap: round;
78 stroke-linejoin: round;
79}
80.progress-track {
81 fill: none;
82 stroke: var(--t-secondaryLabel);
83 stroke-opacity: 0.25;
84 stroke-width: 3;
85}
86.progress {
87 fill: none;
88 stroke: var(--t-accent);
89 stroke-width: 3;
90 stroke-linecap: round;
91}
92.accent {
93 fill: var(--t-accent);
94}
95.accent-soft {
96 fill: var(--t-accent);
97 fill-opacity: 0.25;
98}
99.on-accent {
100 fill: var(--t-foregroundOnAccent);
101}
102.secondary {
103 fill: var(--t-secondaryBackground);
104}
105.tertiary {
106 fill: var(--t-tertiaryBackground);
107}
108.separator {
109 fill: var(--t-separator);
110}
111.info {
112 fill: var(--t-statusInfo);
113}
114.support {
115 fill: #fd5d51;
116}
117.support-label {
118 fill: #ffffff;
119}
120.support-label-soft {
121 fill: #ffffff;
122 fill-opacity: 0.72;
123}
124.destructive {
125 fill: var(--t-statusDestructive);
126}
127.scrim {
128 fill: var(--scrim);
129}
130.fade {
131 fill: var(--fade);
132}
133.glass {
134 fill: var(--t-secondaryBackground);
135 fill-opacity: 0.92;
136 stroke: var(--t-separator);
137}
138.raised {
139 fill: var(--t-secondaryBackground);
140 stroke: var(--t-separator);
141}
142.raised-tertiary {
143 fill: var(--t-tertiaryBackground);
144 stroke: var(--t-separator);
145}
146.card {
147 fill: var(--t-secondaryBackground);
148 stroke: var(--t-separator);
149}
150.chip {
151 fill: var(--t-secondaryBackground);
152 stroke: var(--t-separator);
153}
154.info-chip {
155 fill: var(--t-statusInfo);
156 fill-opacity: 0.12;
157 stroke: var(--t-statusInfo);
158}
159</style>
docs/.vitepress/theme/components/themerepo/index.ts added +3
@@ -0,0 +1,3 @@
1import ThemeRepos from './ThemeRepos.vue'
2
3export { ThemeRepos }
docs/.vitepress/theme/components/themerepo/screens.ts added +361
@@ -0,0 +1,361 @@
1export interface Shape {
2 tag: 'rect' | 'circle' | 'path'
3 attrs: Record<string, string | number>
4}
5
6export interface Screen {
7 id: string
8 title: string
9 shapes: Shape[]
10}
11
12const box = (
13 x: number,
14 y: number,
15 width: number,
16 height: number,
17 cls: string,
18 rx = 0
19): Shape => ({ tag: 'rect', attrs: { x, y, width, height, rx, class: cls } })
20
21const dot = (cx: number, cy: number, r: number, cls: string): Shape => ({
22 tag: 'circle',
23 attrs: { cx, cy, r, class: cls }
24})
25
26const bar = (
27 x: number,
28 y: number,
29 width: number,
30 height: number,
31 cls = 'label'
32) => box(x, y, width, height, cls, height / 2)
33
34const line = (x: number, y: number, width: number) =>
35 box(x, y, width, 1, 'separator')
36
37function pill(
38 x: number,
39 y: number,
40 width: number,
41 height: number,
42 cls = 'chip',
43 text = 'muted'
44) {
45 const inner = width * 0.6
46 return [
47 box(x, y, width, height, cls, height / 2),
48 bar(x + (width - inner) / 2, y + height / 2 - 5, inner, 10, text)
49 ]
50}
51
52const iconButton = (
53 cx: number,
54 cy: number
55) => [dot(cx, cy, 24, 'raised'), dot(cx, cy, 8, 'label')]
56
57const tabBar = (active: number) => {
58 const centers = [75, 162, 248, 334, 420]
59 return [
60 box(24, 930, 448, 70, 'glass', 35),
61 box(centers[active] - 47, 936, 94, 58, 'tertiary', 29),
62 ...centers.flatMap((x, i) => {
63 const cls = i === active ? 'accent' : 'label'
64 return [dot(x, 956, 11, cls), bar(x - 21, 977, 42, 8, cls)]
65 })
66 ]
67}
68
69const searchField = (trailing: Shape[] = []) => [
70 box(23, 135, 451, 48, 'secondary', 24),
71 dot(47, 159, 8, 'label'),
72 bar(68, 153, 122, 13, 'muted'),
73 ...trailing
74]
75
76const cover = (
77 x: number,
78 y: number,
79 width: number,
80 height: number,
81 cls: string,
82 rx: number
83) => [box(x, y, width, height, cls, rx), box(x, y, width, height, 'scrim', rx)]
84
85function libraryTile(x: number, y: number, i: number) {
86 return [
87 ...cover(x, y, 146, 218, i % 2 ? 'secondary' : 'tertiary', 12),
88 box(x + 118, y + 6, 24, 22, 'accent', 6),
89 bar(x + 10, y + 178, 122, 11),
90 bar(x + 10, y + 197, 90, 11)
91 ]
92}
93
94const content: Shape[] = [
95 box(0, 0, 497, 400, 'tertiary'),
96 box(0, 180, 497, 220, 'fade'),
97 ...iconButton(46, 46),
98 bar(32, 328, 430, 24),
99 bar(117, 360, 260, 24),
100
101 box(22, 407, 79, 31, 'info-chip', 15.5),
102 bar(36, 417, 51, 10, 'info'),
103 ...[[107, 76], [189, 58], [253, 66], [325, 82], [413, 100]].flatMap((
104 [x, w]
105 ) => pill(x, 407, w, 31)),
106
107 bar(96, 462, 72, 15),
108 bar(335, 462, 52, 15, 'muted'),
109 line(18, 494, 458),
110 box(18, 491, 228, 3, 'accent'),
111
112 box(22, 513, 450, 530, 'card', 28),
113 bar(41, 531, 86, 13, 'muted'),
114 bar(431, 532, 18, 2),
115 bar(433, 537, 14, 2),
116 bar(436, 542, 8, 2),
117 ...[0, 1, 2, 3, 4, 5, 6].flatMap((i) => {
118 const y = 581 + i * 69
119 return [
120 bar(61, y, 90, 15),
121 box(61, y + 24, 14, 10, 'muted', 2),
122 bar(78, y + 23, 60, 11, 'muted'),
123 line(45, y + 51, 404)
124 ]
125 }),
126
127 box(22, 937, 389, 49, 'accent', 24.5),
128 bar(133, 954, 168, 15, 'on-accent'),
129 dot(447, 961, 25, 'raised-tertiary'),
130 box(439, 953, 16, 16, 'label', 5),
131 bar(159, 1010, 176, 5)
132]
133
134const library: Shape[] = [
135 box(294, 15, 180, 48, 'raised', 24),
136 ...[320, 382, 446].map(x => dot(x, 39, 12, 'label')),
137 box(374, 12, 36, 18, 'destructive', 9),
138
139 bar(23, 88, 125, 30),
140 ...searchField(),
141
142 ...pill(18, 196, 71, 38),
143 ...pill(97, 196, 112, 38),
144 ...pill(225, 196, 142, 38, 'accent', 'on-accent'),
145 ...pill(377, 196, 120, 38),
146
147 ...[0, 1, 2, 3].flatMap(row =>
148 [18, 175, 331].flatMap((x, column) =>
149 libraryTile(x, 247 + row * 230, row + column)
150 )
151 ),
152
153 ...[328, 390, 453].flatMap(x => iconButton(x, 884)),
154 ...tabBar(0)
155]
156
157const discover: Shape[] = [
158 box(0, 0, 497, 720, 'secondary'),
159 box(0, 300, 497, 420, 'fade'),
160
161 ...iconButton(47, 40),
162 bar(196, 31, 106, 18),
163 box(354, 15, 120, 50, 'raised', 25),
164 dot(382, 40, 12, 'label'),
165 dot(446, 40, 12, 'label'),
166
167 ...cover(-15, 215, 47, 370, 'tertiary', 12),
168 ...cover(465, 215, 47, 370, 'tertiary', 12),
169 ...cover(50, 114, 397, 570, 'tertiary', 16),
170 box(61, 124, 55, 28, 'accent', 14),
171 dot(76, 138, 6, 'on-accent'),
172 bar(87, 133, 21, 10, 'on-accent'),
173 bar(99, 604, 300, 20),
174 bar(201, 633, 96, 14, 'muted'),
175
176 bar(18, 772, 158, 20),
177 dot(190, 782, 8, 'accent'),
178 bar(18, 811, 270, 12, 'muted'),
179
180 box(18, 838, 461, 180, 'secondary', 12),
181 box(29, 850, 103, 150, 'tertiary', 6),
182 bar(145, 853, 315, 18),
183 bar(145, 884, 88, 13, 'muted'),
184 bar(365, 884, 100, 13, 'muted'),
185 bar(145, 908, 88, 13, 'muted'),
186 bar(365, 908, 100, 13, 'muted'),
187
188 ...tabBar(1)
189]
190
191const settingRow = (y: number, width: number) => bar(45, y, width, 15)
192const stepper = (y: number) => [
193 box(347, y, 105, 36, 'tertiary', 18),
194 box(398, y + 8, 1, 20, 'separator'),
195 dot(372, y + 18, 6, 'muted'),
196 dot(425, y + 18, 6, 'label')
197]
198
199const search: Shape[] = [
200 ...iconButton(47, 40),
201 ...pill(376, 15, 98, 50, 'accent', 'on-accent'),
202
203 bar(23, 88, 150, 30),
204 ...searchField([dot(444, 159, 11, 'label')]),
205
206 bar(45, 210, 100, 12, 'muted'),
207 box(23, 236, 451, 117, 'secondary', 22),
208 settingRow(258, 56),
209 dot(441, 265, 8, 'muted'),
210 line(45, 294, 407),
211 settingRow(317, 36),
212 dot(441, 324, 10, 'accent'),
213
214 bar(34, 388, 34, 12, 'muted'),
215 ...[[23, 70], [101, 82], [191, 76], [275, 56]].flatMap(([x, w]) =>
216 pill(x, 422, w, 32)
217 ),
218
219 bar(34, 487, 44, 12, 'muted'),
220 ...[[23, 81], [113, 101], [222, 69], [299, 89]].flatMap(([x, w]) =>
221 pill(x, 521, w, 32)
222 ),
223
224 bar(45, 585, 80, 12, 'muted'),
225 box(23, 611, 451, 176, 'secondary', 22),
226 settingRow(633, 98),
227 bar(302, 635, 34, 12, 'muted'),
228 ...stepper(623),
229 line(45, 669, 407),
230 settingRow(692, 142),
231 bar(324, 694, 12, 12, 'muted'),
232 ...stepper(682),
233 line(45, 728, 407),
234 settingRow(751, 186),
235 box(381, 742, 71, 32, 'tertiary', 16),
236 box(383, 744, 44, 28, 'label', 14),
237
238 bar(45, 821, 34, 12, 'muted'),
239 box(23, 847, 451, 59, 'secondary', 22),
240 settingRow(869, 36),
241 box(324, 862, 128, 29, 'accent-soft', 14.5),
242 bar(352, 871, 72, 11, 'accent'),
243
244 ...tabBar(2)
245]
246
247const chevronDown = (x: number, y: number): Shape => ({
248 tag: 'path',
249 attrs: { d: `M${x} ${y}l9 9 9-9`, class: 'chevron' }
250})
251
252const chevronRight = (x: number, y: number): Shape => ({
253 tag: 'path',
254 attrs: { d: `M${x} ${y}l9 9-9 9`, class: 'chevron' }
255})
256
257function progressRing(cx: number, cy: number, progress: number): Shape[] {
258 const r = 10.5
259 const circumference = 2 * Math.PI * r
260 return [
261 { tag: 'circle', attrs: { cx, cy, r, class: 'progress-track' } },
262 {
263 tag: 'circle',
264 attrs: {
265 cx,
266 cy,
267 r,
268 class: 'progress',
269 transform: `rotate(-90 ${cx} ${cy})`,
270 'stroke-dasharray': `${circumference * progress} ${circumference}`
271 }
272 }
273 ]
274}
275
276function historyRow(y: number, divider: boolean, progress: number) {
277 return [
278 ...cover(36, y, 86, 118, 'tertiary', 10),
279 bar(140, y + 4, 150, 15),
280 bar(140, y + 27, 118, 11, 'muted'),
281 ...progressRing(443, y + 46, progress),
282 bar(366, y + 92, 88, 10, 'muted'),
283 ...(divider ? [line(140, y + 128, 336)] : [])
284 ]
285}
286
287function settingsRow(y: number, width: number) {
288 return [
289 box(40, y + 13, 26, 26, 'accent', 8),
290 bar(84, y + 19, width, 14),
291 chevronRight(446, y + 15)
292 ]
293}
294
295const history: Shape[] = [
296 bar(23, 88, 130, 30),
297 ...searchField(),
298
299 bar(23, 208, 70, 14),
300 chevronDown(444, 208),
301 box(20, 232, 457, 500, 'secondary', 22),
302 ...[0, 1, 2].flatMap(i =>
303 historyRow(248 + i * 154, i < 2, [0.72, 0.48, 0.86][i])
304 ),
305
306 bar(23, 772, 96, 15),
307 chevronRight(446, 771),
308 bar(23, 832, 168, 15),
309 chevronDown(444, 834),
310 box(20, 857, 457, 300, 'secondary', 22),
311 ...historyRow(873, false, 0.32),
312
313 ...tabBar(3),
314 bar(159, 1010, 176, 5)
315]
316
317const settings: Shape[] = [
318 bar(23, 88, 150, 30),
319
320 box(20, 135, 457, 126, 'support', 24),
321 dot(88, 198, 34, 'support-label'),
322 bar(140, 168, 110, 16, 'support-label'),
323 bar(140, 194, 250, 11, 'support-label-soft'),
324 bar(140, 213, 190, 11, 'support-label-soft'),
325
326 box(20, 277, 457, 106, 'secondary', 22),
327 box(40, 317, 26, 26, 'accent', 8),
328 bar(84, 300, 110, 15),
329 bar(84, 322, 220, 11, 'muted'),
330 bar(84, 339, 130, 11, 'muted'),
331 box(392, 308, 66, 30, 'separator', 15),
332 box(396, 311, 42, 24, 'label', 12),
333
334 box(20, 405, 457, 272, 'secondary', 22),
335 ...[[424, 70], [476, 58], [528, 66], [580, 60], [632, 108]].flatMap(
336 ([y, width]) => settingsRow(y, width)
337 ),
338 line(84, 475, 368),
339 line(84, 527, 368),
340 line(84, 579, 368),
341 line(84, 631, 368),
342
343 box(20, 700, 457, 176, 'secondary', 22),
344 ...settingsRow(712, 62),
345 ...settingsRow(764, 66),
346 ...settingsRow(816, 78),
347 line(84, 763, 368),
348 line(84, 815, 368),
349
350 ...tabBar(4),
351 bar(159, 1010, 176, 5)
352]
353
354export const screens: Screen[] = [
355 { id: 'library', title: 'Library', shapes: library },
356 { id: 'discover', title: 'Discover', shapes: discover },
357 { id: 'search', title: 'Search', shapes: search },
358 { id: 'history', title: 'History', shapes: history },
359 { id: 'settings', title: 'Settings', shapes: settings },
360 { id: 'content', title: 'Chapters', shapes: content }
361]
docs/.vitepress/theme/globalComponents.ts +5
@@ -17,6 +17,10 @@ const ExtensionRepos = defineAsyncComponent(
1717 () => import('./components/extrepo').then(m => m.ExtensionRepos)
1818)
1919
20const ThemeRepos = defineAsyncComponent(
21 () => import('./components/themerepo').then(m => m.ThemeRepos)
22)
23
2024export function registerGlobalComponents(app: App) {
2125 app.component('LinkInline', LinkInline)
2226 app.component('hl', Highlight)
@@ -31,4 +35,5 @@ export function registerGlobalComponents(app: App) {
3135 app.component('ScrapeTable', ScrapeTable)
3236 app.component('CrossAppSupport', CrossAppSupport)
3337 app.component('ExtensionRepos', ExtensionRepos)
38 app.component('ThemeRepos', ThemeRepos)
3439}
docs/ext/mana.md +11
@@ -7,6 +7,8 @@ og:
77---
88# Mana
99
10## Extensions
11
1012::: extrepo {scheme=mana}
1113
1214== Kakarot
@@ -45,3 +47,12 @@ og:
4547- raw: https://mana-core.github.io/Books/sources.json
4648
4749:::
50
51## Themes
52
53::: themerepo
54== Mana Themes
55- url: https://mana-core.github.io/themes/
56- src: https://github.com/Mana-Core/Themes
57- raw: https://mana-core.github.io/Themes/themes.json
58:::
docs/ext/themeRepos/defaults.ts added +26
@@ -0,0 +1,26 @@
1import type { ManaTheme } from './types'
2
3export const DEFAULT_THEME: ManaTheme = {
4 name: 'Default',
5 colors: {
6 accent: '#1782FFFF',
7 background: '#131313FF',
8 contentTileOverlay: '#0F0F0FEB',
9 foregroundOnAccent: '#FFFFFFFF',
10 label: '#FFFFFFFF',
11 secondaryBackground: '#181818FF',
12 secondaryLabel: '#929292FF',
13 separator: '#EBEBF52E',
14 separatorSubtle: '#EBEBF52E',
15 shadow: '#000000FF',
16 statusDestructive: '#B82A1BFF',
17 statusInfo: '#1A6BAFFF',
18 statusPositive: '#15780CFF',
19 statusWarning: '#A07D10FF',
20 tertiaryBackground: '#282828FF'
21 }
22}
23
24export const resolveThemeColors = (
25 colors?: Record<string, string>
26): Record<string, string> => ({ ...DEFAULT_THEME.colors, ...(colors ?? {}) })
docs/ext/themeRepos/types.ts added +13
@@ -0,0 +1,13 @@
1export interface ThemeRepoEntry {
2 name: string
3 url?: string
4 src?: string
5 raw?: string
6}
7
8export interface ManaTheme {
9 name: string
10 author?: string
11 colors: Record<string, string>
12 raw?: string
13}