vitepress-theme-element-plus 0.0.2 → 0.0.4

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.
Files changed (42) hide show
  1. package/README.md +3 -3
  2. package/client/components/A11yTag.vue +29 -29
  3. package/client/components/ApiTyping.vue +54 -54
  4. package/client/components/Backdrop.vue +41 -41
  5. package/client/components/Bili.vue +94 -94
  6. package/client/components/Content.vue +148 -150
  7. package/client/components/DeprecatedTag.vue +19 -19
  8. package/client/components/Doc.vue +181 -181
  9. package/client/components/DocAside.vue +46 -46
  10. package/client/components/DocAsideOutline.vue +82 -82
  11. package/client/components/DocFooter.vue +159 -159
  12. package/client/components/Footer.vue +77 -77
  13. package/client/components/FooterCopyright.vue +27 -27
  14. package/client/components/Layout.vue +156 -156
  15. package/client/components/Link.vue +41 -41
  16. package/client/components/LocalNav.vue +160 -160
  17. package/client/components/Nav.vue +69 -69
  18. package/client/components/NavBar.vue +203 -203
  19. package/client/components/NavBarTitle.vue +75 -75
  20. package/client/components/Sidebar.vue +129 -129
  21. package/client/components/SidebarGroup.vue +51 -51
  22. package/client/components/SidebarItem.vue +302 -302
  23. package/client/components/Tag.vue +25 -25
  24. package/client/components/VPNavBarSearch.vue +23 -23
  25. package/client/components/VersionTag.vue +18 -18
  26. package/client/hooks/useBackTop.ts +72 -72
  27. package/client/hooks/useLangs.ts +50 -50
  28. package/client/hooks/useSidebar.ts +93 -18
  29. package/client/hooks/useSidebarControl.ts +78 -78
  30. package/client/hooks/useSize.ts +69 -69
  31. package/client/utils/client/common.ts +49 -49
  32. package/client/utils/client/outline.ts +113 -113
  33. package/client/utils/common.ts +90 -86
  34. package/client/utils/throttle.ts +46 -0
  35. package/index.ts +26 -26
  36. package/package.json +73 -72
  37. package/shared/constants.ts +3 -3
  38. package/styles/base.scss +37 -37
  39. package/styles/code.scss +282 -282
  40. package/styles/doc-content.scss +161 -161
  41. package/styles/index.scss +69 -69
  42. package/styles/tag-content.scss +30 -30
@@ -1,302 +1,302 @@
1
- <script setup lang="ts">
2
- import type { DefaultTheme } from 'vitepress'
3
- import { Icon } from '@iconify/vue'
4
- import { computed } from 'vue'
5
- import { useSidebarControl } from '../hooks/useSidebarControl'
6
- import Link from './Link.vue'
7
- import VersionTag from './VersionTag.vue'
8
-
9
- const props = defineProps<{
10
- item: DefaultTheme.SidebarItem & {
11
- hide?: boolean
12
- icon?: string
13
- promotion?: string
14
- }
15
- depth: number
16
- }>()
17
- const {
18
- collapsed,
19
- collapsible,
20
- isLink,
21
- isActiveLink,
22
- hasActiveLink,
23
- hasChildren,
24
- toggle,
25
- } = useSidebarControl(computed(() => props.item))
26
-
27
- const sectionTag = computed(() => (hasChildren.value ? 'section' : 'div'))
28
-
29
- const linkTag = computed(() => (isLink.value ? 'a' : 'div'))
30
-
31
- const textTag = computed(() => {
32
- return !hasChildren.value
33
- ? 'p'
34
- : props.depth + 2 === 7
35
- ? 'p'
36
- : `h${props.depth + 2}`
37
- })
38
-
39
- const itemRole = computed(() => (isLink.value ? undefined : 'button'))
40
-
41
- const classes = computed(() => [
42
- [`level-${props.depth}`],
43
- { collapsible: collapsible.value },
44
- { collapsed: collapsed.value },
45
- { 'is-link': isLink.value },
46
- { 'is-active': isActiveLink.value },
47
- { 'has-active': hasActiveLink.value },
48
- ])
49
-
50
- function onItemInteraction(e: MouseEvent | Event) {
51
- if ('key' in e && e.key !== 'Enter') {
52
- return
53
- }
54
- !props.item.link && toggle()
55
- }
56
- function onCaretClick() {
57
- props.item.link && toggle()
58
- }
59
-
60
- function onLinkAreaClick(e: MouseEvent) {
61
- const elA = (e.target as HTMLElement).querySelector('a')
62
- elA && elA.click()
63
- }
64
- </script>
65
-
66
- <template>
67
- <component :is="sectionTag" class="VPSidebarItem" :class="classes">
68
- <div
69
- v-if="item.text && !item.hide"
70
- class="item"
71
- :role="itemRole"
72
- :tabindex="item.items && 0"
73
- v-on="
74
- item.items
75
- ? { click: onItemInteraction, keydown: onItemInteraction }
76
- : { click: onLinkAreaClick }
77
- "
78
- >
79
- <div class="indicator" />
80
- <Icon
81
- v-if="item.icon && item.items"
82
- :icon="item.icon"
83
- style="margin-right: 5px;"
84
- ssr
85
- />
86
- <Link
87
- v-if="item.link"
88
- :tag="linkTag"
89
- class="link"
90
- :href="item.link"
91
- :rel="item.rel"
92
- :target="item.target"
93
- >
94
- <Icon
95
- v-if="item.icon && item.link"
96
- :icon="item.icon"
97
- class="text text-icon"
98
- ssr
99
- />
100
- <component :is="textTag" class="text" v-html="item.text" />
101
- <VersionTag v-if="item.promotion" class="version-tag" :version="item.promotion" />
102
- </Link>
103
- <component
104
- :is="textTag"
105
- v-else
106
- class="text"
107
- v-html="item.text"
108
- />
109
-
110
- <div
111
- v-if="item.collapsed !== undefined && item.items && item.items.length"
112
- class="caret"
113
- role="button"
114
- aria-label="toggle section"
115
- tabindex="0"
116
- @click="onCaretClick"
117
- @keydown.enter="onCaretClick"
118
- >
119
- <span class="vpi-chevron-right caret-icon" />
120
- </div>
121
- </div>
122
-
123
- <div v-if="item?.items && item?.items.length" class="items">
124
- <template v-if="depth < 5">
125
- <SidebarItem
126
- v-for="i in item.items"
127
- :key="i.text"
128
- :item="i"
129
- :depth="depth + 1"
130
- />
131
- </template>
132
- </div>
133
- </component>
134
- </template>
135
-
136
- <style scoped lang="scss">
137
- .VPSidebarItem.collapsed.level-0 {
138
- padding-bottom: 10px;
139
- }
140
-
141
- .item {
142
- position: relative;
143
- display: flex;
144
- width: 100%;
145
- display: flex;
146
- align-items: center;
147
- border-radius: 8px;
148
- transition: background-color 0.25s;
149
- cursor: pointer;
150
- }
151
-
152
- .VPSidebarItem.collapsible > .item {
153
- cursor: pointer;
154
- }
155
-
156
- .indicator {
157
- position: absolute;
158
- top: 6px;
159
- bottom: 6px;
160
- left: -17px;
161
- width: 2px;
162
- border-radius: 2px;
163
- transition: background-color 0.25s;
164
- }
165
-
166
- .VPSidebarItem.level-2.is-active > .item > .indicator,
167
- .VPSidebarItem.level-3.is-active > .item > .indicator,
168
- .VPSidebarItem.level-4.is-active > .item > .indicator,
169
- .VPSidebarItem.level-5.is-active > .item > .indicator {
170
- background-color: var(--vp-c-brand-1);
171
- }
172
-
173
- .link {
174
- display: flex;
175
- align-items: center;
176
- padding: 10px 16px;
177
- line-height: 20px;
178
- font-size: 13px;
179
- }
180
-
181
- .text {
182
- flex-grow: 1;
183
- line-height: 24px;
184
- transition: color 0.25s;
185
- }
186
- .text-icon {
187
- flex-grow: 0;
188
- padding: 0;
189
- margin-right: 4px;
190
- }
191
- .version-tag {
192
- margin-left: 8px;
193
- }
194
- .VPSidebarItem.level-0 > .item {
195
- color: var(--vp-c-text-1);
196
- margin-bottom: 8px;
197
- line-height: 24px;
198
- }
199
- .VPSidebarItem.level-0 > .item h2 {
200
- color: var(--vp-c-text-1);
201
- font-size: 1rem;
202
- font-weight: 700;
203
- margin-bottom: 8px;
204
- line-height: 24px;
205
- }
206
-
207
- .VPSidebarItem.level-1,
208
- .VPSidebarItem.level-2,
209
- .VPSidebarItem.level-3,
210
- .VPSidebarItem.level-4,
211
- .VPSidebarItem.level-5 {
212
- font-weight: 500;
213
- color: var(--vp-c-text-2);
214
- }
215
-
216
- .VPSidebarItem.level-0.is-link > .item > .link:hover,
217
- .VPSidebarItem.level-1.is-link > .item > .link:hover,
218
- .VPSidebarItem.level-2.is-link > .item > .link:hover,
219
- .VPSidebarItem.level-3.is-link > .item > .link:hover,
220
- .VPSidebarItem.level-4.is-link > .item > .link:hover,
221
- .VPSidebarItem.level-5.is-link > .item > .link:hover {
222
- color: var(--vp-c-brand-1);
223
- }
224
-
225
- .VPSidebarItem.level-0.has-active > .item,
226
- .VPSidebarItem.level-1.has-active > .item,
227
- .VPSidebarItem.level-2.has-active > .item,
228
- .VPSidebarItem.level-3.has-active > .item,
229
- .VPSidebarItem.level-4.has-active > .item,
230
- .VPSidebarItem.level-5.has-active > .item,
231
- .VPSidebarItem.level-0.has-active > .item > .link,
232
- .VPSidebarItem.level-1.has-active > .item > .link,
233
- .VPSidebarItem.level-2.has-active > .item > .link,
234
- .VPSidebarItem.level-3.has-active > .item > .link,
235
- .VPSidebarItem.level-4.has-active > .item > .link,
236
- .VPSidebarItem.level-5.has-active > .item > .link {
237
- color: var(--vp-c-text-1);
238
- }
239
-
240
- .VPSidebarItem.level-0.is-active > .item .link,
241
- .VPSidebarItem.level-1.is-active > .item .link,
242
- .VPSidebarItem.level-2.is-active > .item .link,
243
- .VPSidebarItem.level-3.is-active > .item .link,
244
- .VPSidebarItem.level-4.is-active > .item .link,
245
- .VPSidebarItem.level-5.is-active > .item .link {
246
- color: var(--vp-c-brand-1);
247
- font-weight: 600;
248
- }
249
-
250
- .VPSidebarItem.level-0.is-active > .item,
251
- .VPSidebarItem.level-1.is-active > .item,
252
- .VPSidebarItem.level-2.is-active > .item,
253
- .VPSidebarItem.level-3.is-active > .item,
254
- .VPSidebarItem.level-4.is-active > .item,
255
- .VPSidebarItem.level-5.is-active > .item {
256
- background-color: var(--el-color-primary-light-9);
257
- }
258
-
259
- .caret {
260
- display: flex;
261
- justify-content: center;
262
- align-items: center;
263
- margin-right: -7px;
264
- width: 32px;
265
- height: 32px;
266
- color: var(--vp-c-text-3);
267
- cursor: pointer;
268
- transition: color 0.25s;
269
- flex-shrink: 0;
270
- }
271
-
272
- .item:hover .caret {
273
- color: var(--vp-c-text-2);
274
- }
275
-
276
- .item:hover .caret:hover {
277
- color: var(--vp-c-text-1);
278
- }
279
-
280
- .caret-icon {
281
- font-size: 18px;
282
- transform: rotate(90deg);
283
- transition: transform 0.25s;
284
- }
285
-
286
- .VPSidebarItem.collapsed .caret-icon {
287
- transform: rotate(0);
288
- }
289
-
290
- .VPSidebarItem.level-1 .items,
291
- .VPSidebarItem.level-2 .items,
292
- .VPSidebarItem.level-3 .items,
293
- .VPSidebarItem.level-4 .items,
294
- .VPSidebarItem.level-5 .items {
295
- border-left: 1px solid var(--vp-c-divider);
296
- padding-left: 16px;
297
- }
298
-
299
- .VPSidebarItem.collapsed .items {
300
- display: none;
301
- }
302
- </style>
1
+ <script setup lang="ts">
2
+ import type { DefaultTheme } from 'vitepress'
3
+ import { Icon } from '@iconify/vue'
4
+ import { computed } from 'vue'
5
+ import { useSidebarControl } from '../hooks/useSidebarControl'
6
+ import Link from './Link.vue'
7
+ import VersionTag from './VersionTag.vue'
8
+
9
+ const props = defineProps<{
10
+ item: DefaultTheme.SidebarItem & {
11
+ hide?: boolean
12
+ icon?: string
13
+ promotion?: string
14
+ }
15
+ depth: number
16
+ }>()
17
+ const {
18
+ collapsed,
19
+ collapsible,
20
+ isLink,
21
+ isActiveLink,
22
+ hasActiveLink,
23
+ hasChildren,
24
+ toggle,
25
+ } = useSidebarControl(computed(() => props.item))
26
+
27
+ const sectionTag = computed(() => (hasChildren.value ? 'section' : 'div'))
28
+
29
+ const linkTag = computed(() => (isLink.value ? 'a' : 'div'))
30
+
31
+ const textTag = computed(() => {
32
+ return !hasChildren.value
33
+ ? 'p'
34
+ : props.depth + 2 === 7
35
+ ? 'p'
36
+ : `h${props.depth + 2}`
37
+ })
38
+
39
+ const itemRole = computed(() => (isLink.value ? undefined : 'button'))
40
+
41
+ const classes = computed(() => [
42
+ [`level-${props.depth}`],
43
+ { collapsible: collapsible.value },
44
+ { collapsed: collapsed.value },
45
+ { 'is-link': isLink.value },
46
+ { 'is-active': isActiveLink.value },
47
+ { 'has-active': hasActiveLink.value },
48
+ ])
49
+
50
+ function onItemInteraction(e: MouseEvent | Event) {
51
+ if ('key' in e && e.key !== 'Enter') {
52
+ return
53
+ }
54
+ !props.item.link && toggle()
55
+ }
56
+ function onCaretClick() {
57
+ props.item.link && toggle()
58
+ }
59
+
60
+ function onLinkAreaClick(e: MouseEvent) {
61
+ const elA = (e.target as HTMLElement).querySelector('a')
62
+ elA && elA.click()
63
+ }
64
+ </script>
65
+
66
+ <template>
67
+ <component :is="sectionTag" class="VPSidebarItem" :class="classes">
68
+ <div
69
+ v-if="item.text && !item.hide"
70
+ class="item"
71
+ :role="itemRole"
72
+ :tabindex="item.items && 0"
73
+ v-on="
74
+ item.items
75
+ ? { click: onItemInteraction, keydown: onItemInteraction }
76
+ : { click: onLinkAreaClick }
77
+ "
78
+ >
79
+ <div class="indicator" />
80
+ <Icon
81
+ v-if="item.icon && item.items"
82
+ :icon="item.icon"
83
+ style="margin-right: 5px;"
84
+ ssr
85
+ />
86
+ <Link
87
+ v-if="item.link"
88
+ :tag="linkTag"
89
+ class="link"
90
+ :href="item.link"
91
+ :rel="item.rel"
92
+ :target="item.target"
93
+ >
94
+ <Icon
95
+ v-if="item.icon && item.link"
96
+ :icon="item.icon"
97
+ class="text text-icon"
98
+ ssr
99
+ />
100
+ <component :is="textTag" class="text" v-html="item.text" />
101
+ <VersionTag v-if="item.promotion" class="version-tag" :version="item.promotion" />
102
+ </Link>
103
+ <component
104
+ :is="textTag"
105
+ v-else
106
+ class="text"
107
+ v-html="item.text"
108
+ />
109
+
110
+ <div
111
+ v-if="item.collapsed !== undefined && item.items && item.items.length"
112
+ class="caret"
113
+ role="button"
114
+ aria-label="toggle section"
115
+ tabindex="0"
116
+ @click="onCaretClick"
117
+ @keydown.enter="onCaretClick"
118
+ >
119
+ <span class="vpi-chevron-right caret-icon" />
120
+ </div>
121
+ </div>
122
+
123
+ <div v-if="item?.items && item?.items.length" class="items">
124
+ <template v-if="depth < 5">
125
+ <SidebarItem
126
+ v-for="i in item.items"
127
+ :key="i.text"
128
+ :item="i"
129
+ :depth="depth + 1"
130
+ />
131
+ </template>
132
+ </div>
133
+ </component>
134
+ </template>
135
+
136
+ <style scoped lang="scss">
137
+ .VPSidebarItem.collapsed.level-0 {
138
+ padding-bottom: 10px;
139
+ }
140
+
141
+ .item {
142
+ position: relative;
143
+ display: flex;
144
+ width: 100%;
145
+ display: flex;
146
+ align-items: center;
147
+ border-radius: 8px;
148
+ transition: background-color 0.25s;
149
+ cursor: pointer;
150
+ }
151
+
152
+ .VPSidebarItem.collapsible > .item {
153
+ cursor: pointer;
154
+ }
155
+
156
+ .indicator {
157
+ position: absolute;
158
+ top: 6px;
159
+ bottom: 6px;
160
+ left: -17px;
161
+ width: 2px;
162
+ border-radius: 2px;
163
+ transition: background-color 0.25s;
164
+ }
165
+
166
+ .VPSidebarItem.level-2.is-active > .item > .indicator,
167
+ .VPSidebarItem.level-3.is-active > .item > .indicator,
168
+ .VPSidebarItem.level-4.is-active > .item > .indicator,
169
+ .VPSidebarItem.level-5.is-active > .item > .indicator {
170
+ background-color: var(--vp-c-brand-1);
171
+ }
172
+
173
+ .link {
174
+ display: flex;
175
+ align-items: center;
176
+ padding: 10px 16px;
177
+ line-height: 20px;
178
+ font-size: 13px;
179
+ }
180
+
181
+ .text {
182
+ flex-grow: 1;
183
+ line-height: 24px;
184
+ transition: color 0.25s;
185
+ }
186
+ .text-icon {
187
+ flex-grow: 0;
188
+ padding: 0;
189
+ margin-right: 4px;
190
+ }
191
+ .version-tag {
192
+ margin-left: 8px;
193
+ }
194
+ .VPSidebarItem.level-0 > .item {
195
+ color: var(--vp-c-text-1);
196
+ margin-bottom: 8px;
197
+ line-height: 24px;
198
+ }
199
+ .VPSidebarItem.level-0 > .item h2 {
200
+ color: var(--vp-c-text-1);
201
+ font-size: 1rem;
202
+ font-weight: 700;
203
+ margin-bottom: 8px;
204
+ line-height: 24px;
205
+ }
206
+
207
+ .VPSidebarItem.level-1,
208
+ .VPSidebarItem.level-2,
209
+ .VPSidebarItem.level-3,
210
+ .VPSidebarItem.level-4,
211
+ .VPSidebarItem.level-5 {
212
+ font-weight: 500;
213
+ color: var(--vp-c-text-2);
214
+ }
215
+
216
+ .VPSidebarItem.level-0.is-link > .item > .link:hover,
217
+ .VPSidebarItem.level-1.is-link > .item > .link:hover,
218
+ .VPSidebarItem.level-2.is-link > .item > .link:hover,
219
+ .VPSidebarItem.level-3.is-link > .item > .link:hover,
220
+ .VPSidebarItem.level-4.is-link > .item > .link:hover,
221
+ .VPSidebarItem.level-5.is-link > .item > .link:hover {
222
+ color: var(--vp-c-brand-1);
223
+ }
224
+
225
+ .VPSidebarItem.level-0.has-active > .item,
226
+ .VPSidebarItem.level-1.has-active > .item,
227
+ .VPSidebarItem.level-2.has-active > .item,
228
+ .VPSidebarItem.level-3.has-active > .item,
229
+ .VPSidebarItem.level-4.has-active > .item,
230
+ .VPSidebarItem.level-5.has-active > .item,
231
+ .VPSidebarItem.level-0.has-active > .item > .link,
232
+ .VPSidebarItem.level-1.has-active > .item > .link,
233
+ .VPSidebarItem.level-2.has-active > .item > .link,
234
+ .VPSidebarItem.level-3.has-active > .item > .link,
235
+ .VPSidebarItem.level-4.has-active > .item > .link,
236
+ .VPSidebarItem.level-5.has-active > .item > .link {
237
+ color: var(--vp-c-text-1);
238
+ }
239
+
240
+ .VPSidebarItem.level-0.is-active > .item .link,
241
+ .VPSidebarItem.level-1.is-active > .item .link,
242
+ .VPSidebarItem.level-2.is-active > .item .link,
243
+ .VPSidebarItem.level-3.is-active > .item .link,
244
+ .VPSidebarItem.level-4.is-active > .item .link,
245
+ .VPSidebarItem.level-5.is-active > .item .link {
246
+ color: var(--vp-c-brand-1);
247
+ font-weight: 600;
248
+ }
249
+
250
+ .VPSidebarItem.level-0.is-active > .item,
251
+ .VPSidebarItem.level-1.is-active > .item,
252
+ .VPSidebarItem.level-2.is-active > .item,
253
+ .VPSidebarItem.level-3.is-active > .item,
254
+ .VPSidebarItem.level-4.is-active > .item,
255
+ .VPSidebarItem.level-5.is-active > .item {
256
+ background-color: var(--el-color-primary-light-9);
257
+ }
258
+
259
+ .caret {
260
+ display: flex;
261
+ justify-content: center;
262
+ align-items: center;
263
+ margin-right: -7px;
264
+ width: 32px;
265
+ height: 32px;
266
+ color: var(--vp-c-text-3);
267
+ cursor: pointer;
268
+ transition: color 0.25s;
269
+ flex-shrink: 0;
270
+ }
271
+
272
+ .item:hover .caret {
273
+ color: var(--vp-c-text-2);
274
+ }
275
+
276
+ .item:hover .caret:hover {
277
+ color: var(--vp-c-text-1);
278
+ }
279
+
280
+ .caret-icon {
281
+ font-size: 18px;
282
+ transform: rotate(90deg);
283
+ transition: transform 0.25s;
284
+ }
285
+
286
+ .VPSidebarItem.collapsed .caret-icon {
287
+ transform: rotate(0);
288
+ }
289
+
290
+ .VPSidebarItem.level-1 .items,
291
+ .VPSidebarItem.level-2 .items,
292
+ .VPSidebarItem.level-3 .items,
293
+ .VPSidebarItem.level-4 .items,
294
+ .VPSidebarItem.level-5 .items {
295
+ border-left: 1px solid var(--vp-c-divider);
296
+ padding-left: 16px;
297
+ }
298
+
299
+ .VPSidebarItem.collapsed .items {
300
+ display: none;
301
+ }
302
+ </style>
@@ -1,25 +1,25 @@
1
- <script lang="ts" setup>
2
- interface Props {
3
- text: string
4
- }
5
- defineProps<Props>()
6
- </script>
7
-
8
- <template>
9
- <span class="VPTTag">
10
- {{ text }}
11
- </span>
12
- </template>
13
-
14
- <style lang="scss" scoped>
15
- .VPTTag {
16
- font-size: 12px;
17
- line-height: 26px;
18
- background-color: var(--vpt-bg-opacity);
19
- border-radius: 6px;
20
- padding: 0 12px;
21
- box-sizing: border-box;
22
- margin-right: 12px;
23
- margin-bottom: 12px;
24
- }
25
- </style>
1
+ <script lang="ts" setup>
2
+ interface Props {
3
+ text: string
4
+ }
5
+ defineProps<Props>()
6
+ </script>
7
+
8
+ <template>
9
+ <span class="VPTTag">
10
+ {{ text }}
11
+ </span>
12
+ </template>
13
+
14
+ <style lang="scss" scoped>
15
+ .VPTTag {
16
+ font-size: 12px;
17
+ line-height: 26px;
18
+ background-color: var(--vpt-bg-opacity);
19
+ border-radius: 6px;
20
+ padding: 0 12px;
21
+ box-sizing: border-box;
22
+ margin-right: 12px;
23
+ margin-bottom: 12px;
24
+ }
25
+ </style>