vitepress-theme-element-plus 0.0.7 → 0.0.8

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