@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.
Files changed (97) hide show
  1. package/README.md +67 -23
  2. package/dist/app.css +1 -0
  3. package/dist/assets/logo-rounded.png +0 -0
  4. package/dist/assets/logo.png +0 -0
  5. package/dist/components/base/Alert.astro +186 -0
  6. package/dist/components/base/Button.astro +103 -0
  7. package/dist/components/base/Image.astro +291 -0
  8. package/dist/components/base/Link.astro +131 -0
  9. package/dist/components/base/README.md +53 -0
  10. package/dist/components/base/index.ts +6 -0
  11. package/dist/components/containers/Container.astro +103 -0
  12. package/dist/components/containers/Main.astro +167 -0
  13. package/dist/components/containers/Section.astro +145 -0
  14. package/dist/components/containers/index.ts +3 -0
  15. package/dist/components/data-display/Blog.astro +195 -0
  16. package/dist/components/data-display/README.md +37 -0
  17. package/dist/components/data-display/TeamMember.astro +135 -0
  18. package/dist/components/data-display/TeamMembers.astro +101 -0
  19. package/dist/components/data-display/index.ts +3 -0
  20. package/dist/components/display/Banner.astro +57 -0
  21. package/dist/components/display/Card.astro +135 -0
  22. package/dist/components/display/CodeBlock.astro +147 -0
  23. package/dist/components/display/CodeExample.astro +330 -0
  24. package/dist/components/display/Hero.astro +119 -0
  25. package/dist/components/display/Modal.astro +115 -0
  26. package/dist/components/display/README.md +32 -0
  27. package/dist/components/display/index.ts +6 -0
  28. package/dist/components/icons/AlertTriangle.astro +35 -0
  29. package/dist/components/icons/CalendarIcon.astro +38 -0
  30. package/dist/components/icons/CheckCircle.astro +36 -0
  31. package/dist/components/icons/CheckIcon.astro +38 -0
  32. package/dist/components/icons/ClipboardIcon.astro +39 -0
  33. package/dist/components/icons/CloseIcon.astro +38 -0
  34. package/dist/components/icons/ErrorIcon.astro +35 -0
  35. package/dist/components/icons/GithubIcon.astro +31 -0
  36. package/dist/components/icons/InfoCircle.astro +37 -0
  37. package/dist/components/icons/InfoIcon.astro +38 -0
  38. package/dist/components/icons/LinkIcon.astro +39 -0
  39. package/dist/components/icons/LinkedinIcon.astro +31 -0
  40. package/dist/components/icons/MenuIcon.astro +41 -0
  41. package/dist/components/icons/SearchIcon.astro +40 -0
  42. package/dist/components/icons/SocialIcon.astro +100 -0
  43. package/dist/components/icons/SuccessIcon.astro +35 -0
  44. package/dist/components/icons/SunCloudyIcon.astro +45 -0
  45. package/dist/components/icons/TwitterIcon.astro +31 -0
  46. package/dist/components/icons/UserIcon.astro +35 -0
  47. package/dist/components/icons/WarningIcon.astro +38 -0
  48. package/dist/components/icons/XCircle.astro +37 -0
  49. package/dist/components/icons/index.ts +23 -0
  50. package/dist/components/layouts/BaseLayout.astro +144 -0
  51. package/dist/components/layouts/DashboardLayout.astro +660 -0
  52. package/dist/components/layouts/DefaultLayout.astro +170 -0
  53. package/dist/components/layouts/DocumentationLayout.astro +469 -0
  54. package/dist/components/layouts/Flex.astro +138 -0
  55. package/dist/components/layouts/Footer.astro +284 -0
  56. package/dist/components/layouts/Grid.astro +182 -0
  57. package/dist/components/layouts/Header.astro +114 -0
  58. package/dist/components/layouts/LandingLayout.astro +388 -0
  59. package/dist/components/layouts/README.md +37 -0
  60. package/dist/components/layouts/Stack.astro +149 -0
  61. package/dist/components/layouts/index.ts +6 -0
  62. package/dist/components/navigation/LanguageSwitcher.astro +81 -0
  63. package/dist/components/navigation/README.md +24 -0
  64. package/dist/components/navigation/TableOfContents.astro +352 -0
  65. package/dist/components/navigation/ThemeSwitcher.astro +89 -0
  66. package/dist/components/navigation/index.ts +3 -0
  67. package/dist/components/typography/Article.astro +144 -0
  68. package/dist/components/typography/Heading.astro +205 -0
  69. package/dist/components/typography/README.md +29 -0
  70. package/dist/components/typography/Text.astro +187 -0
  71. package/dist/components/typography/index.ts +3 -0
  72. package/dist/index.ts +9 -0
  73. package/dist/integration.ts +14 -0
  74. package/dist/style.ts +1 -0
  75. package/{src → dist}/types/footer.ts +11 -7
  76. package/{src → dist}/utils/social.ts +5 -12
  77. package/dist/utils/theme.ts +55 -0
  78. package/package.json +65 -59
  79. package/index.ts +0 -18
  80. package/src/components/Alert.astro +0 -78
  81. package/src/components/Article.astro +0 -11
  82. package/src/components/Banner.astro +0 -49
  83. package/src/components/Blog.astro +0 -115
  84. package/src/components/Button.astro +0 -49
  85. package/src/components/Card.astro +0 -113
  86. package/src/components/CodeBlock.astro +0 -186
  87. package/src/components/Footer.astro +0 -130
  88. package/src/components/Header.astro +0 -305
  89. package/src/components/Hero.astro +0 -69
  90. package/src/components/Image.astro +0 -251
  91. package/src/components/Link.astro +0 -82
  92. package/src/components/Modal.astro +0 -67
  93. package/src/components/SocialIcon.astro +0 -36
  94. package/src/components/TeamMember.astro +0 -68
  95. package/src/components/TeamMembers.astro +0 -43
  96. package/src/env.d.ts +0 -0
  97. /package/{src/components → dist/components/base}/ThemeItem.astro +0 -0
@@ -0,0 +1,101 @@
1
+ ---
2
+ /**
3
+ * @component TeamMembers
4
+ *
5
+ * @description
6
+ * TeamMembers 组件用于展示团队成员列表,以网格布局呈现多个 TeamMember 组件。
7
+ * 支持响应式布局,可以根据屏幕大小自动调整列数。
8
+ *
9
+ * @design
10
+ * 设计理念:
11
+ * 1. 一致性展示 - 以统一的卡片形式展示团队成员信息
12
+ * 2. 响应式布局 - 在不同屏幕尺寸下自动调整列数
13
+ * 3. 灵活配置 - 支持自定义列数和样式
14
+ *
15
+ * @usage
16
+ * 基本用法:
17
+ * ```astro
18
+ * <TeamMembers members={teamData} />
19
+ * ```
20
+ *
21
+ * 自定义列数:
22
+ * ```astro
23
+ * <TeamMembers members={teamData} columns={2} />
24
+ * ```
25
+ *
26
+ * 添加自定义类名:
27
+ * ```astro
28
+ * <TeamMembers members={teamData} class="mt-8" />
29
+ * ```
30
+ */
31
+
32
+ import TeamMember from './TeamMember.astro';
33
+
34
+ // 导入样式
35
+ import '../../app.css';
36
+
37
+ // 自定义图片元数据接口
38
+ interface ImageMetadata {
39
+ src: string;
40
+ width: number;
41
+ height: number;
42
+ format: string;
43
+ }
44
+
45
+ interface SocialLink {
46
+ platform: 'github' | 'twitter' | 'linkedin' | 'website' | 'email';
47
+ url: string;
48
+ }
49
+
50
+ interface TeamMemberData {
51
+ name: string;
52
+ role: string;
53
+ avatar: ImageMetadata | string;
54
+ bio: string;
55
+ socialLinks?: SocialLink[];
56
+ }
57
+
58
+ interface Props {
59
+ /**
60
+ * 团队成员数据数组
61
+ */
62
+ members: TeamMemberData[];
63
+ /**
64
+ * 网格列数
65
+ * @default 3
66
+ */
67
+ columns?: 2 | 3 | 4;
68
+ /**
69
+ * 自定义类名
70
+ */
71
+ class?: string;
72
+ }
73
+
74
+ const {
75
+ members,
76
+ columns = 3,
77
+ class: className = ''
78
+ } = Astro.props;
79
+
80
+ // 使用类型断言确保 columns 是有效的键
81
+ const columnsValue = columns as 2 | 3 | 4;
82
+
83
+ // 根据列数生成对应的类名
84
+ const getGridClasses = (cols: 2 | 3 | 4) => {
85
+ const baseClass = 'team-members-cols-1';
86
+ const mdClass = 'team-members-cols-md-2';
87
+ const lgClass = cols === 4 ? 'team-members-cols-lg-4' : 'team-members-cols-lg-3';
88
+
89
+ return [baseClass, mdClass, lgClass];
90
+ };
91
+ ---
92
+
93
+ <div class:list={["team-members-container", className]}>
94
+ <div class:list={["team-members-grid", ...getGridClasses(columnsValue)]}>
95
+ {members.map((member: TeamMemberData, index: number) => (
96
+ <div class="team-members-animate">
97
+ <TeamMember {...member} />
98
+ </div>
99
+ ))}
100
+ </div>
101
+ </div>
@@ -0,0 +1,3 @@
1
+ export { default as TeamMember } from './TeamMember.astro';
2
+ export { default as TeamMembers } from './TeamMembers.astro';
3
+ export { default as Blog } from './Blog.astro';
@@ -0,0 +1,57 @@
1
+ ---
2
+ /**
3
+ * @component Banner
4
+ *
5
+ * @description
6
+ * Banner 组件用于在页面中展示醒目的横幅信息,通常用于展示重要的标语、公告或营销信息。
7
+ * 组件设计简洁大方,具有平滑的动画效果,能够吸引用户注意力。
8
+ *
9
+ * @design
10
+ * 设计理念:
11
+ * 1. 视觉冲击力 - 使用大号字体和醒目的背景,确保信息能够被用户注意到
12
+ * 2. 简洁明了 - 简单的布局和充足的留白,让信息更容易被理解
13
+ * 3. 动态效果 - 使用淡入和上滑动画,增强用户体验
14
+ * 4. 响应式设计 - 在不同屏幕尺寸下保持良好的可读性
15
+ *
16
+ * 视觉特点:
17
+ * - 圆角设计:柔和的视觉效果
18
+ * - 悬停效果:轻微放大和阴影增强,提供交互反馈
19
+ * - 动画效果:淡入和上滑动画,增强视觉吸引力
20
+ * - 模糊背景:半透明背景配合模糊效果,现代感强
21
+ *
22
+ * @usage
23
+ * 基本用法:
24
+ * ```astro
25
+ * <Banner>欢迎使用我们的服务</Banner>
26
+ * ```
27
+ *
28
+ * 在页脚中使用:
29
+ * ```astro
30
+ * <footer>
31
+ * <Banner>构建美好的数字体验</Banner>
32
+ * </footer>
33
+ * ```
34
+ *
35
+ * @slots
36
+ * @slot default - Banner 中显示的文本内容
37
+ *
38
+ * @accessibility
39
+ * - 使用适当的字体大小和行高,确保文本可读性
40
+ * - 动画遵循 prefers-reduced-motion 媒体查询,尊重用户的动画偏好设置
41
+ */
42
+
43
+ // 导入样式
44
+ import '../../app.css';
45
+ ---
46
+
47
+ <div class="banner-container">
48
+ <div class="banner">
49
+ <div class="banner-content">
50
+ <div class="banner-text">
51
+ <p class="banner-message">
52
+ <slot />
53
+ </p>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </div>
@@ -0,0 +1,135 @@
1
+ ---
2
+ /**
3
+ * @component Card
4
+ *
5
+ * @description
6
+ * Card 组件用于在页面中展示相关内容的容器,通常包含标题、描述和可选的图片。
7
+ * 组件设计简洁大方,具有平滑的动画效果和交互反馈,适合展示产品、文章或功能介绍等内容。
8
+ *
9
+ * @design
10
+ * 设计理念:
11
+ * 1. 视觉层次感 - 通过阴影、悬停效果和微妙的动画创造深度感
12
+ * 2. 内容聚焦 - 简洁的布局让用户关注卡片内容
13
+ * 3. 交互反馈 - 悬停和点击时提供明确的视觉反馈
14
+ * 4. 适应性强 - 响应式设计,适应不同屏幕尺寸
15
+ *
16
+ * 视觉特点:
17
+ * - 半透明背景:现代感强,适合叠加在各种背景上
18
+ * - 模糊效果:背景模糊增强内容可读性
19
+ * - 光效设计:顶部有微妙的光晕效果,增强立体感
20
+ * - 悬停动画:轻微放大和阴影增强,提供交互反馈
21
+ * - 图片缩放:图片在悬停时轻微放大,增强视觉吸引力
22
+ *
23
+ * @usage
24
+ * 基本用法:
25
+ * ```astro
26
+ * <Card
27
+ * title="卡片标题"
28
+ * subtitle="卡片描述文本"
29
+ * >
30
+ * 卡片内容
31
+ * </Card>
32
+ * ```
33
+ *
34
+ * 带图片的卡片:
35
+ * ```astro
36
+ * <Card
37
+ * title="产品名称"
38
+ * subtitle="产品描述"
39
+ * imageUrl="/path/to/image.jpg"
40
+ * >
41
+ * 其他产品信息
42
+ * </Card>
43
+ * ```
44
+ *
45
+ * 可点击的卡片(链接):
46
+ * ```astro
47
+ * <Card
48
+ * title="文章标题"
49
+ * subtitle="文章摘要"
50
+ * imageUrl="/path/to/image.jpg"
51
+ * href="/articles/article-slug"
52
+ * />
53
+ * ```
54
+ *
55
+ * @props
56
+ * @prop {string} [title] - 卡片标题
57
+ * @prop {string} [subtitle] - 卡片副标题或描述
58
+ * @prop {string} [imageUrl] - 卡片顶部图片的URL
59
+ * @prop {string} [href] - 如果提供,卡片将变成可点击的链接
60
+ *
61
+ * @slots
62
+ * @slot default - 卡片的主要内容区域
63
+ *
64
+ * @accessibility
65
+ * - 使用语义化HTML结构
66
+ * - 当作为链接使用时,确保提供有意义的文本内容
67
+ * - 动画遵循 prefers-reduced-motion 媒体查询,尊重用户的动画偏好设置
68
+ */
69
+
70
+ // 导入样式
71
+ import '../../app.css';
72
+
73
+ interface Props {
74
+ title?: string;
75
+ subtitle?: string;
76
+ imageUrl?: string;
77
+ href?: string;
78
+ }
79
+
80
+ const { title, subtitle, imageUrl, href } = Astro.props;
81
+ ---
82
+
83
+ <div class="group perspective-1000">
84
+ <div class:list={[
85
+ "card",
86
+ href && "cursor-pointer",
87
+ "motion-safe:animate-fadeIn"
88
+ ]}>
89
+ {href ? (
90
+ <a href={href} class="card-body">
91
+ {imageUrl && (
92
+ <figure>
93
+ <img
94
+ src={imageUrl}
95
+ alt={title}
96
+ />
97
+ </figure>
98
+ )}
99
+ {title && (
100
+ <h2 class="card-title">
101
+ {title}
102
+ </h2>
103
+ )}
104
+ {subtitle && (
105
+ <p>
106
+ {subtitle}
107
+ </p>
108
+ )}
109
+ <slot />
110
+ </a>
111
+ ) : (
112
+ <div class="card-body">
113
+ {imageUrl && (
114
+ <figure>
115
+ <img
116
+ src={imageUrl}
117
+ alt={title}
118
+ />
119
+ </figure>
120
+ )}
121
+ {title && (
122
+ <h2 class="card-title">
123
+ {title}
124
+ </h2>
125
+ )}
126
+ {subtitle && (
127
+ <p>
128
+ {subtitle}
129
+ </p>
130
+ )}
131
+ <slot />
132
+ </div>
133
+ )}
134
+ </div>
135
+ </div>
@@ -0,0 +1,147 @@
1
+ ---
2
+ /**
3
+ * @component CodeBlock
4
+ *
5
+ * @description
6
+ * CodeBlock 组件用于在页面中展示格式化的代码片段,支持语法高亮、行号显示和代码复制功能。
7
+ * 组件设计简洁美观,提供良好的代码可读性和用户交互体验。
8
+ *
9
+ * @design
10
+ * 设计理念:
11
+ * 1. 可读性优先 - 清晰的字体、合适的间距和语法高亮,确保代码易于阅读
12
+ * 2. 功能完备 - 支持行号显示、代码复制等实用功能
13
+ * 3. 视觉一致性 - 与整体设计系统保持一致的视觉风格
14
+ * 4. 响应式设计 - 在不同屏幕尺寸下保持良好的可用性
15
+ *
16
+ * 视觉特点:
17
+ * - 语法高亮:使用北欧风格的配色方案,柔和且易于阅读
18
+ * - 行号显示:可选的行号显示,帮助定位代码位置
19
+ * - 标题栏:可选的标题栏,显示文件名或代码类型
20
+ * - 复制按钮:便捷的代码复制功能,带有状态反馈
21
+ *
22
+ * @usage
23
+ * 基本用法:
24
+ * ```astro
25
+ * <CodeBlock code={`console.log('Hello, world!');`} lang="js" />
26
+ * ```
27
+ *
28
+ * 带标题和行号:
29
+ * ```astro
30
+ * <CodeBlock
31
+ * code={`function greet(name) {\n return 'Hello, ' + name + '!';\n}`}
32
+ * lang="js"
33
+ * title="greeting.js"
34
+ * showLineNumbers={true}
35
+ * />
36
+ * ```
37
+ *
38
+ * @props
39
+ * @prop {string} code - 要显示的代码字符串
40
+ * @prop {string} [lang="plaintext"] - 代码语言,用于语法高亮
41
+ * @prop {string} [title] - 代码块的标题,通常是文件名
42
+ * @prop {boolean} [showLineNumbers=true] - 是否显示行号
43
+ *
44
+ * @accessibility
45
+ * - 使用语义化HTML结构
46
+ * - 复制按钮提供清晰的视觉反馈
47
+ * - 代码使用等宽字体,确保对齐和可读性
48
+ */
49
+
50
+ // 导入样式
51
+ import '../../app.css';
52
+
53
+ interface Props {
54
+ code: string;
55
+ lang?: string;
56
+ title?: string;
57
+ showLineNumbers?: boolean;
58
+ }
59
+
60
+ const {
61
+ code,
62
+ lang = 'plaintext',
63
+ title,
64
+ showLineNumbers = true,
65
+ } = Astro.props;
66
+
67
+ // 移除代码字符串开头和结尾的空行
68
+ const trimmedCode = code.trim();
69
+
70
+ // 生成行号
71
+ const lines = trimmedCode.split('\n');
72
+ const lineNumbers = Array.from({ length: lines.length }, (_, i) => i + 1);
73
+ ---
74
+
75
+ <div class="code-block not-prose">
76
+ {/* 标题栏 */}
77
+ {title && (
78
+ <div class="code-block-header">
79
+ <span class="code-block-title">{title}</span>
80
+ <button
81
+ class="copy-button"
82
+ data-code={trimmedCode}
83
+ title="复制代码"
84
+ >
85
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor">
86
+ <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
87
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
88
+ </svg>
89
+ <span class="copy-text">复制</span>
90
+ </button>
91
+ </div>
92
+ )}
93
+
94
+ {/* 代码区域 */}
95
+ <div class="code-content">
96
+ {/* 行号 */}
97
+ {showLineNumbers && (
98
+ <div class="line-numbers">
99
+ {lineNumbers.map(num => (
100
+ <div class="line-number">{num}</div>
101
+ ))}
102
+ </div>
103
+ )}
104
+
105
+ {/* 代码内容 */}
106
+ <pre class:list={["language-" + lang, { "with-line-numbers": showLineNumbers }]}>
107
+ <code class={"language-" + lang} set:html={trimmedCode} />
108
+ </pre>
109
+ </div>
110
+ </div>
111
+
112
+ <script>
113
+ function initializeCopyButtons() {
114
+ const copyButtons = document.querySelectorAll('.copy-button');
115
+
116
+ copyButtons.forEach(button => {
117
+ button.addEventListener('click', async () => {
118
+ const code = button.getAttribute('data-code') || '';
119
+ const copyText = button.querySelector('.copy-text');
120
+
121
+ try {
122
+ await navigator.clipboard.writeText(code);
123
+ if (copyText) {
124
+ copyText.textContent = '已复制!';
125
+ setTimeout(() => {
126
+ copyText.textContent = '复制';
127
+ }, 2000);
128
+ }
129
+ } catch (err) {
130
+ console.error('复制失败:', err);
131
+ if (copyText) {
132
+ copyText.textContent = '复制失败';
133
+ setTimeout(() => {
134
+ copyText.textContent = '复制';
135
+ }, 2000);
136
+ }
137
+ }
138
+ });
139
+ });
140
+ }
141
+
142
+ // 在页面加载时初始化
143
+ initializeCopyButtons();
144
+
145
+ // 在 Astro 页面切换时重新初始化
146
+ document.addEventListener('astro:page-load', initializeCopyButtons);
147
+ </script>