Skip to content

Commit bc03fdf

Browse files
committed
feat: update documentation examples and styles for improved clarity and responsiveness
1 parent 675a68c commit bc03fdf

File tree

16 files changed

+95
-70
lines changed

16 files changed

+95
-70
lines changed

docs/.vitepress/components/Example.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<script setup lang="ts">
2+
/// <reference types="vite/client" />
23
import { useClipboard } from '@vueuse/core'
34
import { useData } from 'vitepress'
45
import { computed, ref } from 'vue'
5-
import { GITHUB_EDIT_URL } from '../config/constants'
6+
import { GITHUB_URL } from '../config/constants'
67
import ExampleComponent from './ExampleComponent.vue'
78
import ExampleOperate from './ExampleOperate.vue'
89
import ExampleSourceCode from './ExampleSourceCode.vue'
@@ -24,12 +25,12 @@ const props = defineProps({
2425
2526
const { isDark } = useData()
2627
27-
const components = import.meta.glob('../../examples/**/*.vue', { eager: true })
28+
const components: Record<string, { default: any }> = import.meta.glob('../../examples/**/*.vue', { eager: true })
2829
2930
const pathComponents = computed(() => {
30-
const _obj = {}
31+
const _obj: Record<string, any> = {}
3132
Object.keys(components).forEach((key) => {
32-
_obj[key.replace('../../components/', '').replace('.vue', '')]
33+
_obj[key.replace('../../examples/', '').replace('.vue', '')]
3334
= components[key].default
3435
})
3536
return _obj
@@ -55,7 +56,7 @@ const path = computed(() => {
5556
})
5657
5758
function openHandle() {
58-
window.open(`${GITHUB_EDIT_URL}/docs/${path.value}`)
59+
window.open(`${GITHUB_URL}/blob/main/docs/examples/${path.value}.vue`)
5960
}
6061
</script>
6162

docs/.vitepress/components/ExampleOperate.vue

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
11
<script setup lang="ts">
2-
import { ref } from 'vue'
2+
import { useData } from 'vitepress'
3+
import { computed, ref } from 'vue'
34
45
const emit = defineEmits(['toggle', 'copy', 'open'])
56
7+
const { lang } = useData()
8+
69
const code = ref(false)
710
11+
const copy = ref(false)
12+
13+
const codeText = computed(() => {
14+
if (!code.value) {
15+
return lang.value === 'en-US' ? 'Show Code' : '显示代码'
16+
}
17+
else {
18+
return lang.value === 'en-US' ? 'Hide Code' : '隐藏代码'
19+
}
20+
})
21+
22+
const copyCodeText = computed(() => {
23+
if (!copy.value) {
24+
return lang.value === 'en-US' ? 'Copy Code' : '复制代码'
25+
}
26+
else {
27+
return lang.value === 'en-US' ? 'Copied to clipboard' : '已复制到剪贴板'
28+
}
29+
})
30+
31+
const viewCodeText = computed(() => lang.value === 'en-US' ? 'View Source Code' : '查看源码')
32+
833
function toggleSourceCode() {
934
code.value = !code.value
1035
emit('toggle')
1136
}
1237
13-
const copy = ref(false)
1438
function copySourceCode() {
1539
copy.value = true
1640
setTimeout(() => {
@@ -26,7 +50,7 @@ function openSourceCode() {
2650

2751
<template>
2852
<div class="example-operate">
29-
<i class="icon" :title="!code ? '展示代码' : '隐藏代码'" @click="toggleSourceCode">
53+
<i class="icon" :title="codeText" @click="toggleSourceCode">
3054
<svg v-if="!code" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 32 32">
3155
<path
3256
fill="currentColor"
@@ -40,7 +64,7 @@ function openSourceCode() {
4064
/>
4165
</svg>
4266
</i>
43-
<i class="icon" :title="copy ? '已复制到剪贴板' : '复制代码'" @click="copySourceCode">
67+
<i class="icon" :title="copyCodeText" @click="copySourceCode">
4468
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 32 32">
4569
<path
4670
fill="currentColor"
@@ -49,11 +73,11 @@ function openSourceCode() {
4973
<path fill="currentColor" d="M4 18H2V4a2 2 0 0 1 2-2h14v2H4Z" />
5074
</svg>
5175
</i>
52-
<i class="icon" title="访问源码" @click="openSourceCode">
53-
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24">
76+
<i class="icon" :title="viewCodeText" @click="openSourceCode">
77+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 32 32">
5478
<path
55-
fill="currentColor"
56-
d="M5.544 2.673a1.549 1.549 0 0 1 1.8.097v.001c.246.198.426.466.515.769l1.446 4.428h5.39L16.14 3.54a1.54 1.54 0 0 1 .515-.769l.004-.004a1.554 1.554 0 0 1 1.795-.095l.002.001c.274.174.486.43.605.732l.004.01l2.473 6.451a5.45 5.45 0 0 1-1.813 6.303l-6.73 5.064h-.002a1.66 1.66 0 0 1-2 0l-6.731-5.065a5.452 5.452 0 0 1-1.806-6.294l2.48-6.469c.12-.302.333-.558.607-.732m.811 2.063L4.16 10.464c-.28.737-.337 1.604-.12 2.362c.217.755.671 1.42 1.295 1.896l6.66 5.01l6.653-5.005a3.65 3.65 0 0 0 1.308-1.904c.22-.76.159-1.638-.123-2.378l-2.189-5.71L16 9.769H8z"
79+
fill="currentColor" fill-rule="evenodd"
80+
d="M16 2a14 14 0 0 0-4.43 27.28c.7.13 1-.3 1-.67v-2.38c-3.89.84-4.71-1.88-4.71-1.88a3.7 3.7 0 0 0-1.62-2.05c-1.27-.86.1-.85.1-.85a2.94 2.94 0 0 1 2.14 1.45a3 3 0 0 0 4.08 1.16a2.93 2.93 0 0 1 .88-1.87c-3.1-.36-6.37-1.56-6.37-6.92a5.4 5.4 0 0 1 1.44-3.76a5 5 0 0 1 .14-3.7s1.17-.38 3.85 1.43a13.3 13.3 0 0 1 7 0c2.67-1.81 3.84-1.43 3.84-1.43a5 5 0 0 1 .14 3.7a5.4 5.4 0 0 1 1.44 3.76c0 5.38-3.27 6.56-6.39 6.91a3.33 3.33 0 0 1 .95 2.59v3.84c0 .46.25.81 1 .67A14 14 0 0 0 16 2"
5781
/>
5882
</svg>
5983
</i>
@@ -83,7 +107,7 @@ function openSourceCode() {
83107
transition: all 0.3s ease-in-out;
84108
}
85109
86-
.example-operate .icon:hover ::after {
110+
.example-operate .icon:hover::after {
87111
cursor: auto;
88112
content: attr(title);
89113
position: absolute;
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
export const GITHUB_URL = 'https://github.com/starter-collective/starter-lib-vue3'
22

3-
export const GITHUB_EDIT_URL = `${GITHUB_URL}/-/tree/master/`
4-
53
export const WEBSITE_URL = 'https://starter-lib-vue3.netlify.app/'

docs/.vitepress/config/en.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { defineConfig } from 'vitepress'
22
import pkg from '../../../package.json'
3+
import { GITHUB_URL } from './constants'
34

45
export const en = defineConfig({
56
lang: 'en-US',
67
description: 'Vue 3 component library starter template, provides VitePress documentation, supports building ESM, CJS and IIFE formats.',
78
themeConfig: {
89
editLink: {
9-
pattern: 'https://github.com/starter-collective/starter-lib-vue3/edit/main/docs/:path',
10+
pattern: `${GITHUB_URL}/edit/main/docs/:path`,
1011
text: 'Edit this page on GitHub',
1112
},
1213
nav: [
@@ -17,7 +18,7 @@ export const en = defineConfig({
1718
items: [
1819
{
1920
text: 'Changelog',
20-
link: 'https://github.com/starter-collective/starter-lib-vue3/releases',
21+
link: `${GITHUB_URL}/releases`,
2122
},
2223
],
2324
},
@@ -39,6 +40,9 @@ export const en = defineConfig({
3940
],
4041
},
4142
],
43+
lastUpdated: {
44+
text: 'Last Updated',
45+
},
4246
footer: {
4347
message: 'Released under the MIT License.',
4448
copyright: 'Copyright © 2024-present Kieran Wang',

docs/.vitepress/config/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ export default defineConfig({
1414
// Vite config.
1515
// https://vitejs.dev
1616
vite: {
17-
resolve: {
18-
conditions: ['dev'],
19-
alias: {
20-
'starter-lib-vue3': '/src/index.ts',
21-
},
22-
},
2317
server: {
2418
host: true,
2519
port: 9865,

docs/.vitepress/config/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const shared = defineConfig({
1919
head: [
2020
['link', { rel: 'icon', href: '/favicon.ico' }],
2121
['link', { rel: 'icon', type: 'image/png', href: '/logo.png' }],
22-
['meta', { name: 'theme-color', content: '#FF057C' }],
22+
['meta', { name: 'theme-color', content: '#42b883' }],
2323
['meta', { property: 'og:type', content: 'website' }],
2424
['meta', { property: 'og:locale', content: 'en' }],
2525
['meta', { property: 'og:title', content: 'Vue3 Component Library Starter Template' }],

docs/.vitepress/config/zh.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import { defineConfig } from 'vitepress'
22
import pkg from '../../../package.json'
3+
import { GITHUB_URL } from './constants'
34

45
export const zh = defineConfig({
56
lang: 'zh-CN',
67
description: 'Vue 3 组件库启动模板,提供 VitePress 文档,支持构建 ESM、CJS 和 IIFE 格式。',
78
themeConfig: {
89
editLink: {
9-
pattern: 'https://github.com/starter-collective/starter-lib-vue3/edit/main/docs/:path',
10+
pattern: `${GITHUB_URL}/edit/main/docs/:path`,
1011
text: '在 GitHub 上编辑此页面',
1112
},
1213
nav: [
1314
{ text: '指南', link: '/zh/guide/what-is', activeMatch: '/zh/guide/' },
14-
{ text: '函数', link: '/zh/components', activeMatch: '/zh/components/' },
15+
{ text: '组件', link: '/zh/components', activeMatch: '/zh/components/' },
1516
{
1617
text: `v${pkg.version}`,
1718
items: [
1819
{
19-
text: 'Changelog',
20-
link: 'https://github.com/starter-collective/starter-lib-vue3/releases',
20+
text: '更新日志',
21+
link: `${GITHUB_URL}/releases`,
2122
},
2223
],
2324
},
@@ -39,6 +40,9 @@ export const zh = defineConfig({
3940
],
4041
},
4142
],
43+
lastUpdated: {
44+
text: '最后更新于',
45+
},
4246
footer: {
4347
message: '基于 MIT 许可证发布。',
4448
copyright: '版权 © 2024-present Kieran Wang',

docs/.vitepress/theme/style.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
:root {
2-
--vp-c-brand-1: #44bd87;
2+
--vp-c-brand-1: #42b883;
33
--vp-c-brand-2: #249252;
44
--vp-c-brand-3: #19633b;
55
--vp-home-hero-name-color: transparent;
@@ -29,3 +29,12 @@ html {
2929
overflow: hidden;
3030
text-overflow: ellipsis;
3131
}
32+
33+
html.dark .shiki,
34+
html.dark .shiki span {
35+
color: var(--shiki-dark) !important;
36+
background-color: var(--shiki-dark-bg) !important;
37+
font-style: var(--shiki-dark-font-style) !important;
38+
font-weight: var(--shiki-dark-font-weight) !important;
39+
text-decoration: var(--shiki-dark-text-decoration) !important;
40+
}

docs/en/guide/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ It will be exposed to global as `window.StarterLibVue3`
3030
```vue
3131
<script setup>
3232
import { SayHello } from 'starter-lib-vue3'
33+
import 'starter-lib-vue3/style.css'
3334
</script>
3435
3536
<template>

docs/examples/say-hello/basic.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
22
import { SayHello } from 'starter-lib-vue3'
3+
import 'starter-lib-vue3/style.css'
34
</script>
45

56
<template>

0 commit comments

Comments
 (0)