@coffic/cosy-ui 0.9.18 → 0.9.20
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.
- package/dist/app.css +1 -1
- package/dist/src-astro/code-container/ButtonCodeToggle.astro +0 -1
- package/dist/src-astro/code-container/ButtonCopyCode.astro +0 -2
- package/dist/src-astro/code-container/CodeContainer.astro +0 -3
- package/dist/src-astro/code-container/CodeToolbar.astro +0 -2
- package/dist/src-astro/footer/Footer.astro +1 -0
- package/dist/src-astro/header/Header.astro +3 -44
- package/dist/src-astro/header/LogoLink.astro +87 -0
- package/dist/src-astro/language-switcher/LanguageSwitcher.astro +3 -1
- package/dist/src-astro/layout-app/AppLayout.astro +12 -12
- package/dist/src-astro/layout-app/SkeletonLoader.astro +191 -0
- package/dist/src-astro/layout-app/loading-classes.ts +55 -0
- package/dist/src-astro/layout-basic/BaseLayout.astro +6 -6
- package/dist/src-astro/layout-basic/index.ts +1 -9
- package/dist/src-astro/loading-overlay/LoadingOverlay.astro +147 -75
- package/dist/src-astro/loading-overlay/index.ts +1 -1
- package/dist/src-astro/sidebar/MobileNav.astro +55 -0
- package/dist/src-astro/sidebar/NavItem.astro +100 -0
- package/dist/src-astro/sidebar/Sidebar.astro +37 -98
- package/dist/src-astro/sidebar/SidebarNav.astro +10 -87
- package/dist/src-astro/sidebar/index.ts +3 -1
- package/dist/src-astro/sidebar/utils.ts +64 -0
- package/dist/src-astro/theme-switcher/ThemeSwitcher.astro +3 -1
- package/dist/src-astro/types/layout.ts +5 -0
- package/dist/src-astro/types/meta.ts +0 -6
- package/package.json +1 -1
- package/dist/src-astro/layout-basic/BaseLayoutBasic.astro +0 -17
- package/dist/src-astro/loading-overlay/types.ts +0 -12
@@ -2,11 +2,11 @@
|
|
2
2
|
/**
|
3
3
|
* SidebarNav组件
|
4
4
|
*
|
5
|
-
*
|
5
|
+
* 用于渲染侧边栏的导航内容,支持无限层级
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { isPathMatch } from '../../src/utils/path.ts';
|
9
8
|
import '../../style.ts';
|
9
|
+
import NavItem from './NavItem.astro';
|
10
10
|
import type { ISidebarItem } from '../types/sidebar.ts';
|
11
11
|
|
12
12
|
interface Props {
|
@@ -61,91 +61,14 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
|
|
61
61
|
'cosy:menu cosy:bg-base-200 cosy:rounded-box cosy:w-56 cosy:no-underline',
|
62
62
|
debugClass,
|
63
63
|
]}>
|
64
|
-
{section.items?.map((item: ISidebarItem) =>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
class:list={[
|
73
|
-
'cosy:hover:bg-base-300 cosy:no-underline',
|
74
|
-
{ 'cosy:menu-active': isActive },
|
75
|
-
debugClass,
|
76
|
-
]}>
|
77
|
-
{item.text}
|
78
|
-
{item.badge !== undefined && item.badge !== null && (
|
79
|
-
<span class="cosy:badge cosy:badge-sm cosy:ml-2">
|
80
|
-
{item.badge}
|
81
|
-
</span>
|
82
|
-
)}
|
83
|
-
</a>
|
84
|
-
{item.items && (
|
85
|
-
<ul class:list={[debugClass]}>
|
86
|
-
{item.items.map((subitem: ISidebarItem) => {
|
87
|
-
const isSubActive = isPathMatch(
|
88
|
-
currentPath,
|
89
|
-
subitem.href
|
90
|
-
);
|
91
|
-
return (
|
92
|
-
<li class:list={[debugClass]}>
|
93
|
-
<a
|
94
|
-
data-sidebar-item
|
95
|
-
data-current-path={currentPath}
|
96
|
-
href={subitem.href}
|
97
|
-
class:list={[
|
98
|
-
'cosy:hover:bg-base-300',
|
99
|
-
{ 'cosy:menu-active': isSubActive },
|
100
|
-
debugClass,
|
101
|
-
]}>
|
102
|
-
{subitem.text}
|
103
|
-
{subitem.badge !== undefined &&
|
104
|
-
subitem.badge !== null && (
|
105
|
-
<span class="cosy:badge cosy:badge-xs cosy:ml-2">
|
106
|
-
{subitem.badge}
|
107
|
-
</span>
|
108
|
-
)}
|
109
|
-
</a>
|
110
|
-
{subitem.items && (
|
111
|
-
<ul class:list={[debugClass]}>
|
112
|
-
{subitem.items.map((subsubitem: ISidebarItem) => {
|
113
|
-
const isSubSubActive = isPathMatch(
|
114
|
-
currentPath,
|
115
|
-
subsubitem.href
|
116
|
-
);
|
117
|
-
return (
|
118
|
-
<li class:list={[debugClass]}>
|
119
|
-
<a
|
120
|
-
data-sidebar-item
|
121
|
-
data-current-path={currentPath}
|
122
|
-
href={subsubitem.href}
|
123
|
-
class:list={[
|
124
|
-
'cosy:hover:bg-base-300',
|
125
|
-
{ 'cosy:menu-active': isSubSubActive },
|
126
|
-
debugClass,
|
127
|
-
]}>
|
128
|
-
{subsubitem.text}
|
129
|
-
{subsubitem.badge !== undefined &&
|
130
|
-
subsubitem.badge !== null && (
|
131
|
-
<span class="cosy:badge cosy:badge-xs cosy:ml-2">
|
132
|
-
{subsubitem.badge}
|
133
|
-
</span>
|
134
|
-
)}
|
135
|
-
</a>
|
136
|
-
</li>
|
137
|
-
);
|
138
|
-
})}
|
139
|
-
</ul>
|
140
|
-
)}
|
141
|
-
</li>
|
142
|
-
);
|
143
|
-
})}
|
144
|
-
</ul>
|
145
|
-
)}
|
146
|
-
</li>
|
147
|
-
);
|
148
|
-
})}
|
64
|
+
{section.items?.map((item: ISidebarItem) => (
|
65
|
+
<NavItem
|
66
|
+
item={item}
|
67
|
+
currentPath={currentPath}
|
68
|
+
level={0}
|
69
|
+
debug={debug}
|
70
|
+
/>
|
71
|
+
))}
|
149
72
|
</ul>
|
150
73
|
</div>
|
151
74
|
))
|
@@ -0,0 +1,64 @@
|
|
1
|
+
/**
|
2
|
+
* 侧边栏工具函数
|
3
|
+
*/
|
4
|
+
|
5
|
+
const MARGIN_CLASSES = {
|
6
|
+
none: 'cosy:mt-0',
|
7
|
+
xs: 'cosy:mt-1',
|
8
|
+
sm: 'cosy:mt-2',
|
9
|
+
md: 'cosy:mt-4',
|
10
|
+
lg: 'cosy:mt-6',
|
11
|
+
xl: 'cosy:mt-8',
|
12
|
+
'2xl': 'cosy:mt-10',
|
13
|
+
'3xl': 'cosy:mt-12',
|
14
|
+
'4xl': 'cosy:mt-16',
|
15
|
+
'5xl': 'cosy:mt-20',
|
16
|
+
} as const;
|
17
|
+
|
18
|
+
const MARGIN_BOTTOM_CLASSES = {
|
19
|
+
none: 'cosy:mb-0',
|
20
|
+
xs: 'cosy:mb-1',
|
21
|
+
sm: 'cosy:mb-2',
|
22
|
+
md: 'cosy:mb-4',
|
23
|
+
lg: 'cosy:mb-6',
|
24
|
+
xl: 'cosy:mb-8',
|
25
|
+
'2xl': 'cosy:mb-10',
|
26
|
+
'3xl': 'cosy:mb-12',
|
27
|
+
'4xl': 'cosy:mb-16',
|
28
|
+
'5xl': 'cosy:mb-20',
|
29
|
+
} as const;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* 获取顶部外边距类名
|
33
|
+
*/
|
34
|
+
export function getMarginTopClass(marginTop: string): string {
|
35
|
+
return MARGIN_CLASSES[marginTop as keyof typeof MARGIN_CLASSES] || '';
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* 获取底部外边距类名
|
40
|
+
*/
|
41
|
+
export function getMarginBottomClass(marginBottom: string): string {
|
42
|
+
return MARGIN_BOTTOM_CLASSES[marginBottom as keyof typeof MARGIN_BOTTOM_CLASSES] || '';
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* 保存滚动位置到 localStorage
|
47
|
+
*/
|
48
|
+
export function saveScrollPosition(container: Element, key: string): void {
|
49
|
+
if (container) {
|
50
|
+
localStorage.setItem(key, container.scrollTop.toString());
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* 从 localStorage 恢复滚动位置
|
56
|
+
*/
|
57
|
+
export function restoreScrollPosition(container: Element, key: string): void {
|
58
|
+
if (container) {
|
59
|
+
const savedPosition = localStorage.getItem(key);
|
60
|
+
if (savedPosition) {
|
61
|
+
container.scrollTop = parseInt(savedPosition, 10);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
@@ -52,7 +52,9 @@ const themes = [
|
|
52
52
|
---
|
53
53
|
|
54
54
|
<!-- 主题切换按钮 -->
|
55
|
-
<div
|
55
|
+
<div
|
56
|
+
transition:persist
|
57
|
+
class:list={['cosy:dropdown-end cosy:dropdown', className]}>
|
56
58
|
<div tabindex="0" role="button" class:list={['cosy:btn cosy:btn-ghost']}>
|
57
59
|
<SunCloudyIcon size="16px" class="cosy:w-4 cosy:h-4" />
|
58
60
|
</div>
|
@@ -66,10 +66,4 @@ export interface IMetaProps {
|
|
66
66
|
* @default 'default'
|
67
67
|
*/
|
68
68
|
background?: 'default' | 'white' | 'gray' | 'dark' | 'gradient-blue' | 'gradient-pink' | 'gradient-green';
|
69
|
-
|
70
|
-
/**
|
71
|
-
* 加载延迟时间(毫秒),默认1000ms
|
72
|
-
* @default 1000
|
73
|
-
*/
|
74
|
-
loadingDelay?: number;
|
75
69
|
}
|
package/package.json
CHANGED
@@ -1,17 +0,0 @@
|
|
1
|
-
---
|
2
|
-
import BaseLayout from './BaseLayout.astro';
|
3
|
-
---
|
4
|
-
|
5
|
-
<BaseLayout
|
6
|
-
title="基本布局示例"
|
7
|
-
description="这是一个基本布局的示例页面"
|
8
|
-
keywords="布局,示例,基本布局"
|
9
|
-
author="CofficLab"
|
10
|
-
robots="noindex,nofollow"
|
11
|
-
>
|
12
|
-
<main class="cosy:p-4">
|
13
|
-
<h1 class="cosy:text-2xl cosy:font-bold cosy:mb-4">欢迎使用基本布局</h1>
|
14
|
-
<p class="cosy:mb-2">这是一个简单的页面内容示例。</p>
|
15
|
-
<p>基本布局提供了完整的 HTML 结构和元数据设置。</p>
|
16
|
-
</main>
|
17
|
-
</BaseLayout>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
export interface LoadingOverlayProps {
|
2
|
-
/** 加载文本 */
|
3
|
-
text?: string;
|
4
|
-
/** 自定义 CSS 类名 */
|
5
|
-
class?: string;
|
6
|
-
/** 是否显示加载动画 */
|
7
|
-
showSpinner?: boolean;
|
8
|
-
/** 加载动画类型 */
|
9
|
-
spinnerType?: 'dots' | 'spinner' | 'pulse';
|
10
|
-
/** 延迟显示时间(毫秒),默认1000ms */
|
11
|
-
delay?: number;
|
12
|
-
}
|