clarity-theme 0.1.0
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/LICENSE +21 -0
- package/README.md +276 -0
- package/README.zh-CN.md +297 -0
- package/app/app.config.ts +110 -0
- package/app/app.vue +5 -0
- package/app/assets/css/_variable.scss +8 -0
- package/app/assets/css/animation.scss +50 -0
- package/app/assets/css/article.scss +152 -0
- package/app/assets/css/color.scss +58 -0
- package/app/assets/css/font.scss +35 -0
- package/app/assets/css/main.scss +230 -0
- package/app/assets/css/reusable.scss +186 -0
- package/app/assets/icons/solar-rewind-back-bold-duotone.svg +1 -0
- package/app/assets/icons/solar-rewind-forward-bold-duotone.svg +1 -0
- package/app/components/blog/BlogAside.vue +63 -0
- package/app/components/blog/BlogFooter.vue +61 -0
- package/app/components/blog/BlogHeader.global.vue +146 -0
- package/app/components/blog/BlogPanel.vue +79 -0
- package/app/components/blog/BlogSidebar.vue +160 -0
- package/app/components/blog/BlogWidget.vue +134 -0
- package/app/components/blog/Mask.vue +42 -0
- package/app/components/blog/SkipToContent.vue +22 -0
- package/app/components/blog/ThemeToggle.vue +50 -0
- package/app/components/content/Alert.vue +96 -0
- package/app/components/content/Badge.vue +90 -0
- package/app/components/content/Blur.vue +22 -0
- package/app/components/content/CardList.vue +32 -0
- package/app/components/content/Chat.vue +79 -0
- package/app/components/content/Copy.vue +134 -0
- package/app/components/content/EmojiClock.vue +53 -0
- package/app/components/content/FeedCard.vue +212 -0
- package/app/components/content/FeedGroup.vue +130 -0
- package/app/components/content/Folding.vue +69 -0
- package/app/components/content/Key.vue +164 -0
- package/app/components/content/LinkBanner.vue +59 -0
- package/app/components/content/LinkCard.vue +74 -0
- package/app/components/content/MdTitle.vue +26 -0
- package/app/components/content/Mermaid.vue +133 -0
- package/app/components/content/MusicScore.vue +178 -0
- package/app/components/content/Pic.vue +55 -0
- package/app/components/content/Poetry.vue +41 -0
- package/app/components/content/ProseA.vue +40 -0
- package/app/components/content/ProseCode.vue +95 -0
- package/app/components/content/ProsePre.vue +291 -0
- package/app/components/content/ProseTable.vue +70 -0
- package/app/components/content/Quote.vue +51 -0
- package/app/components/content/Tab.vue +100 -0
- package/app/components/content/Timeline.vue +73 -0
- package/app/components/content/Tip.vue +52 -0
- package/app/components/content/VideoEmbed.vue +127 -0
- package/app/components/partial/Button.vue +98 -0
- package/app/components/partial/DlGroup.vue +69 -0
- package/app/components/partial/Dropdown.vue +54 -0
- package/app/components/partial/Error.vue +70 -0
- package/app/components/partial/Expand.vue +51 -0
- package/app/components/partial/IconNavList.vue +42 -0
- package/app/components/partial/Pagination.vue +113 -0
- package/app/components/partial/RadioGroup.vue +77 -0
- package/app/components/partial/Secret.vue +23 -0
- package/app/components/partial/Slider.vue +96 -0
- package/app/components/partial/Toggle.vue +70 -0
- package/app/components/popover/Lightbox.vue +77 -0
- package/app/components/popover/Search.vue +214 -0
- package/app/components/popover/SearchItem.vue +64 -0
- package/app/components/post/Archive.vue +104 -0
- package/app/components/post/Article.vue +138 -0
- package/app/components/post/Comment.vue +275 -0
- package/app/components/post/Excerpt.vue +66 -0
- package/app/components/post/OrderToggle.vue +101 -0
- package/app/components/post/PostFooter.vue +80 -0
- package/app/components/post/PostHeader.vue +147 -0
- package/app/components/post/PostSurround.vue +111 -0
- package/app/components/post/Slide.vue +215 -0
- package/app/components/util/Date.vue +62 -0
- package/app/components/util/HydrateSafe.vue +10 -0
- package/app/components/util/Img.vue +38 -0
- package/app/components/util/Link.vue +11 -0
- package/app/components/widget/BlogLog.vue +27 -0
- package/app/components/widget/BlogStats.vue +39 -0
- package/app/components/widget/BlogTech.vue +65 -0
- package/app/components/widget/Empty.vue +3 -0
- package/app/components/widget/Toc.vue +129 -0
- package/app/composables/useArticle.ts +118 -0
- package/app/composables/useAvoid.ts +87 -0
- package/app/composables/useCopy.ts +21 -0
- package/app/composables/usePagination.ts +70 -0
- package/app/composables/useShiki.ts +129 -0
- package/app/composables/useToc.ts +57 -0
- package/app/composables/useWidgets.ts +56 -0
- package/app/error.vue +34 -0
- package/app/layouts/default.vue +66 -0
- package/app/pages/[...slug].vue +59 -0
- package/app/pages/archive.vue +207 -0
- package/app/pages/index.vue +83 -0
- package/app/pages/link.vue +65 -0
- package/app/pages/preview.vue +59 -0
- package/app/plugins/easter-egg.ts +23 -0
- package/app/plugins/init.ts +6 -0
- package/app/plugins/tippy.ts +22 -0
- package/app/shiki.config.ts +8 -0
- package/app/stores/layout.ts +34 -0
- package/app/stores/search.ts +37 -0
- package/app/types/article.ts +16 -0
- package/app/types/feed.ts +1 -0
- package/app/types/index.ts +14 -0
- package/app/types/modal.ts +16 -0
- package/app/types/nav.ts +11 -0
- package/app/utils/anim.ts +37 -0
- package/app/utils/img.ts +83 -0
- package/config/app.ts +88 -0
- package/config/content.d.mts +1 -0
- package/config/content.mjs +69 -0
- package/config/content.ts +91 -0
- package/config/define.mjs +21 -0
- package/config/define.ts +23 -0
- package/config/feed.ts +42 -0
- package/config/feeds.empty.ts +4 -0
- package/config/index.d.mts +1 -0
- package/config/index.mjs +6 -0
- package/config/index.ts +6 -0
- package/config/public.ts +71 -0
- package/config/schema.d.mts +1 -0
- package/config/schema.mjs +103 -0
- package/config/schema.ts +129 -0
- package/config/server.ts +35 -0
- package/img/index.d.mts +1 -0
- package/img/index.mjs +78 -0
- package/img/index.ts +8 -0
- package/modules/clarity-config/anti-mirror-client.ts +11 -0
- package/modules/clarity-config/index.ts +324 -0
- package/nuxt.config.ts +225 -0
- package/package.json +148 -0
- package/public/assets/atom.css +274 -0
- package/public/assets/atom.xsl +110 -0
- package/public/fonts/AlimamaFangYuanTi.woff2 +0 -0
- package/remark-plugins/rehype-meta-slots.d.mts +1 -0
- package/remark-plugins/rehype-meta-slots.mjs +49 -0
- package/remark-plugins/rehype-meta-slots.ts +58 -0
- package/remark-plugins/remark-code-component.d.mts +1 -0
- package/remark-plugins/remark-code-component.mjs +25 -0
- package/remark-plugins/remark-code-component.ts +41 -0
- package/server/api/stats.get.ts +109 -0
- package/server/routes/atom.xml.get.ts +101 -0
- package/server/routes/subscriptions.opml.get.ts +70 -0
- package/server/utils/clarity.ts +11 -0
- package/shared/types/content.ts +30 -0
- package/shared/utils/clarity.ts +34 -0
- package/shared/utils/icon.ts +218 -0
- package/shared/utils/link.ts +52 -0
- package/shared/utils/str.ts +88 -0
- package/shared/utils/time.ts +116 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { escape } from 'es-toolkit/string'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(defineProps<{
|
|
5
|
+
code?: string
|
|
6
|
+
language?: string
|
|
7
|
+
filename?: string
|
|
8
|
+
/** @deprecated Use `transformerNotationHighlight` instead */
|
|
9
|
+
highlights?: number[]
|
|
10
|
+
meta?: string
|
|
11
|
+
class?: string
|
|
12
|
+
}>(), {
|
|
13
|
+
code: '',
|
|
14
|
+
meta: '',
|
|
15
|
+
language: 'text', // Nuxt Content 已经做了此处理
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
interface CodeblockMeta {
|
|
19
|
+
icon?: string
|
|
20
|
+
wrap?: boolean
|
|
21
|
+
[meta: string]: string | boolean | undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const meta = computed(() => props.meta.split(' ').reduce((acc: CodeblockMeta, item) => {
|
|
25
|
+
const [key, value] = item.split('=')
|
|
26
|
+
acc[key!] = value ?? true
|
|
27
|
+
return acc
|
|
28
|
+
}, {}))
|
|
29
|
+
|
|
30
|
+
const clarity = useClarityConfig()
|
|
31
|
+
const compConf = computed(() => clarity.component.codeblock)
|
|
32
|
+
|
|
33
|
+
const rows = computed(() => props.code.split('\n').length - 1)
|
|
34
|
+
const collapsible = computed(() => !meta.value.expand && rows.value > compConf.value.triggerRows)
|
|
35
|
+
const [isCollapsed, toggleCollapsed] = useToggle(collapsible.value)
|
|
36
|
+
|
|
37
|
+
const icon = computed(() => meta.value.icon || getFileIcon(props.filename) || getLangIcon(props.language))
|
|
38
|
+
const isWrap = ref(meta.value.wrap)
|
|
39
|
+
const byteSize = computed(() => formatBytes(new TextEncoder().encode(props.code).length))
|
|
40
|
+
|
|
41
|
+
const codeblock = useTemplateRef('codeblock')
|
|
42
|
+
const { copy, copied } = useCopy(codeblock)
|
|
43
|
+
const shiki = useShiki()
|
|
44
|
+
const rawHtml = ref(escape(props.code))
|
|
45
|
+
|
|
46
|
+
function getIndent() {
|
|
47
|
+
if (meta.value.indent)
|
|
48
|
+
return meta.value.indent
|
|
49
|
+
|
|
50
|
+
if (['md', 'mdc', 'json', 'jsonc', 'yaml', 'yml'].includes(props.language))
|
|
51
|
+
return 2
|
|
52
|
+
|
|
53
|
+
return compConf.value.indent
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
onMounted(async () => {
|
|
57
|
+
rawHtml.value = await shiki.codeToHtml(props.code.trimEnd(), {
|
|
58
|
+
language: props.language,
|
|
59
|
+
transformerOptions: [compConf.value.enableIndentGuide ? 'ignoreRenderWhitespace' : 'ignoreRenderIndentGuides'],
|
|
60
|
+
shikiOptions: { meta: { indent: getIndent() } },
|
|
61
|
+
embeddedLanguages: true,
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<figure
|
|
68
|
+
class="z-codeblock"
|
|
69
|
+
:class="{ collapsed: collapsible && isCollapsed, collapsible }"
|
|
70
|
+
:style="{
|
|
71
|
+
'--collapsed-rows': compConf.collapsedRows,
|
|
72
|
+
'--tab-size': meta.indent as string || compConf.tabSize,
|
|
73
|
+
}"
|
|
74
|
+
>
|
|
75
|
+
<figcaption>
|
|
76
|
+
<span v-if="filename" class="filename">
|
|
77
|
+
<Icon :name="icon" /> {{ filename }}
|
|
78
|
+
</span>
|
|
79
|
+
<span v-else />
|
|
80
|
+
<!-- 语言不采用绝对定位,因为和文件名占据互斥空间 -->
|
|
81
|
+
<span v-if="language" class="language">{{ language }}</span>
|
|
82
|
+
<div class="operations">
|
|
83
|
+
<button @click="isWrap = !isWrap">
|
|
84
|
+
{{ isWrap ? '横向滚动' : '自动换行' }}
|
|
85
|
+
</button>
|
|
86
|
+
<button @click="copy()">
|
|
87
|
+
{{ copied ? '已复制' : '复制' }}
|
|
88
|
+
</button>
|
|
89
|
+
</div>
|
|
90
|
+
</figcaption>
|
|
91
|
+
|
|
92
|
+
<!-- 嘿嘿,不要换行 -->
|
|
93
|
+
<pre
|
|
94
|
+
ref="codeblock"
|
|
95
|
+
class="shiki scrollcheck-x"
|
|
96
|
+
:class="[props.class, { wrap: isWrap }]"
|
|
97
|
+
v-html="rawHtml"
|
|
98
|
+
/>
|
|
99
|
+
|
|
100
|
+
<button
|
|
101
|
+
v-if="collapsible"
|
|
102
|
+
class="toggle-btn"
|
|
103
|
+
:aria-label="isCollapsed ? '展开代码块' : '折叠代码块'"
|
|
104
|
+
@click="toggleCollapsed()"
|
|
105
|
+
>
|
|
106
|
+
<Icon
|
|
107
|
+
class="toggle-icon"
|
|
108
|
+
:class="{ 'is-collapsed': isCollapsed }"
|
|
109
|
+
name="tabler:chevrons-up"
|
|
110
|
+
/>
|
|
111
|
+
<span>{{ rows }} lines, {{ props.code.length }} chars, {{ byteSize }}</span>
|
|
112
|
+
</button>
|
|
113
|
+
</figure>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<style lang="scss" scoped>
|
|
117
|
+
.z-codeblock {
|
|
118
|
+
--line-height: 1.4;
|
|
119
|
+
|
|
120
|
+
contain: paint;
|
|
121
|
+
margin: 0.5em 0;
|
|
122
|
+
border-radius: 0.5em;
|
|
123
|
+
background-color: var(--c-bg-2);
|
|
124
|
+
font-size: 0.85em;
|
|
125
|
+
line-height: 1.4;
|
|
126
|
+
tab-size: var(--tab-size, 4);
|
|
127
|
+
|
|
128
|
+
&.collapsible > pre {
|
|
129
|
+
padding-bottom: 0.5rem;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&.collapsed > pre {
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
max-height: calc(var(--line-height) * var(--collapsed-rows) * 1em + 1rem);
|
|
135
|
+
mask-image: linear-gradient(to top, transparent -2em, #FFF 4em);
|
|
136
|
+
animation: none;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
figcaption {
|
|
141
|
+
display: flex;
|
|
142
|
+
justify-content: space-between;
|
|
143
|
+
gap: 1em;
|
|
144
|
+
position: sticky;
|
|
145
|
+
top: 0;
|
|
146
|
+
padding: 0 1em;
|
|
147
|
+
z-index: 2;
|
|
148
|
+
|
|
149
|
+
> .filename {
|
|
150
|
+
padding: 0.2em 0.8em;
|
|
151
|
+
border-radius: 0 0 0.5em 0.5em;
|
|
152
|
+
background-color: var(--c-border);
|
|
153
|
+
word-break: break-all;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
> .language {
|
|
157
|
+
opacity: 0.4;
|
|
158
|
+
height: 0;
|
|
159
|
+
transform: translateY(0.2em);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
> .operations {
|
|
163
|
+
position: absolute;
|
|
164
|
+
opacity: 0;
|
|
165
|
+
inset-inline-end: 0;
|
|
166
|
+
padding: 0 0.6em;
|
|
167
|
+
border-end-start-radius: 0.5em;
|
|
168
|
+
background-color: var(--c-bg-2);
|
|
169
|
+
transition: opacity 0.2s;
|
|
170
|
+
|
|
171
|
+
:hover > &, :focus-within > & {
|
|
172
|
+
opacity: 1;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
> button {
|
|
176
|
+
opacity: 0.4;
|
|
177
|
+
padding: 0.2em 0.4em;
|
|
178
|
+
transition: opacity 0.2s;
|
|
179
|
+
|
|
180
|
+
&:hover {
|
|
181
|
+
opacity: 1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
pre {
|
|
188
|
+
// 如果填写 0 会在 calc() 时出错
|
|
189
|
+
--start-offset: 4em;
|
|
190
|
+
|
|
191
|
+
padding: 1rem;
|
|
192
|
+
padding-inline-start: var(--start-offset);
|
|
193
|
+
|
|
194
|
+
&.wrap {
|
|
195
|
+
white-space: pre-wrap;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
:deep(.line) {
|
|
200
|
+
&.diff {
|
|
201
|
+
background-color: var(--ld-bg-active);
|
|
202
|
+
|
|
203
|
+
&.add {
|
|
204
|
+
--line-indicator: "+ ";
|
|
205
|
+
--line-indicator-color: var(--c-success);
|
|
206
|
+
--ld-bg-active: var(--c-success-soft);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
&.remove {
|
|
210
|
+
--line-indicator: "- ";
|
|
211
|
+
--line-indicator-color: var(--c-error);
|
|
212
|
+
--ld-bg-active: var(--c-error-soft);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
&.highlighted {
|
|
217
|
+
--line-indicator-color: var(--c-text-1);
|
|
218
|
+
|
|
219
|
+
background-color: var(--ld-bg-active);
|
|
220
|
+
|
|
221
|
+
&.error {
|
|
222
|
+
--line-indicator-color: var(--c-error);
|
|
223
|
+
--ld-bg-active: var(--c-error-soft);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
&.warning {
|
|
227
|
+
--line-indicator-color: var(--c-warning);
|
|
228
|
+
--ld-bg-active: var(--c-warning-soft);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
&.focused {
|
|
233
|
+
--line-indicator: "→ ";
|
|
234
|
+
--line-indicator-color: var(--c-text-1);
|
|
235
|
+
|
|
236
|
+
display: inline-block;
|
|
237
|
+
position: relative;
|
|
238
|
+
box-shadow: 0 0 10rem 4rem var(--c-bg-2);
|
|
239
|
+
transition: box-shadow 0.2s;
|
|
240
|
+
|
|
241
|
+
@supports (color: color-mix(in srgb, transparent, transparent)) {
|
|
242
|
+
box-shadow: 0 0 0 100vmax color-mix(in srgb, transparent, var(--c-bg-2));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
pre:hover > & {
|
|
246
|
+
box-shadow: none;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// 行指示器
|
|
251
|
+
&::before {
|
|
252
|
+
content: var(--line-indicator, "") attr(data-line);
|
|
253
|
+
position: fixed;
|
|
254
|
+
inset-inline-start: 0;
|
|
255
|
+
width: var(--start-offset);
|
|
256
|
+
padding-inline-end: 1em;
|
|
257
|
+
background-color: var(--c-bg-2);
|
|
258
|
+
text-align: end;
|
|
259
|
+
color: var(--line-indicator-color, var(--c-text-3));
|
|
260
|
+
z-index: 1;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
> .highlighted-word {
|
|
264
|
+
border-radius: 0.2em;
|
|
265
|
+
box-shadow: inset 0 0 0 1em var(--ld-bg-active);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.toggle-btn {
|
|
270
|
+
display: block;
|
|
271
|
+
position: relative; // 移动到 pre 上方
|
|
272
|
+
opacity: 0.3;
|
|
273
|
+
width: 100%;
|
|
274
|
+
padding: 0.2em;
|
|
275
|
+
background-color: var(--c-bg-3);
|
|
276
|
+
transition: opacity 0.2s;
|
|
277
|
+
|
|
278
|
+
&:hover {
|
|
279
|
+
opacity: 1;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.toggle-icon {
|
|
284
|
+
margin-inline-end: 0.2em;
|
|
285
|
+
transition: all 0.2s;
|
|
286
|
+
|
|
287
|
+
&.is-collapsed {
|
|
288
|
+
transform: rotate(180deg);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
</style>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const [scroll, toggleScroll] = useToggle(true)
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<Tooltip class="md-table" tag="figure" interactive :delay="500">
|
|
7
|
+
<template #content>
|
|
8
|
+
<Icon v-show="false" :name="scroll ? 'tabler:text-wrap-disabled' : 'tabler:text-wrap'" />
|
|
9
|
+
<ZButton
|
|
10
|
+
variant="text"
|
|
11
|
+
:icon="scroll ? 'tabler:text-wrap' : 'tabler:text-wrap-disabled'"
|
|
12
|
+
:text="scroll ? '自动换行' : '横向滚动'"
|
|
13
|
+
@click="toggleScroll()"
|
|
14
|
+
/>
|
|
15
|
+
</template>
|
|
16
|
+
<table class="scrollcheck-x" :class="{ scroll }">
|
|
17
|
+
<slot />
|
|
18
|
+
</table>
|
|
19
|
+
</Tooltip>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<style lang="scss" scoped>
|
|
23
|
+
.md-table {
|
|
24
|
+
position: relative;
|
|
25
|
+
margin: 1rem 0;
|
|
26
|
+
font-variant-numeric: tabular-nums;
|
|
27
|
+
font-size: 0.9em;
|
|
28
|
+
line-height: 1.4;
|
|
29
|
+
word-break: break-all;
|
|
30
|
+
|
|
31
|
+
table.scroll {
|
|
32
|
+
contain: layout; // KaTeX 撑开宽度
|
|
33
|
+
display: block;
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
word-break: normal;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:deep(table) {
|
|
40
|
+
max-height: 80vh;
|
|
41
|
+
max-height: 80dvh;
|
|
42
|
+
margin: auto;
|
|
43
|
+
border-collapse: collapse;
|
|
44
|
+
|
|
45
|
+
> thead {
|
|
46
|
+
position: sticky;
|
|
47
|
+
top: 0;
|
|
48
|
+
z-index: 1; // ProseA 图标会透到表头上方
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
th {
|
|
52
|
+
background-color: var(--c-bg-2);
|
|
53
|
+
font-weight: bold;
|
|
54
|
+
text-align: center;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
tr {
|
|
58
|
+
transition: background-color 0.2s;
|
|
59
|
+
|
|
60
|
+
&:hover {
|
|
61
|
+
background-color: var(--c-bg-2);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
th, td {
|
|
66
|
+
padding: 0.5em 0.8em;
|
|
67
|
+
border: 1px solid var(--c-border);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
icon?: string
|
|
4
|
+
}>()
|
|
5
|
+
|
|
6
|
+
const icon = computed(() => props.icon || 'tabler:message-2')
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div class="quote title-like">
|
|
11
|
+
<div class="icon-line">
|
|
12
|
+
<slot name="icon">
|
|
13
|
+
<Icon :name="icon" />
|
|
14
|
+
</slot>
|
|
15
|
+
</div>
|
|
16
|
+
<slot />
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<style lang="scss" scoped>
|
|
21
|
+
.quote {
|
|
22
|
+
font-size: 1.2rem;
|
|
23
|
+
line-height: 1.5;
|
|
24
|
+
color: var(--c-text-2);
|
|
25
|
+
isolation: isolate;
|
|
26
|
+
|
|
27
|
+
:deep(p) {
|
|
28
|
+
margin: 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.icon-line {
|
|
33
|
+
position: relative;
|
|
34
|
+
opacity: 0.5;
|
|
35
|
+
min-height: 0.5em;
|
|
36
|
+
margin-bottom: -0.5em;
|
|
37
|
+
mask-image: linear-gradient(#FFF, transparent);
|
|
38
|
+
font-size: 4rem;
|
|
39
|
+
transition: all 0.2s;
|
|
40
|
+
z-index: -1;
|
|
41
|
+
|
|
42
|
+
@media (max-width: $breakpoint-phone) {
|
|
43
|
+
font-size: 3rem;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:hover > & {
|
|
47
|
+
opacity: 1;
|
|
48
|
+
transform: translateY(-0.5rem);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
/** tab 下标从 1 开始 */
|
|
4
|
+
tabs: string[]
|
|
5
|
+
center?: boolean
|
|
6
|
+
active?: string | number
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
const activeTab = ref(Number(props.active) || 1)
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<!-- BUG: MDC Tab插槽块内会吞代码缩进 -->
|
|
14
|
+
<div :class="{ center }">
|
|
15
|
+
<div class="tabs">
|
|
16
|
+
<button
|
|
17
|
+
v-for="(tab, tabIndex) in tabs"
|
|
18
|
+
:key="tabIndex"
|
|
19
|
+
:class="{ active: activeTab === tabIndex + 1 }"
|
|
20
|
+
@click="activeTab = tabIndex + 1"
|
|
21
|
+
>
|
|
22
|
+
{{ tab }}
|
|
23
|
+
</button>
|
|
24
|
+
</div>
|
|
25
|
+
<div v-for="tabIndex in tabs.length" v-show="activeTab === tabIndex" :key="tabIndex" class="tab-content">
|
|
26
|
+
<slot :name="`tab${tabIndex}`" />
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<style lang="scss" scoped>
|
|
32
|
+
.float-in-leave-active {
|
|
33
|
+
/* stylelint-disable-next-line declaration-no-important */
|
|
34
|
+
position: revert !important;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.center {
|
|
38
|
+
width: fit-content;
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
margin-inline: auto;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.tabs {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-wrap: wrap;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
gap: 0.5em;
|
|
48
|
+
position: relative;
|
|
49
|
+
width: fit-content;
|
|
50
|
+
margin: 0 auto;
|
|
51
|
+
font-size: 0.9em;
|
|
52
|
+
line-height: 1.4;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
button {
|
|
56
|
+
position: relative;
|
|
57
|
+
margin-bottom: 0.5em;
|
|
58
|
+
padding: 0.3em 0.5em;
|
|
59
|
+
border-radius: 0.4em;
|
|
60
|
+
color: var(--c-text-2);
|
|
61
|
+
transition: all 0.2s;
|
|
62
|
+
|
|
63
|
+
&:hover {
|
|
64
|
+
background-color: var(--c-bg-soft);
|
|
65
|
+
color: var(--c-text);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&::before, &::after {
|
|
69
|
+
display: block;
|
|
70
|
+
position: absolute;
|
|
71
|
+
inset-inline: 0.8em;
|
|
72
|
+
bottom: -0.5em;
|
|
73
|
+
height: 2px;
|
|
74
|
+
border-radius: 1em;
|
|
75
|
+
pointer-events: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&::after {
|
|
79
|
+
content: "";
|
|
80
|
+
inset-inline: -0.8em;
|
|
81
|
+
background-color: var(--c-border);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&.active {
|
|
85
|
+
box-shadow: var(--box-shadow-1), var(--box-shadow-1);
|
|
86
|
+
background-color: var(--ld-bg-card);
|
|
87
|
+
color: var(--c-text);
|
|
88
|
+
|
|
89
|
+
&::before {
|
|
90
|
+
content: "";
|
|
91
|
+
background-color: var(--c-primary);
|
|
92
|
+
z-index: 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.tab-content {
|
|
98
|
+
margin: 1em 0;
|
|
99
|
+
}
|
|
100
|
+
</style>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script lang="tsx" setup>
|
|
2
|
+
const slots = defineSlots<{
|
|
3
|
+
default: () => VNode[]
|
|
4
|
+
}>()
|
|
5
|
+
|
|
6
|
+
const timelineRegex = /^\{(?<caption>.*)\}$/
|
|
7
|
+
|
|
8
|
+
function render() {
|
|
9
|
+
const slotContent = slots.default()
|
|
10
|
+
if (!slotContent)
|
|
11
|
+
return <span>时间线为空</span>
|
|
12
|
+
|
|
13
|
+
return slotContent.map((node: VNode) => {
|
|
14
|
+
// WARN: 此处使用了非标准的 v-slot:default
|
|
15
|
+
const textContent = (node.children as any)?.default?.()[0].children
|
|
16
|
+
const matchGroups = typeof textContent === 'string'
|
|
17
|
+
? textContent.match(timelineRegex)?.groups
|
|
18
|
+
: undefined
|
|
19
|
+
return matchGroups
|
|
20
|
+
? <dt class="timeline-caption">{matchGroups.caption}</dt>
|
|
21
|
+
: <dd class="timeline-body card">{node}</dd>
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<dl class="timeline">
|
|
28
|
+
<render />
|
|
29
|
+
</dl>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<style lang="scss" scoped>
|
|
33
|
+
// TODO: 优化时间线样式
|
|
34
|
+
.timeline {
|
|
35
|
+
position: relative;
|
|
36
|
+
padding-inline-start: 1.5em;
|
|
37
|
+
font-size: 0.9em;
|
|
38
|
+
|
|
39
|
+
&::before {
|
|
40
|
+
content: "";
|
|
41
|
+
position: absolute;
|
|
42
|
+
inset: 0.5em auto 0;
|
|
43
|
+
inset-inline-start: 0.5em;
|
|
44
|
+
width: 0.3em;
|
|
45
|
+
background-color: var(--c-bg-soft);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:deep() {
|
|
50
|
+
> .timeline-caption {
|
|
51
|
+
opacity: 0.8;
|
|
52
|
+
font-size: 0.9em;
|
|
53
|
+
|
|
54
|
+
&::before {
|
|
55
|
+
content: "";
|
|
56
|
+
position: absolute;
|
|
57
|
+
inset-inline-start: 0.3em;
|
|
58
|
+
width: 0.8em;
|
|
59
|
+
height: 0.8em;
|
|
60
|
+
margin-top: 0.5em;
|
|
61
|
+
border-radius: 1em;
|
|
62
|
+
background-color: var(--c-text-2);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
> .timeline-body {
|
|
67
|
+
width: fit-content;
|
|
68
|
+
max-width: 100%;
|
|
69
|
+
margin-bottom: 1em;
|
|
70
|
+
padding: 0 1em;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { TippyOptions } from 'vue-tippy'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(defineProps<{
|
|
5
|
+
text?: string
|
|
6
|
+
tip?: string
|
|
7
|
+
icon?: string | boolean
|
|
8
|
+
copy?: boolean
|
|
9
|
+
tipOptions?: TippyOptions
|
|
10
|
+
}>(), {
|
|
11
|
+
icon: undefined,
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const tip = computed(() => ({
|
|
15
|
+
content: props.tip || (props.copy ? '点击复制' : ''),
|
|
16
|
+
inlinePositioning: true,
|
|
17
|
+
...props.tipOptions,
|
|
18
|
+
}))
|
|
19
|
+
const tipSource = useTemplateRef('tip-text')
|
|
20
|
+
|
|
21
|
+
const { copy, copied } = useCopy(tipSource)
|
|
22
|
+
const icon = computed(() => props.icon ?? (copied.value ? 'tabler:check' : props.copy && 'tabler:copy'))
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<span
|
|
27
|
+
ref="tip-text"
|
|
28
|
+
v-tip="tip"
|
|
29
|
+
class="tip"
|
|
30
|
+
tabindex="0"
|
|
31
|
+
@keypress.enter="props.copy && copy()"
|
|
32
|
+
@click="props.copy && copy()"
|
|
33
|
+
>
|
|
34
|
+
<slot>{{ text }}</slot>
|
|
35
|
+
<Icon v-if="typeof icon === 'string'" :name="icon" class="tip-icon" />
|
|
36
|
+
</span>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<style lang="scss" scoped>
|
|
40
|
+
.tip {
|
|
41
|
+
position: relative;
|
|
42
|
+
text-decoration: underline dashed var(--c-text-3);
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
text-underline-offset: 4px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.tip-icon {
|
|
48
|
+
display: inline-block;
|
|
49
|
+
font-size: 1em;
|
|
50
|
+
vertical-align: top;
|
|
51
|
+
}
|
|
52
|
+
</style>
|