@coffic/cosy-ui 0.4.3 → 0.4.5

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.
@@ -69,8 +69,6 @@
69
69
  import Link from '../base/Link.astro';
70
70
  import Image from '../base/Image.astro';
71
71
  import SocialIcon from '../icons/SocialIcon.astro';
72
-
73
- // 导入样式
74
72
  import '../../app.css';
75
73
 
76
74
  // 自定义图片元数据接口,替代 astro 的 ImageMetadata
@@ -64,8 +64,6 @@
64
64
 
65
65
  import ProductCard from './ProductCard.astro';
66
66
  import '../../app.css';
67
-
68
- // 导入ProductCard的类型定义
69
67
  import type { Props as ProductCardProps } from './ProductCard.astro';
70
68
 
71
69
  // 定义产品项类型
@@ -43,8 +43,6 @@
43
43
  import Link from '../base/Link.astro';
44
44
  import SocialIcon from '../icons/SocialIcon.astro';
45
45
  import Image from '../base/Image.astro';
46
-
47
- // 导入样式
48
46
  import '../../app.css';
49
47
 
50
48
  interface SocialLink {
@@ -30,8 +30,6 @@
30
30
  */
31
31
 
32
32
  import TeamMember from './TeamMember.astro';
33
-
34
- // 导入样式
35
33
  import '../../app.css';
36
34
 
37
35
  // 自定义图片元数据接口
@@ -40,7 +40,6 @@
40
40
  * - 动画遵循 prefers-reduced-motion 媒体查询,尊重用户的动画偏好设置
41
41
  */
42
42
 
43
- // 导入样式
44
43
  import '../../app.css';
45
44
 
46
45
  interface Props {
@@ -68,7 +68,6 @@
68
68
  * - 动画遵循 prefers-reduced-motion 媒体查询,尊重用户的动画偏好设置
69
69
  */
70
70
 
71
- // 导入样式
72
71
  import '../../app.css';
73
72
 
74
73
  interface Props {
@@ -47,7 +47,6 @@
47
47
  * - 代码使用等宽字体,确保对齐和可读性
48
48
  */
49
49
 
50
- // 导入样式
51
50
  import '../../app.css';
52
51
 
53
52
  interface Props {
@@ -27,7 +27,6 @@
27
27
  * @slot default - 组件的实际渲染内容
28
28
  */
29
29
 
30
- // 导入图标
31
30
  import { ClipboardIcon, CheckIcon } from '../../index';
32
31
  import '../../app.css';
33
32
 
@@ -1,18 +1,18 @@
1
1
  ---
2
2
  /**
3
3
  * @component Modal
4
- *
4
+ *
5
5
  * @description
6
6
  * Modal 组件是一个模态对话框,用于在不离开当前页面的情况下显示内容、通知或请求用户输入。
7
7
  * 它会覆盖在页面内容上方,并提供一个聚焦的交互环境。
8
- *
8
+ *
9
9
  * @design
10
10
  * 设计理念:
11
11
  * 1. 聚焦交互 - 通过遮罩层和动画效果引导用户注意力
12
12
  * 2. 灵活布局 - 支持标题、内容和操作按钮的灵活组合
13
13
  * 3. 可访问性 - 支持键盘导航和屏幕阅读器
14
14
  * 4. 响应式设计 - 在不同屏幕尺寸下保持良好的用户体验
15
- *
15
+ *
16
16
  * @usage
17
17
  * 基本用法:
18
18
  * ```astro
@@ -20,11 +20,11 @@
20
20
  * <p>这是一个模态对话框的内容。</p>
21
21
  * <button slot="actions" data-modal-target="my-modal">关闭</button>
22
22
  * </Modal>
23
- *
23
+ *
24
24
  * <!-- 触发按钮 -->
25
25
  * <button data-modal-target="my-modal">打开模态框</button>
26
26
  * ```
27
- *
27
+ *
28
28
  * 自定义操作按钮:
29
29
  * ```astro
30
30
  * <Modal id="confirm-modal" title="确认操作">
@@ -35,7 +35,7 @@
35
35
  * </div>
36
36
  * </Modal>
37
37
  * ```
38
- *
38
+ *
39
39
  * 不带标题的模态框:
40
40
  * ```astro
41
41
  * <Modal id="image-modal">
@@ -44,79 +44,77 @@
44
44
  * ```
45
45
  */
46
46
 
47
- // 导入样式
48
47
  import '../../app.css';
49
48
  import Button from '../base/Button.astro';
50
49
 
51
50
  interface Props {
52
- /**
53
- * Modal 的唯一标识符
54
- */
55
- id: string;
56
- /**
57
- * 模态框的标题
58
- */
59
- title?: string;
60
- /**
61
- * 是否显示关闭按钮
62
- * @default true
63
- */
64
- showCloseButton?: boolean;
65
- /**
66
- * 自定义类名
67
- */
68
- class?: string;
51
+ /**
52
+ * Modal 的唯一标识符
53
+ */
54
+ id: string;
55
+ /**
56
+ * 模态框的标题
57
+ */
58
+ title?: string;
59
+ /**
60
+ * 是否显示关闭按钮
61
+ * @default true
62
+ */
63
+ showCloseButton?: boolean;
64
+ /**
65
+ * 自定义类名
66
+ */
67
+ class?: string;
69
68
  }
70
69
 
71
- const {
72
- id,
73
- title,
74
- showCloseButton = true,
75
- class: className = '',
76
- } = Astro.props;
70
+ const { id, title, showCloseButton = true, class: className = '' } = Astro.props;
77
71
  ---
78
72
 
79
73
  <dialog id={id} class="cosy:modal">
80
- <div class:list={["cosy:modal-box", className]}>
81
- {showCloseButton && (
82
- <form method="dialog">
83
- <Button
84
- variant="ghost"
85
- size="sm"
86
- shape="circle"
87
- formmethod="dialog"
88
- class="cosy:modal-close-button"
89
- >✕</Button>
90
- </form>
91
- )}
92
-
93
- {title && <h3 class="cosy:modal-title">{title}</h3>}
94
-
95
- <div class="cosy:modal-content">
96
- <slot />
97
- </div>
74
+ <div class:list={['cosy:modal-box', className]}>
75
+ {
76
+ showCloseButton && (
77
+ <form method="dialog">
78
+ <Button
79
+ variant="ghost"
80
+ size="sm"
81
+ shape="circle"
82
+ formmethod="dialog"
83
+ class="cosy:modal-close-button">
84
+
85
+ </Button>
86
+ </form>
87
+ )
88
+ }
98
89
 
99
- <div class="cosy:modal-action">
100
- <slot name="actions" />
101
- </div>
102
- </div>
90
+ {title && <h3 class="cosy:modal-title">{title}</h3>}
103
91
 
104
- <form method="dialog" class="cosy:modal-backdrop">
105
- <button>关闭</button>
106
- </form>
92
+ <div class="cosy:modal-content">
93
+ <slot />
94
+ </div>
95
+
96
+ <div class="cosy:modal-action">
97
+ <slot name="actions" />
98
+ </div>
99
+ </div>
100
+
101
+ <form method="dialog" class="cosy:modal-backdrop">
102
+ <button>关闭</button>
103
+ </form>
107
104
  </dialog>
108
105
 
109
106
  <script define:vars={{ id }}>
110
- // 为了方便使用,我们提供一些辅助方法
111
- document.addEventListener('DOMContentLoaded', () => {
112
- const modal = document.getElementById(id);
113
- if (!modal) return;
107
+ // 为了方便使用,我们提供一些辅助方法
108
+ document.addEventListener('DOMContentLoaded', () => {
109
+ const modal = document.getElementById(id);
110
+ if (!modal) return;
111
+
112
+ // 为所有触发这个模态框的按钮添加点击事件
113
+ document.querySelectorAll(`[data-modal-target="${id}"]`).forEach((trigger) => {
114
+ trigger.addEventListener('click', () => {
115
+ modal.showModal();
116
+ });
117
+ });
118
+ });
119
+ </script>
114
120
 
115
- // 为所有触发这个模态框的按钮添加点击事件
116
- document.querySelectorAll(`[data-modal-target="${id}"]`).forEach(trigger => {
117
- trigger.addEventListener('click', () => {
118
- modal.showModal();
119
- });
120
- });
121
- });
122
- </script>
@@ -172,7 +172,8 @@ import Main from '../containers/Main.astro';
172
172
  import Header from './Header.astro';
173
173
  import Sidebar from './Sidebar.astro';
174
174
  import { ClientRouter } from 'astro:transitions';
175
- import type { AppLayoutProps } from '@/types/layout';
175
+ import type { AppLayoutProps } from '../../index';
176
+ import Container from '../containers/Container.astro';
176
177
 
177
178
  interface Props extends AppLayoutProps {}
178
179
 
@@ -199,10 +200,7 @@ const {
199
200
  author={metaConfig.author}
200
201
  robots={metaConfig.robots}
201
202
  head={metaConfig.head}
202
- class:list={[
203
- 'cosy:min-h-screen cosy:flex cosy:flex-col',
204
- { 'cosy:border cosy:border-base-300': debug },
205
- ]}
203
+ debug={debug}
206
204
  {...rest}>
207
205
  {
208
206
  showHeader && (
@@ -222,7 +220,7 @@ const {
222
220
  )
223
221
  }
224
222
 
225
- <div class="cosy:flex cosy:flex-row cosy:flex-1 cosy:pb-0 cosy:min-h-screen">
223
+ <Container flex="row" gap="md" size="full" padding="none">
226
224
  <!-- 侧边栏容器 -->
227
225
  {showSidebar && <Sidebar {...sidebarConfig} />}
228
226
 
@@ -231,10 +229,16 @@ const {
231
229
  <slot />
232
230
  <ClientRouter />
233
231
  </Main>
234
- </div>
232
+ </Container>
235
233
 
236
234
  <!-- Footer -->
237
- {showFooter && <Footer {...footerConfig} />}
235
+ {
236
+ showFooter && (
237
+ <Container size="full" padding="none">
238
+ <Footer {...footerConfig} />
239
+ </Container>
240
+ )
241
+ }
238
242
 
239
243
  <script>
240
244
  // Handle sidebar toggle
@@ -1,25 +1,25 @@
1
1
  ---
2
2
  /**
3
3
  * @component BaseLayout
4
- *
4
+ *
5
5
  * @description
6
6
  * BaseLayout 组件是最基础的 HTML 结构布局,提供完整的 HTML 骨架和元数据设置。
7
7
  * 它是所有页面布局的基础,处理了基本的 HTML 结构、元数据和全局样式。
8
- *
8
+ *
9
9
  * @design
10
10
  * 设计理念:
11
11
  * 1. 基础结构 - 提供标准的 HTML5 文档结构
12
12
  * 2. 元数据管理 - 集中管理页面的标题、描述和关键词等元数据
13
13
  * 3. 全局样式 - 应用基础的重置样式和全局变量
14
14
  * 4. 灵活扩展 - 支持自定义头部内容和样式
15
- *
15
+ *
16
16
  * @usage
17
17
  * 基本用法:
18
18
  * ```astro
19
19
  * ---
20
20
  * import { BaseLayout } from '@coffic/cosy-ui';
21
21
  * ---
22
- *
22
+ *
23
23
  * <BaseLayout title="页面标题" description="页面描述">
24
24
  * <main>
25
25
  * <h1>页面内容</h1>
@@ -27,21 +27,21 @@
27
27
  * </main>
28
28
  * </BaseLayout>
29
29
  * ```
30
- *
30
+ *
31
31
  * 添加自定义头部内容:
32
32
  * ```astro
33
- * <BaseLayout
34
- * title="页面标题"
33
+ * <BaseLayout
34
+ * title="页面标题"
35
35
  * head={`<link rel="canonical" href="https://example.com" />`}
36
36
  * >
37
37
  * <p>页面内容</p>
38
38
  * </BaseLayout>
39
39
  * ```
40
- *
40
+ *
41
41
  * 自定义样式:
42
42
  * ```astro
43
- * <BaseLayout
44
- * title="页面标题"
43
+ * <BaseLayout
44
+ * title="页面标题"
45
45
  * customStyles={`body { background-color: #f5f5f5; }`}
46
46
  * >
47
47
  * <p>页面内容</p>
@@ -50,46 +50,49 @@
50
50
  */
51
51
 
52
52
  import '../../app.css';
53
- import type { MetaProps } from '@/types/meta';
53
+ import type { MetaProps } from '../../index';
54
54
 
55
- export interface Props extends MetaProps {}
55
+ export interface Props extends MetaProps {
56
+ debug?: boolean;
57
+ }
56
58
 
57
59
  const {
58
- title,
59
- description = "",
60
- keywords = "",
61
- lang = "zh-CN",
62
- viewport = true,
63
- customStyles = "",
64
- head,
65
- class: className,
66
- 'class:list': classList,
60
+ title,
61
+ description = '',
62
+ keywords = '',
63
+ lang = 'zh-CN',
64
+ viewport = true,
65
+ customStyles = '',
66
+ head,
67
+ debug = true,
68
+ class: className,
69
+ 'class:list': classList,
67
70
  } = Astro.props;
68
71
 
69
72
  // 处理类名
70
- let bodyClasses = className || "";
73
+ let bodyClasses = debug ? 'cosy:border cosy:border-red-500' : className || '';
71
74
  ---
72
75
 
73
- <!DOCTYPE html>
76
+ <!doctype html>
74
77
  <html lang={lang}>
75
- <head>
76
- <meta charset="UTF-8" />
77
- {viewport && <meta name="viewport" content="width=device-width, initial-scale=1.0" />}
78
- <title>{title}</title>
79
- {description && <meta name="description" content={description} />}
80
- {keywords && <meta name="keywords" content={keywords} />}
81
- <meta name="generator" content={Astro.generator} />
82
- <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
83
-
84
- <!-- 自定义样式 -->
85
- {customStyles && <style set:html={customStyles}></style>}
86
-
87
- <!-- 自定义头部内容 -->
88
- {head && <div set:html={head} />}
89
-
90
- <slot name="head" />
91
- </head>
92
- <body class:list={[bodyClasses, classList]}>
93
- <slot />
94
- </body>
95
- </html>
78
+ <head>
79
+ <meta charset="UTF-8" />
80
+ {viewport && <meta name="viewport" content="width=device-width, initial-scale=1.0" />}
81
+ <title>{title}</title>
82
+ {description && <meta name="description" content={description} />}
83
+ {keywords && <meta name="keywords" content={keywords} />}
84
+ <meta name="generator" content={Astro.generator} />
85
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
86
+
87
+ <!-- 自定义样式 -->
88
+ {customStyles && <style set:html={customStyles} />}
89
+
90
+ <!-- 自定义头部内容 -->
91
+ {head && <div set:html={head} />}
92
+
93
+ <slot name="head" />
94
+ </head>
95
+ <body class:list={[bodyClasses, classList, 'min-h-screen']}>
96
+ <slot />
97
+ </body>
98
+ </html>