@coffic/cosy-ui 0.9.19 → 0.9.22
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/app.css +1 -1
- package/dist/index-astro.ts +1 -0
- package/dist/src-astro/alert/Alert.astro +28 -1
- package/dist/src-astro/container/Container.astro +40 -0
- package/dist/src-astro/container/index.ts +0 -15
- package/dist/src-astro/errors/404.astro +4 -8
- package/dist/src-astro/heading/Heading.astro +202 -83
- package/dist/src-astro/heading/HeadingAnchor.astro +33 -0
- package/dist/src-astro/language-switcher/LanguageSwitcher.astro +1 -3
- package/dist/src-astro/layout-app/AppLayout.astro +71 -4
- package/dist/src-astro/layout-dashboard/index.ts +1 -1
- package/dist/src-astro/placeholder/PlaceHolder.astro +142 -0
- package/dist/src-astro/placeholder/index.ts +2 -0
- package/dist/src-astro/placeholder/types.ts +16 -0
- package/dist/src-astro/products/ProductCard.astro +3 -1
- package/dist/src-astro/products/Products.astro +48 -0
- package/dist/src-astro/sidebar/NavItem.astro +0 -51
- package/dist/src-astro/sidebar/Sidebar.astro +19 -20
- package/dist/src-astro/sidebar/SidebarNav.astro +6 -9
- package/package.json +17 -17
- package/dist/src-astro/container/EContainerBasic.astro +0 -15
- package/dist/src-astro/container/EContainerBasicContainer.astro +0 -11
- package/dist/src-astro/container/EContainerFlexBetween.astro +0 -23
- package/dist/src-astro/container/EContainerFlexCenter.astro +0 -30
- package/dist/src-astro/container/EContainerFlexColumn.astro +0 -23
- package/dist/src-astro/container/EContainerFlexContainer.astro +0 -34
- package/dist/src-astro/container/EContainerFlexRow.astro +0 -23
- package/dist/src-astro/container/EContainerPadding.astro +0 -32
- package/dist/src-astro/container/EContainerPaddingContainer.astro +0 -11
- package/dist/src-astro/container/EContainerSizes.astro +0 -36
- package/dist/src-astro/container/EContainerSizesContainer.astro +0 -11
@@ -194,6 +194,60 @@ const {
|
|
194
194
|
loadingDelay = 100,
|
195
195
|
...rest
|
196
196
|
}: Props = Astro.props;
|
197
|
+
|
198
|
+
// 动态计算Container最小高度
|
199
|
+
function getContainerMinHeightClass(headerHeight: string = 'md') {
|
200
|
+
const heightValueMap = {
|
201
|
+
'3xs': 'cosy:min-h-[calc(100vh-1rem)]',
|
202
|
+
'2xs': 'cosy:min-h-[calc(100vh-1.5rem)]',
|
203
|
+
xs: 'cosy:min-h-[calc(100vh-2rem)]',
|
204
|
+
sm: 'cosy:min-h-[calc(100vh-2.5rem)]',
|
205
|
+
md: 'cosy:min-h-[calc(100vh-3rem)]',
|
206
|
+
lg: 'cosy:min-h-[calc(100vh-4rem)]',
|
207
|
+
xl: 'cosy:min-h-[calc(100vh-5rem)]',
|
208
|
+
};
|
209
|
+
return (
|
210
|
+
heightValueMap[headerHeight as keyof typeof heightValueMap] ||
|
211
|
+
'cosy:min-h-[calc(100vh-3rem)]'
|
212
|
+
);
|
213
|
+
}
|
214
|
+
|
215
|
+
const containerMinHeightClass = getContainerMinHeightClass(
|
216
|
+
headerConfig?.height
|
217
|
+
);
|
218
|
+
|
219
|
+
// 计算Sidebar的top值和高度值
|
220
|
+
function getSidebarTopClass(headerHeight: string = 'md') {
|
221
|
+
const topMap = {
|
222
|
+
'3xs': 'cosy:top-4',
|
223
|
+
'2xs': 'cosy:top-6',
|
224
|
+
xs: 'cosy:top-8',
|
225
|
+
sm: 'cosy:top-10',
|
226
|
+
md: 'cosy:top-12',
|
227
|
+
lg: 'cosy:top-16',
|
228
|
+
xl: 'cosy:top-20',
|
229
|
+
};
|
230
|
+
return topMap[headerHeight as keyof typeof topMap] || 'cosy:top-12';
|
231
|
+
}
|
232
|
+
|
233
|
+
function getSidebarHeightClass(headerHeight: string = 'md') {
|
234
|
+
const heightValueMap = {
|
235
|
+
'3xs': 'cosy:h-[calc(100vh-1rem)]',
|
236
|
+
'2xs': 'cosy:h-[calc(100vh-1.5rem)]',
|
237
|
+
xs: 'cosy:h-[calc(100vh-2rem)]',
|
238
|
+
sm: 'cosy:h-[calc(100vh-2.5rem)]',
|
239
|
+
md: 'cosy:h-[calc(100vh-3rem)]',
|
240
|
+
lg: 'cosy:h-[calc(100vh-4rem)]',
|
241
|
+
xl: 'cosy:h-[calc(100vh-5rem)]',
|
242
|
+
};
|
243
|
+
return (
|
244
|
+
heightValueMap[headerHeight as keyof typeof heightValueMap] ||
|
245
|
+
'cosy:h-[calc(100vh-3rem)]'
|
246
|
+
);
|
247
|
+
}
|
248
|
+
|
249
|
+
const sidebarTopClass = getSidebarTopClass(headerConfig?.height);
|
250
|
+
const sidebarHeightClass = getSidebarHeightClass(headerConfig?.height);
|
197
251
|
---
|
198
252
|
|
199
253
|
<BaseLayout {...metaConfig} debug={debug}>
|
@@ -213,17 +267,30 @@ const {
|
|
213
267
|
)
|
214
268
|
}
|
215
269
|
|
216
|
-
<Container
|
270
|
+
<Container
|
271
|
+
flex="row"
|
272
|
+
gap="none"
|
273
|
+
size="full"
|
274
|
+
padding="none"
|
275
|
+
class={containerMinHeightClass}>
|
217
276
|
<!-- 侧边栏容器 -->
|
218
|
-
{
|
277
|
+
{
|
278
|
+
showSidebar && (
|
279
|
+
<Sidebar
|
280
|
+
{...sidebarConfig}
|
281
|
+
topClass={sidebarTopClass}
|
282
|
+
heightClass={sidebarHeightClass}
|
283
|
+
/>
|
284
|
+
)
|
285
|
+
}
|
219
286
|
|
220
287
|
<!-- 主内容区域 -->
|
221
|
-
<Main {...mainContentConfig}>
|
288
|
+
<Main {...mainContentConfig} class="cosy:flex-1 cosy:min-w-0">
|
222
289
|
<SkeletonLoader
|
223
290
|
showLoading={true}
|
224
291
|
loadingSize="xl"
|
225
292
|
loadingDelay={loadingDelay}
|
226
|
-
skeletonClass="cosy:w-full cosy:h-screen
|
293
|
+
skeletonClass="cosy:w-full cosy:h-screen cosy:flex cosy:items-center cosy:justify-center">
|
227
294
|
<slot />
|
228
295
|
</SkeletonLoader>
|
229
296
|
</Main>
|
@@ -0,0 +1,142 @@
|
|
1
|
+
---
|
2
|
+
/**
|
3
|
+
* @component PlaceHolder
|
4
|
+
* @description 占位符组件,用于在布局中占用指定的空间
|
5
|
+
* @usage
|
6
|
+
* ```astro
|
7
|
+
* <PlaceHolder width="md" height="lg" padding="md" background="base-200">
|
8
|
+
* <p>内容</p>
|
9
|
+
* </PlaceHolder>
|
10
|
+
* ```
|
11
|
+
* @props
|
12
|
+
* - width: 宽度尺寸 ('none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | 'full')
|
13
|
+
* - height: 高度尺寸 ('none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | 'full')
|
14
|
+
* - padding: 内边距大小 ('none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl')
|
15
|
+
* - background: 背景色类名,如 'base-200', 'primary', 'secondary'
|
16
|
+
* - class: 自定义 CSS 类名
|
17
|
+
* @slots
|
18
|
+
* - default: 占位符内容
|
19
|
+
*/
|
20
|
+
import '../../style.ts';
|
21
|
+
import type { PlaceHolderProps } from './types';
|
22
|
+
|
23
|
+
interface Props extends PlaceHolderProps {
|
24
|
+
width?:
|
25
|
+
| 'none'
|
26
|
+
| 'xs'
|
27
|
+
| 'sm'
|
28
|
+
| 'md'
|
29
|
+
| 'lg'
|
30
|
+
| 'xl'
|
31
|
+
| '2xl'
|
32
|
+
| '3xl'
|
33
|
+
| '4xl'
|
34
|
+
| '5xl'
|
35
|
+
| '6xl'
|
36
|
+
| 'full';
|
37
|
+
height?:
|
38
|
+
| 'none'
|
39
|
+
| 'xs'
|
40
|
+
| 'sm'
|
41
|
+
| 'md'
|
42
|
+
| 'lg'
|
43
|
+
| 'xl'
|
44
|
+
| '2xl'
|
45
|
+
| '3xl'
|
46
|
+
| '4xl'
|
47
|
+
| '5xl'
|
48
|
+
| '6xl'
|
49
|
+
| 'full';
|
50
|
+
padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
51
|
+
background?: string;
|
52
|
+
class?: string;
|
53
|
+
}
|
54
|
+
|
55
|
+
const {
|
56
|
+
width = 'md',
|
57
|
+
height = 'md',
|
58
|
+
padding = 'none',
|
59
|
+
background,
|
60
|
+
class: className = '',
|
61
|
+
} = Astro.props;
|
62
|
+
|
63
|
+
// 宽度样式映射
|
64
|
+
const widthClassMap = {
|
65
|
+
none: '',
|
66
|
+
xs: 'cosy:w-8',
|
67
|
+
sm: 'cosy:w-16',
|
68
|
+
md: 'cosy:w-24',
|
69
|
+
lg: 'cosy:w-32',
|
70
|
+
xl: 'cosy:w-40',
|
71
|
+
'2xl': 'cosy:w-48',
|
72
|
+
'3xl': 'cosy:w-56',
|
73
|
+
'4xl': 'cosy:w-64',
|
74
|
+
'5xl': 'cosy:w-72',
|
75
|
+
'6xl': 'cosy:w-80',
|
76
|
+
full: 'cosy:w-full',
|
77
|
+
} as const;
|
78
|
+
|
79
|
+
// 高度样式映射
|
80
|
+
const heightClassMap = {
|
81
|
+
none: '',
|
82
|
+
xs: 'cosy:h-8',
|
83
|
+
sm: 'cosy:h-16',
|
84
|
+
md: 'cosy:h-24',
|
85
|
+
lg: 'cosy:h-32',
|
86
|
+
xl: 'cosy:h-40',
|
87
|
+
'2xl': 'cosy:h-48',
|
88
|
+
'3xl': 'cosy:h-56',
|
89
|
+
'4xl': 'cosy:h-64',
|
90
|
+
'5xl': 'cosy:h-72',
|
91
|
+
'6xl': 'cosy:h-80',
|
92
|
+
full: 'cosy:h-full',
|
93
|
+
} as const;
|
94
|
+
|
95
|
+
// 内边距样式映射
|
96
|
+
const paddingClassMap = {
|
97
|
+
none: '',
|
98
|
+
xs: 'cosy:p-1',
|
99
|
+
sm: 'cosy:p-2',
|
100
|
+
md: 'cosy:p-4',
|
101
|
+
lg: 'cosy:p-6',
|
102
|
+
xl: 'cosy:p-8',
|
103
|
+
} as const;
|
104
|
+
|
105
|
+
// 背景色样式映射
|
106
|
+
const backgroundClassMap = {
|
107
|
+
'base-100': 'cosy:bg-base-100',
|
108
|
+
'base-200': 'cosy:bg-base-200',
|
109
|
+
'base-300': 'cosy:bg-base-300',
|
110
|
+
primary: 'cosy:bg-primary',
|
111
|
+
secondary: 'cosy:bg-secondary',
|
112
|
+
accent: 'cosy:bg-accent',
|
113
|
+
info: 'cosy:bg-info',
|
114
|
+
success: 'cosy:bg-success',
|
115
|
+
warning: 'cosy:bg-warning',
|
116
|
+
error: 'cosy:bg-error',
|
117
|
+
} as const;
|
118
|
+
|
119
|
+
const widthClass = widthClassMap[width as keyof typeof widthClassMap] || '';
|
120
|
+
const heightClass = heightClassMap[height as keyof typeof heightClassMap] || '';
|
121
|
+
const paddingClass =
|
122
|
+
paddingClassMap[padding as keyof typeof paddingClassMap] || '';
|
123
|
+
const backgroundClass = background
|
124
|
+
? backgroundClassMap[background as keyof typeof backgroundClassMap] || ''
|
125
|
+
: '';
|
126
|
+
|
127
|
+
const combinedClass =
|
128
|
+
`placeholder ${widthClass} ${heightClass} ${paddingClass} ${backgroundClass} ${className}`.trim();
|
129
|
+
---
|
130
|
+
|
131
|
+
<div class={combinedClass}>
|
132
|
+
<slot />
|
133
|
+
</div>
|
134
|
+
|
135
|
+
<style>
|
136
|
+
.placeholder {
|
137
|
+
display: flex;
|
138
|
+
align-items: center;
|
139
|
+
justify-content: center;
|
140
|
+
border-radius: 0.5rem;
|
141
|
+
}
|
142
|
+
</style>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
export type PlaceHolderWidth = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | 'full';
|
2
|
+
export type PlaceHolderHeight = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | 'full';
|
3
|
+
export type PlaceHolderPadding = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
4
|
+
|
5
|
+
export interface PlaceHolderProps {
|
6
|
+
/** 占位符宽度 */
|
7
|
+
width?: PlaceHolderWidth;
|
8
|
+
/** 占位符高度 */
|
9
|
+
height?: PlaceHolderHeight;
|
10
|
+
/** 内边距大小 */
|
11
|
+
padding?: PlaceHolderPadding;
|
12
|
+
/** 背景色类名,如 'base-200', 'primary', 'secondary' */
|
13
|
+
background?: string;
|
14
|
+
/** 自定义 CSS 类名 */
|
15
|
+
class?: string;
|
16
|
+
}
|
@@ -81,6 +81,8 @@
|
|
81
81
|
* description="无阴影的简洁风格"
|
82
82
|
* />
|
83
83
|
* ```
|
84
|
+
*
|
85
|
+
|
84
86
|
*/
|
85
87
|
|
86
88
|
import {
|
@@ -321,7 +323,7 @@ const buttonsContainerClass =
|
|
321
323
|
|
322
324
|
<div
|
323
325
|
class:list={[
|
324
|
-
'cosy:card cosy:bg-base-
|
326
|
+
'cosy:card cosy:bg-base-200 cosy:transition-shadow cosy:duration-300',
|
325
327
|
shadowStyles[shadow],
|
326
328
|
currentSize.card,
|
327
329
|
equalHeight && currentSize.cardHeight,
|
@@ -60,6 +60,22 @@
|
|
60
60
|
* products={products}
|
61
61
|
* />
|
62
62
|
* ```
|
63
|
+
*
|
64
|
+
* 显示容器边框:
|
65
|
+
* ```astro
|
66
|
+
* <Products
|
67
|
+
* showBorder={true}
|
68
|
+
* products={products}
|
69
|
+
* />
|
70
|
+
* ```
|
71
|
+
*
|
72
|
+
* 设置上下外边距:
|
73
|
+
* ```astro
|
74
|
+
* <Products
|
75
|
+
* margin="lg"
|
76
|
+
* products={products}
|
77
|
+
* />
|
78
|
+
* ```
|
63
79
|
*/
|
64
80
|
|
65
81
|
import { ProductCard } from '../../index-astro';
|
@@ -81,6 +97,9 @@ type ResponsiveColumns = {
|
|
81
97
|
// 定义间距大小
|
82
98
|
type GapSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
83
99
|
|
100
|
+
// 定义外边距大小
|
101
|
+
type MarginSize = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
102
|
+
|
84
103
|
// 定义布局类型
|
85
104
|
type LayoutType = 'grid' | 'list';
|
86
105
|
|
@@ -125,6 +144,21 @@ export interface Props {
|
|
125
144
|
* 应用于所有ProductCard
|
126
145
|
*/
|
127
146
|
descriptionLines?: number;
|
147
|
+
/**
|
148
|
+
* 是否显示容器边框
|
149
|
+
* 控制Products组件整体容器的边框显示
|
150
|
+
*/
|
151
|
+
showBorder?: boolean;
|
152
|
+
/**
|
153
|
+
* 上下外边距
|
154
|
+
* - none: 无外边距
|
155
|
+
* - xs: 超小外边距
|
156
|
+
* - sm: 小外边距
|
157
|
+
* - md: 中等外边距(默认)
|
158
|
+
* - lg: 大外边距
|
159
|
+
* - xl: 超大外边距
|
160
|
+
*/
|
161
|
+
margin?: MarginSize;
|
128
162
|
/**
|
129
163
|
* 自定义类名
|
130
164
|
*/
|
@@ -139,6 +173,8 @@ const {
|
|
139
173
|
gap = 'md',
|
140
174
|
equalHeight = true,
|
141
175
|
descriptionLines,
|
176
|
+
showBorder = false,
|
177
|
+
margin = 'md',
|
142
178
|
class: className = '',
|
143
179
|
} = Astro.props;
|
144
180
|
|
@@ -151,6 +187,16 @@ const gapMap = {
|
|
151
187
|
xl: 'cosy:gap-8',
|
152
188
|
};
|
153
189
|
|
190
|
+
// 外边距映射
|
191
|
+
const marginMap = {
|
192
|
+
none: '',
|
193
|
+
xs: 'cosy:my-1',
|
194
|
+
sm: 'cosy:my-2',
|
195
|
+
md: 'cosy:my-4',
|
196
|
+
lg: 'cosy:my-6',
|
197
|
+
xl: 'cosy:my-8',
|
198
|
+
};
|
199
|
+
|
154
200
|
// 获取响应式列数类名
|
155
201
|
const getColumnsClasses = () => {
|
156
202
|
if (typeof columns === 'number') {
|
@@ -181,7 +227,9 @@ const getLayoutClasses = () => {
|
|
181
227
|
const containerClasses = [
|
182
228
|
...getLayoutClasses(),
|
183
229
|
gapMap[gap],
|
230
|
+
marginMap[margin],
|
184
231
|
'cosy:w-full',
|
232
|
+
showBorder && 'cosy:border cosy:border-base-300 cosy:p-4 cosy:rounded-lg',
|
185
233
|
className,
|
186
234
|
];
|
187
235
|
---
|
@@ -75,16 +75,6 @@ const badgeSize = level === 0 ? 'cosy:badge-sm' : 'cosy:badge-xs';
|
|
75
75
|
</li>
|
76
76
|
|
77
77
|
<script>
|
78
|
-
// 简化的路径匹配函数
|
79
|
-
function isPathMatch(currentPath: string, href: string): boolean {
|
80
|
-
if (href === currentPath) return true;
|
81
|
-
if (href === '/') return currentPath === '/';
|
82
|
-
if (href.endsWith('/')) {
|
83
|
-
return currentPath.startsWith(href) || currentPath === href.slice(0, -1);
|
84
|
-
}
|
85
|
-
return currentPath.startsWith(href);
|
86
|
-
}
|
87
|
-
|
88
78
|
// 立即处理导航项点击,更新高亮状态
|
89
79
|
document.addEventListener('click', (event) => {
|
90
80
|
const target = event.target as HTMLElement;
|
@@ -107,45 +97,4 @@ const badgeSize = level === 0 ? 'cosy:badge-sm' : 'cosy:badge-xs';
|
|
107
97
|
}, 200);
|
108
98
|
}
|
109
99
|
});
|
110
|
-
|
111
|
-
// 处理 Astro 页面切换后的状态恢复
|
112
|
-
document.addEventListener('astro:page-load', () => {
|
113
|
-
const currentPath = window.location.pathname;
|
114
|
-
const allNavItems = document.querySelectorAll(
|
115
|
-
'[data-sidebar-item]'
|
116
|
-
) as NodeListOf<HTMLAnchorElement>;
|
117
|
-
|
118
|
-
// 移除所有高亮状态
|
119
|
-
allNavItems.forEach((item) => {
|
120
|
-
item.classList.remove('cosy:menu-active');
|
121
|
-
});
|
122
|
-
|
123
|
-
// 找到最精确匹配的导航项
|
124
|
-
let bestMatch: HTMLAnchorElement | null = null;
|
125
|
-
let bestMatchLength = 0;
|
126
|
-
|
127
|
-
allNavItems.forEach((item) => {
|
128
|
-
const href = item.getAttribute('data-href');
|
129
|
-
if (href) {
|
130
|
-
// 精确匹配优先
|
131
|
-
if (href === currentPath) {
|
132
|
-
bestMatch = item;
|
133
|
-
bestMatchLength = href.length;
|
134
|
-
}
|
135
|
-
// 如果没有精确匹配,选择最长的前缀匹配
|
136
|
-
else if (
|
137
|
-
currentPath.startsWith(href) &&
|
138
|
-
href.length > bestMatchLength
|
139
|
-
) {
|
140
|
-
bestMatch = item;
|
141
|
-
bestMatchLength = href.length;
|
142
|
-
}
|
143
|
-
}
|
144
|
-
});
|
145
|
-
|
146
|
-
// 只高亮最匹配的项
|
147
|
-
if (bestMatch) {
|
148
|
-
(bestMatch as HTMLAnchorElement).classList.add('cosy:menu-active');
|
149
|
-
}
|
150
|
-
});
|
151
100
|
</script>
|
@@ -27,14 +27,19 @@ import { getMarginTopClass, getMarginBottomClass } from './utils.ts';
|
|
27
27
|
import MobileNav from './MobileNav.astro';
|
28
28
|
import type { ISidebarProps } from '../../index-astro';
|
29
29
|
|
30
|
-
export interface Props extends ISidebarProps {
|
30
|
+
export interface Props extends ISidebarProps {
|
31
|
+
topClass?: string;
|
32
|
+
heightClass?: string;
|
33
|
+
}
|
31
34
|
|
32
35
|
const {
|
33
36
|
sidebarItems,
|
34
37
|
class: className,
|
35
38
|
debug = false,
|
36
|
-
marginTop = '
|
37
|
-
marginBottom = '
|
39
|
+
marginTop = 'none',
|
40
|
+
marginBottom = 'none',
|
41
|
+
topClass = 'cosy:top-12',
|
42
|
+
heightClass = 'cosy:h-[calc(100vh-3rem)]',
|
38
43
|
} = Astro.props;
|
39
44
|
|
40
45
|
// 自动获取当前路径
|
@@ -67,26 +72,24 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
|
|
67
72
|
|
68
73
|
{/* 桌面端侧边栏 */}
|
69
74
|
<aside
|
70
|
-
data-sidebar
|
75
|
+
data-desktop-sidebar
|
71
76
|
data-current-path={currentPath}
|
72
77
|
data-margin-top={marginTop}
|
73
78
|
data-margin-bottom={marginBottom}
|
74
79
|
class:list={[
|
75
80
|
className,
|
76
81
|
debugClass,
|
77
|
-
'cosy:hidden cosy:lg:block',
|
82
|
+
'cosy:hidden cosy:w-60 cosy:lg:block cosy:bg-base-200 cosy:px-4 cosy:overflow-y-auto cosy:sticky',
|
83
|
+
topClass,
|
84
|
+
heightClass,
|
78
85
|
getMarginTopClass(marginTop),
|
79
86
|
getMarginBottomClass(marginBottom),
|
80
87
|
]}>
|
81
|
-
<
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
currentPath={currentPath}
|
87
|
-
debug={debug}
|
88
|
-
/>
|
89
|
-
</div>
|
88
|
+
<SidebarNav
|
89
|
+
sidebarItems={sidebarItems}
|
90
|
+
currentPath={currentPath}
|
91
|
+
debug={debug}
|
92
|
+
/>
|
90
93
|
</aside>
|
91
94
|
|
92
95
|
<script>
|
@@ -95,9 +98,7 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
|
|
95
98
|
// 处理侧边栏滚动位置保存和恢复
|
96
99
|
document.addEventListener('astro:before-preparation', () => {
|
97
100
|
// 保存桌面端滚动位置
|
98
|
-
const desktopContent = document.querySelector(
|
99
|
-
'[data-desktop-sidebar-content]'
|
100
|
-
);
|
101
|
+
const desktopContent = document.querySelector('[data-desktop-sidebar]');
|
101
102
|
if (desktopContent) {
|
102
103
|
saveScrollPosition(desktopContent, 'sidebarScrollPosition');
|
103
104
|
}
|
@@ -113,9 +114,7 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
|
|
113
114
|
|
114
115
|
document.addEventListener('astro:page-load', () => {
|
115
116
|
// 恢复桌面端滚动位置
|
116
|
-
const desktopContent = document.querySelector(
|
117
|
-
'[data-desktop-sidebar-content]'
|
118
|
-
);
|
117
|
+
const desktopContent = document.querySelector('[data-desktop-sidebar]');
|
119
118
|
if (desktopContent) {
|
120
119
|
restoreScrollPosition(desktopContent, 'sidebarScrollPosition');
|
121
120
|
}
|
@@ -8,6 +8,7 @@
|
|
8
8
|
import '../../style.ts';
|
9
9
|
import NavItem from './NavItem.astro';
|
10
10
|
import type { ISidebarItem } from '../types/sidebar.ts';
|
11
|
+
import { Heading } from '../../index-astro.ts';
|
11
12
|
|
12
13
|
interface Props {
|
13
14
|
/**
|
@@ -45,20 +46,16 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
|
|
45
46
|
<nav
|
46
47
|
data-sidebar-nav
|
47
48
|
data-current-path={currentPath}
|
48
|
-
class:list={['cosy:p-
|
49
|
+
class:list={['cosy:p-0', debugClass, className]}>
|
49
50
|
{
|
50
51
|
sidebarItems.map((section: ISidebarItem) => (
|
51
|
-
<div class:list={[
|
52
|
-
<
|
53
|
-
class:list={[
|
54
|
-
'cosy:font-bold cosy:mb-2 cosy:text-base-content/70',
|
55
|
-
debugClass,
|
56
|
-
]}>
|
52
|
+
<div class:list={[debugClass]}>
|
53
|
+
<Heading level={5} align="center" href={section.href}>
|
57
54
|
{section.text}
|
58
|
-
</
|
55
|
+
</Heading>
|
59
56
|
<ul
|
60
57
|
class:list={[
|
61
|
-
'cosy:menu cosy:
|
58
|
+
'cosy:menu cosy:rounded-box cosy:w-full cosy:no-underline',
|
62
59
|
debugClass,
|
63
60
|
]}>
|
64
61
|
{section.items?.map((item: ISidebarItem) => (
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@coffic/cosy-ui",
|
3
|
-
"version": "0.9.
|
3
|
+
"version": "0.9.22",
|
4
4
|
"description": "An astro component library",
|
5
5
|
"author": {
|
6
6
|
"name": "nookery",
|
@@ -60,38 +60,38 @@
|
|
60
60
|
"astro-integration-kit": "^0.18.0",
|
61
61
|
"fs-extra": "^11.3.0",
|
62
62
|
"html-to-image": "^1.11.13",
|
63
|
-
"shiki": "^3.
|
63
|
+
"shiki": "^3.9.1"
|
64
64
|
},
|
65
65
|
"devDependencies": {
|
66
66
|
"@astrojs/check": "^0.9.4",
|
67
|
-
"@astrojs/mdx": "^4.
|
67
|
+
"@astrojs/mdx": "^4.3.3",
|
68
68
|
"@astrojs/ts-plugin": "^1.10.4",
|
69
|
-
"@eslint/js": "^9.
|
69
|
+
"@eslint/js": "^9.32.0",
|
70
70
|
"@tailwindcss/typography": "^0.5.16",
|
71
|
-
"@tailwindcss/vite": "^4.1.
|
71
|
+
"@tailwindcss/vite": "^4.1.11",
|
72
72
|
"@tsconfig/node22": "^22.0.2",
|
73
73
|
"@types/chai": "^5.2.2",
|
74
74
|
"@types/eslint": "^9.6.1",
|
75
75
|
"@types/fs-extra": "^11.0.4",
|
76
76
|
"@types/mocha": "^10.0.10",
|
77
|
-
"@types/node": "^22.
|
78
|
-
"@types/react": "^19.1.
|
79
|
-
"@typescript-eslint/parser": "^8.
|
80
|
-
"astro": "^5.
|
77
|
+
"@types/node": "^22.17.0",
|
78
|
+
"@types/react": "^19.1.9",
|
79
|
+
"@typescript-eslint/parser": "^8.38.0",
|
80
|
+
"astro": "^5.12.8",
|
81
81
|
"chai": "^4.5.0",
|
82
|
-
"daisyui": "^5.0.
|
83
|
-
"eslint": "^9.
|
82
|
+
"daisyui": "^5.0.50",
|
83
|
+
"eslint": "^9.32.0",
|
84
84
|
"eslint-plugin-astro": "^1.3.1",
|
85
|
-
"globals": "^16.
|
85
|
+
"globals": "^16.3.0",
|
86
86
|
"mocha": "^10.8.2",
|
87
|
-
"prettier": "^3.
|
87
|
+
"prettier": "^3.6.2",
|
88
88
|
"prettier-plugin-astro": "^0.14.1",
|
89
89
|
"rollup-plugin-copy": "^3.5.0",
|
90
90
|
"sharp": "^0.33.5",
|
91
|
-
"tailwindcss": "^4.1.
|
92
|
-
"tsx": "^4.
|
93
|
-
"typescript": "^5.
|
94
|
-
"typescript-eslint": "^8.
|
91
|
+
"tailwindcss": "^4.1.11",
|
92
|
+
"tsx": "^4.20.3",
|
93
|
+
"typescript": "^5.9.2",
|
94
|
+
"typescript-eslint": "^8.38.0",
|
95
95
|
"vite": "^6.3.5"
|
96
96
|
}
|
97
97
|
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
/**
|
3
|
-
* @component Container.Basic
|
4
|
-
*
|
5
|
-
* @description
|
6
|
-
* 基础Container组件示例,展示最简单的容器用法。
|
7
|
-
*/
|
8
|
-
import { Container } from '../../index-astro';
|
9
|
-
---
|
10
|
-
|
11
|
-
<Container>
|
12
|
-
<p class="cosy:text-center">
|
13
|
-
这是一个基础容器,内容会被限制在一个合理的宽度内并居中显示
|
14
|
-
</p>
|
15
|
-
</Container>
|
@@ -1,11 +0,0 @@
|
|
1
|
-
---
|
2
|
-
import { CodeContainer } from '../../index-astro';
|
3
|
-
import ContainerBasic from './EContainerBasic.astro';
|
4
|
-
import ContainerBasicSourceCode from './EContainerBasic.astro?raw';
|
5
|
-
---
|
6
|
-
|
7
|
-
<CodeContainer codes={[ContainerBasicSourceCode]}>
|
8
|
-
<div id="tab-1">
|
9
|
-
<ContainerBasic />
|
10
|
-
</div>
|
11
|
-
</CodeContainer>
|
@@ -1,23 +0,0 @@
|
|
1
|
-
---
|
2
|
-
/**
|
3
|
-
* @component Container.FlexBetween
|
4
|
-
*
|
5
|
-
* @description
|
6
|
-
* 展示Container组件的两端对齐(justify="between")布局功能。
|
7
|
-
*/
|
8
|
-
import '../../style.ts';
|
9
|
-
import { Container } from '../../index-astro';
|
10
|
-
---
|
11
|
-
|
12
|
-
<Container flex="row" justify="between" border padding="md">
|
13
|
-
<div class="cosy:bg-primary cosy:text-primary-content cosy:p-4 cosy:rounded">
|
14
|
-
左侧
|
15
|
-
</div>
|
16
|
-
<div
|
17
|
-
class="cosy:bg-secondary cosy:text-secondary-content cosy:p-4 cosy:rounded">
|
18
|
-
中间
|
19
|
-
</div>
|
20
|
-
<div class="cosy:bg-accent cosy:text-accent-content cosy:p-4 cosy:rounded">
|
21
|
-
右侧
|
22
|
-
</div>
|
23
|
-
</Container>
|