@coffic/cosy-ui 0.6.26 → 0.6.30

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 (126) hide show
  1. package/README.md +1 -0
  2. package/dist/{components/base → alert}/Alert.astro +6 -3
  3. package/dist/alert/AlertBasic.astro +11 -0
  4. package/dist/alert/AlertCustomStyle.astro +14 -0
  5. package/dist/alert/AlertTypes.astro +17 -0
  6. package/dist/alert/AlertWithTitle.astro +12 -0
  7. package/dist/alert/index.ts +20 -0
  8. package/dist/app.css +1 -1
  9. package/dist/{components/typography → article}/Article.astro +2 -2
  10. package/dist/article/ArticleBasic.astro +31 -0
  11. package/dist/article/index.ts +11 -0
  12. package/dist/{components/base → button}/Button.astro +1 -2
  13. package/dist/button/ButtonBasic.astro +18 -0
  14. package/dist/button/ButtonShapes.astro +23 -0
  15. package/dist/button/ButtonSizes.astro +15 -0
  16. package/dist/button/ButtonStates.astro +12 -0
  17. package/dist/button/ButtonWithIcons.astro +25 -0
  18. package/dist/button/index.ts +23 -0
  19. package/dist/components/containers/Main.astro +1 -2
  20. package/dist/components/data-display/ProductCard.astro +2 -1
  21. package/dist/components/data-display/TeamMember.astro +2 -1
  22. package/dist/components/data-display/TeamMembers.astro +2 -1
  23. package/dist/components/display/Hero.astro +1 -1
  24. package/dist/components/display/Modal.astro +1 -1
  25. package/dist/{components/errors → errors}/404.astro +1 -1
  26. package/dist/errors/404Basic.astro +5 -0
  27. package/dist/errors/index.ts +11 -0
  28. package/dist/flex/FlexBasic.astro +9 -0
  29. package/dist/flex/index.ts +11 -0
  30. package/dist/{components/layouts → footer}/Footer.astro +8 -8
  31. package/dist/footer/FooterBasic.astro +12 -0
  32. package/dist/footer/FooterSection.astro +46 -0
  33. package/dist/footer/index.ts +11 -0
  34. package/dist/{components/layouts → grid}/Grid.astro +1 -1
  35. package/dist/grid/GridBasic.astro +9 -0
  36. package/dist/grid/index.ts +11 -0
  37. package/dist/{components/layouts → header}/Header.astro +20 -56
  38. package/dist/header/HeaderBasic.astro +14 -0
  39. package/dist/header/HeaderCustomNavbarCenter.astro +23 -0
  40. package/dist/header/HeaderCustomNavbarEnd.astro +20 -0
  41. package/dist/header/HeaderCustomNavbarStart.astro +20 -0
  42. package/dist/header/HeaderCustomPosition.astro +23 -0
  43. package/dist/header/HeaderWithNavigation.astro +22 -0
  44. package/dist/header/index.ts +26 -0
  45. package/dist/{components/typography → heading}/Heading.astro +2 -2
  46. package/dist/heading/HeadingBasic.astro +10 -0
  47. package/dist/heading/index.ts +11 -0
  48. package/dist/{components/base → image}/Image.astro +9 -7
  49. package/dist/image/ImageBasic.astro +1 -0
  50. package/dist/image/ImageEffects.astro +32 -0
  51. package/dist/image/ImageLoading.astro +35 -0
  52. package/dist/image/index.ts +17 -0
  53. package/dist/index.ts +2 -95
  54. package/dist/index_astro.ts +78 -0
  55. package/dist/index_utils.ts +8 -0
  56. package/dist/{components/navigation → language-switcher}/LanguageSwitcher.astro +3 -3
  57. package/dist/language-switcher/LanguageSwitcherBasic.astro +7 -0
  58. package/dist/language-switcher/index.ts +11 -0
  59. package/dist/{components/layouts → layout-app}/AppLayout.astro +25 -5
  60. package/dist/layout-app/AppLayoutBasic.astro +53 -0
  61. package/dist/layout-app/index.ts +11 -0
  62. package/dist/{components/layouts → layout-basic}/BaseLayout.astro +2 -2
  63. package/dist/layout-basic/BaseLayoutBasic.astro +16 -0
  64. package/dist/layout-basic/index.ts +11 -0
  65. package/dist/{components/layouts → layout-dashboard}/DashboardLayout.astro +2 -2
  66. package/dist/layout-dashboard/DashboardLayoutBasic.astro +48 -0
  67. package/dist/layout-dashboard/index.ts +11 -0
  68. package/dist/{components/base → link}/Link.astro +1 -1
  69. package/dist/link/LinkAnimations.astro +21 -0
  70. package/dist/link/LinkBasic.astro +17 -0
  71. package/dist/link/LinkVariants.astro +20 -0
  72. package/dist/link/index.ts +17 -0
  73. package/dist/module/Module.astro +61 -0
  74. package/dist/module/ModuleBasic.astro +12 -0
  75. package/dist/module/ModuleCustom.astro +14 -0
  76. package/dist/module/ModuleGrid.astro +26 -0
  77. package/dist/module/index.ts +17 -0
  78. package/dist/{components/layouts → nav-item}/NavItems.astro +2 -3
  79. package/dist/nav-item/NavItemsBasic.astro +27 -0
  80. package/dist/nav-item/index.ts +11 -0
  81. package/dist/nav-section/NavSection.astro +42 -0
  82. package/dist/nav-section/NavSectionBasic.astro +12 -0
  83. package/dist/nav-section/index.ts +11 -0
  84. package/dist/{components/layouts → sidebar}/Sidebar.astro +5 -6
  85. package/dist/sidebar/SidebarBasic.astro +1 -0
  86. package/dist/sidebar/index.ts +11 -0
  87. package/dist/{components/layouts → sidebar-nav}/SidebarNav.astro +3 -3
  88. package/dist/sidebar-nav/SidebarNavBasic.astro +32 -0
  89. package/dist/sidebar-nav/index.ts +11 -0
  90. package/dist/speak/Speak.astro +65 -0
  91. package/dist/speak/SpeakBasic.astro +13 -0
  92. package/dist/speak/SpeakGrid.astro +29 -0
  93. package/dist/speak/index.ts +14 -0
  94. package/dist/{components/layouts → stack}/Stack.astro +1 -1
  95. package/dist/stack/StackBasic.astro +15 -0
  96. package/dist/stack/index.ts +11 -0
  97. package/dist/{components/typography → text}/Text.astro +1 -1
  98. package/dist/text/TextBasic.astro +12 -0
  99. package/dist/text/TextSizes.astro +11 -0
  100. package/dist/text/index.ts +11 -0
  101. package/dist/theme-item/ThemeItem.astro +45 -0
  102. package/dist/theme-item/ThemeItemBasic.astro +10 -0
  103. package/dist/theme-item/index.ts +11 -0
  104. package/dist/{components/navigation → theme-switcher}/ThemeSwitcher.astro +4 -4
  105. package/dist/theme-switcher/ThemeSwitcherBasic.astro +7 -0
  106. package/dist/theme-switcher/index.ts +11 -0
  107. package/dist/{components/navigation → toc}/TableOfContents.astro +3 -3
  108. package/dist/toc/TableOfContentsBasic.astro +25 -0
  109. package/dist/toc/index.ts +11 -0
  110. package/dist/types/image.ts +16 -0
  111. package/dist/types/menu.ts +24 -0
  112. package/dist/utils/component.ts +39 -0
  113. package/dist/vue/AlertDialog/index.ts +3 -41
  114. package/dist/vue/BannerBox/index.ts +9 -44
  115. package/dist/vue/BlogList/index.ts +5 -27
  116. package/dist/vue/Buttons/index.ts +5 -27
  117. package/dist/vue/ConfirmDialog/index.ts +3 -41
  118. package/dist/vue/MacWindow/index.ts +7 -21
  119. package/dist/vue/SmartHero/index.ts +4 -26
  120. package/dist/vue/iPhone/index.ts +5 -18
  121. package/package.json +7 -7
  122. package/dist/components/base/Module.astro +0 -18
  123. package/dist/components/base/Speak.astro +0 -22
  124. package/dist/components/base/ThemeItem.astro +0 -21
  125. package/dist/components/layouts/NavSection.astro +0 -32
  126. /package/dist/{components/layouts → flex}/Flex.astro +0 -0
@@ -0,0 +1,31 @@
1
+ ---
2
+ import Article from './Article.astro';
3
+ ---
4
+
5
+ <Article>
6
+ <h1>文章标题</h1>
7
+ <p>这是一段介绍性文字,可以包含<a href="#">链接</a>和<code>行内代码</code>。</p>
8
+
9
+ <h2>二级标题</h2>
10
+ <p>这是二级标题下的段落内容。</p>
11
+
12
+ <blockquote>这是一段引用内容,可以用来强调重要信息或引用他人的话。</blockquote>
13
+
14
+ <h3>三级标题</h3>
15
+ <ul>
16
+ <li>无序列表项一</li>
17
+ <li>无序列表项二</li>
18
+ </ul>
19
+
20
+ <h4>四级标题</h4>
21
+ <ol>
22
+ <li>有序列表项一</li>
23
+ <li>有序列表项二</li>
24
+ </ol>
25
+
26
+ <pre><code>// 这是一个代码块
27
+ function example() &#123;
28
+ return "示例代码";
29
+ &#125;
30
+ </code></pre>
31
+ </Article>
@@ -0,0 +1,11 @@
1
+ import Article from './Article.astro';
2
+ import ArticleBasic from './ArticleBasic.astro';
3
+ import BasicSourceCode from './ArticleBasic.astro?raw';
4
+ import { extractSimpleExample } from '../utils/component';
5
+
6
+ export { Article, ArticleBasic };
7
+
8
+ // 导出示例源代码
9
+ export const ArticleExampleCodes = {
10
+ Basic: extractSimpleExample(BasicSourceCode, 'Article'),
11
+ };
@@ -49,7 +49,7 @@
49
49
  */
50
50
 
51
51
  // 导入样式
52
- import '../../style.ts';
52
+ import '../style.ts';
53
53
 
54
54
  interface Props {
55
55
  variant?:
@@ -159,4 +159,3 @@ const buttonClasses = getButtonClasses();
159
159
  <slot name="icon-right" />
160
160
  </span>
161
161
  </button>
162
-
@@ -0,0 +1,18 @@
1
+ ---
2
+ import Button from './Button.astro';
3
+ ---
4
+
5
+ <div class="cosy:flex cosy:flex-wrap cosy:gap-2">
6
+ <Button>默认按钮</Button>
7
+ <Button variant="primary">主要按钮</Button>
8
+ <Button variant="secondary">次要按钮</Button>
9
+ <Button variant="accent">强调按钮</Button>
10
+ <Button variant="info">信息按钮</Button>
11
+ <Button variant="success">成功按钮</Button>
12
+ <Button variant="warning">警告按钮</Button>
13
+ <Button variant="error">错误按钮</Button>
14
+ <Button variant="ghost">幽灵按钮</Button>
15
+ <Button variant="link">链接按钮</Button>
16
+ <Button variant="outline">轮廓按钮</Button>
17
+ <Button variant="neutral">中性按钮</Button>
18
+ </div>
@@ -0,0 +1,23 @@
1
+ ---
2
+ import Button from './Button.astro';
3
+ ---
4
+
5
+ <div class="cosy:flex cosy:flex-wrap cosy:gap-2">
6
+ <Button>默认形状</Button>
7
+
8
+ <Button shape="circle" variant="primary">
9
+ <span slot="icon-left">🔄</span>
10
+ </Button>
11
+
12
+ <Button shape="square" variant="success">
13
+ <span slot="icon-left">✨</span>
14
+ </Button>
15
+
16
+ <Button shape="circle" variant="warning" size="lg">
17
+ <span slot="icon-left">⚡</span>
18
+ </Button>
19
+
20
+ <Button shape="square" variant="error" size="sm">
21
+ <span slot="icon-left">❌</span>
22
+ </Button>
23
+ </div>
@@ -0,0 +1,15 @@
1
+ ---
2
+ import Button from './Button.astro';
3
+ ---
4
+
5
+ <div class="cosy:flex cosy:items-center cosy:gap-2">
6
+ <Button size="xs">超小按钮</Button>
7
+ <Button size="sm">小型按钮</Button>
8
+ <Button size="md">中等按钮</Button>
9
+ <Button size="lg">大型按钮</Button>
10
+ </div>
11
+
12
+ <div class="cosy:mt-4 cosy:flex cosy:items-center cosy:gap-2">
13
+ <Button size="lg" wide>宽按钮</Button>
14
+ <Button block>块级按钮</Button>
15
+ </div>
@@ -0,0 +1,12 @@
1
+ ---
2
+ import Button from './Button.astro';
3
+ ---
4
+
5
+ <div class="cosy:flex cosy:flex-wrap cosy:gap-2">
6
+ <Button>正常按钮</Button>
7
+ <Button disabled>禁用按钮</Button>
8
+ <Button loading>加载中</Button>
9
+ <Button variant="primary" loading>加载中</Button>
10
+ <Button variant="success" disabled>禁用成功按钮</Button>
11
+ <Button variant="error" loading>处理错误中</Button>
12
+ </div>
@@ -0,0 +1,25 @@
1
+ ---
2
+ import Button from './Button.astro';
3
+ ---
4
+
5
+ <div class="cosy:flex cosy:flex-wrap cosy:gap-2">
6
+ <Button variant="primary">
7
+ <span slot="icon-left">👈</span>
8
+ 返回
9
+ </Button>
10
+
11
+ <Button variant="success">
12
+ 确认
13
+ <span slot="icon-right">✅</span>
14
+ </Button>
15
+
16
+ <Button variant="info">
17
+ <span slot="icon-left">💾</span>
18
+ 保存
19
+ <span slot="icon-right">📁</span>
20
+ </Button>
21
+
22
+ <Button variant="warning" shape="circle">
23
+ <span slot="icon-left">⚠️</span>
24
+ </Button>
25
+ </div>
@@ -0,0 +1,23 @@
1
+ import Button from './Button.astro';
2
+ import ButtonBasic from './ButtonBasic.astro';
3
+ import ButtonSizes from './ButtonSizes.astro';
4
+ import ButtonStates from './ButtonStates.astro';
5
+ import ButtonWithIcons from './ButtonWithIcons.astro';
6
+ import ButtonShapes from './ButtonShapes.astro';
7
+ import BasicSourceCode from './ButtonBasic.astro?raw';
8
+ import SizesSourceCode from './ButtonSizes.astro?raw';
9
+ import StatesSourceCode from './ButtonStates.astro?raw';
10
+ import WithIconsSourceCode from './ButtonWithIcons.astro?raw';
11
+ import ShapesSourceCode from './ButtonShapes.astro?raw';
12
+ import { extractSimpleExample } from '../utils/component';
13
+
14
+ export { Button, ButtonBasic, ButtonSizes, ButtonStates, ButtonWithIcons, ButtonShapes };
15
+
16
+ // 导出示例源代码
17
+ export const ButtonExampleCodes = {
18
+ Basic: extractSimpleExample(BasicSourceCode, 'Button'),
19
+ Sizes: extractSimpleExample(SizesSourceCode, 'Button'),
20
+ States: extractSimpleExample(StatesSourceCode, 'Button'),
21
+ WithIcons: extractSimpleExample(WithIconsSourceCode, 'Button'),
22
+ Shapes: extractSimpleExample(ShapesSourceCode, 'Button'),
23
+ };
@@ -49,8 +49,7 @@
49
49
  */
50
50
  import '../../style.ts';
51
51
  import type { IMainContentProps } from '../../index';
52
- import Article from '../typography/Article.astro';
53
- import TableOfContents from '../navigation/TableOfContents.astro';
52
+ import { Article, TableOfContents } from '../../index';
54
53
 
55
54
  export interface Props extends IMainContentProps {}
56
55
 
@@ -68,6 +68,7 @@
68
68
 
69
69
  import { SocialIcon, Image, Link } from '../../index';
70
70
  import '../../style.ts';
71
+ import type { ImageSource } from '../../types/image';
71
72
 
72
73
  // 自定义图片元数据接口,替代 astro 的 ImageMetadata
73
74
  interface CustomImageMetadata {
@@ -87,7 +88,7 @@ export interface Props {
87
88
  /**
88
89
  * 产品图片
89
90
  */
90
- image: CustomImageMetadata | string;
91
+ image: ImageSource;
91
92
  /**
92
93
  * 产品描述
93
94
  */
@@ -42,6 +42,7 @@
42
42
 
43
43
  import { SocialIcon, Image, Link } from '../../index';
44
44
  import '../../style.ts';
45
+ import type { ImageSource } from '../../types/image';
45
46
 
46
47
  interface SocialLink {
47
48
  /**
@@ -74,7 +75,7 @@ export interface Props {
74
75
  /**
75
76
  * 团队成员头像
76
77
  */
77
- avatar: CustomImageMetadata | string;
78
+ avatar: ImageSource;
78
79
  /**
79
80
  * 团队成员简介
80
81
  */
@@ -31,6 +31,7 @@
31
31
 
32
32
  import TeamMember from './TeamMember.astro';
33
33
  import '../../style.ts';
34
+ import type { ImageSource } from '../../types/image';
34
35
 
35
36
  // 自定义图片元数据接口
36
37
  interface ImageMetadata {
@@ -48,7 +49,7 @@ interface SocialLink {
48
49
  interface TeamMemberData {
49
50
  name: string;
50
51
  role: string;
51
- avatar: ImageMetadata | string;
52
+ avatar: ImageSource;
52
53
  bio: string;
53
54
  socialLinks?: SocialLink[];
54
55
  }
@@ -151,7 +151,7 @@
151
151
  */
152
152
 
153
153
  import '../../style.ts';
154
- import Link from '../base/Link.astro';
154
+ import { Link } from '../../index';
155
155
 
156
156
  interface Link {
157
157
  text: string;
@@ -45,7 +45,7 @@
45
45
  */
46
46
 
47
47
  import '../../style.ts';
48
- import Button from '../base/Button.astro';
48
+ import { Button } from '../../index';
49
49
 
50
50
  interface Props {
51
51
  /**
@@ -1,5 +1,5 @@
1
1
  ---
2
- import { LinkUtil } from '../../utils/link';
2
+ import { LinkUtil } from '../utils/link';
3
3
  const baseUrl = LinkUtil.getBaseUrl();
4
4
  const path = Astro.url.pathname;
5
5
 
@@ -0,0 +1,5 @@
1
+ ---
2
+ import Error404 from './404.astro';
3
+ ---
4
+
5
+ <Error404 debugKVs={{ reason: '示例:页面不存在', try: '请检查链接是否正确' }} />
@@ -0,0 +1,11 @@
1
+ import Error404 from './404.astro';
2
+ import Error404Basic from './404Basic.astro';
3
+ import BasicSourceCode from './404Basic.astro?raw';
4
+ import { extractSimpleExample } from '../utils/component';
5
+
6
+ export { Error404, Error404Basic };
7
+
8
+ // 导出示例源代码
9
+ export const Error404ExampleCodes = {
10
+ Basic: extractSimpleExample(BasicSourceCode, 'Error404'),
11
+ };
@@ -0,0 +1,9 @@
1
+ ---
2
+ import Flex from './Flex.astro';
3
+ ---
4
+
5
+ <Flex gap="md" justify="center" align="center" style="height: 200px; background: #f3f4f6;">
6
+ <div style="background: #60a5fa; color: white; padding: 16px; border-radius: 8px;">元素 1</div>
7
+ <div style="background: #34d399; color: white; padding: 16px; border-radius: 8px;">元素 2</div>
8
+ <div style="background: #f59e42; color: white; padding: 16px; border-radius: 8px;">元素 3</div>
9
+ </Flex>
@@ -0,0 +1,11 @@
1
+ import Flex from './Flex.astro';
2
+ import FlexBasic from './FlexBasic.astro';
3
+ import BasicSourceCode from './FlexBasic.astro?raw';
4
+ import { extractSimpleExample } from '../utils/component';
5
+
6
+ export { Flex, FlexBasic };
7
+
8
+ // 导出示例源代码
9
+ export const FlexExampleCodes = {
10
+ Basic: extractSimpleExample(BasicSourceCode, 'Flex'),
11
+ };
@@ -145,10 +145,10 @@
145
145
  * - 社交媒体图标包含屏幕阅读器专用的文本说明
146
146
  */
147
147
 
148
- import { processSocialLink } from '../../utils/social';
149
- import { SocialIcon, LanguageUtil, type IFooterProps, createTextGetter } from '../../index';
150
- import NavSection from './NavSection.astro';
151
- import '../../style.ts';
148
+ import { processSocialLink } from '../utils/social.ts';
149
+ import { SocialIcon, LanguageUtil, type IFooterProps, createTextGetter } from '../index';
150
+ import FooterSection from './FooterSection.astro';
151
+ import '../style.ts';
152
152
 
153
153
  const {
154
154
  siteName,
@@ -259,12 +259,12 @@ const debugClasses = debug
259
259
  debugClasses.section,
260
260
  ]}>
261
261
  {/* 产品导航 */}
262
- {products.length > 0 && <NavSection title={t('products')} links={products} />}
262
+ {products.length > 0 && <FooterSection title={t('products')} links={products} />}
263
263
 
264
264
  {/* 关于导航 */}
265
265
  {
266
266
  (aboutLink || contactLink || teamLink || careersLink) && (
267
- <NavSection
267
+ <FooterSection
268
268
  title={t('about')}
269
269
  links={[
270
270
  { name: t('aboutUs'), href: aboutLink },
@@ -285,7 +285,7 @@ const debugClasses = debug
285
285
  faqLink ||
286
286
  mediaLink ||
287
287
  techStackLink) && (
288
- <NavSection
288
+ <FooterSection
289
289
  title={t('resources')}
290
290
  links={[
291
291
  { name: t('news'), href: newsLink },
@@ -301,7 +301,7 @@ const debugClasses = debug
301
301
  {/* 法律导航 */}
302
302
  {
303
303
  (termsLink || privacyLink) && (
304
- <NavSection
304
+ <FooterSection
305
305
  title={t('legal')}
306
306
  links={[
307
307
  { name: t('terms'), href: termsLink },
@@ -0,0 +1,12 @@
1
+ ---
2
+ import Footer from './Footer.astro';
3
+ ---
4
+
5
+ <Footer
6
+ siteName="我的网站"
7
+ homeLink="/"
8
+ slogan="简单而强大"
9
+ company="我的公司"
10
+ copyright="保留所有权利"
11
+ inspirationalSlogan="构建美好的数字体验"
12
+ />
@@ -0,0 +1,46 @@
1
+ ---
2
+ /**
3
+ * @component FooterSection
4
+ *
5
+ * @description
6
+ * FooterSection 组件用于在页脚中显示一组链接,通常用于导航、产品列表等。
7
+ */
8
+
9
+ interface Link {
10
+ name: string;
11
+ href?: string;
12
+ }
13
+
14
+ interface Props {
15
+ /**
16
+ * 区块标题
17
+ */
18
+ title: string;
19
+
20
+ /**
21
+ * 链接列表
22
+ */
23
+ links: Link[];
24
+ }
25
+
26
+ const { title, links } = Astro.props;
27
+ ---
28
+
29
+ <nav class="cosy:flex cosy:flex-col cosy:gap-2">
30
+ <h6 class="cosy:footer-title">{title}</h6>
31
+ <ul class="cosy:flex cosy:flex-col cosy:gap-2">
32
+ {
33
+ links.map((link) => (
34
+ <li>
35
+ {link.href ? (
36
+ <a href={link.href} class="cosy:link cosy:link-hover">
37
+ {link.name}
38
+ </a>
39
+ ) : (
40
+ <span class="cosy:opacity-50">{link.name}</span>
41
+ )}
42
+ </li>
43
+ ))
44
+ }
45
+ </ul>
46
+ </nav>
@@ -0,0 +1,11 @@
1
+ import Footer from './Footer.astro';
2
+ import FooterBasic from './FooterBasic.astro';
3
+ import BasicSourceCode from './FooterBasic.astro?raw';
4
+ import { extractSimpleExample } from '../utils/component';
5
+
6
+ export { Footer, FooterBasic };
7
+
8
+ // 导出示例源代码
9
+ export const FooterExampleCodes = {
10
+ Basic: extractSimpleExample(BasicSourceCode, 'Footer'),
11
+ };
@@ -52,7 +52,7 @@
52
52
  */
53
53
 
54
54
  // 导入样式
55
- import '../../style.ts';
55
+ import '../style.ts';
56
56
 
57
57
  import type { HTMLAttributes } from 'astro/types';
58
58
 
@@ -0,0 +1,9 @@
1
+ ---
2
+ import Grid from './Grid.astro';
3
+ ---
4
+
5
+ <Grid cols={3} gap="md">
6
+ <div style="background: #60a5fa; color: white; padding: 16px; border-radius: 8px;">第一列</div>
7
+ <div style="background: #34d399; color: white; padding: 16px; border-radius: 8px;">第二列</div>
8
+ <div style="background: #f59e42; color: white; padding: 16px; border-radius: 8px;">第三列</div>
9
+ </Grid>
@@ -0,0 +1,11 @@
1
+ import Grid from './Grid.astro';
2
+ import GridBasic from './GridBasic.astro';
3
+ import BasicSourceCode from './GridBasic.astro?raw';
4
+ import { extractSimpleExample } from '../utils/component';
5
+
6
+ export { Grid, GridBasic };
7
+
8
+ // 导出示例源代码
9
+ export const GridExampleCodes = {
10
+ Basic: extractSimpleExample(BasicSourceCode, 'Grid'),
11
+ };
@@ -12,57 +12,18 @@
12
12
  * 2. 响应式适配 - 在移动端和桌面端都有合适的展现形式
13
13
  * 3. 可定制性 - 支持多种配置选项,适应不同网站的风格和需求
14
14
  * 4. 多语言支持 - 内置语言切换功能,便于构建国际化网站
15
- *
16
- * @usage
17
- * 基本用法:
18
- * ```astro
19
- * <Header
20
- * logo={import("../assets/logo.png")}
21
- * logoHref="/"
22
- * navItems={[
23
- * { href: "/docs", label: "文档", match: (path) => path.startsWith("/docs") },
24
- * { href: "/components", label: "组件", match: (path) => path.startsWith("/components") }
25
- * ]}
26
- * />
27
- * ```
28
- *
29
- * 自定义导航菜单位置:
30
- * ```astro
31
- * <Header
32
- * logo={import("../assets/logo.png")}
33
- * navPosition="start"
34
- * navItems={[
35
- * { href: "/docs", label: "文档", match: (path) => path.startsWith("/docs") },
36
- * { href: "/components", label: "组件", match: (path) => path.startsWith("/components") }
37
- * ]}
38
- * />
39
- * ```
40
- * navPosition 可选值:
41
- * - start: 导航菜单在左侧
42
- * - center: 导航菜单在中间(默认)
43
- * - end: 导航菜单在右侧
44
- *
45
- * 自定义语言选项:
46
- * ```astro
47
- * <Header
48
- * logo={import("../assets/logo.png")}
49
- * languages={["zh-cn", "en", "ja"]}
50
- * />
51
- * ```
52
- *
53
- * 自定义高度:
54
- * ```astro
55
- * <Header
56
- * logo={import("../assets/logo.png")}
57
- * height="lg"
58
- * />
59
15
  */
60
- import '../../style.ts';
61
- import Link from '../base/Link.astro';
62
- import Image from '../base/Image.astro';
63
- import NavItems from './NavItems.astro';
64
- import { LanguageSwitcher, LinkUtil, type IHeaderProps, type INavItem } from '../../index';
65
- import Logo from '../../assets/logo-rounded.png';
16
+ import '../style.ts';
17
+ import {
18
+ LanguageSwitcher,
19
+ LinkUtil,
20
+ type IHeaderProps,
21
+ type INavItem,
22
+ NavItems,
23
+ Link,
24
+ Image,
25
+ } from '../index';
26
+ import Logo from '../assets/logo-rounded.png';
66
27
 
67
28
  export interface Props extends IHeaderProps {
68
29
  debug?: boolean;
@@ -207,15 +168,17 @@ const activeLink = LinkUtil.getActiveLink(
207
168
  </Link>
208
169
  )
209
170
  }
171
+ <slot name="navbar-start" />
210
172
  </div>
211
173
 
212
- {
213
- navPosition === 'center' && (
214
- <div class="cosy:hidden cosy:lg:flex cosy:navbar-center">
174
+ <div class="cosy:hidden cosy:lg:flex cosy:navbar-center">
175
+ {
176
+ navPosition === 'center' && (
215
177
  <NavItems navItems={navItems} activeLink={activeLink} linkHeightClass={linkHeightClass} />
216
- </div>
217
- )
218
- }
178
+ )
179
+ }
180
+ <slot name="navbar-center" />
181
+ </div>
219
182
 
220
183
  <div class="cosy:navbar-end cosy:pr-1">
221
184
  {
@@ -230,6 +193,7 @@ const activeLink = LinkUtil.getActiveLink(
230
193
  )
231
194
  }
232
195
  <LanguageSwitcher languages={languages} />
196
+ <slot name="navbar-end" />
233
197
  </div>
234
198
  </div>
235
199
  </header>
@@ -0,0 +1,14 @@
1
+ ---
2
+ /**
3
+ * @component Header.Basic
4
+ *
5
+ * @description
6
+ * Header组件的基础示例,展示最基本的顶部导航栏,包含logo和语言切换功能。
7
+ */
8
+ import Header from './Header.astro';
9
+ import { getExampleImage } from '../utils/image';
10
+
11
+ const logo = getExampleImage({ width: 100, height: 100, provider: 'picsum', tag: 'tech' });
12
+ ---
13
+
14
+ <Header logoHref={logo} rounded="lg" sticky={false} />
@@ -0,0 +1,23 @@
1
+ ---
2
+ /**
3
+ * @component Header.CustomNavbarCenter
4
+ *
5
+ * @description
6
+ * 自定义导航栏中间内容的Header组件示例,展示如何使用slot自定义中间内容。
7
+ */
8
+ import '../style.ts';
9
+ import Header from './Header.astro';
10
+ import { getExampleImage } from '../utils/image';
11
+
12
+ const logo = getExampleImage({ width: 100, height: 100, provider: 'picsum', tag: 'tech' });
13
+ ---
14
+
15
+ <Header logoHref={logo} rounded="lg" sticky={false}>
16
+ <div slot="navbar-center" class="cosy:flex cosy:items-center cosy:gap-4">
17
+ <span class="cosy:badge cosy:badge-accent">新功能</span>
18
+ <div class="cosy:divider cosy:divider-horizontal"></div>
19
+ <span class="cosy:badge cosy:badge-secondary">热门</span>
20
+ <div class="cosy:divider cosy:divider-horizontal"></div>
21
+ <span class="cosy:badge">推荐</span>
22
+ </div>
23
+ </Header>
@@ -0,0 +1,20 @@
1
+ ---
2
+ /**
3
+ * @component Header.CustomNavbarEnd
4
+ *
5
+ * @description
6
+ * 自定义导航栏右侧内容的Header组件示例,展示如何使用slot自定义右侧内容。
7
+ */
8
+ import '../style.ts';
9
+ import Header from './Header.astro';
10
+ import { getExampleImage } from '../utils/image';
11
+
12
+ const logo = getExampleImage({ width: 100, height: 100, provider: 'picsum', tag: 'tech' });
13
+ ---
14
+
15
+ <Header logoHref={logo} rounded="lg" sticky={false}>
16
+ <div slot="navbar-end" class="cosy:flex cosy:items-center cosy:gap-2">
17
+ <button class="cosy:btn cosy:btn-sm cosy:btn-ghost">登录</button>
18
+ <button class="cosy:btn cosy:btn-sm cosy:btn-primary">注册</button>
19
+ </div>
20
+ </Header>
@@ -0,0 +1,20 @@
1
+ ---
2
+ /**
3
+ * @component Header.CustomNavbarStart
4
+ *
5
+ * @description
6
+ * 自定义导航栏左侧内容的Header组件示例,展示如何使用slot自定义左侧内容。
7
+ */
8
+ import '../style.ts';
9
+ import Header from './Header.astro';
10
+ import { getExampleImage } from '../utils/image';
11
+
12
+ const logo = getExampleImage({ width: 100, height: 100, provider: 'picsum', tag: 'tech' });
13
+ ---
14
+
15
+ <Header logoHref={logo} rounded="lg" sticky={false}>
16
+ <div slot="navbar-start" class="cosy:flex cosy:items-center cosy:gap-2 cosy:ml-2">
17
+ <button class="cosy:btn cosy:btn-sm cosy:btn-primary">联系我们</button>
18
+ <span class="cosy:badge cosy:badge-outline">在线咨询</span>
19
+ </div>
20
+ </Header>