valaxy-theme-press 0.0.1 → 0.0.3

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 (51) hide show
  1. package/README.md +8 -0
  2. package/client/index.ts +1 -0
  3. package/components/DocsBoard.vue +24 -0
  4. package/components/PressArticle.vue +15 -10
  5. package/components/PressArticleCard.vue +6 -2
  6. package/components/PressAside.vue +87 -0
  7. package/components/PressBackdrop.vue +39 -0
  8. package/components/PressButton.vue +31 -0
  9. package/components/PressCategories.vue +71 -0
  10. package/components/PressCategory.vue +58 -0
  11. package/components/PressDocFooter.vue +15 -0
  12. package/components/PressDocFooterLastUpdated.vue +44 -0
  13. package/components/PressFeature.vue +61 -0
  14. package/components/PressFeatures.vue +26 -0
  15. package/components/PressFooter.vue +53 -0
  16. package/components/PressHome.vue +15 -0
  17. package/components/PressHomeFeatures.vue +12 -0
  18. package/components/PressHomeHero.vue +34 -0
  19. package/components/PressLocalNav.vue +109 -0
  20. package/components/PressNav.vue +17 -35
  21. package/components/PressOutline.vue +111 -0
  22. package/components/PressOutlineItem.vue +48 -0
  23. package/components/PressSidebar.vue +88 -0
  24. package/components/PressToggleLocale.vue +1 -1
  25. package/components/ValaxyMain.vue +56 -12
  26. package/components/nav/PressNavBar.vue +111 -0
  27. package/components/nav/PressNavItemGroup.vue +101 -0
  28. package/components/nav/PressNavItemLink.vue +39 -0
  29. package/components/nav/PressSwitchAppearance.vue +71 -0
  30. package/composables/edit-link.ts +14 -0
  31. package/composables/index.ts +1 -0
  32. package/config/index.ts +7 -12
  33. package/layouts/404.vue +13 -12
  34. package/layouts/home.vue +1 -7
  35. package/layouts/layout.vue +52 -39
  36. package/node/index.ts +1 -42
  37. package/package.json +16 -15
  38. package/pages/[..all].vue +15 -0
  39. package/setup/main.ts +89 -0
  40. package/styles/css-vars.scss +46 -0
  41. package/styles/helper.scss +34 -0
  42. package/styles/index.scss +7 -0
  43. package/styles/markdown.scss +49 -0
  44. package/types/home.d.ts +5 -0
  45. package/types/index.d.ts +71 -0
  46. package/valaxy.config.ts +38 -0
  47. package/LICENSE +0 -21
  48. package/components/PressHeader.vue +0 -26
  49. package/pages/index.vue +0 -8
  50. package/tsup.config.ts +0 -16
  51. package/types/index.ts +0 -30
@@ -0,0 +1,109 @@
1
+ <script lang="ts" setup>
2
+ import { useSidebar } from 'valaxy/client'
3
+
4
+ defineProps<{
5
+ open: boolean
6
+ }>()
7
+
8
+ defineEmits<{
9
+ (e: 'openMenu'): void
10
+ }>()
11
+
12
+ const { hasSidebar } = useSidebar()
13
+
14
+ function scrollToTop() {
15
+ window.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
16
+ }
17
+ </script>
18
+
19
+ <template>
20
+ <div v-if="hasSidebar" class="press-local-nav">
21
+ <button
22
+ class="menu"
23
+ :aria-expanded="open"
24
+ aria-controls="VPSidebarNav"
25
+ @click="$emit('openMenu')"
26
+ >
27
+ <div i-ri-align-left class="menu-icon" />
28
+ <span class="menu-text">Menu</span>
29
+ </button>
30
+
31
+ <a class="top-link" href="#" @click="scrollToTop">
32
+ Return to top
33
+ </a>
34
+ </div>
35
+ </template>
36
+
37
+ <style scoped lang="scss">
38
+ @use 'valaxy/client/styles/mixins' as *;
39
+
40
+ .press-local-nav {
41
+ position: sticky;
42
+ top: 0;
43
+ left: 0;
44
+ z-index: var(--pr-z-index-local-nav);
45
+ display: flex;
46
+ justify-content: space-between;
47
+ align-items: center;
48
+ border-bottom: 1px solid var(--pr-c-divider-light);
49
+ width: 100%;
50
+ background-color: var(--va-c-bg);
51
+ transition: border-color 0.5s;
52
+ }
53
+
54
+ @include media('md') {
55
+ .press-local-nav {
56
+ display: none;
57
+ }
58
+ }
59
+
60
+ .menu {
61
+ display: flex;
62
+ align-items: center;
63
+ padding: 12px 24px 11px;
64
+ line-height: 24px;
65
+ font-size: 12px;
66
+ font-weight: 500;
67
+ color: var(--va-c-text-light);
68
+ transition: color 0.5s;
69
+ }
70
+
71
+ .menu:hover {
72
+ color: var(--va-c-text);
73
+ transition: color 0.25s;
74
+ }
75
+
76
+ @include media('md') {
77
+ .menu {
78
+ padding: 0 32px;
79
+ }
80
+ }
81
+
82
+ .menu-icon {
83
+ margin-right: 8px;
84
+ width: 16px;
85
+ height: 16px;
86
+ fill: currentColor;
87
+ }
88
+
89
+ .top-link {
90
+ display: block;
91
+ padding: 12px 24px 11px;
92
+ line-height: 24px;
93
+ font-size: 12px;
94
+ font-weight: 500;
95
+ color: var(--vp-c-text-2);
96
+ transition: color 0.5s;
97
+ }
98
+
99
+ .top-link:hover {
100
+ color: var(--vp-c-text-1);
101
+ transition: color 0.25s;
102
+ }
103
+
104
+ @include media('md') {
105
+ .top-link {
106
+ padding: 12px 32px 11px;
107
+ }
108
+ }
109
+ </style>
@@ -1,38 +1,20 @@
1
- <script lang="ts" setup>
2
- import { useConfig } from 'valaxy'
3
- import { computed } from 'vue'
4
- import { useRoute } from 'vue-router'
5
- import { useThemeConfig } from '../composables'
6
-
7
- const route = useRoute()
8
- const isIndex = computed(() => route.path.replace(/index.html$/, '') === '/')
9
-
10
- const config = useConfig()
11
- const themeConfig = useThemeConfig()
12
- </script>
13
-
14
1
  <template>
15
- <nav w="full" class="flex justify-between items-center py-10 font-bold">
16
- <a class="text-xl" href="/" :aria-label="config.title">
17
- <img
18
- class="inline-block mr-2"
19
- style="width: 50px; height: 35px"
20
- alt="logo"
21
- :src="config.favicon"
22
- >
23
- <span v-if="!isIndex" class="hidden md:inline">{{ config.title }}</span>
24
- </a>
25
- <div class="text-sm text-gray-500 leading-5">
26
- <template v-for="(item, i) in themeConfig.nav" :key="i">
27
- <a
28
- class="hover:text-gray-700"
29
- :href="item.link"
30
- target="_blank"
31
- rel="noopener"
32
- >{{ item.text }}</a>
33
-
34
- <span v-if="i !== themeConfig.nav.length - 1" class="mr-2 ml-2">·</span>
35
- </template>
36
- </div>
2
+ <nav w="full" class="press-nav relative md:fixed md:z-99 font-bold">
3
+ <PressNavBar />
37
4
  </nav>
38
5
  </template>
6
+
7
+ <style lang="scss">
8
+ @use 'valaxy/client/styles/mixins' as *;
9
+
10
+ .press-nav {
11
+ z-index: var(--pr-z-index-nav);
12
+ }
13
+
14
+ @include media('md') {
15
+ .press-nav {
16
+ -webkit-backdrop-filter: saturate(50%) blur(8px);
17
+ backdrop-filter: saturate(50%) blur(8px);
18
+ }
19
+ }
20
+ </style>
@@ -0,0 +1,111 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue'
3
+ import {
4
+ useActiveAnchor,
5
+ useOutline,
6
+ } from 'valaxy'
7
+ import { useI18n } from 'vue-i18n'
8
+ import { useThemeConfig } from '../composables'
9
+
10
+ const { t } = useI18n()
11
+ const themeConfig = useThemeConfig()
12
+
13
+ const container = ref()
14
+ const marker = ref()
15
+
16
+ useActiveAnchor(container, marker)
17
+
18
+ const { headers, handleClick } = useOutline()
19
+ </script>
20
+
21
+ <template>
22
+ <div v-show="headers.length" ref="container">
23
+ <div class="content">
24
+ <div class="outline-title">
25
+ {{ themeConfig.outlineTitle || t('sidebar.toc') }}
26
+ </div>
27
+
28
+ <div ref="marker" class="outline-marker" />
29
+
30
+ <nav aria-labelledby="doc-outline-aria-label">
31
+ <span id="doc-outline-aria-label" class="visually-hidden">
32
+ Table of Contents for current page
33
+ </span>
34
+
35
+ <PressOutlineItem
36
+ class="va-toc relative z-1"
37
+ :headers="headers"
38
+ :on-click="handleClick"
39
+ root
40
+ />
41
+ </nav>
42
+ </div>
43
+ </div>
44
+ </template>
45
+
46
+ <style lang="scss" scoped>
47
+ .va-toc {
48
+ text-align: left;
49
+
50
+ .va-toc-item {
51
+ color: var(--va-c-text-light);
52
+ }
53
+ }
54
+
55
+ .content {
56
+ position: relative;
57
+ padding-left: 16px;
58
+ font-size: 14px;
59
+ text-align: left;
60
+ border-left: 1px solid var(--pr-aside-divider);
61
+ }
62
+
63
+ .outline-marker {
64
+ position: absolute;
65
+ top: 32px;
66
+ left: -1px;
67
+ z-index: 0;
68
+ opacity: 0;
69
+ width: 1px;
70
+ height: 18px;
71
+ background-color: var(--va-c-brand);
72
+ transition: top 0.25s cubic-bezier(0, 1, 0.5, 1), background-color 0.5s, opacity 0.25s;
73
+ border-top-right-radius: 2px;
74
+ border-bottom-right-radius: 2px;
75
+ }
76
+
77
+ .outline-title {
78
+ letter-spacing: 0.4px;
79
+ line-height: 28px;
80
+ font-size: 14px;
81
+ font-weight: 600;
82
+ color: var(--pr-c-text-1);
83
+ }
84
+
85
+ .outline-link {
86
+ display: block;
87
+ line-height: 28px;
88
+ font-size: 13px;
89
+ color: var(--pr-aside-text-2);
90
+ white-space: nowrap;
91
+ overflow: hidden;
92
+ text-overflow: ellipsis;
93
+ transition: color 0.5s;
94
+ }
95
+
96
+ .outline-link:hover,
97
+ .outline-link.active {
98
+ color: var(--pr-aside-text-1);
99
+ transition: color 0.25s;
100
+ }
101
+
102
+ .visually-hidden {
103
+ position: absolute;
104
+ width: 1px;
105
+ height: 1px;
106
+ white-space: nowrap;
107
+ clip: rect(0 0 0 0);
108
+ clip-path: inset(50%);
109
+ overflow: hidden;
110
+ }
111
+ </style>
@@ -0,0 +1,48 @@
1
+ <script setup lang="ts">
2
+ import type { MenuItem } from 'valaxy'
3
+ import { useI18n } from 'vue-i18n'
4
+
5
+ defineProps<{
6
+ headers: MenuItem[]
7
+ onClick: (e: MouseEvent) => void
8
+ root?: boolean
9
+ }>()
10
+
11
+ const { locale } = useI18n()
12
+ </script>
13
+
14
+ <template>
15
+ <ul :class="root ? 'root' : 'nested'">
16
+ <li v-for="{ children, link, title, lang } in headers" :key="link" class="va-toc-item" :lang="lang || locale">
17
+ <a class="outline-link" :href="link" @click="onClick">{{ title }}</a>
18
+ <template v-if="children?.length">
19
+ <PressOutlineItem :headers="children" :on-click="onClick" />
20
+ </template>
21
+ </li>
22
+ </ul>
23
+ </template>
24
+
25
+ <style lang="scss" scoped>
26
+ .va-toc {
27
+ .va-toc-item {
28
+ .outline-link {
29
+ color: var(--va-c-text-light);
30
+ white-space: nowrap;
31
+ overflow: hidden;
32
+ text-overflow: ellipsis;
33
+ transition: color 0.5s;
34
+
35
+ &:hover,
36
+ &.active {
37
+ color: var(--va-c-brand);
38
+ transition: color 0.25s;
39
+ }
40
+
41
+ }
42
+
43
+ .nested {
44
+ padding-left: 0.8rem;
45
+ }
46
+ }
47
+ }
48
+ </style>
@@ -0,0 +1,88 @@
1
+ <script lang="ts" setup>
2
+ import { computed } from 'vue'
3
+ import { useCategory, usePageList, useSidebar } from 'valaxy'
4
+ import { useThemeConfig } from '../composables'
5
+
6
+ defineProps<{
7
+ open: boolean
8
+ }>()
9
+
10
+ const pages = usePageList()
11
+ const themeConfig = useThemeConfig()
12
+
13
+ const categories = computed(() => {
14
+ const cs = useCategory('', pages.value)
15
+ cs.children.delete('Uncategorized')
16
+
17
+ const sidebar = themeConfig.value.sidebar
18
+ if (sidebar) {
19
+ cs.children.forEach((_, key) => {
20
+ if (!themeConfig.value.sidebar.includes(key))
21
+ cs.children.delete(key)
22
+ })
23
+ }
24
+ return cs
25
+ })
26
+
27
+ const { hasSidebar } = useSidebar()
28
+ </script>
29
+
30
+ <template>
31
+ <aside
32
+ v-if="hasSidebar"
33
+ class="press-sidebar shadow-lg" :class="{ open }"
34
+ @click.stop
35
+ >
36
+ <div text="left" m="2">
37
+ <PressCategories :categories="categories.children" :collapsable="false" />
38
+ </div>
39
+ </aside>
40
+ </template>
41
+
42
+ <style lang="scss">
43
+ @use 'valaxy/client/styles/mixins' as *;
44
+
45
+ .press-sidebar {
46
+ position: fixed;
47
+ top: 0;
48
+ bottom: 0;
49
+ left: 0;
50
+ padding: 1rem;
51
+ top: var(--pr-nav-height);
52
+ z-index: var(--pr-z-index-sidebar);
53
+ width: calc(100vw - 64px);
54
+ max-width: 320px;
55
+ background-color: var(--va-c-bg);
56
+ opacity: 0;
57
+ overflow-x: hidden;
58
+ overflow-y: auto;
59
+ overflow-y: overlay;
60
+ transform: translateX(-100%);
61
+ transition: opacity 0.5s, transform 0.25s ease;
62
+
63
+ &.open {
64
+ opacity: 1;
65
+ transform: translateX(0);
66
+ transition: opacity 0.25s,
67
+ transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
68
+ }
69
+ }
70
+
71
+ @include media('md') {
72
+ .press-sidebar {
73
+ z-index: 1;
74
+ width: var(--va-sidebar-width);
75
+ max-width: 100%;
76
+ background-color: var(--va-c-bg-alt);
77
+ opacity: 1;
78
+ box-shadow: none;
79
+ transform: translateX(0);
80
+ }
81
+ }
82
+
83
+ @include mobile {
84
+ .press-sidebar {
85
+ top: 0;
86
+ }
87
+ }
88
+ </style>
@@ -7,7 +7,7 @@ const { toggleLocales } = useLocale()
7
7
  </script>
8
8
 
9
9
  <template>
10
- <button class="yun-icon-btn" :title="t('button.toggle_langs')" style="color:var(--va-c-text)" @click="toggleLocales">
10
+ <button :title="t('button.toggle_langs')" @click="toggleLocales">
11
11
  <div i-ri-translate class="transition transform" :class="locale === 'en' ? 'rotate-y-180' : ''" />
12
12
  </button>
13
13
  </template>
@@ -1,29 +1,47 @@
1
1
  <script lang="ts" setup>
2
2
  import type { PageData, Post } from 'valaxy'
3
- import { useConfig } from 'valaxy'
3
+ import { useConfig, useFrontmatter, useLayout, useSidebar } from 'valaxy'
4
4
 
5
5
  defineProps<{
6
6
  frontmatter: Post
7
7
  data?: PageData
8
8
  }>()
9
+
9
10
  const config = useConfig()
11
+ const frontmatter = useFrontmatter()
12
+
13
+ const { hasSidebar } = useSidebar()
14
+ const isHome = useLayout('home')
10
15
  </script>
11
16
 
12
17
  <template>
13
- <main>
14
- <div w="full" flex="~">
18
+ <main
19
+ class="press-main flex" :class="{
20
+ 'has-sidebar': hasSidebar,
21
+ }"
22
+ >
23
+ <div
24
+ w="full" flex="~" :class="{
25
+ 'px-6 md:pl-12': hasSidebar,
26
+ }" p="t-4"
27
+ >
15
28
  <slot name="main">
16
- <div class="content" flex="~ col grow" w="full" p="l-4 lt-md:0">
29
+ <div class="content" w="full" :class="{ 'm-auto': !hasSidebar }" flex="~ col grow" p="lt-md:0">
17
30
  <slot name="main-header" />
18
31
  <slot name="main-header-after" />
19
32
 
20
33
  <slot name="main-content">
21
- <div class="markdown-body prose max-w-none pb-8">
22
- <ValaxyMd :frontmatter="frontmatter">
23
- <slot name="main-content-md" />
24
- <slot />
25
- </ValaxyMd>
26
- </div>
34
+ <ValaxyMd class="prose mx-auto w-full max-w-4xl" :frontmatter="frontmatter">
35
+ <h1 v-if="hasSidebar && !isHome && frontmatter.title" :id="frontmatter.title" tabindex="-1">
36
+ {{ frontmatter.title }}
37
+ <a class="header-anchor" :href="`#${frontmatter.title}`" aria-hidden="true">#</a>
38
+ </h1>
39
+ <slot name="main-content-md" />
40
+ <slot />
41
+ </ValaxyMd>
42
+
43
+ <PressDocFooter v-if="!isHome" class="pb-8 max-w-4xl" w="full" m="auto" />
44
+
27
45
  <slot name="main-content-after" />
28
46
  </slot>
29
47
  </div>
@@ -38,8 +56,34 @@ const config = useConfig()
38
56
 
39
57
  <slot name="footer" />
40
58
  </slot>
41
- </div>
42
59
 
43
- <slot name="aside" />
60
+ <slot name="aside">
61
+ <PressAside v-if="!isHome" />
62
+ </slot>
63
+ </div>
44
64
  </main>
45
65
  </template>
66
+
67
+ <style lang="scss">
68
+ @use 'valaxy/client/styles/mixins' as *;
69
+
70
+ @include media('md') {
71
+ .press-main {
72
+ &.has-sidebar {
73
+ padding-top: var(--pr-nav-height);
74
+ padding-left: var(--va-sidebar-width);
75
+ }
76
+ }
77
+ }
78
+
79
+ @include media('xl') {
80
+ .content{
81
+ // 8px scrollbar width
82
+ max-width: calc(100vw - 2 * var(--va-sidebar-width) - 2.5rem);
83
+
84
+ &.no-aside {
85
+ max-width: calc(100vw - var(--va-sidebar-width));
86
+ }
87
+ }
88
+ }
89
+ </style>
@@ -0,0 +1,111 @@
1
+ <script lang="ts" setup>
2
+ import { useConfig, useSidebar } from 'valaxy'
3
+ import { useThemeConfig } from '../../composables'
4
+ import PressSwitchAppearance from './PressSwitchAppearance.vue'
5
+ import PressNavItemLink from './PressNavItemLink.vue'
6
+ import PressNavItemGroup from './PressNavItemGroup.vue'
7
+
8
+ defineProps<{
9
+ isScreenOpen?: boolean
10
+ }>()
11
+
12
+ defineEmits<{
13
+ (e: 'toggle-screen'): void
14
+ }>()
15
+
16
+ const { hasSidebar } = useSidebar()
17
+
18
+ const config = useConfig()
19
+ const themeConfig = useThemeConfig()
20
+ </script>
21
+
22
+ <template>
23
+ <div class="press-navbar flex justify-between items-center px-6 py-4" :class="{ 'has-sidebar': hasSidebar }">
24
+ <router-link class="text-xl" to="/" :aria-label="config.title">
25
+ <span class="md:inline">{{ config.title }}</span>
26
+ </router-link>
27
+ <div class="self-stretch flex justify-center items-center text-sm leading-5">
28
+ <template v-for="item in themeConfig.nav" :key="item.text">
29
+ <PressNavItemLink v-if="'link' in item" class="px-2" :item="item" />
30
+ <PressNavItemGroup v-else class="px-2" :item="item" />
31
+ </template>
32
+ <PressToggleLocale p="x-2" />
33
+ <PressSwitchAppearance m="l-2" />
34
+ </div>
35
+ </div>
36
+ </template>
37
+
38
+ <style lang="scss">
39
+ @use 'valaxy/client/styles/mixins' as *;
40
+
41
+ :root {
42
+ --pr-navbar-c-bg: rgba(255, 255, 255, 0.8);
43
+ }
44
+
45
+ .dark {
46
+ --pr-navbar-c-bg: rgba(24, 24, 24, 0.8);
47
+ }
48
+
49
+ .press-navbar {
50
+ position: relative;
51
+ border-bottom: 1px solid var(--pr-c-divider-light);
52
+ padding: 0 8px 0 24px;
53
+ height: var(--pr-nav-height);
54
+ transition: border-color 0.5s;
55
+ background-color: var(--pr-navbar-c-bg);
56
+ }
57
+
58
+ @include media('md') {
59
+ .press-navbar {
60
+ padding: 0 32px;
61
+ }
62
+ }
63
+
64
+ @include media('md') {
65
+ .press-navbar.has-sidebar .content {
66
+ margin-right: -32px;
67
+ padding-right: 32px;
68
+ -webkit-backdrop-filter: saturate(50%) blur(8px);
69
+ backdrop-filter: saturate(50%) blur(8px);
70
+ }
71
+
72
+ @supports not (backdrop-filter: saturate(50%) blur(8px)) {
73
+ .press-navbar.has-sidebar .content {
74
+ background: rgba(255, 255, 255, 0.95);
75
+ }
76
+
77
+ .dark .press-navbar.has-sidebar .content {
78
+ background: rgba(36, 36, 36, 0.95);
79
+ }
80
+ }
81
+ }
82
+
83
+ .container {
84
+ display: flex;
85
+ justify-content: space-between;
86
+ margin: 0 auto;
87
+ max-width: calc(var(--pr-layout-max-width) - 64px);
88
+ }
89
+
90
+ .menu + .translations::before,
91
+ .menu + .appearance::before,
92
+ .menu + .social-links::before,
93
+ .translations + .appearance::before,
94
+ .appearance + .social-links::before {
95
+ margin-right: 8px;
96
+ margin-left: 8px;
97
+ width: 1px;
98
+ height: 24px;
99
+ background-color: var(--pr-c-divider-light);
100
+ content: "";
101
+ }
102
+
103
+ .menu + .appearance::before,
104
+ .translations + .appearance::before {
105
+ margin-right: 16px;
106
+ }
107
+
108
+ .appearance + .social-links::before {
109
+ margin-left: 16px;
110
+ }
111
+ </style>