vitepress-theme-element-plus 0.0.1 → 0.0.2

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 (49) hide show
  1. package/client/components/A11yTag.vue +29 -0
  2. package/client/components/ApiTyping.vue +54 -0
  3. package/client/components/Backdrop.vue +41 -0
  4. package/client/components/Bili.vue +94 -0
  5. package/client/components/Content.vue +150 -0
  6. package/client/components/DeprecatedTag.vue +19 -0
  7. package/client/components/Doc.vue +181 -0
  8. package/client/components/DocAside.vue +46 -0
  9. package/client/components/DocAsideOutline.vue +82 -0
  10. package/client/components/DocFooter.vue +159 -0
  11. package/client/components/Footer.vue +77 -0
  12. package/client/components/FooterCopyright.vue +27 -0
  13. package/client/components/Layout.vue +156 -0
  14. package/client/components/Link.vue +41 -0
  15. package/client/components/LocalNav.vue +160 -0
  16. package/client/components/Nav.vue +69 -0
  17. package/client/components/NavBar.vue +203 -0
  18. package/client/components/NavBarTitle.vue +75 -0
  19. package/client/components/Sidebar.vue +129 -0
  20. package/client/components/SidebarGroup.vue +51 -0
  21. package/client/components/SidebarItem.vue +302 -0
  22. package/client/components/Tag.vue +25 -0
  23. package/client/components/VPNavBarSearch.vue +23 -0
  24. package/client/components/VersionTag.vue +18 -0
  25. package/client/hooks/useBackTop.ts +74 -0
  26. package/client/hooks/useLangs.ts +50 -0
  27. package/client/hooks/useSidebar.ts +105 -0
  28. package/client/hooks/useSidebarControl.ts +78 -0
  29. package/client/hooks/useSize.ts +69 -0
  30. package/client/utils/client/common.ts +49 -0
  31. package/client/utils/client/outline.ts +113 -0
  32. package/client/utils/common.ts +86 -0
  33. package/dist/index.d.mts +5 -0
  34. package/dist/index.mjs +6 -0
  35. package/dist/markdown/plugins/external-link-icon.d.mts +6 -0
  36. package/dist/markdown/plugins/external-link-icon.mjs +26 -0
  37. package/dist/markdown/plugins/table-wrapper.d.mts +6 -0
  38. package/dist/markdown/plugins/table-wrapper.mjs +8 -0
  39. package/dist/markdown/plugins/tag.d.mts +6 -0
  40. package/dist/markdown/plugins/tag.mjs +25 -0
  41. package/dist/markdown/plugins/tooltip.d.mts +6 -0
  42. package/dist/markdown/plugins/tooltip.mjs +24 -0
  43. package/package.json +5 -5
  44. package/shared/constants.ts +3 -0
  45. package/styles/base.scss +37 -0
  46. package/styles/code.scss +283 -0
  47. package/styles/doc-content.scss +161 -0
  48. package/styles/index.scss +69 -0
  49. package/styles/tag-content.scss +30 -0
@@ -0,0 +1,203 @@
1
+ <script lang="ts" setup>
2
+ import { useWindowScroll } from '@vueuse/core'
3
+ import { useData } from 'vitepress'
4
+ import VPNavBarAppearance from 'vitepress/dist/client/theme-default/components/VPNavBarAppearance.vue'
5
+ import VPNavBarExtra from 'vitepress/dist/client/theme-default/components/VPNavBarExtra.vue'
6
+ import VPNavBarHamburger from 'vitepress/dist/client/theme-default/components/VPNavBarHamburger.vue'
7
+ import VPNavBarMenu from 'vitepress/dist/client/theme-default/components/VPNavBarMenu.vue'
8
+ import VPNavBarSocialLinks from 'vitepress/dist/client/theme-default/components/VPNavBarSocialLinks.vue'
9
+ import VPNavBarTranslations from 'vitepress/dist/client/theme-default/components/VPNavBarTranslations.vue'
10
+ import { ref, watchPostEffect } from 'vue'
11
+ import VPNavBarTitle from './NavBarTitle.vue'
12
+ import VPNavBarSearch from './VPNavBarSearch.vue'
13
+
14
+ const props = defineProps<{
15
+ isScreenOpen: boolean
16
+ }>()
17
+
18
+ defineEmits<{
19
+ (e: 'toggleScreen'): void
20
+ }>()
21
+
22
+ const { y } = useWindowScroll()
23
+ const { frontmatter } = useData()
24
+ const classes = ref<Record<string, boolean>>({})
25
+
26
+ watchPostEffect(() => {
27
+ classes.value = {
28
+ 'home': frontmatter.value.layout === 'home',
29
+ 'top': y.value === 0,
30
+ 'screen-open': props.isScreenOpen,
31
+ }
32
+ })
33
+ </script>
34
+
35
+ <template>
36
+ <div class="VPNavBar" :class="classes">
37
+ <div class="wrapper">
38
+ <div class="container">
39
+ <div class="title">
40
+ <VPNavBarTitle>
41
+ <template #nav-bar-title-before>
42
+ <slot name="nav-bar-title-before" />
43
+ </template>
44
+ <template #nav-bar-title-after>
45
+ <slot name="nav-bar-title-after" />
46
+ </template>
47
+ </VPNavBarTitle>
48
+ </div>
49
+
50
+ <div class="content">
51
+ <div class="content-body">
52
+ <slot name="nav-bar-content-before" />
53
+ <VPNavBarSearch class="search" />
54
+ <VPNavBarMenu class="menu" />
55
+ <VPNavBarTranslations class="translations" />
56
+ <VPNavBarAppearance class="appearance" />
57
+ <VPNavBarSocialLinks class="social-links" />
58
+ <VPNavBarExtra class="extra" />
59
+ <slot name="nav-bar-content-after" />
60
+ <VPNavBarHamburger class="hamburger" :active="isScreenOpen" @click="$emit('toggleScreen')" />
61
+ </div>
62
+ </div>
63
+ </div>
64
+ </div>
65
+
66
+ <div class="divider">
67
+ <div class="divider-line" />
68
+ </div>
69
+ </div>
70
+ </template>
71
+
72
+ <style scoped lang="scss">
73
+ .VPNavBar {
74
+ position: relative;
75
+ height: var(--vp-nav-height);
76
+ pointer-events: none;
77
+ white-space: nowrap;
78
+ transition: background-color 0.25s;
79
+ background-image: radial-gradient(transparent 1px, var(--vp-c-bg) 1px);
80
+ background-size: 4px 4px;
81
+ backdrop-filter: saturate(50%) blur(4px);
82
+ -webkit-backdrop-filter: saturate(50%) blur(4px);
83
+ }
84
+
85
+ .VPNavBar.screen-open {
86
+ transition: none;
87
+ background-color: var(--vp-nav-bg-color);
88
+ border-bottom: 1px solid var(--vp-c-divider);
89
+ }
90
+
91
+ .VPNavBar:not(.home) {
92
+ background-color: var(--vp-nav-bg-color);
93
+ }
94
+
95
+ :deep(.VPNavBarMenuLink) {
96
+ border-bottom: 2px solid transparent;
97
+ }
98
+
99
+ :deep(.VPNavBarMenuLink.active) {
100
+ border-bottom-color: var(--vp-c-brand-1);
101
+ }
102
+
103
+ @media (min-width: 960px) {
104
+ .VPNavBar:not(.home) {
105
+ background-color: transparent;
106
+ }
107
+ }
108
+
109
+ .wrapper {
110
+ padding: 0 8px 0 24px;
111
+ }
112
+
113
+ @media (min-width: 768px) {
114
+ .wrapper {
115
+ padding: 0 32px;
116
+ }
117
+ }
118
+
119
+ @media screen and (min-width: var(--vp-layout-max-width)) {
120
+ .wrapper {
121
+ padding: 0px 48px;
122
+ }
123
+ }
124
+
125
+ .container {
126
+ display: flex;
127
+ justify-content: space-between;
128
+ margin: 0 auto;
129
+ height: var(--vp-nav-height);
130
+ pointer-events: none;
131
+ }
132
+
133
+ .container > .title,
134
+ .container > .content {
135
+ pointer-events: none;
136
+ }
137
+
138
+ .container :deep(*) {
139
+ pointer-events: auto;
140
+ }
141
+
142
+ .title {
143
+ flex-shrink: 0;
144
+ height: calc(var(--vp-nav-height) - 1px);
145
+ transition: background-color 0.5s;
146
+ }
147
+
148
+ .content {
149
+ flex-grow: 1;
150
+ }
151
+
152
+ .content-body {
153
+ display: flex;
154
+ justify-content: flex-end;
155
+ align-items: center;
156
+ height: var(--vp-nav-height);
157
+ transition: background-color 0.5s;
158
+ }
159
+
160
+ @media (max-width: 767px) {
161
+ .content-body {
162
+ column-gap: 0.5rem;
163
+ }
164
+ }
165
+
166
+ .menu + .translations::before,
167
+ .menu + .appearance::before,
168
+ .menu + .social-links::before,
169
+ .translations + .appearance::before,
170
+ .appearance + .social-links::before {
171
+ margin-right: 8px;
172
+ margin-left: 8px;
173
+ width: 1px;
174
+ height: 24px;
175
+ background-color: var(--vp-c-divider);
176
+ content: '';
177
+ }
178
+
179
+ .menu + .appearance::before,
180
+ .translations + .appearance::before {
181
+ margin-right: 16px;
182
+ }
183
+
184
+ .appearance + .social-links::before {
185
+ margin-left: 16px;
186
+ }
187
+
188
+ .social-links {
189
+ margin-right: -8px;
190
+ }
191
+
192
+ .divider {
193
+ width: 100%;
194
+ height: 1px;
195
+ }
196
+
197
+ .divider-line {
198
+ width: 100%;
199
+ height: 1px;
200
+ transition: background-color 0.5s;
201
+ background-color: var(--vp-c-gutter);
202
+ }
203
+ </style>
@@ -0,0 +1,75 @@
1
+ <script setup lang="ts">
2
+ import { ElTag } from 'element-plus'
3
+ import { useData } from 'vitepress'
4
+ import VPImage from 'vitepress/dist/client/theme-default/components/VPImage.vue'
5
+ import { normalizeLink } from 'vitepress/dist/client/theme-default/support/utils'
6
+ import { computed } from 'vue'
7
+ import { useLangs } from '../hooks/useLangs'
8
+
9
+ const { site, theme } = useData()
10
+ const { currentLang } = useLangs()
11
+ const link = computed(() =>
12
+ typeof theme.value.logoLink === 'string'
13
+ ? theme.value.logoLink
14
+ : theme.value.logoLink?.link,
15
+ )
16
+
17
+ const rel = computed(() =>
18
+ typeof theme.value.logoLink === 'string'
19
+ ? undefined
20
+ : theme.value.logoLink?.rel,
21
+ )
22
+
23
+ const target = computed(() =>
24
+ typeof theme.value.logoLink === 'string'
25
+ ? undefined
26
+ : theme.value.logoLink?.target,
27
+ )
28
+ </script>
29
+
30
+ <template>
31
+ <div class="VPNavBarTitle">
32
+ <a
33
+ class="title"
34
+ :href="link ?? normalizeLink(currentLang.link)"
35
+ :rel="rel"
36
+ :target="target"
37
+ >
38
+ <slot name="nav-bar-title-before" />
39
+ <VPImage v-if="theme.logo" class="logo" :image="theme.logo" />
40
+ <span v-if="theme.siteTitle" v-html="theme.siteTitle" />
41
+ <span v-else-if="theme.siteTitle === undefined">{{ site.title }}</span>
42
+ <ElTag v-if="theme.version" type="primary" round>{{ theme.version }}</ElTag>
43
+ <slot name="nav-bar-title-after" />
44
+ </a>
45
+ </div>
46
+ </template>
47
+
48
+ <style scoped lang="scss">
49
+ .title {
50
+ display: flex;
51
+ align-items: center;
52
+ border-bottom: 1px solid transparent;
53
+ width: 100%;
54
+ height: var(--vp-nav-height);
55
+ font-size: 16px;
56
+ font-weight: 600;
57
+ color: var(--vp-c-text-1);
58
+ transition: opacity 0.25s;
59
+ }
60
+
61
+ .title .el-tag {
62
+ font-weight: normal;
63
+ }
64
+
65
+ @media (min-width: 960px) {
66
+ .title {
67
+ flex-shrink: 0;
68
+ }
69
+ }
70
+
71
+ :deep(.logo) {
72
+ margin-right: 14px;
73
+ height: var(--vp-nav-logo-height);
74
+ }
75
+ </style>
@@ -0,0 +1,129 @@
1
+ <script lang="ts" setup>
2
+ import { useScrollLock } from '@vueuse/core'
3
+ import { inBrowser } from 'vitepress'
4
+ import { useLayout } from 'vitepress/theme'
5
+ import { ref, watch } from 'vue'
6
+ import VPSidebarGroup from './SidebarGroup.vue'
7
+
8
+ const props = defineProps<{
9
+ open: boolean
10
+ }>()
11
+
12
+ const { sidebarGroups, hasSidebar } = useLayout()
13
+
14
+ // a11y: focus Nav element when menu has opened
15
+ const navEl = ref<HTMLElement | null>(null)
16
+ const isLocked = useScrollLock(inBrowser ? document.body : null)
17
+ watch(
18
+ [props, navEl],
19
+ () => {
20
+ if (props.open) {
21
+ isLocked.value = true
22
+ navEl.value?.focus()
23
+ }
24
+ else {
25
+ isLocked.value = false
26
+ }
27
+ },
28
+ { immediate: true, flush: 'post' },
29
+ )
30
+
31
+ const key = ref(0)
32
+ watch(
33
+ sidebarGroups,
34
+ () => {
35
+ key.value += 1
36
+ },
37
+ { deep: true },
38
+ )
39
+ </script>
40
+
41
+ <template>
42
+ <aside v-if="hasSidebar" ref="navEl" class="VPSidebar" :class="{ open: open && hasSidebar }" @click.stop>
43
+ <nav id="VPSidebarNav" class="nav" aria-labelledby="sidebar-aria-label" tabindex="-1">
44
+ <span id="sidebar-aria-label" class="visually-hidden">
45
+ Sidebar Navigation
46
+ </span>
47
+
48
+ <slot name="sidebar-nav-before" />
49
+ <VPSidebarGroup :key="key" :items="sidebarGroups" />
50
+ <slot name="sidebar-nav-after" />
51
+ </nav>
52
+ </aside>
53
+ </template>
54
+
55
+ <style lang="scss" scoped>
56
+ .VPSidebar {
57
+ position: fixed;
58
+ top: 0;
59
+ bottom: 0;
60
+ left: 0;
61
+ z-index: var(--vp-z-index-sidebar);
62
+ padding: 32px 32px 96px;
63
+ background-color: var(--vp-c-bg);
64
+ opacity: 0;
65
+ box-shadow: var(--vp-c-shadow-3);
66
+ overflow-x: hidden;
67
+ overflow-y: auto;
68
+ transform: translateX(-100%);
69
+ transition:
70
+ opacity 0.5s,
71
+ transform 0.25s ease;
72
+ overscroll-behavior: contain;
73
+ }
74
+
75
+ .VPSidebar.open {
76
+ opacity: 1;
77
+ transform: translateX(0);
78
+ transition:
79
+ opacity 0.25s,
80
+ transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
81
+ }
82
+
83
+ .dark .VPSidebar {
84
+ box-shadow: var(--vp-shadow-1);
85
+ }
86
+
87
+ @media (max-width: 767px) {
88
+ .VPSidebar {
89
+ width: calc(var(--vp-sidebar-width-mobile) - 14px);
90
+ }
91
+ }
92
+
93
+ @media screen and (min-width: 768px) {
94
+ .VPSidebar {
95
+ width: calc(var(--vp-sidebar-width-small));
96
+ top: 0;
97
+ }
98
+ }
99
+
100
+ @media screen and (min-width: 960px) {
101
+ .VPSidebar {
102
+ top: var(--vp-nav-height);
103
+ padding: 48px 32px;
104
+ background-color: var(--vp-c-bg);
105
+ opacity: 1;
106
+ visibility: visible;
107
+ box-shadow: none;
108
+ transform: translateX(0);
109
+ }
110
+ }
111
+
112
+ @media screen and (min-width: 1440px) {
113
+ .VPSidebar {
114
+ padding: 48px 32px;
115
+ width: calc(var(--vp-sidebar-width-small) + 39px)
116
+ }
117
+ }
118
+
119
+ @media screen and (min-width: 1680px) {
120
+ .VPSidebar {
121
+ padding: 48px;
122
+ width: calc(var(--vp-sidebar-width-small) + 48px)
123
+ }
124
+ }
125
+
126
+ .nav {
127
+ outline: 0;
128
+ }
129
+ </style>
@@ -0,0 +1,51 @@
1
+ <script setup lang="ts">
2
+ import type { DefaultTheme } from 'vitepress/theme'
3
+ import { onBeforeUnmount, onMounted, ref } from 'vue'
4
+ import VPSidebarItem from './SidebarItem.vue'
5
+
6
+ defineProps<{
7
+ items: (DefaultTheme.SidebarItem & { hide?: boolean })[]
8
+ }>()
9
+
10
+ const disableTransition = ref(true)
11
+ let timer: ReturnType<typeof setTimeout> | null = null
12
+
13
+ onMounted(() => {
14
+ timer = setTimeout(() => {
15
+ timer = null
16
+ disableTransition.value = false
17
+ }, 300)
18
+ })
19
+
20
+ onBeforeUnmount(() => {
21
+ if (timer !== null) {
22
+ clearTimeout(timer)
23
+ timer = null
24
+ }
25
+ })
26
+ </script>
27
+
28
+ <template>
29
+ <template
30
+ v-for="item in items"
31
+ :key="item.link"
32
+ >
33
+ <div
34
+ v-if="!item.hide"
35
+ class="group"
36
+ :class="{ 'no-transition': disableTransition }"
37
+ >
38
+ <VPSidebarItem :item="item" :depth="0" />
39
+ </div>
40
+ </template>
41
+ </template>
42
+
43
+ <style scoped lang="scss">
44
+ .no-transition :deep(.caret-icon) {
45
+ transition: none;
46
+ }
47
+
48
+ .group + .group {
49
+ padding-top: 24px;
50
+ }
51
+ </style>