@coffic/cosy-ui 0.1.29 → 0.2.2
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 +43 -22
- package/dist/app.css +1 -0
- package/dist/assets/logo-rounded.png +0 -0
- package/dist/assets/logo.png +0 -0
- package/dist/components/base/Alert.astro +186 -0
- package/dist/components/base/Button.astro +103 -0
- package/dist/components/base/Image.astro +291 -0
- package/dist/components/base/Link.astro +131 -0
- package/dist/components/containers/Container.astro +103 -0
- package/dist/components/containers/Main.astro +167 -0
- package/dist/components/containers/Section.astro +145 -0
- package/dist/components/containers/index.ts +3 -0
- package/dist/components/data-display/Blog.astro +195 -0
- package/dist/components/data-display/TeamMember.astro +135 -0
- package/dist/components/data-display/TeamMembers.astro +101 -0
- package/dist/components/display/Banner.astro +57 -0
- package/dist/components/display/Card.astro +135 -0
- package/dist/components/display/CodeBlock.astro +147 -0
- package/dist/components/display/CodeExample.astro +330 -0
- package/dist/components/display/Hero.astro +119 -0
- package/dist/components/display/Modal.astro +115 -0
- package/dist/components/icons/AlertTriangle.astro +35 -0
- package/dist/components/icons/CalendarIcon.astro +38 -0
- package/dist/components/icons/CheckCircle.astro +36 -0
- package/dist/components/icons/CheckIcon.astro +38 -0
- package/dist/components/icons/ClipboardIcon.astro +39 -0
- package/dist/components/icons/CloseIcon.astro +38 -0
- package/dist/components/icons/ErrorIcon.astro +35 -0
- package/dist/components/icons/GithubIcon.astro +31 -0
- package/dist/components/icons/InfoCircle.astro +37 -0
- package/dist/components/icons/InfoIcon.astro +38 -0
- package/dist/components/icons/LinkIcon.astro +39 -0
- package/dist/components/icons/LinkedinIcon.astro +31 -0
- package/dist/components/icons/MenuIcon.astro +41 -0
- package/dist/components/icons/SearchIcon.astro +40 -0
- package/dist/components/icons/SocialIcon.astro +100 -0
- package/dist/components/icons/SuccessIcon.astro +35 -0
- package/dist/components/icons/SunCloudyIcon.astro +45 -0
- package/dist/components/icons/TwitterIcon.astro +31 -0
- package/dist/components/icons/UserIcon.astro +35 -0
- package/dist/components/icons/WarningIcon.astro +38 -0
- package/dist/components/icons/XCircle.astro +37 -0
- package/dist/components/layouts/BaseLayout.astro +144 -0
- package/dist/components/layouts/DashboardLayout.astro +660 -0
- package/dist/components/layouts/DefaultLayout.astro +170 -0
- package/dist/components/layouts/DocumentationLayout.astro +469 -0
- package/dist/components/layouts/Flex.astro +138 -0
- package/dist/components/layouts/Footer.astro +284 -0
- package/dist/components/layouts/Grid.astro +182 -0
- package/dist/components/layouts/Header.astro +114 -0
- package/dist/components/layouts/LandingLayout.astro +388 -0
- package/dist/components/layouts/Stack.astro +149 -0
- package/dist/components/navigation/LanguageSwitcher.astro +81 -0
- package/dist/components/navigation/TableOfContents.astro +352 -0
- package/dist/components/navigation/ThemeSwitcher.astro +89 -0
- package/dist/components/typography/Article.astro +144 -0
- package/dist/components/typography/Heading.astro +205 -0
- package/dist/components/typography/Text.astro +187 -0
- package/dist/index.ts +70 -0
- package/dist/integration.ts +14 -0
- package/dist/style.ts +1 -0
- package/{src → dist}/types/footer.ts +1 -0
- package/dist/utils/theme.ts +55 -0
- package/package.json +67 -59
- package/index.ts +0 -18
- package/src/components/Alert.astro +0 -78
- package/src/components/Article.astro +0 -11
- package/src/components/Banner.astro +0 -49
- package/src/components/Blog.astro +0 -115
- package/src/components/Button.astro +0 -49
- package/src/components/Card.astro +0 -113
- package/src/components/CodeBlock.astro +0 -186
- package/src/components/Footer.astro +0 -148
- package/src/components/Header.astro +0 -305
- package/src/components/Hero.astro +0 -69
- package/src/components/Image.astro +0 -251
- package/src/components/Link.astro +0 -82
- package/src/components/Modal.astro +0 -67
- package/src/components/SocialIcon.astro +0 -36
- package/src/components/TeamMember.astro +0 -68
- package/src/components/TeamMembers.astro +0 -43
- package/src/env.d.ts +0 -0
- /package/{src/components → dist/components/base}/ThemeItem.astro +0 -0
- /package/{src → dist}/utils/social.ts +0 -0
@@ -0,0 +1,205 @@
|
|
1
|
+
---
|
2
|
+
/**
|
3
|
+
* @component Heading
|
4
|
+
*
|
5
|
+
* @description
|
6
|
+
* Heading 组件用于创建各级标题,提供一致的排版样式和灵活的定制选项。
|
7
|
+
*
|
8
|
+
* @design
|
9
|
+
* 设计理念:
|
10
|
+
* 1. 层次清晰 - 通过不同级别的标题建立内容的视觉层次结构
|
11
|
+
* 2. 一致性 - 确保整个应用中标题样式的一致性
|
12
|
+
* 3. 可定制性 - 支持多种配置选项,适应不同场景需求
|
13
|
+
* 4. 无障碍性 - 遵循语义化HTML标准,确保屏幕阅读器可以正确解析内容结构
|
14
|
+
*
|
15
|
+
* 视觉特点:
|
16
|
+
* - 字体大小和粗细随级别变化
|
17
|
+
* - 可选的下划线或底部边框
|
18
|
+
* - 可定制的颜色和间距
|
19
|
+
* - 响应式设计,在不同屏幕尺寸下保持良好的可读性
|
20
|
+
*
|
21
|
+
* @usage
|
22
|
+
* 基本用法:
|
23
|
+
* ```astro
|
24
|
+
* <Heading level={1}>这是一个一级标题</Heading>
|
25
|
+
* <Heading level={2}>这是一个二级标题</Heading>
|
26
|
+
* <Heading level={3}>这是一个三级标题</Heading>
|
27
|
+
* ```
|
28
|
+
*
|
29
|
+
* 自定义样式:
|
30
|
+
* ```astro
|
31
|
+
* <Heading level={2} color="primary" underline>带下划线的二级标题</Heading>
|
32
|
+
* ```
|
33
|
+
*
|
34
|
+
* 带锚点链接:
|
35
|
+
* ```astro
|
36
|
+
* <Heading level={2} id="section-1" anchor>带锚点的标题</Heading>
|
37
|
+
* ```
|
38
|
+
*
|
39
|
+
* 自定义间距:
|
40
|
+
* ```astro
|
41
|
+
* <Heading level={1} class="mb-8">自定义底部间距的标题</Heading>
|
42
|
+
* ```
|
43
|
+
*
|
44
|
+
* @props
|
45
|
+
* @prop {1|2|3|4|5|6} [level=2] - 标题级别,对应 h1-h6 标签
|
46
|
+
* @prop {string} [id] - 标题的 ID,用于锚点链接
|
47
|
+
* @prop {boolean} [anchor=false] - 是否显示锚点链接图标
|
48
|
+
* @prop {boolean} [underline=false] - 是否显示下划线
|
49
|
+
* @prop {string} [align='left'] - 文本对齐方式:'left', 'center', 'right'
|
50
|
+
* @prop {'default'|'primary'|'secondary'|'accent'|'muted'} [color='default'] - 标题颜色
|
51
|
+
* @prop {string} [class] - 自定义 CSS 类名
|
52
|
+
*
|
53
|
+
* @slots
|
54
|
+
* @slot default - 标题内容
|
55
|
+
*
|
56
|
+
* @accessibility
|
57
|
+
* - 使用语义化的 h1-h6 标签
|
58
|
+
* - 锚点链接带有描述性 aria-label
|
59
|
+
* - 遵循标题层次结构的最佳实践
|
60
|
+
*
|
61
|
+
* @dependencies
|
62
|
+
* 依赖于以下图标组件:
|
63
|
+
* - LinkIcon (用于锚点链接)
|
64
|
+
*/
|
65
|
+
|
66
|
+
import LinkIcon from '../icons/LinkIcon.astro';
|
67
|
+
|
68
|
+
interface Props {
|
69
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
70
|
+
id?: string;
|
71
|
+
anchor?: boolean;
|
72
|
+
underline?: boolean;
|
73
|
+
align?: 'left' | 'center' | 'right';
|
74
|
+
color?: 'default' | 'primary' | 'secondary' | 'accent' | 'muted';
|
75
|
+
class?: string;
|
76
|
+
}
|
77
|
+
|
78
|
+
const {
|
79
|
+
level = 2,
|
80
|
+
id,
|
81
|
+
anchor = false,
|
82
|
+
underline = false,
|
83
|
+
align = 'left',
|
84
|
+
color = 'default',
|
85
|
+
class: className = '',
|
86
|
+
} = Astro.props;
|
87
|
+
|
88
|
+
// 根据级别和颜色设置样式
|
89
|
+
const headingClass = {
|
90
|
+
1: 'text-4xl font-bold',
|
91
|
+
2: 'text-3xl font-semibold',
|
92
|
+
3: 'text-2xl font-semibold',
|
93
|
+
4: 'text-xl font-medium',
|
94
|
+
5: 'text-lg font-medium',
|
95
|
+
6: 'text-base font-medium',
|
96
|
+
}[(level ?? 2) as 1|2|3|4|5|6];
|
97
|
+
|
98
|
+
const colorClass = {
|
99
|
+
default: 'text-gray-900 dark:text-gray-100',
|
100
|
+
primary: 'text-primary-600 dark:text-primary-400',
|
101
|
+
secondary: 'text-secondary-600 dark:text-secondary-400',
|
102
|
+
accent: 'text-accent-600 dark:text-accent-400',
|
103
|
+
muted: 'text-gray-600 dark:text-gray-400',
|
104
|
+
}[(color ?? 'default') as 'default'|'primary'|'secondary'|'accent'|'muted'];
|
105
|
+
|
106
|
+
const alignClass = {
|
107
|
+
left: 'text-left',
|
108
|
+
center: 'text-center',
|
109
|
+
right: 'text-right',
|
110
|
+
}[(align ?? 'left') as 'left'|'center'|'right'];
|
111
|
+
|
112
|
+
const underlineClass = underline ? 'border-b pb-2 border-gray-200 dark:border-gray-700' : '';
|
113
|
+
|
114
|
+
// 组合所有类名
|
115
|
+
const combinedClass = `heading ${headingClass} ${colorClass} ${alignClass} ${underlineClass} ${className}`;
|
116
|
+
---
|
117
|
+
|
118
|
+
{level === 1 && (
|
119
|
+
<h1 id={id} class={combinedClass}>
|
120
|
+
<slot />
|
121
|
+
{anchor && id && (
|
122
|
+
<a href={`#${id}`} class="heading-anchor ml-2 opacity-0 hover:opacity-100 transition-opacity" aria-label={`链接到 ${id} 部分`}>
|
123
|
+
<LinkIcon class="w-4 h-4 inline-block" />
|
124
|
+
</a>
|
125
|
+
)}
|
126
|
+
</h1>
|
127
|
+
)}
|
128
|
+
|
129
|
+
{level === 2 && (
|
130
|
+
<h2 id={id} class={combinedClass}>
|
131
|
+
<slot />
|
132
|
+
{anchor && id && (
|
133
|
+
<a href={`#${id}`} class="heading-anchor ml-2 opacity-0 hover:opacity-100 transition-opacity" aria-label={`链接到 ${id} 部分`}>
|
134
|
+
<LinkIcon class="w-4 h-4 inline-block" />
|
135
|
+
</a>
|
136
|
+
)}
|
137
|
+
</h2>
|
138
|
+
)}
|
139
|
+
|
140
|
+
{level === 3 && (
|
141
|
+
<h3 id={id} class={combinedClass}>
|
142
|
+
<slot />
|
143
|
+
{anchor && id && (
|
144
|
+
<a href={`#${id}`} class="heading-anchor ml-2 opacity-0 hover:opacity-100 transition-opacity" aria-label={`链接到 ${id} 部分`}>
|
145
|
+
<LinkIcon class="w-4 h-4 inline-block" />
|
146
|
+
</a>
|
147
|
+
)}
|
148
|
+
</h3>
|
149
|
+
)}
|
150
|
+
|
151
|
+
{level === 4 && (
|
152
|
+
<h4 id={id} class={combinedClass}>
|
153
|
+
<slot />
|
154
|
+
{anchor && id && (
|
155
|
+
<a href={`#${id}`} class="heading-anchor ml-2 opacity-0 hover:opacity-100 transition-opacity" aria-label={`链接到 ${id} 部分`}>
|
156
|
+
<LinkIcon class="w-4 h-4 inline-block" />
|
157
|
+
</a>
|
158
|
+
)}
|
159
|
+
</h4>
|
160
|
+
)}
|
161
|
+
|
162
|
+
{level === 5 && (
|
163
|
+
<h5 id={id} class={combinedClass}>
|
164
|
+
<slot />
|
165
|
+
{anchor && id && (
|
166
|
+
<a href={`#${id}`} class="heading-anchor ml-2 opacity-0 hover:opacity-100 transition-opacity" aria-label={`链接到 ${id} 部分`}>
|
167
|
+
<LinkIcon class="w-4 h-4 inline-block" />
|
168
|
+
</a>
|
169
|
+
)}
|
170
|
+
</h5>
|
171
|
+
)}
|
172
|
+
|
173
|
+
{level === 6 && (
|
174
|
+
<h6 id={id} class={combinedClass}>
|
175
|
+
<slot />
|
176
|
+
{anchor && id && (
|
177
|
+
<a href={`#${id}`} class="heading-anchor ml-2 opacity-0 hover:opacity-100 transition-opacity" aria-label={`链接到 ${id} 部分`}>
|
178
|
+
<LinkIcon class="w-4 h-4 inline-block" />
|
179
|
+
</a>
|
180
|
+
)}
|
181
|
+
</h6>
|
182
|
+
)}
|
183
|
+
|
184
|
+
<style>
|
185
|
+
.heading {
|
186
|
+
margin-bottom: 0.5em;
|
187
|
+
line-height: 1.2;
|
188
|
+
scroll-margin-top: 100px;
|
189
|
+
}
|
190
|
+
|
191
|
+
.heading-anchor {
|
192
|
+
color: inherit;
|
193
|
+
text-decoration: none;
|
194
|
+
vertical-align: middle;
|
195
|
+
}
|
196
|
+
|
197
|
+
/* 悬停效果 */
|
198
|
+
.heading:hover .heading-anchor {
|
199
|
+
opacity: 0.7 !important;
|
200
|
+
}
|
201
|
+
|
202
|
+
.heading-anchor:hover {
|
203
|
+
opacity: 1 !important;
|
204
|
+
}
|
205
|
+
</style>
|
@@ -0,0 +1,187 @@
|
|
1
|
+
---
|
2
|
+
/**
|
3
|
+
* @component Text
|
4
|
+
*
|
5
|
+
* @description
|
6
|
+
* Text 组件用于创建各种文本元素,提供一致的排版样式和灵活的定制选项。
|
7
|
+
*
|
8
|
+
* @design
|
9
|
+
* 设计理念:
|
10
|
+
* 1. 一致性 - 确保整个应用中文本样式的一致性
|
11
|
+
* 2. 可读性 - 优化文本的可读性和舒适度
|
12
|
+
* 3. 可定制性 - 支持多种配置选项,适应不同场景需求
|
13
|
+
* 4. 无障碍性 - 遵循语义化HTML标准,确保屏幕阅读器可以正确解析内容
|
14
|
+
*
|
15
|
+
* 视觉特点:
|
16
|
+
* - 不同的字体大小和行高
|
17
|
+
* - 可选的字体粗细和样式
|
18
|
+
* - 可定制的颜色和对齐方式
|
19
|
+
* - 支持截断和省略号
|
20
|
+
*
|
21
|
+
* @usage
|
22
|
+
* 基本用法:
|
23
|
+
* ```astro
|
24
|
+
* <Text>这是一段普通文本</Text>
|
25
|
+
* ```
|
26
|
+
*
|
27
|
+
* 不同大小:
|
28
|
+
* ```astro
|
29
|
+
* <Text size="xs">超小文本</Text>
|
30
|
+
* <Text size="sm">小文本</Text>
|
31
|
+
* <Text size="md">中等文本</Text>
|
32
|
+
* <Text size="lg">大文本</Text>
|
33
|
+
* <Text size="xl">超大文本</Text>
|
34
|
+
* ```
|
35
|
+
*
|
36
|
+
* 不同颜色:
|
37
|
+
* ```astro
|
38
|
+
* <Text color="primary">主要颜色文本</Text>
|
39
|
+
* <Text color="secondary">次要颜色文本</Text>
|
40
|
+
* <Text color="accent">强调色文本</Text>
|
41
|
+
* <Text color="muted">柔和色文本</Text>
|
42
|
+
* ```
|
43
|
+
*
|
44
|
+
* 字体粗细:
|
45
|
+
* ```astro
|
46
|
+
* <Text weight="light">细体文本</Text>
|
47
|
+
* <Text weight="normal">常规文本</Text>
|
48
|
+
* <Text weight="medium">中等粗文本</Text>
|
49
|
+
* <Text weight="semibold">半粗体文本</Text>
|
50
|
+
* <Text weight="bold">粗体文本</Text>
|
51
|
+
* ```
|
52
|
+
*
|
53
|
+
* 文本对齐:
|
54
|
+
* ```astro
|
55
|
+
* <Text align="left">左对齐文本</Text>
|
56
|
+
* <Text align="center">居中对齐文本</Text>
|
57
|
+
* <Text align="right">右对齐文本</Text>
|
58
|
+
* <Text align="justify">两端对齐文本</Text>
|
59
|
+
* ```
|
60
|
+
*
|
61
|
+
* 文本截断:
|
62
|
+
* ```astro
|
63
|
+
* <Text truncate>这是一段很长的文本,将会被截断并显示省略号...</Text>
|
64
|
+
* ```
|
65
|
+
*
|
66
|
+
* 组合使用:
|
67
|
+
* ```astro
|
68
|
+
* <Text
|
69
|
+
* size="lg"
|
70
|
+
* color="primary"
|
71
|
+
* weight="bold"
|
72
|
+
* align="center"
|
73
|
+
* class="my-4"
|
74
|
+
* >
|
75
|
+
* 这是一段重要的提示文本
|
76
|
+
* </Text>
|
77
|
+
* ```
|
78
|
+
*
|
79
|
+
* @props
|
80
|
+
* @prop {string} [as='p'] - 要渲染的HTML元素,如 'p', 'span', 'div' 等
|
81
|
+
* @prop {'xs'|'sm'|'md'|'lg'|'xl'} [size='md'] - 文本大小
|
82
|
+
* @prop {'light'|'normal'|'medium'|'semibold'|'bold'} [weight='normal'] - 字体粗细
|
83
|
+
* @prop {'default'|'primary'|'secondary'|'accent'|'muted'} [color='default'] - 文本颜色
|
84
|
+
* @prop {'left'|'center'|'right'|'justify'} [align='left'] - 文本对齐方式
|
85
|
+
* @prop {boolean} [italic=false] - 是否使用斜体
|
86
|
+
* @prop {boolean} [underline=false] - 是否添加下划线
|
87
|
+
* @prop {boolean} [truncate=false] - 是否截断文本并显示省略号
|
88
|
+
* @prop {string} [class] - 自定义 CSS 类名
|
89
|
+
*
|
90
|
+
* @slots
|
91
|
+
* @slot default - 文本内容
|
92
|
+
*
|
93
|
+
* @accessibility
|
94
|
+
* - 使用语义化的HTML元素
|
95
|
+
* - 确保文本颜色与背景色的对比度符合WCAG标准
|
96
|
+
*/
|
97
|
+
|
98
|
+
interface Props {
|
99
|
+
as?: string;
|
100
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
101
|
+
weight?: 'light' | 'normal' | 'medium' | 'semibold' | 'bold';
|
102
|
+
color?: 'default' | 'primary' | 'secondary' | 'accent' | 'muted';
|
103
|
+
align?: 'left' | 'center' | 'right' | 'justify';
|
104
|
+
italic?: boolean;
|
105
|
+
underline?: boolean;
|
106
|
+
truncate?: boolean;
|
107
|
+
class?: string;
|
108
|
+
}
|
109
|
+
|
110
|
+
const {
|
111
|
+
as: Element = 'p',
|
112
|
+
size = 'md',
|
113
|
+
weight = 'normal',
|
114
|
+
color = 'default',
|
115
|
+
align = 'left',
|
116
|
+
italic = false,
|
117
|
+
underline = false,
|
118
|
+
truncate = false,
|
119
|
+
class: className = '',
|
120
|
+
} = Astro.props;
|
121
|
+
|
122
|
+
// 根据大小设置样式
|
123
|
+
const sizeClasses = {
|
124
|
+
xs: 'text-xs',
|
125
|
+
sm: 'text-sm',
|
126
|
+
md: 'text-base',
|
127
|
+
lg: 'text-lg',
|
128
|
+
xl: 'text-xl',
|
129
|
+
};
|
130
|
+
const sizeClass = sizeClasses[size as keyof typeof sizeClasses];
|
131
|
+
|
132
|
+
// 根据粗细设置样式
|
133
|
+
const weightClasses = {
|
134
|
+
light: 'font-light',
|
135
|
+
normal: 'font-normal',
|
136
|
+
medium: 'font-medium',
|
137
|
+
semibold: 'font-semibold',
|
138
|
+
bold: 'font-bold',
|
139
|
+
};
|
140
|
+
const weightClass = weightClasses[weight as keyof typeof weightClasses];
|
141
|
+
|
142
|
+
// 根据颜色设置样式
|
143
|
+
const colorClasses = {
|
144
|
+
default: 'text-gray-900 dark:text-gray-100',
|
145
|
+
primary: 'text-primary-600 dark:text-primary-400',
|
146
|
+
secondary: 'text-secondary-600 dark:text-secondary-400',
|
147
|
+
accent: 'text-accent-600 dark:text-accent-400',
|
148
|
+
muted: 'text-gray-600 dark:text-gray-400',
|
149
|
+
};
|
150
|
+
const colorClass = colorClasses[color as keyof typeof colorClasses];
|
151
|
+
|
152
|
+
// 根据对齐方式设置样式
|
153
|
+
const alignClasses = {
|
154
|
+
left: 'text-left',
|
155
|
+
center: 'text-center',
|
156
|
+
right: 'text-right',
|
157
|
+
justify: 'text-justify',
|
158
|
+
};
|
159
|
+
const alignClass = alignClasses[align as keyof typeof alignClasses];
|
160
|
+
|
161
|
+
// 其他样式
|
162
|
+
const italicClass = italic ? 'italic' : '';
|
163
|
+
const underlineClass = underline ? 'underline' : '';
|
164
|
+
const truncateClass = truncate ? 'truncate' : '';
|
165
|
+
|
166
|
+
// 组合所有类名
|
167
|
+
const combinedClass = `text ${sizeClass} ${weightClass} ${colorClass} ${alignClass} ${italicClass} ${underlineClass} ${truncateClass} ${className}`;
|
168
|
+
---
|
169
|
+
|
170
|
+
<Element class={combinedClass}>
|
171
|
+
<slot />
|
172
|
+
</Element>
|
173
|
+
|
174
|
+
<style>
|
175
|
+
.text {
|
176
|
+
margin-bottom: 1em;
|
177
|
+
line-height: 1.5;
|
178
|
+
}
|
179
|
+
|
180
|
+
/* 确保截断文本正常工作 */
|
181
|
+
.truncate {
|
182
|
+
white-space: nowrap;
|
183
|
+
overflow: hidden;
|
184
|
+
text-overflow: ellipsis;
|
185
|
+
max-width: 100%;
|
186
|
+
}
|
187
|
+
</style>
|
package/dist/index.ts
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
// Base
|
2
|
+
export { default as Button } from './components/base/Button.astro';
|
3
|
+
export { default as Link } from './components/base/Link.astro';
|
4
|
+
export { default as Image } from './components/base/Image.astro';
|
5
|
+
export { default as ThemeItem } from './components/base/ThemeItem.astro';
|
6
|
+
export { default as Alert } from './components/base/Alert.astro';
|
7
|
+
|
8
|
+
// Navigation
|
9
|
+
export { default as ThemeSwitcher } from './components/navigation/ThemeSwitcher.astro';
|
10
|
+
export { default as TableOfContents } from './components/navigation/TableOfContents.astro';
|
11
|
+
export { default as LanguageSwitcher } from './components/navigation/LanguageSwitcher.astro';
|
12
|
+
|
13
|
+
// Display
|
14
|
+
export { default as CodeBlock } from './components/display/CodeBlock.astro';
|
15
|
+
export { default as Modal } from './components/display/Modal.astro';
|
16
|
+
export { default as Hero } from './components/display/Hero.astro';
|
17
|
+
export { default as Banner } from './components/display/Banner.astro';
|
18
|
+
export { default as Card } from './components/display/Card.astro';
|
19
|
+
export { default as CodeExample } from './components/display/CodeExample.astro';
|
20
|
+
|
21
|
+
// Data Display
|
22
|
+
export { default as TeamMembers } from './components/data-display/TeamMembers.astro';
|
23
|
+
export { default as TeamMember } from './components/data-display/TeamMember.astro';
|
24
|
+
export { default as Blog } from './components/data-display/Blog.astro';
|
25
|
+
|
26
|
+
// Layouts
|
27
|
+
export { default as Footer } from './components/layouts/Footer.astro';
|
28
|
+
export { default as Header } from './components/layouts/Header.astro';
|
29
|
+
export { default as DocumentationLayout } from './components/layouts/DocumentationLayout.astro';
|
30
|
+
export { default as DefaultLayout } from './components/layouts/DefaultLayout.astro';
|
31
|
+
export { default as Stack } from './components/layouts/Stack.astro';
|
32
|
+
export { default as Grid } from './components/layouts/Grid.astro';
|
33
|
+
export { default as BaseLayout } from './components/layouts/BaseLayout.astro';
|
34
|
+
export { default as LandingLayout } from './components/layouts/LandingLayout.astro';
|
35
|
+
export { default as DashboardLayout } from './components/layouts/DashboardLayout.astro';
|
36
|
+
export { default as Flex } from './components/layouts/Flex.astro';
|
37
|
+
|
38
|
+
// Typography
|
39
|
+
export { default as Article } from './components/typography/Article.astro';
|
40
|
+
export { default as Text } from './components/typography/Text.astro';
|
41
|
+
export { default as Heading } from './components/typography/Heading.astro';
|
42
|
+
|
43
|
+
// Icons
|
44
|
+
export { default as SocialIcon } from './components/icons/SocialIcon.astro';
|
45
|
+
export { default as TwitterIcon } from './components/icons/TwitterIcon.astro';
|
46
|
+
export { default as UserIcon } from './components/icons/UserIcon.astro';
|
47
|
+
export { default as WarningIcon } from './components/icons/WarningIcon.astro';
|
48
|
+
export { default as XCircle } from './components/icons/XCircle.astro';
|
49
|
+
export { default as InfoIcon } from './components/icons/InfoIcon.astro';
|
50
|
+
export { default as LinkIcon } from './components/icons/LinkIcon.astro';
|
51
|
+
export { default as LinkedinIcon } from './components/icons/LinkedinIcon.astro';
|
52
|
+
export { default as MenuIcon } from './components/icons/MenuIcon.astro';
|
53
|
+
export { default as SearchIcon } from './components/icons/SearchIcon.astro';
|
54
|
+
export { default as SuccessIcon } from './components/icons/SuccessIcon.astro';
|
55
|
+
export { default as SunCloudyIcon } from './components/icons/SunCloudyIcon.astro';
|
56
|
+
export { default as AlertTriangle } from './components/icons/AlertTriangle.astro';
|
57
|
+
export { default as CalendarIcon } from './components/icons/CalendarIcon.astro';
|
58
|
+
export { default as CheckCircle } from './components/icons/CheckCircle.astro';
|
59
|
+
export { default as CheckIcon } from './components/icons/CheckIcon.astro';
|
60
|
+
export { default as ClipboardIcon } from './components/icons/ClipboardIcon.astro';
|
61
|
+
export { default as CloseIcon } from './components/icons/CloseIcon.astro';
|
62
|
+
export { default as ErrorIcon } from './components/icons/ErrorIcon.astro';
|
63
|
+
export { default as GithubIcon } from './components/icons/GithubIcon.astro';
|
64
|
+
export { default as InfoCircle } from './components/icons/InfoCircle.astro';
|
65
|
+
|
66
|
+
// Containers
|
67
|
+
export { default as Container } from './components/containers/Container.astro';
|
68
|
+
export { default as Main } from './components/containers/Main.astro';
|
69
|
+
export { default as Section } from './components/containers/Section.astro';
|
70
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { defineIntegration } from "astro-integration-kit";
|
2
|
+
|
3
|
+
export const integration = defineIntegration({
|
4
|
+
name: "astro-cosy",
|
5
|
+
setup() {
|
6
|
+
return {
|
7
|
+
hooks: {
|
8
|
+
"astro:config:setup": ({ logger }) => {
|
9
|
+
logger.info("astro-cosy integration setup");
|
10
|
+
},
|
11
|
+
},
|
12
|
+
};
|
13
|
+
},
|
14
|
+
});
|
package/dist/style.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
import './app.css';
|
@@ -0,0 +1,55 @@
|
|
1
|
+
interface ThemeManager {
|
2
|
+
updateActiveTheme: (currentTheme: string) => void;
|
3
|
+
handleThemeClick: (this: HTMLElement) => void;
|
4
|
+
initialize: () => void;
|
5
|
+
setTheme: (theme: string) => void;
|
6
|
+
}
|
7
|
+
|
8
|
+
export function createThemeManager(): ThemeManager {
|
9
|
+
const getThemeItems = () => document.querySelectorAll<HTMLElement>('[data-set-theme]');
|
10
|
+
|
11
|
+
const updateActiveTheme = (currentTheme: string) => {
|
12
|
+
const themeItems = getThemeItems();
|
13
|
+
themeItems.forEach((item) => {
|
14
|
+
const themeId = item.getAttribute('data-set-theme');
|
15
|
+
const isActive = themeId === currentTheme;
|
16
|
+
item.classList.toggle('bg-primary', isActive);
|
17
|
+
item.classList.toggle('text-primary-content', isActive);
|
18
|
+
});
|
19
|
+
};
|
20
|
+
|
21
|
+
function handleThemeClick(this: HTMLElement) {
|
22
|
+
const theme = this.getAttribute('data-set-theme');
|
23
|
+
document.documentElement.setAttribute('data-theme', theme ?? 'default');
|
24
|
+
localStorage.setItem('theme', theme ?? 'default');
|
25
|
+
updateActiveTheme(theme ?? 'default');
|
26
|
+
}
|
27
|
+
|
28
|
+
const setTheme = (theme: string) => {
|
29
|
+
document.documentElement.setAttribute('data-theme', theme);
|
30
|
+
localStorage.setItem('theme', theme);
|
31
|
+
updateActiveTheme(theme);
|
32
|
+
};
|
33
|
+
|
34
|
+
const initialize = () => {
|
35
|
+
const themeItems = getThemeItems();
|
36
|
+
|
37
|
+
// 移除旧的事件监听器并添加新的
|
38
|
+
themeItems.forEach((item) => {
|
39
|
+
item.removeEventListener('click', handleThemeClick);
|
40
|
+
item.addEventListener('click', handleThemeClick);
|
41
|
+
});
|
42
|
+
|
43
|
+
// 从本地存储中获取主题并更新激活状态
|
44
|
+
const savedTheme = localStorage.getItem('theme') || 'default';
|
45
|
+
document.documentElement.setAttribute('data-theme', savedTheme);
|
46
|
+
updateActiveTheme(savedTheme);
|
47
|
+
};
|
48
|
+
|
49
|
+
return {
|
50
|
+
updateActiveTheme,
|
51
|
+
handleThemeClick,
|
52
|
+
initialize,
|
53
|
+
setTheme,
|
54
|
+
};
|
55
|
+
}
|
package/package.json
CHANGED
@@ -1,60 +1,68 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
2
|
+
"name": "@coffic/cosy-ui",
|
3
|
+
"version": "0.2.2",
|
4
|
+
"description": "An astro component library",
|
5
|
+
"author": {
|
6
|
+
"name": "nookery",
|
7
|
+
"url": "https://github.com/nookery"
|
8
|
+
},
|
9
|
+
"license": "MIT",
|
10
|
+
"keywords": [
|
11
|
+
"astro-integration",
|
12
|
+
"astro-component",
|
13
|
+
"withastro",
|
14
|
+
"astro",
|
15
|
+
"cosy-ui"
|
16
|
+
],
|
17
|
+
"homepage": "https://github.con/CofficLab/cosy-ui",
|
18
|
+
"publishConfig": {
|
19
|
+
"access": "public"
|
20
|
+
},
|
21
|
+
"sideEffects": false,
|
22
|
+
"main": "./dist/index.js",
|
23
|
+
"exports": {
|
24
|
+
".": "./dist/index.js"
|
25
|
+
},
|
26
|
+
"files": [
|
27
|
+
"dist",
|
28
|
+
"index.ts"
|
29
|
+
],
|
30
|
+
"scripts": {
|
31
|
+
"dev": "astro dev",
|
32
|
+
"build": "vite build && tsx scripts/post-build.ts"
|
33
|
+
},
|
34
|
+
"type": "module",
|
35
|
+
"peerDependencies": {
|
36
|
+
"astro": "^5.1.3"
|
37
|
+
},
|
38
|
+
"dependencies": {
|
39
|
+
"astro-integration-kit": "^0.18.0",
|
40
|
+
"fs-extra": "^11.3.0"
|
41
|
+
},
|
42
|
+
"devDependencies": {
|
43
|
+
"@astrojs/check": "^0.9.4",
|
44
|
+
"@astrojs/ts-plugin": "^1.10.4",
|
45
|
+
"@tailwindcss/vite": "^4.0.14",
|
46
|
+
"@types/chai": "^5.2.0",
|
47
|
+
"@types/eslint": "^9.6.1",
|
48
|
+
"@types/fs-extra": "^11.0.4",
|
49
|
+
"@types/mocha": "^10.0.10",
|
50
|
+
"@types/node": "^22.13.10",
|
51
|
+
"@types/react": "^19.0.10",
|
52
|
+
"@typescript-eslint/parser": "^8.26.1",
|
53
|
+
"astro": "^5.5.2",
|
54
|
+
"chai": "^4.5.0",
|
55
|
+
"daisyui": "^5.0.4",
|
56
|
+
"eslint": "^8.57.1",
|
57
|
+
"eslint-plugin-astro": "^1.3.1",
|
58
|
+
"mocha": "^10.8.2",
|
59
|
+
"prettier": "^3.5.3",
|
60
|
+
"prettier-plugin-astro": "^0.14.1",
|
61
|
+
"rollup-plugin-copy": "^3.5.0",
|
62
|
+
"sharp": "^0.33.2",
|
63
|
+
"tailwindcss": "^4.0.14",
|
64
|
+
"tsx": "^4.19.3",
|
65
|
+
"typescript": "^5.8.2",
|
66
|
+
"vite": "^6.2.2"
|
67
|
+
}
|
68
|
+
}
|