@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.
- package/dist/app.css +1 -1
- package/dist/components/base/Alert.astro +3 -3
- package/dist/components/containers/Container.astro +78 -2
- package/dist/components/containers/Main.astro +1 -1
- package/dist/components/data-display/Blog.astro +1 -0
- package/dist/components/data-display/ProductCard.astro +0 -2
- package/dist/components/data-display/Products.astro +0 -2
- package/dist/components/data-display/TeamMember.astro +0 -2
- package/dist/components/data-display/TeamMembers.astro +0 -2
- package/dist/components/display/Banner.astro +0 -1
- package/dist/components/display/Card.astro +0 -1
- package/dist/components/display/CodeBlock.astro +0 -1
- package/dist/components/display/CodeExample.astro +0 -1
- package/dist/components/display/Modal.astro +65 -67
- package/dist/components/layouts/AppLayout.astro +12 -8
- package/dist/components/layouts/BaseLayout.astro +47 -44
- package/dist/components/layouts/DashboardLayout.astro +615 -604
- package/dist/components/layouts/Header.astro +3 -2
- package/dist/components/layouts/Sidebar.astro +0 -1
- package/dist/components/typography/Article.astro +1 -1
- package/dist/index.ts +6 -3
- package/dist/types/header.ts +1 -1
- package/package.json +1 -1
- package/dist/components/layouts/DefaultLayout.astro +0 -170
- package/dist/components/layouts/LandingLayout.astro +0 -388
@@ -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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
-
|
100
|
-
<slot name="actions" />
|
101
|
-
</div>
|
102
|
-
</div>
|
90
|
+
{title && <h3 class="cosy:modal-title">{title}</h3>}
|
103
91
|
|
104
|
-
|
105
|
-
|
106
|
-
|
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
|
-
|
113
|
-
|
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 '
|
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
|
-
|
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
|
-
<
|
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
|
-
</
|
232
|
+
</Container>
|
235
233
|
|
236
234
|
<!-- Footer -->
|
237
|
-
{
|
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 '
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
<!
|
76
|
+
<!doctype html>
|
74
77
|
<html lang={lang}>
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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>
|