@coffic/cosy-ui 0.9.11 → 0.9.13
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/src/assets/iconData.ts +5 -0
- package/dist/src-astro/card-course/CardCourse.astro +15 -3
- package/dist/src-astro/card-course/config.ts +26 -0
- package/dist/src-astro/card-course/types.ts +7 -0
- package/dist/src-astro/sidebar/SidebarNav.astro +1 -1
- package/dist/src-astro/smart-bg/SmartBg.astro +1 -1
- package/package.json +1 -1
@@ -234,4 +234,9 @@ export const iconData: Record<string, IconData> = {
|
|
234
234
|
code: {
|
235
235
|
path: 'M8 6L2 12L8 18M16 6L22 12L16 18M10 16L14 8',
|
236
236
|
},
|
237
|
+
|
238
|
+
// 网站图标
|
239
|
+
website: {
|
240
|
+
path: 'M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z',
|
241
|
+
},
|
237
242
|
};
|
@@ -8,6 +8,7 @@
|
|
8
8
|
* @usage
|
9
9
|
* ```astro
|
10
10
|
* <CardCourse courseName="React 基础教程" lang="zh" href="/courses/react-basics" />
|
11
|
+
* <CardCourse courseName="Vue 进阶" lang="zh" href="/courses/vue" padding="xl" contentPadding="md" />
|
11
12
|
* ```
|
12
13
|
*
|
13
14
|
* @props
|
@@ -16,14 +17,20 @@
|
|
16
17
|
* - lang: string - 语言("en" 或 "zh")
|
17
18
|
* - href: string - 课程链接
|
18
19
|
* - iconSize?: "sm" | "md" | "lg" | "xl" - 图标尺寸,默认为 "md"
|
20
|
+
* - contentPadding?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" - 内容区域内边距,默认为 "lg"
|
19
21
|
*/
|
20
22
|
|
21
23
|
import '../../style.ts';
|
22
|
-
import {
|
24
|
+
import {
|
25
|
+
formatDisplayName,
|
26
|
+
getIconSizeClasses,
|
27
|
+
getContentPaddingClasses,
|
28
|
+
} from './config';
|
23
29
|
import CardCourseIcon from './CardCourseIcon.astro';
|
24
30
|
import CardCourseContent from './CardCourseContent.astro';
|
25
31
|
import CardCourseButton from './CardCourseButton.astro';
|
26
32
|
import { SmartBg } from '../smart-bg';
|
33
|
+
import type { PaddingSize } from './types';
|
27
34
|
|
28
35
|
interface Props {
|
29
36
|
courseName: string;
|
@@ -31,6 +38,8 @@ interface Props {
|
|
31
38
|
lang: string;
|
32
39
|
href: string;
|
33
40
|
iconSize?: 'sm' | 'md' | 'lg' | 'xl';
|
41
|
+
padding?: PaddingSize;
|
42
|
+
contentPadding?: PaddingSize;
|
34
43
|
}
|
35
44
|
|
36
45
|
const {
|
@@ -39,10 +48,12 @@ const {
|
|
39
48
|
lang,
|
40
49
|
href,
|
41
50
|
iconSize = 'md',
|
51
|
+
contentPadding = 'lg',
|
42
52
|
} = Astro.props;
|
43
53
|
|
44
54
|
const displayName = formatDisplayName(courseName);
|
45
55
|
const iconSizeClasses = getIconSizeClasses(iconSize);
|
56
|
+
const contentPaddingClasses = getContentPaddingClasses(contentPadding);
|
46
57
|
---
|
47
58
|
|
48
59
|
<div
|
@@ -65,12 +76,13 @@ const iconSizeClasses = getIconSizeClasses(iconSize);
|
|
65
76
|
<!-- 背景 -->
|
66
77
|
<SmartBg
|
67
78
|
keyword={courseName}
|
68
|
-
class=
|
79
|
+
class={`cosy:relative cosy:z-10`}
|
69
80
|
enableGradient={true}>
|
70
81
|
<!-- 背景图标 -->
|
71
82
|
<CardCourseIcon courseName={courseName} iconSizeClasses={iconSizeClasses} />
|
72
83
|
|
73
|
-
<div
|
84
|
+
<div
|
85
|
+
class={`cosy:card-body ${contentPaddingClasses} cosy:relative cosy:z-10`}>
|
74
86
|
<!-- 内容区域 -->
|
75
87
|
<CardCourseContent displayName={displayName} description={description} />
|
76
88
|
|
@@ -9,6 +9,21 @@ export const iconSizeConfig: Record<string, string> = {
|
|
9
9
|
xl: 'cosy:w-40 cosy:h-40',
|
10
10
|
};
|
11
11
|
|
12
|
+
/**
|
13
|
+
* 内容区域内边距配置
|
14
|
+
* 预设的几种内容区域内边距类名
|
15
|
+
*/
|
16
|
+
export const contentPaddingConfig: Record<string, string> = {
|
17
|
+
none: 'cosy:p-0',
|
18
|
+
xs: 'cosy:p-2',
|
19
|
+
sm: 'cosy:p-3',
|
20
|
+
md: 'cosy:p-4',
|
21
|
+
lg: 'cosy:p-6',
|
22
|
+
xl: 'cosy:p-8',
|
23
|
+
'2xl': 'cosy:p-10',
|
24
|
+
'3xl': 'cosy:p-12',
|
25
|
+
};
|
26
|
+
|
12
27
|
/**
|
13
28
|
* 获取图标尺寸类名
|
14
29
|
* @param size 图标尺寸
|
@@ -18,6 +33,17 @@ export function getIconSizeClasses(size: "sm" | "md" | "lg" | "xl" = "md"): stri
|
|
18
33
|
return iconSizeConfig[size] || iconSizeConfig.md;
|
19
34
|
}
|
20
35
|
|
36
|
+
|
37
|
+
|
38
|
+
/**
|
39
|
+
* 获取内容区域内边距类名
|
40
|
+
* @param padding 内容区域内边距尺寸
|
41
|
+
* @returns 对应的CSS类名
|
42
|
+
*/
|
43
|
+
export function getContentPaddingClasses(padding: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" = "lg"): string {
|
44
|
+
return contentPaddingConfig[padding] || contentPaddingConfig.lg;
|
45
|
+
}
|
46
|
+
|
21
47
|
/**
|
22
48
|
* 标准化课程名称
|
23
49
|
* 将课程名称转换为小写并用下划线替换特殊字符
|
@@ -1,3 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* 内边距尺寸类型
|
3
|
+
*/
|
4
|
+
export type PaddingSize = "none" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl";
|
5
|
+
|
1
6
|
/**
|
2
7
|
* CardCourse 组件的 Props 接口
|
3
8
|
*/
|
@@ -12,4 +17,6 @@ export interface CardCourseProps {
|
|
12
17
|
href: string;
|
13
18
|
/** 图标尺寸,默认为 "md" */
|
14
19
|
iconSize?: "sm" | "md" | "lg" | "xl";
|
20
|
+
/** 内容区域内边距,默认为 "lg" */
|
21
|
+
contentPadding?: PaddingSize;
|
15
22
|
}
|
@@ -122,7 +122,7 @@ const debugClass = debug ? 'cosy:border cosy:border-red-500' : '';
|
|
122
122
|
href={subsubitem.href}
|
123
123
|
class:list={[
|
124
124
|
'cosy:hover:bg-base-300',
|
125
|
-
{ 'cosy:active': isSubSubActive },
|
125
|
+
{ 'cosy:menu-active': isSubSubActive },
|
126
126
|
debugClass,
|
127
127
|
]}>
|
128
128
|
{subsubitem.text}
|