@coffic/cosy-ui 0.3.15 → 0.3.35
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/README.md +28 -28
- package/dist/app.css +1 -1
- package/dist/components/base/Alert.astro +45 -140
- package/dist/components/layouts/DocumentationLayout.astro +396 -386
- package/dist/components/layouts/Footer.astro +1 -1
- package/dist/components/layouts/Sidebar.astro +52 -75
- package/dist/index.ts +2 -0
- package/dist/types/layout.ts +10 -0
- package/package.json +2 -5
@@ -220,7 +220,7 @@ const debugClasses = debug ? {
|
|
220
220
|
};
|
221
221
|
---
|
222
222
|
|
223
|
-
<footer class:list={["cosy:footer cosy:sm:footer-horizontal cosy:bg-base-200 cosy:text-base-content cosy:p-10", debugClasses.footer]}>
|
223
|
+
<footer class:list={["cosy:footer cosy:z-50 cosy:sm:footer-horizontal cosy:bg-base-200 cosy:text-base-content cosy:p-10", debugClasses.footer]}>
|
224
224
|
<div class:list={["cosy:flex cosy:flex-col cosy:md:h-56 cosy:gap-8 cosy:container cosy:mx-auto cosy:items-center cosy:w-full cosy:md:flex-row cosy:md:justify-between", debugClasses.section]}>
|
225
225
|
{/* 品牌区域 */}
|
226
226
|
<aside class:list={["cosy:max-w-xs cosy:text-center", debugClasses.aside]}>
|
@@ -1,14 +1,14 @@
|
|
1
1
|
---
|
2
2
|
/**
|
3
3
|
* Sidebar组件
|
4
|
-
*
|
4
|
+
*
|
5
5
|
* 用于文档页面的侧边栏导航
|
6
|
-
*
|
6
|
+
*
|
7
7
|
* @example
|
8
8
|
* ```astro
|
9
9
|
* ---
|
10
10
|
* import Sidebar from './Sidebar.astro';
|
11
|
-
*
|
11
|
+
*
|
12
12
|
* const sidebarItems = [
|
13
13
|
* { title: "入门", items: [
|
14
14
|
* { href: "/docs/getting-started", text: "快速开始" },
|
@@ -16,104 +16,81 @@
|
|
16
16
|
* ]}
|
17
17
|
* ];
|
18
18
|
* ---
|
19
|
-
*
|
19
|
+
*
|
20
20
|
* <Sidebar sidebarItems={sidebarItems} currentPath="/docs/getting-started" />
|
21
21
|
* ```
|
22
22
|
*/
|
23
23
|
|
24
24
|
import { isPathMatch } from '../../utils/path';
|
25
25
|
import Modal from '../display/Modal.astro';
|
26
|
-
import Button from '../base/Button.astro';
|
27
26
|
import SidebarNav from './SidebarNav.astro';
|
28
27
|
import MenuIcon from '../icons/MenuIcon.astro';
|
29
|
-
import
|
28
|
+
import '../../app.css';
|
30
29
|
|
31
|
-
|
32
|
-
href: string;
|
33
|
-
text: string;
|
34
|
-
items?: SidebarItem[];
|
35
|
-
}
|
36
|
-
|
37
|
-
export interface SidebarSection {
|
38
|
-
title: string;
|
39
|
-
items: SidebarItem[];
|
40
|
-
}
|
30
|
+
import type { SidebarSection } from '../../types/layout';
|
41
31
|
|
42
32
|
export interface Props {
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
33
|
+
/**
|
34
|
+
* 侧边栏项目
|
35
|
+
*/
|
36
|
+
sidebarItems: SidebarSection[];
|
37
|
+
|
38
|
+
/**
|
39
|
+
* 当前路径
|
40
|
+
*/
|
41
|
+
currentPath: string;
|
52
42
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
43
|
+
/**
|
44
|
+
* 桌面端类名
|
45
|
+
*/
|
46
|
+
class?: string;
|
57
47
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
48
|
+
/**
|
49
|
+
* 是否开启调试模式,显示边框
|
50
|
+
* @default false
|
51
|
+
*/
|
52
|
+
debug?: boolean;
|
63
53
|
}
|
64
54
|
|
65
|
-
const {
|
66
|
-
sidebarItems,
|
67
|
-
currentPath,
|
68
|
-
class: className,
|
69
|
-
debug = false
|
70
|
-
} = Astro.props;
|
55
|
+
const { sidebarItems, currentPath, class: className, debug = false } = Astro.props;
|
71
56
|
|
72
|
-
const debugClass = debug ?
|
57
|
+
const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
|
73
58
|
|
74
59
|
// 获取当前活动的一级导航项
|
75
|
-
const currentSection = sidebarItems.find(section =>
|
76
|
-
|
60
|
+
const currentSection = sidebarItems.find((section) =>
|
61
|
+
section.items.some((item) => isPathMatch(currentPath, item.href))
|
77
62
|
);
|
78
63
|
---
|
79
64
|
|
80
65
|
{/* 移动端导航栏 */}
|
81
|
-
<div
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
66
|
+
<div
|
67
|
+
class:list={[
|
68
|
+
'cosy:flex cosy:lg:hidden cosy:items-center cosy:justify-between cosy:px-4 cosy:py-2 cosy:border-b cosy:border-base-300 cosy:bg-base-100 cosy:relative cosy:z-10',
|
69
|
+
debugClass,
|
70
|
+
]}>
|
71
|
+
<div class="cosy:flex cosy:items-center cosy:gap-2">
|
72
|
+
<button
|
73
|
+
type="button"
|
74
|
+
class="cosy:p-2 cosy:btn cosy:btn-ghost cosy:btn-sm"
|
75
|
+
data-modal-target="mobile-sidebar">
|
76
|
+
<MenuIcon class="cosy:w-5 cosy:h-5" />
|
77
|
+
</button>
|
78
|
+
<span class="cosy:font-medium cosy:text-sm">
|
79
|
+
{currentSection?.title || '导航'}
|
80
|
+
</span>
|
81
|
+
</div>
|
97
82
|
</div>
|
98
83
|
|
99
84
|
{/* 移动端侧边栏弹出层 */}
|
100
85
|
<Modal id="mobile-sidebar" class="cosy:mx-4 cosy:lg:w-80 cosy:w-[calc(100vw-2rem)] cosy:max-w-full">
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
currentPath={currentPath}
|
105
|
-
debug={debug}
|
106
|
-
/>
|
107
|
-
</div>
|
86
|
+
<div class="cosy:h-[calc(100vh-8rem)] cosy:overflow-y-auto">
|
87
|
+
<SidebarNav sidebarItems={sidebarItems} currentPath={currentPath} debug={debug} />
|
88
|
+
</div>
|
108
89
|
</Modal>
|
109
90
|
|
110
91
|
{/* 桌面端侧边栏 */}
|
111
|
-
<aside class:list={[className, debugClass,
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
debug={debug}
|
117
|
-
/>
|
118
|
-
</div>
|
119
|
-
</aside>
|
92
|
+
<aside class:list={[className, debugClass, 'cosy:hidden cosy:lg:block']}>
|
93
|
+
<div class="cosy:top-16 cosy:sticky cosy:h-[calc(100vh-4rem)]">
|
94
|
+
<SidebarNav sidebarItems={sidebarItems} currentPath={currentPath} debug={debug} />
|
95
|
+
</div>
|
96
|
+
</aside>
|
package/dist/index.ts
CHANGED
@@ -68,3 +68,5 @@ export { default as Container } from './components/containers/Container.astro';
|
|
68
68
|
export { default as Main } from './components/containers/Main.astro';
|
69
69
|
export { default as Section } from './components/containers/Section.astro';
|
70
70
|
|
71
|
+
// Types
|
72
|
+
export type { SidebarSection } from './types/layout';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@coffic/cosy-ui",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.35",
|
4
4
|
"description": "An astro component library",
|
5
5
|
"author": {
|
6
6
|
"name": "nookery",
|
@@ -31,10 +31,7 @@
|
|
31
31
|
"index.ts"
|
32
32
|
],
|
33
33
|
"scripts": {
|
34
|
-
"
|
35
|
-
"build": "pnpm build:ui && pnpm build:docs",
|
36
|
-
"build:ui": "vite build && tsx scripts/post-build.ts",
|
37
|
-
"build:docs": "astro build"
|
34
|
+
"build": "vite build && tsx scripts/post-build.ts"
|
38
35
|
},
|
39
36
|
"type": "module",
|
40
37
|
"peerDependencies": {
|