@coffic/cosy-ui 0.1.28 → 0.2.0
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 +67 -23
- 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/base/README.md +53 -0
- package/dist/components/base/index.ts +6 -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/README.md +37 -0
- package/dist/components/data-display/TeamMember.astro +135 -0
- package/dist/components/data-display/TeamMembers.astro +101 -0
- package/dist/components/data-display/index.ts +3 -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/display/README.md +32 -0
- package/dist/components/display/index.ts +6 -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/icons/index.ts +23 -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/README.md +37 -0
- package/dist/components/layouts/Stack.astro +149 -0
- package/dist/components/layouts/index.ts +6 -0
- package/dist/components/navigation/LanguageSwitcher.astro +81 -0
- package/dist/components/navigation/README.md +24 -0
- package/dist/components/navigation/TableOfContents.astro +352 -0
- package/dist/components/navigation/ThemeSwitcher.astro +89 -0
- package/dist/components/navigation/index.ts +3 -0
- package/dist/components/typography/Article.astro +144 -0
- package/dist/components/typography/Heading.astro +205 -0
- package/dist/components/typography/README.md +29 -0
- package/dist/components/typography/Text.astro +187 -0
- package/dist/components/typography/index.ts +3 -0
- package/dist/index.ts +9 -0
- package/dist/integration.ts +14 -0
- package/dist/style.ts +1 -0
- package/{src → dist}/types/footer.ts +11 -7
- package/{src → dist}/utils/social.ts +5 -12
- package/dist/utils/theme.ts +55 -0
- package/package.json +65 -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 -130
- 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
@@ -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,29 @@
|
|
1
|
+
# 排版组件 (Typography Components)
|
2
|
+
|
3
|
+
这个目录包含了用于文本排版和内容展示的基础组件。
|
4
|
+
|
5
|
+
## 设计原则
|
6
|
+
|
7
|
+
1. **可读性**:确保文本清晰易读
|
8
|
+
2. **层次感**:通过不同的文本样式创建视觉层次
|
9
|
+
3. **一致性**:保持文本样式的一致性
|
10
|
+
|
11
|
+
## 包含的组件
|
12
|
+
|
13
|
+
- `Heading.astro`: 标题组件,用于各级标题
|
14
|
+
- `Article.astro`: 文章组件,用于文章内容的排版
|
15
|
+
- `Text.astro`: 文本组件,用于普通段落文本
|
16
|
+
|
17
|
+
## 使用指南
|
18
|
+
|
19
|
+
排版组件用于构建结构化的文本内容:
|
20
|
+
|
21
|
+
```astro
|
22
|
+
<Heading level={1}>主标题</Heading>
|
23
|
+
<Heading level={2}>副标题</Heading>
|
24
|
+
|
25
|
+
<Article>
|
26
|
+
<Text>这是一段普通的文本内容</Text>
|
27
|
+
<Text variant="lead">这是一段引导文本</Text>
|
28
|
+
</Article>
|
29
|
+
```
|
@@ -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,9 @@
|
|
1
|
+
export * from './components/base';
|
2
|
+
export * from './components/navigation';
|
3
|
+
export * from './components/display';
|
4
|
+
export * from './components/data-display';
|
5
|
+
export * from './components/layouts';
|
6
|
+
export * from './components/typography';
|
7
|
+
export * from './components/icons';
|
8
|
+
export * from './components/containers';
|
9
|
+
|
@@ -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';
|
@@ -9,12 +9,6 @@ export interface Product {
|
|
9
9
|
external?: boolean;
|
10
10
|
}
|
11
11
|
|
12
|
-
export interface SocialLink {
|
13
|
-
name: string;
|
14
|
-
url: string;
|
15
|
-
platform: string;
|
16
|
-
}
|
17
|
-
|
18
12
|
export interface FooterProps {
|
19
13
|
siteName: string;
|
20
14
|
homeLink: string;
|
@@ -22,6 +16,7 @@ export interface FooterProps {
|
|
22
16
|
company: string;
|
23
17
|
copyright: string;
|
24
18
|
inspirationalSlogan: string;
|
19
|
+
debug?: boolean;
|
25
20
|
icp?: string;
|
26
21
|
logo?: Logo;
|
27
22
|
products?: Product[];
|
@@ -29,5 +24,14 @@ export interface FooterProps {
|
|
29
24
|
contactLink?: string;
|
30
25
|
termsLink?: string;
|
31
26
|
privacyLink?: string;
|
32
|
-
socialLinks?:
|
27
|
+
socialLinks?: string[];
|
28
|
+
teamLink?: string;
|
29
|
+
careersLink?: string;
|
30
|
+
newsLink?: string;
|
31
|
+
historyLink?: string;
|
32
|
+
partnersLink?: string;
|
33
|
+
blogLink?: string;
|
34
|
+
faqLink?: string;
|
35
|
+
mediaLink?: string;
|
36
|
+
techStackLink?: string;
|
33
37
|
}
|
@@ -4,13 +4,6 @@ interface PlatformConfig {
|
|
4
4
|
domains: string[];
|
5
5
|
}
|
6
6
|
|
7
|
-
// 社交链接类型
|
8
|
-
export interface SocialLink {
|
9
|
-
name: string;
|
10
|
-
url: string;
|
11
|
-
platform: string;
|
12
|
-
}
|
13
|
-
|
14
7
|
// 处理后的社交链接类型
|
15
8
|
export interface ProcessedSocialLink {
|
16
9
|
url: string;
|
@@ -76,21 +69,21 @@ function detectPlatform(url: string): [string, PlatformConfig] | null {
|
|
76
69
|
}
|
77
70
|
|
78
71
|
// 处理社交链接
|
79
|
-
export function processSocialLink(
|
80
|
-
const platformInfo = detectPlatform(
|
72
|
+
export function processSocialLink(url: string): ProcessedSocialLink {
|
73
|
+
const platformInfo = detectPlatform(url);
|
81
74
|
|
82
75
|
if (!platformInfo) {
|
83
76
|
// 如果无法识别平台,返回默认值
|
84
77
|
return {
|
85
|
-
url:
|
86
|
-
name:
|
78
|
+
url: url,
|
79
|
+
name: '社交链接',
|
87
80
|
platform: 'default',
|
88
81
|
};
|
89
82
|
}
|
90
83
|
|
91
84
|
const [platform, config] = platformInfo;
|
92
85
|
return {
|
93
|
-
url:
|
86
|
+
url: url,
|
94
87
|
name: config.name,
|
95
88
|
platform,
|
96
89
|
};
|
@@ -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
|
+
}
|