@coffic/cosy-ui 0.6.32 → 0.6.34
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/alert/AlertBasicContainer.astro +11 -0
- package/dist/alert/AlertCustomStyleContainer.astro +11 -0
- package/dist/alert/AlertError.astro +6 -0
- package/dist/alert/AlertInfo.astro +6 -0
- package/dist/alert/AlertSuccess.astro +6 -0
- package/dist/alert/AlertTypesContainer.astro +43 -0
- package/dist/alert/AlertWarning.astro +6 -0
- package/dist/alert/AlertWithTitleContainer.astro +11 -0
- package/dist/alert/index.ts +14 -18
- package/dist/app.css +1 -1
- package/dist/{components/display → banner}/Banner.astro +32 -11
- package/dist/banner/BannerAllAnimations.astro +10 -0
- package/dist/banner/BannerBasic.astro +5 -0
- package/dist/banner/BannerCustomStyle.astro +7 -0
- package/dist/banner/BannerDanger.astro +5 -0
- package/dist/banner/BannerFadeIn.astro +5 -0
- package/dist/banner/BannerInfo.astro +5 -0
- package/dist/banner/BannerPrimary.astro +5 -0
- package/dist/banner/BannerSecondary.astro +5 -0
- package/dist/banner/BannerSlideUp.astro +5 -0
- package/dist/banner/BannerSuccess.astro +5 -0
- package/dist/banner/BannerWarning.astro +5 -0
- package/dist/banner/index.ts +41 -0
- package/dist/{components/data-display → blog}/Blog.astro +2 -2
- package/dist/blog/index.ts +1 -0
- package/dist/button/Button.astro +42 -14
- package/dist/button/Button.vue +105 -0
- package/dist/button/ButtonBasic.vue +11 -0
- package/dist/button/ButtonBasicContainer.astro +17 -0
- package/dist/button/ButtonBlock.astro +5 -0
- package/dist/button/ButtonError.astro +5 -0
- package/dist/{vue/Buttons/FeatureButton.vue → button/ButtonFeature.vue} +23 -23
- package/dist/{vue/Buttons/FeatureBasic.vue → button/ButtonFeatureBasic.vue} +2 -2
- package/dist/button/ButtonFeatureContainer.astro +18 -0
- package/dist/{vue/Buttons/FeatureWithTips.vue → button/ButtonFeatureWithTips.vue} +1 -2
- package/dist/button/ButtonGhost.astro +5 -0
- package/dist/button/ButtonIconBoth.astro +9 -0
- package/dist/button/ButtonIconLeft.astro +8 -0
- package/dist/button/ButtonIconRight.astro +8 -0
- package/dist/button/ButtonInfo.astro +5 -0
- package/dist/button/ButtonLink.astro +5 -0
- package/dist/button/ButtonLink.vue +13 -0
- package/dist/button/ButtonLinkContainer.astro +25 -0
- package/dist/button/ButtonLinkExternal.astro +8 -0
- package/dist/button/ButtonNeutral.astro +5 -0
- package/dist/button/ButtonOutline.astro +5 -0
- package/dist/button/ButtonShapeCircle.astro +5 -0
- package/dist/button/ButtonShapeDefault.astro +5 -0
- package/dist/button/ButtonShapeSquare.astro +5 -0
- package/dist/button/ButtonShapesContainer.astro +25 -0
- package/dist/button/ButtonSizes.astro +1 -1
- package/dist/button/ButtonSizes.vue +12 -0
- package/dist/button/ButtonSizesContainer.astro +17 -0
- package/dist/button/ButtonStatesContainer.astro +11 -0
- package/dist/button/ButtonSuccess.astro +5 -0
- package/dist/button/ButtonVariants.astro +14 -0
- package/dist/button/ButtonVariants.vue +16 -0
- package/dist/button/ButtonVariantsContainer.astro +71 -0
- package/dist/button/ButtonWarning.astro +5 -0
- package/dist/button/ButtonWide.astro +5 -0
- package/dist/button/ButtonWidth.astro +8 -0
- package/dist/button/ButtonWidthContainer.astro +19 -0
- package/dist/button/ButtonWithIcons.vue +21 -0
- package/dist/button/ButtonWithIconsContainer.astro +36 -0
- package/dist/button/index_astro.ts +64 -0
- package/dist/button/index_vue.ts +4 -0
- package/dist/card/Card.astro +91 -0
- package/dist/card/CardBasic.astro +5 -0
- package/dist/card/CardCompact.astro +77 -0
- package/dist/card/CardLink.astro +75 -0
- package/dist/card/CardWithImage.astro +39 -0
- package/dist/card/index.ts +7 -0
- package/dist/{components/display → code-block}/CodeBlock.astro +1 -1
- package/dist/code-block/index.ts +1 -0
- package/dist/code-container/CodeContainer.astro +254 -0
- package/dist/code-container/CodeContainerBasic.astro +19 -0
- package/dist/code-container/CodeContainerMultiple.astro +49 -0
- package/dist/code-container/index.ts +14 -0
- package/dist/{components/display → code-example}/CodeExample.astro +10 -11
- package/dist/code-example/index.ts +1 -0
- package/dist/{components/containers → container}/Container.astro +1 -1
- package/dist/container/index.ts +1 -0
- package/dist/env.d.ts +0 -6
- package/dist/footer/Footer.astro +2 -6
- package/dist/header/Header.astro +3 -2
- package/dist/{components/display → hero}/Hero.astro +2 -2
- package/dist/hero/HeroAlignCenter.astro +13 -0
- package/dist/hero/HeroAlignContainer.astro +23 -0
- package/dist/hero/HeroAlignLeft.astro +13 -0
- package/dist/hero/HeroAlignRight.astro +13 -0
- package/dist/hero/HeroBackgroundContainer.astro +18 -0
- package/dist/hero/HeroBackgroundImage.astro +12 -0
- package/dist/hero/HeroBackgroundImageContainer.astro +11 -0
- package/dist/hero/HeroBasic.astro +12 -0
- package/dist/hero/HeroBasicContainer.astro +11 -0
- package/dist/hero/HeroGradientBackground.astro +10 -0
- package/dist/hero/HeroPlainBackground.astro +10 -0
- package/dist/hero/HeroWithButton.astro +11 -0
- package/dist/hero/HeroWithButtonContainer.astro +11 -0
- package/dist/hero/HeroWithImage.astro +16 -0
- package/dist/hero/HeroWithImageContainer.astro +11 -0
- package/dist/hero/index.ts +39 -0
- package/dist/index.ts +1 -1
- package/dist/index_astro.ts +16 -26
- package/dist/index_vue.ts +1 -4
- package/dist/{components/containers → main}/Main.astro +2 -3
- package/dist/main/index.ts +1 -0
- package/dist/{components/display → modal}/Modal.astro +2 -2
- package/dist/modal/index.ts +1 -0
- package/dist/{components/data-display → products}/ProductCard.astro +3 -3
- package/dist/{components/data-display → products}/Products.astro +2 -2
- package/dist/products/index.ts +2 -0
- package/dist/{components/containers → section}/Section.astro +2 -2
- package/dist/section/index.ts +1 -0
- package/dist/sidebar/Sidebar.astro +1 -2
- package/dist/{components/data-display → team-member}/TeamMember.astro +4 -4
- package/dist/team-member/TeamMemberBasic.astro +25 -0
- package/dist/team-member/TeamMemberCustomStyle.astro +26 -0
- package/dist/team-member/TeamMemberGroup.astro +60 -0
- package/dist/team-member/TeamMemberWithSocial.astro +30 -0
- package/dist/{components/data-display → team-member}/TeamMembers.astro +2 -2
- package/dist/team-member/index.ts +23 -0
- package/dist/types/header.ts +32 -9
- package/package.json +5 -1
- package/dist/alert/AlertTypes.astro +0 -17
- package/dist/button/index.ts +0 -23
- package/dist/components/display/Card.astro +0 -162
- package/dist/vue/Buttons/LinkBasic.vue +0 -8
- package/dist/vue/Buttons/LinkButton.vue +0 -65
- package/dist/vue/Buttons/Multiple.vue +0 -11
- package/dist/vue/Buttons/index.ts +0 -37
- package/dist/vue/SmartHero/Basic.vue +0 -14
- package/dist/vue/SmartHero/SmartHero.vue +0 -132
- package/dist/vue/SmartHero/WithCustomContent.vue +0 -36
- package/dist/vue/SmartHero/WithImage.vue +0 -19
- package/dist/vue/SmartHero/index.ts +0 -24
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
import '../style.ts';
|
3
|
+
|
4
|
+
interface Props {
|
5
|
+
title: string;
|
6
|
+
subtitle?: string;
|
7
|
+
imageUrl: string;
|
8
|
+
class?: string;
|
9
|
+
}
|
10
|
+
|
11
|
+
const { title, subtitle, imageUrl, class: className } = Astro.props;
|
12
|
+
---
|
13
|
+
|
14
|
+
<article class={`cosy-card cosy-card--with-image ${className || ''}`}>
|
15
|
+
<div class="cosy-card__image" style={`background-image: url(${imageUrl})`} aria-hidden="true">
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<header class="cosy-card__header">
|
19
|
+
<h3 class="cosy-card__title">{title}</h3>
|
20
|
+
{subtitle && <p class="cosy-card__subtitle">{subtitle}</p>}
|
21
|
+
</header>
|
22
|
+
|
23
|
+
<div class="cosy-card__content">
|
24
|
+
<slot />
|
25
|
+
</div>
|
26
|
+
</article>
|
27
|
+
|
28
|
+
<style>
|
29
|
+
.cosy-card__image {
|
30
|
+
height: 160px;
|
31
|
+
background-size: cover;
|
32
|
+
background-position: center;
|
33
|
+
border-radius: 8px 8px 0 0;
|
34
|
+
}
|
35
|
+
|
36
|
+
.cosy-card__header {
|
37
|
+
padding-top: 1rem;
|
38
|
+
}
|
39
|
+
</style>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
export { default as Card } from './Card.astro';
|
4
|
+
export { default as CardBasic } from './CardBasic.astro';
|
5
|
+
export { default as CardWithImage } from './CardWithImage.astro';
|
6
|
+
export { default as CardLink } from './CardLink.astro';
|
7
|
+
export { default as CardCompact } from './CardCompact.astro';
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as CodeBlock} from './CodeBlock.astro';
|
@@ -0,0 +1,254 @@
|
|
1
|
+
---
|
2
|
+
/**
|
3
|
+
* @component CodeContainer
|
4
|
+
*
|
5
|
+
* @description
|
6
|
+
* 用于展示代码示例的容器组件。使用时只需在默认slot中传入内容,
|
7
|
+
* 并为每个示例设置对应的id (tab-1, tab-2等)
|
8
|
+
*
|
9
|
+
* @example
|
10
|
+
* ```astro
|
11
|
+
* <CodeContainer>
|
12
|
+
* <div id="tab-1">
|
13
|
+
* <Alert type="info">这是第一个示例</Alert>
|
14
|
+
* </div>
|
15
|
+
* <div id="tab-2">
|
16
|
+
* <Alert type="success">这是第二个示例</Alert>
|
17
|
+
* </div>
|
18
|
+
* </CodeContainer>
|
19
|
+
* ```
|
20
|
+
*/
|
21
|
+
|
22
|
+
import { ClipboardIcon, CheckIcon, InfoIcon } from '../index';
|
23
|
+
import '../style.ts';
|
24
|
+
|
25
|
+
interface Props {
|
26
|
+
/**
|
27
|
+
* tab的标题,如果不提供则使用"示例 1"这样的默认标题
|
28
|
+
*/
|
29
|
+
titles?: string[];
|
30
|
+
/**
|
31
|
+
* tab的描述文本
|
32
|
+
*/
|
33
|
+
descriptions?: string[];
|
34
|
+
/**
|
35
|
+
* 每个示例对应的源代码
|
36
|
+
*/
|
37
|
+
codes: string[];
|
38
|
+
}
|
39
|
+
|
40
|
+
const { titles = [], descriptions = [], codes } = Astro.props;
|
41
|
+
---
|
42
|
+
|
43
|
+
<div data-role="code-container" class="cosy:mb-8 cosy:card" ignore-heading>
|
44
|
+
<!-- 工具栏 -->
|
45
|
+
<div
|
46
|
+
class="cosy:flex cosy:justify-between cosy:items-center cosy:bg-base-200 cosy:px-4 cosy:rounded-t">
|
47
|
+
<!-- 标签 -->
|
48
|
+
<div class="cosy:flex cosy:items-center cosy:gap-4">
|
49
|
+
<div role="tablist" class="cosy:tabs cosy:tabs-box">
|
50
|
+
{
|
51
|
+
codes.map((_, index) => (
|
52
|
+
<button
|
53
|
+
role="tab"
|
54
|
+
class={`cosy:tab ${index === 0 ? 'cosy:tab-active' : ''}`}
|
55
|
+
data-tab={`tab-${index + 1}`}>
|
56
|
+
{titles[index] || `示例 ${index + 1}`}
|
57
|
+
</button>
|
58
|
+
))
|
59
|
+
}
|
60
|
+
</div>
|
61
|
+
</div>
|
62
|
+
|
63
|
+
<!-- 工具按钮 -->
|
64
|
+
<div class="cosy:flex cosy:items-center cosy:gap-2">
|
65
|
+
<button
|
66
|
+
role="switch"
|
67
|
+
class="cosy:btn cosy:btn-ghost cosy:btn-sm"
|
68
|
+
aria-checked="false"
|
69
|
+
aria-label="切换代码/预览"
|
70
|
+
data-toggle="code">
|
71
|
+
<span class="cosy:code-icon"><InfoIcon /></span>
|
72
|
+
</button>
|
73
|
+
<button class="cosy:gap-2 cosy:btn cosy:btn-ghost cosy:btn-sm" aria-label="复制代码">
|
74
|
+
<span class="cosy:copy-icon"><ClipboardIcon /></span>
|
75
|
+
<span class="cosy:hidden cosy:check-icon"><CheckIcon /></span>
|
76
|
+
</button>
|
77
|
+
</div>
|
78
|
+
</div>
|
79
|
+
|
80
|
+
{
|
81
|
+
codes.map((code, index) => (
|
82
|
+
<div
|
83
|
+
class={`cosy:example-container ${index === 0 ? 'cosy:block' : 'cosy:hidden'}`}
|
84
|
+
data-example={`tab-${index + 1}`}>
|
85
|
+
{/* 描述 */}
|
86
|
+
{descriptions[index] && (
|
87
|
+
<p class="cosy:px-4 cosy:py-2 cosy:bg-gradient-to-b not-prose cosy:from-blue-100/50 cosy:to-blue-100/90 ">
|
88
|
+
{descriptions[index]}
|
89
|
+
</p>
|
90
|
+
)}
|
91
|
+
|
92
|
+
<div class="cosy:relative cosy:p-4 cosy:bg-gradient-to-br cosy:from-red-100 cosy:to-green-300 cosy:rounded-b">
|
93
|
+
<div class="cosy:block cosy:code-example-panel" data-panel="preview">
|
94
|
+
<slot />
|
95
|
+
</div>
|
96
|
+
|
97
|
+
<div class="cosy:hidden cosy:code-example-panel" data-panel="code">
|
98
|
+
<pre class="cosy:overflow-x-auto" style="margin:0">
|
99
|
+
<code class="cosy:language-astro">{code}</code>
|
100
|
+
</pre>
|
101
|
+
</div>
|
102
|
+
</div>
|
103
|
+
</div>
|
104
|
+
))
|
105
|
+
}
|
106
|
+
</div>
|
107
|
+
|
108
|
+
<script>
|
109
|
+
function initializeCodeContainer() {
|
110
|
+
console.log('CodeContainer: 初始化代码容器');
|
111
|
+
|
112
|
+
// 示例切换功能
|
113
|
+
const exampleTabs = document.querySelectorAll('[role="tab"][data-tab^="tab-"]');
|
114
|
+
exampleTabs.forEach((tab) => {
|
115
|
+
tab.addEventListener('click', () => {
|
116
|
+
console.log('CodeContainer: 切换示例', tab);
|
117
|
+
const container = tab.closest('[data-role="code-container"]');
|
118
|
+
if (!container) return;
|
119
|
+
|
120
|
+
// 更新标签状态
|
121
|
+
container.querySelectorAll('[role="tab"][data-tab^="tab-"]').forEach((t) => {
|
122
|
+
t.classList.remove('cosy:tab-active');
|
123
|
+
});
|
124
|
+
tab.classList.add('cosy:tab-active');
|
125
|
+
|
126
|
+
// 获取当前标签对应的内容 id
|
127
|
+
const targetId = tab.getAttribute('data-tab');
|
128
|
+
if (!targetId) return;
|
129
|
+
|
130
|
+
// 切换示例容器
|
131
|
+
container.querySelectorAll('.cosy\\:example-container').forEach((example) => {
|
132
|
+
if (example.getAttribute('data-example') === targetId) {
|
133
|
+
example.classList.remove('cosy:hidden');
|
134
|
+
example.classList.add('cosy:block');
|
135
|
+
} else {
|
136
|
+
example.classList.add('cosy:hidden');
|
137
|
+
example.classList.remove('cosy:block');
|
138
|
+
}
|
139
|
+
});
|
140
|
+
|
141
|
+
// 更新对应内容的可见性
|
142
|
+
const allContent = container.querySelectorAll('[id^="tab-"]');
|
143
|
+
allContent.forEach((content) => {
|
144
|
+
if (content.id === targetId) {
|
145
|
+
content.classList.remove('cosy:hidden');
|
146
|
+
content.classList.add('cosy:block');
|
147
|
+
} else {
|
148
|
+
content.classList.add('cosy:hidden');
|
149
|
+
content.classList.remove('cosy:block');
|
150
|
+
}
|
151
|
+
});
|
152
|
+
});
|
153
|
+
});
|
154
|
+
|
155
|
+
// 代码开关功能
|
156
|
+
const codeToggles = document.querySelectorAll('[data-toggle="code"]');
|
157
|
+
codeToggles.forEach((toggle) => {
|
158
|
+
toggle.addEventListener('click', () => {
|
159
|
+
console.log('code toggle clicked', toggle);
|
160
|
+
const container = toggle.closest('[data-role="code-container"]');
|
161
|
+
if (!container) {
|
162
|
+
console.error('CodeContainer: 无法找到父容器');
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
|
166
|
+
// 切换开关状态
|
167
|
+
const isChecked = toggle.getAttribute('aria-checked') === 'true';
|
168
|
+
console.log('代码按钮 isChecked:', isChecked);
|
169
|
+
toggle.setAttribute('aria-checked', !isChecked ? 'true' : 'false');
|
170
|
+
toggle.classList.toggle('cosy:btn-primary', !isChecked);
|
171
|
+
toggle.classList.toggle('cosy:btn-ghost', isChecked);
|
172
|
+
|
173
|
+
// 找到当前显示的示例
|
174
|
+
const activeExample = container.querySelector(
|
175
|
+
'.cosy\\:example-container:not(.cosy\\:hidden)'
|
176
|
+
);
|
177
|
+
if (!activeExample) {
|
178
|
+
console.error('CodeContainer: 无法找到活动示例');
|
179
|
+
return;
|
180
|
+
}
|
181
|
+
|
182
|
+
// 切换面板
|
183
|
+
activeExample.querySelectorAll('.cosy\\:code-example-panel').forEach((panel) => {
|
184
|
+
if (panel.getAttribute('data-panel') === 'code') {
|
185
|
+
console.log('处理代码面板的展示/隐藏,此时的isChecked:', isChecked);
|
186
|
+
panel.classList.toggle('cosy:hidden', isChecked);
|
187
|
+
panel.classList.toggle('cosy:block', !isChecked);
|
188
|
+
} else {
|
189
|
+
console.log('处理预览面板的展示/隐藏,此时的isChecked:', isChecked);
|
190
|
+
panel.classList.toggle('cosy:hidden', !isChecked);
|
191
|
+
panel.classList.toggle('cosy:block', isChecked);
|
192
|
+
}
|
193
|
+
});
|
194
|
+
});
|
195
|
+
});
|
196
|
+
|
197
|
+
// 复制代码功能
|
198
|
+
const copyButtons = document.querySelectorAll('[aria-label="复制代码"]');
|
199
|
+
copyButtons.forEach((button) => {
|
200
|
+
button.addEventListener('click', () => {
|
201
|
+
const container = button.closest('[data-role="code-container"]');
|
202
|
+
if (!container) return;
|
203
|
+
|
204
|
+
// 确保代码面板是显示的
|
205
|
+
const codeToggle = container.querySelector('[data-toggle="code"]');
|
206
|
+
if (codeToggle?.getAttribute('aria-checked') !== 'true') {
|
207
|
+
(codeToggle as HTMLElement)?.click();
|
208
|
+
}
|
209
|
+
|
210
|
+
// 找到当前显示的示例
|
211
|
+
const activeExample = container.querySelector(
|
212
|
+
'.cosy\\:example-container:not(.cosy\\:hidden)'
|
213
|
+
);
|
214
|
+
if (!activeExample) return;
|
215
|
+
|
216
|
+
const codePanel = activeExample.querySelector('[data-panel="code"]');
|
217
|
+
if (!codePanel) return;
|
218
|
+
|
219
|
+
const codeElement = codePanel.querySelector('code');
|
220
|
+
if (!codeElement) return;
|
221
|
+
|
222
|
+
const code = codeElement.textContent || '';
|
223
|
+
|
224
|
+
// 复制到剪贴板
|
225
|
+
navigator.clipboard.writeText(code).then(() => {
|
226
|
+
button.classList.add('cosy:btn-success');
|
227
|
+
button.querySelector('.cosy\\:copy-icon')?.classList.add('cosy:hidden');
|
228
|
+
button.querySelector('.cosy\\:check-icon')?.classList.remove('cosy:hidden');
|
229
|
+
|
230
|
+
setTimeout(() => {
|
231
|
+
button.classList.remove('cosy:btn-success');
|
232
|
+
button.querySelector('.cosy\\:copy-icon')?.classList.remove('cosy:hidden');
|
233
|
+
button.querySelector('.cosy\\:check-icon')?.classList.add('cosy:hidden');
|
234
|
+
}, 3000);
|
235
|
+
});
|
236
|
+
});
|
237
|
+
});
|
238
|
+
|
239
|
+
// 初始化时隐藏除第一个以外的所有内容
|
240
|
+
document.querySelectorAll('[data-role="code-container"]').forEach((container) => {
|
241
|
+
const contents = container.querySelectorAll('[id^="tab-"]');
|
242
|
+
contents.forEach((content, index) => {
|
243
|
+
if (index !== 0) {
|
244
|
+
content.classList.add('cosy:hidden');
|
245
|
+
}
|
246
|
+
});
|
247
|
+
});
|
248
|
+
}
|
249
|
+
|
250
|
+
document.addEventListener('astro:page-load', () => {
|
251
|
+
console.log('CodeContainer: 页面加载完成,初始化代码容器');
|
252
|
+
initializeCodeContainer();
|
253
|
+
});
|
254
|
+
</script>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
/**
|
3
|
+
* CodeContainerBasic - 基础代码容器示例组件
|
4
|
+
* 展示CodeContainer的基本用法
|
5
|
+
*/
|
6
|
+
|
7
|
+
import { CodeContainer } from './index';
|
8
|
+
import { Alert } from '../alert';
|
9
|
+
|
10
|
+
const code = `<Alert type="info">
|
11
|
+
这是一个基础示例
|
12
|
+
</Alert>`;
|
13
|
+
---
|
14
|
+
|
15
|
+
<CodeContainer codes={[code]}>
|
16
|
+
<div id="tab-1">
|
17
|
+
<Alert type="info"> 这是一个基础示例 </Alert>
|
18
|
+
</div>
|
19
|
+
</CodeContainer>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
/**
|
3
|
+
* CodeContainerMultiple - 多标签代码容器示例组件
|
4
|
+
* 展示CodeContainer的多标签用法
|
5
|
+
*/
|
6
|
+
|
7
|
+
import { CodeContainer } from './index';
|
8
|
+
import { Alert } from '../alert';
|
9
|
+
|
10
|
+
const infoCode = `<Alert type="info" title="信息提示">
|
11
|
+
这是一条信息提示
|
12
|
+
</Alert>`;
|
13
|
+
|
14
|
+
const successCode = `<Alert type="success" title="成功提示">
|
15
|
+
操作已成功完成
|
16
|
+
</Alert>`;
|
17
|
+
|
18
|
+
const warningCode = `<Alert type="warning" title="警告提示">
|
19
|
+
请注意可能的风险
|
20
|
+
</Alert>`;
|
21
|
+
|
22
|
+
const errorCode = `<Alert type="error" title="错误提示">
|
23
|
+
操作失败,请重试
|
24
|
+
</Alert>`;
|
25
|
+
|
26
|
+
const titles = ['信息', '成功', '警告', '错误'];
|
27
|
+
const descriptions = [
|
28
|
+
'用于展示一般信息',
|
29
|
+
'用于展示成功状态',
|
30
|
+
'用于展示警告信息',
|
31
|
+
'用于展示错误信息',
|
32
|
+
];
|
33
|
+
const codes = [infoCode, successCode, warningCode, errorCode];
|
34
|
+
---
|
35
|
+
|
36
|
+
<CodeContainer titles={titles} descriptions={descriptions} codes={codes}>
|
37
|
+
<div id="tab-1">
|
38
|
+
<Alert type="info" title="信息提示"> 这是一条信息提示 </Alert>
|
39
|
+
</div>
|
40
|
+
<div id="tab-2">
|
41
|
+
<Alert type="success" title="成功提示"> 操作已成功完成 </Alert>
|
42
|
+
</div>
|
43
|
+
<div id="tab-3">
|
44
|
+
<Alert type="warning" title="警告提示"> 请注意可能的风险 </Alert>
|
45
|
+
</div>
|
46
|
+
<div id="tab-4">
|
47
|
+
<Alert type="error" title="错误提示"> 操作失败,请重试 </Alert>
|
48
|
+
</div>
|
49
|
+
</CodeContainer>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { default as CodeContainer } from './CodeContainer.astro';
|
2
|
+
import { default as CodeContainerBasic } from './CodeContainerBasic.astro';
|
3
|
+
import { default as CodeContainerMultiple } from './CodeContainerMultiple.astro';
|
4
|
+
import BasicSourceCode from './CodeContainerBasic.astro?raw';
|
5
|
+
import MultipleSourceCode from './CodeContainerMultiple.astro?raw';
|
6
|
+
import { extractSimpleExample } from '../utils/component';
|
7
|
+
|
8
|
+
export { CodeContainer, CodeContainerBasic, CodeContainerMultiple };
|
9
|
+
|
10
|
+
// 导出示例源代码
|
11
|
+
export const CodeContainerExampleCodes = {
|
12
|
+
Basic: extractSimpleExample(BasicSourceCode, 'CodeContainer'),
|
13
|
+
Multiple: extractSimpleExample(MultipleSourceCode, 'CodeContainer'),
|
14
|
+
};
|
@@ -27,8 +27,8 @@
|
|
27
27
|
* @slot default - 组件的实际渲染内容
|
28
28
|
*/
|
29
29
|
|
30
|
-
import { ClipboardIcon, CheckIcon } from '
|
31
|
-
import '
|
30
|
+
import { ClipboardIcon, CheckIcon } from '../index';
|
31
|
+
import '../style.ts';
|
32
32
|
|
33
33
|
interface Props {
|
34
34
|
title?: string;
|
@@ -39,12 +39,12 @@ interface Props {
|
|
39
39
|
const { title, description, code } = Astro.props;
|
40
40
|
---
|
41
41
|
|
42
|
-
<div
|
42
|
+
<div data-role="code-example" class="cosy:mb-8 cosy:card" ignore-heading>
|
43
43
|
{title && <h3 class="cosy:p-4 cosy:border-b cosy:border-base-300 cosy:card-title">{title}</h3>}
|
44
44
|
{description && <p class="cosy:px-4 cosy:pt-4 cosy:text-base-content/70">{description}</p>}
|
45
45
|
|
46
46
|
<div
|
47
|
-
class="cosy:flex cosy:justify-between cosy:items-center cosy:bg-base-200 cosy:px-4 cosy:rounded-
|
47
|
+
class="cosy:flex cosy:justify-between cosy:items-center cosy:bg-base-200 cosy:px-4 cosy:rounded-t">
|
48
48
|
<div role="tablist" class="cosy:tabs cosy:tabs-box">
|
49
49
|
<button role="tab" class="cosy:tab cosy:tab-active" data-tab="preview">预览</button>
|
50
50
|
<button role="tab" class="cosy:tab" data-tab="code">代码</button>
|
@@ -58,17 +58,16 @@ const { title, description, code } = Astro.props;
|
|
58
58
|
</div>
|
59
59
|
</div>
|
60
60
|
|
61
|
-
<div
|
61
|
+
<div
|
62
|
+
class="cosy:relative cosy:p-4 cosy:bg-gradient-to-br cosy:from-red-100 cosy:to-green-300 cosy:rounded-b">
|
62
63
|
<div class="cosy:block cosy:code-example-panel" data-panel="preview">
|
63
|
-
<
|
64
|
-
<slot />
|
65
|
-
</div>
|
64
|
+
<slot />
|
66
65
|
</div>
|
67
66
|
|
68
67
|
<div class="cosy:hidden cosy:code-example-panel" data-panel="code">
|
69
|
-
<
|
70
|
-
|
71
|
-
|
68
|
+
<pre
|
69
|
+
class="cosy:overflow-x-auto"
|
70
|
+
style="margin:0"><code class="cosy:language-astro">{code}</code></pre>
|
72
71
|
</div>
|
73
72
|
</div>
|
74
73
|
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as CodeExample } from './CodeExample.astro';
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as Container } from './Container.astro';
|
package/dist/env.d.ts
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
/// <reference types="vite/client" />
|
2
2
|
|
3
|
-
declare module '*.vue' {
|
4
|
-
import type { DefineComponent } from 'vue';
|
5
|
-
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, any>;
|
6
|
-
export default component;
|
7
|
-
}
|
8
|
-
|
9
3
|
declare module '*.vue?raw' {
|
10
4
|
const content: string;
|
11
5
|
export default content;
|
package/dist/footer/Footer.astro
CHANGED
@@ -145,7 +145,7 @@
|
|
145
145
|
* - 社交媒体图标包含屏幕阅读器专用的文本说明
|
146
146
|
*/
|
147
147
|
|
148
|
-
import { processSocialLink } from '../utils/social
|
148
|
+
import { processSocialLink } from '../utils/social';
|
149
149
|
import { SocialIcon, LanguageUtil, type IFooterProps, createTextGetter } from '../index';
|
150
150
|
import FooterSection from './FooterSection.astro';
|
151
151
|
import '../style.ts';
|
@@ -317,11 +317,7 @@ const debugClasses = debug
|
|
317
317
|
{/* 横幅 */}
|
318
318
|
{
|
319
319
|
inspirationalSlogan && (
|
320
|
-
<aside
|
321
|
-
class:list={[
|
322
|
-
'cosy:p-4 cosy:bg-primary cosy:text-primary-content cosy:w-full',
|
323
|
-
debugClasses.aside,
|
324
|
-
]}>
|
320
|
+
<aside class:list={['cosy:p-4 cosy:w-full', debugClasses.aside]}>
|
325
321
|
<p class="cosy:text-center">{inspirationalSlogan}</p>
|
326
322
|
</aside>
|
327
323
|
)
|
package/dist/header/Header.astro
CHANGED
@@ -42,6 +42,7 @@ const {
|
|
42
42
|
paddingHorizontal = 'none',
|
43
43
|
paddingVertical = 'none',
|
44
44
|
navPosition = 'center',
|
45
|
+
showThemeSwitcher = true,
|
45
46
|
} = Astro.props;
|
46
47
|
|
47
48
|
// 根据高度设置样式
|
@@ -194,8 +195,8 @@ const activeLink = LinkUtil.getActiveLink(
|
|
194
195
|
)
|
195
196
|
}
|
196
197
|
|
197
|
-
<ThemeSwitcher />
|
198
|
-
<LanguageSwitcher languages={languages} />
|
198
|
+
{showThemeSwitcher && <ThemeSwitcher />}
|
199
|
+
{languages.length > 1 && <LanguageSwitcher languages={languages} />}
|
199
200
|
|
200
201
|
<slot name="navbar-end" />
|
201
202
|
</div>
|
@@ -150,8 +150,8 @@
|
|
150
150
|
* @prop {number} [overlayOpacity=0.7] - 遮罩的不透明度,可选值:0-1之间的数字
|
151
151
|
*/
|
152
152
|
|
153
|
-
import '
|
154
|
-
import { Link } from '
|
153
|
+
import '../style.ts';
|
154
|
+
import { Link } from '../index';
|
155
155
|
|
156
156
|
interface Link {
|
157
157
|
text: string;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
import { CodeContainer } from '../index';
|
3
|
+
import HeroAlignCenter from './HeroAlignCenter.astro';
|
4
|
+
import HeroAlignLeft from './HeroAlignLeft.astro';
|
5
|
+
import HeroAlignRight from './HeroAlignRight.astro';
|
6
|
+
import HeroAlignCenterSourceCode from './HeroAlignCenter.astro?raw';
|
7
|
+
import HeroAlignLeftSourceCode from './HeroAlignLeft.astro?raw';
|
8
|
+
import HeroAlignRightSourceCode from './HeroAlignRight.astro?raw';
|
9
|
+
---
|
10
|
+
|
11
|
+
<CodeContainer
|
12
|
+
titles={['居中对齐', '左对齐', '右对齐']}
|
13
|
+
codes={[HeroAlignCenterSourceCode, HeroAlignLeftSourceCode, HeroAlignRightSourceCode]}>
|
14
|
+
<div id="tab-1">
|
15
|
+
<HeroAlignCenter />
|
16
|
+
</div>
|
17
|
+
<div id="tab-2">
|
18
|
+
<HeroAlignLeft />
|
19
|
+
</div>
|
20
|
+
<div id="tab-3">
|
21
|
+
<HeroAlignRight />
|
22
|
+
</div>
|
23
|
+
</CodeContainer>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
import { CodeContainer } from '../index';
|
3
|
+
import HeroPlainBackground from './HeroPlainBackground.astro';
|
4
|
+
import HeroGradientBackground from './HeroGradientBackground.astro';
|
5
|
+
import HeroPlainBackgroundSourceCode from './HeroPlainBackground.astro?raw';
|
6
|
+
import HeroGradientBackgroundSourceCode from './HeroGradientBackground.astro?raw';
|
7
|
+
---
|
8
|
+
|
9
|
+
<CodeContainer
|
10
|
+
titles={['纯色背景', '渐变色背景']}
|
11
|
+
codes={[HeroPlainBackgroundSourceCode, HeroGradientBackgroundSourceCode]}>
|
12
|
+
<div id="tab-1">
|
13
|
+
<HeroPlainBackground />
|
14
|
+
</div>
|
15
|
+
<div id="tab-2">
|
16
|
+
<HeroGradientBackground />
|
17
|
+
</div>
|
18
|
+
</CodeContainer>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
import Hero from './Hero.astro';
|
3
|
+
import { getLandscapeImage } from '../index_utils';
|
4
|
+
---
|
5
|
+
|
6
|
+
<Hero
|
7
|
+
title="背景图片"
|
8
|
+
description="使用背景图片增强视觉效果。"
|
9
|
+
backgroundImage={getLandscapeImage({ width: 800, height: 400, provider: 'picsum' })}
|
10
|
+
backgroundOverlay="dark"
|
11
|
+
links={[{ text: '了解更多', href: '/about' }]}
|
12
|
+
/>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
---
|
2
|
+
import { CodeContainer } from '../index';
|
3
|
+
import HeroBackgroundImage from './HeroBackgroundImage.astro';
|
4
|
+
import HeroBackgroundImageSourceCode from './HeroBackgroundImage.astro?raw';
|
5
|
+
---
|
6
|
+
|
7
|
+
<CodeContainer codes={[HeroBackgroundImageSourceCode]}>
|
8
|
+
<div id="tab-1">
|
9
|
+
<HeroBackgroundImage />
|
10
|
+
</div>
|
11
|
+
</CodeContainer>
|