@coffic/cosy-ui 0.3.15 → 0.3.33

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.
@@ -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 "../../app.css"
28
+ import '../../app.css';
30
29
 
31
- export interface SidebarItem {
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
- sidebarItems: SidebarSection[];
47
-
48
- /**
49
- * 当前路径
50
- */
51
- currentPath: string;
33
+ /**
34
+ * 侧边栏项目
35
+ */
36
+ sidebarItems: SidebarSection[];
37
+
38
+ /**
39
+ * 当前路径
40
+ */
41
+ currentPath: string;
52
42
 
53
- /**
54
- * 桌面端类名
55
- */
56
- class?: string;
43
+ /**
44
+ * 桌面端类名
45
+ */
46
+ class?: string;
57
47
 
58
- /**
59
- * 是否开启调试模式,显示边框
60
- * @default false
61
- */
62
- debug?: boolean;
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 ? "cosy:border cosy:border-red-500" : "";
57
+ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
73
58
 
74
59
  // 获取当前活动的一级导航项
75
- const currentSection = sidebarItems.find(section =>
76
- section.items.some(item => isPathMatch(currentPath, item.href))
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 class:list={[
82
- "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",
83
- debugClass
84
- ]}>
85
- <div class="cosy:flex cosy:items-center cosy:gap-2">
86
- <button
87
- type="button"
88
- class="cosy:p-2 cosy:btn cosy:btn-ghost cosy:btn-sm"
89
- data-modal-target="mobile-sidebar"
90
- >
91
- <MenuIcon class="cosy:w-5 cosy:h-5" />
92
- </button>
93
- <span class="cosy:font-medium cosy:text-sm">
94
- {currentSection?.title || "导航"}
95
- </span>
96
- </div>
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
- <div class="cosy:h-[calc(100vh-8rem)] cosy:overflow-y-auto">
102
- <SidebarNav
103
- sidebarItems={sidebarItems}
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, "cosy:hidden cosy:lg:block"]}>
112
- <div class="cosy:top-16 cosy:sticky cosy:h-[calc(100vh-4rem)]">
113
- <SidebarNav
114
- sidebarItems={sidebarItems}
115
- currentPath={currentPath}
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';
@@ -0,0 +1,10 @@
1
+ export interface SidebarItem {
2
+ href: string;
3
+ text: string;
4
+ items?: SidebarItem[];
5
+ }
6
+
7
+ export interface SidebarSection {
8
+ title: string;
9
+ items: SidebarItem[];
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffic/cosy-ui",
3
- "version": "0.3.15",
3
+ "version": "0.3.33",
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
- "dev": "astro dev --host 0.0.0.0",
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": {