@coffic/cosy-ui 1.0.13 → 1.0.15

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 (35) hide show
  1. package/dist/app.css +1 -1
  2. package/dist/index-astro.ts +1 -0
  3. package/dist/index-vue.ts +1 -0
  4. package/dist/src/components/apple-pad/applePadPropsBase.d.ts +31 -0
  5. package/dist/src/components/apple-pad/applePadPropsBase.js +1 -0
  6. package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Blue - Landscape.png +0 -0
  7. package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Blue - Portrait.png +0 -0
  8. package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Purple - Landscape.png +0 -0
  9. package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Purple - Portrait.png +0 -0
  10. package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Space Gray - Landscape.png +0 -0
  11. package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Space Gray - Portrait.png +0 -0
  12. package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Stardust - Landscape.png +0 -0
  13. package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Stardust - Portrait.png +0 -0
  14. package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Blue - Landscape.png +0 -0
  15. package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Blue - Portrait.png +0 -0
  16. package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Purple - Landscape.png +0 -0
  17. package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Purple - Portrait.png +0 -0
  18. package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Space Gray - Landscape.png +0 -0
  19. package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Space Gray - Portrait.png +0 -0
  20. package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Stardust - Landscape.png +0 -0
  21. package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Stardust - Portrait.png +0 -0
  22. package/dist/src/components/apple-pad/constants.d.ts +36 -0
  23. package/dist/src/components/apple-pad/constants.js +43 -0
  24. package/dist/src/styles/prose/prose-table.css +5 -86
  25. package/dist/src-astro/apple-pad/ApplePad.astro +165 -0
  26. package/dist/src-astro/apple-pad/PadFrame.astro +23 -0
  27. package/dist/src-astro/apple-pad/StatusBarContent.astro +119 -0
  28. package/dist/src-astro/apple-pad/index.ts +5 -0
  29. package/dist/src-astro/apple-pad/props.ts +6 -0
  30. package/dist/src-vue/apple-pad/ApplePad.vue +117 -0
  31. package/dist/src-vue/apple-pad/PadFrame.vue +20 -0
  32. package/dist/src-vue/apple-pad/StatusBarContent.vue +153 -0
  33. package/dist/src-vue/apple-pad/index.ts +2 -0
  34. package/dist/src-vue/apple-pad/props.ts +6 -0
  35. package/package.json +1 -1
@@ -0,0 +1,119 @@
1
+ ---
2
+ /**
3
+ * @component StatusBarContent
4
+ *
5
+ * @description
6
+ * StatusBarContent 组件显示 iPad 状态栏的内容,包括时间、信号、WiFi 和电池图标。
7
+ * 组件会自动更新时间显示,并支持根据设备大小进行缩放。
8
+ *
9
+ * @usage
10
+ * 基本用法:
11
+ * ```astro
12
+ * <StatusBarContent />
13
+ * ```
14
+ *
15
+ * 带缩放比例:
16
+ * ```astro
17
+ * <StatusBarContent scaleRatio={1.5} />
18
+ * ```
19
+ *
20
+ * @props
21
+ * @prop {Number} [scaleRatio=1] - 缩放比例,用于根据设备大小调整文字和图标大小
22
+ */
23
+
24
+ import { cn } from '../../src/class';
25
+ import { IPhoneBatteryIcon, IPhoneSignalIcon, IPhoneWifiIcon } from '../icons';
26
+
27
+ interface Props {
28
+ scaleRatio?: number;
29
+ }
30
+
31
+ const { scaleRatio = 1 } = Astro.props as Props;
32
+
33
+ // 计算缩放后的字体大小
34
+ const scaledFontSize = `${14 * scaleRatio}px`;
35
+
36
+ // 计算缩放后的图标尺寸
37
+ const scaledIconSize = `${15 * scaleRatio}px`;
38
+
39
+ // 使用 classBuilder 构建各个部分的类名
40
+ const containerClass = cn()
41
+ .flex('row')
42
+ .items('center')
43
+ .h('full')
44
+ .justify('between')
45
+ .build();
46
+
47
+ const timeTextClass = cn().weight('medium').build();
48
+
49
+ const iconsContainerClass = cn()
50
+ .flex('row')
51
+ .items('center')
52
+ .gap(1)
53
+ .h('full')
54
+ .build();
55
+
56
+ const iconWrapperClass = cn()
57
+ .flex('row')
58
+ .items('center')
59
+ .justify('center')
60
+ .build();
61
+
62
+ const statusIconClass = cn().add('status-icon').build();
63
+
64
+ const batteryIconClass = cn().add('battery-icon').build();
65
+ ---
66
+
67
+ <div class={containerClass}>
68
+ <!-- 左侧时间 -->
69
+ <span
70
+ class={timeTextClass}
71
+ data-time-text
72
+ style={`font-size: ${scaledFontSize}; line-height: 1; transition: font-size 0.2s ease;`}>
73
+ 12:00
74
+ </span>
75
+
76
+ <!-- 右侧状态图标 -->
77
+ <div class={iconsContainerClass}>
78
+ <!-- 信号图标 -->
79
+ <div
80
+ class={iconWrapperClass}
81
+ style={`width: ${scaledIconSize}; height: ${scaledIconSize}; min-width: 0; min-height: 0;`}>
82
+ <IPhoneSignalIcon class={statusIconClass} />
83
+ </div>
84
+
85
+ <!-- WiFi图标 -->
86
+ <div
87
+ class={iconWrapperClass}
88
+ style={`width: ${scaledIconSize}; height: ${scaledIconSize}; min-width: 0; min-height: 0;`}>
89
+ <IPhoneWifiIcon class={statusIconClass} />
90
+ </div>
91
+
92
+ <!-- 电池图标 -->
93
+ <div
94
+ class={iconWrapperClass}
95
+ style={`width: ${scaledIconSize}; height: ${scaledIconSize}; min-width: 0; min-height: 0;`}>
96
+ <IPhoneBatteryIcon class={batteryIconClass} />
97
+ </div>
98
+ </div>
99
+ </div>
100
+
101
+ <style>
102
+ /* 确保图标渲染更平滑 */
103
+ svg {
104
+ shape-rendering: geometricPrecision;
105
+ }
106
+
107
+ /* 状态图标通用样式 */
108
+ .status-icon,
109
+ .battery-icon {
110
+ color: #000000;
111
+ fill: currentColor;
112
+ }
113
+
114
+ .status-icon svg,
115
+ .battery-icon svg {
116
+ width: 100%;
117
+ height: 100%;
118
+ }
119
+ </style>
@@ -0,0 +1,5 @@
1
+ // 导出主组件
2
+ export { default as ApplePad } from "./ApplePad.astro";
3
+
4
+ // 导出类型
5
+ export type { IApplePadProps } from "./props";
@@ -0,0 +1,6 @@
1
+ import type { IApplePadPropsBase } from "../../src/components/apple-pad/applePadPropsBase";
2
+
3
+ /**
4
+ * ApplePad 组件的 Astro 版本属性接口(继承基础接口)
5
+ */
6
+ export interface IApplePadProps extends IApplePadPropsBase {}
@@ -0,0 +1,117 @@
1
+ <script setup lang="ts">
2
+ import { ref } from "vue";
3
+ import { AlertDialog, Container } from "../../index-vue";
4
+ import PadFrame from "./PadFrame.vue";
5
+ import StatusBarContent from "./StatusBarContent.vue";
6
+
7
+ /**
8
+ * @component ApplePad
9
+ * @description ApplePad 组件模拟 iPad 设备的外观,包含状态栏、时间显示和设备边框。
10
+ * 适用于创建平板应用界面原型或展示平板端设计效果。
11
+ * @props
12
+ * @prop {'sm'|'md'|'lg'|'xl'|'2xl'|'3xl'|'4xl'|'5xl'} [height='lg'] - 窗口高度选项
13
+ * - sm: 400px
14
+ * - md: 500px
15
+ * - lg: 600px - 默认值
16
+ * - xl: 700px
17
+ * - 2xl: 800px
18
+ * - 3xl: 900px
19
+ * - 4xl: 1000px
20
+ * - 5xl: 1100px
21
+ * @prop {String} [title=''] - 窗口标题
22
+ * @prop {Boolean} [withShadow=true] - 是否显示阴影效果
23
+ * @prop {Boolean} [showFrame=true] - 是否显示 iPad 边框
24
+ * @prop {BackgroundColor} [backgroundColor=''] - 内容区域背景色
25
+ * @slots
26
+ * @slot default - 主要内容区域
27
+ * @emits
28
+ */
29
+
30
+ import type { IApplePadProps } from "./props";
31
+
32
+ interface Props extends IApplePadProps {}
33
+
34
+ // Props 定义
35
+ const props = withDefaults(defineProps<Props>(), {
36
+ height: "lg",
37
+ title: "",
38
+ withShadow: true,
39
+ showFrame: true,
40
+ backgroundColor: undefined,
41
+ });
42
+
43
+ import {
44
+ HEIGHT_CLASSES,
45
+ HEIGHT_VALUES,
46
+ IPAD_FRAME_HEIGHT,
47
+ IPAD_FRAME_STATUS_BAR_HEIGHT_ASPECT_RATIO,
48
+ IPAD_FRAME_STATUS_BAR_TOP_ASPECT_RATIO,
49
+ IPAD_FRAME_WIDTH,
50
+ MAIN_CONTENT_HEIGHT_ASPECT_RATIO,
51
+ MAIN_CONTENT_WIDTH_ASPECT_RATIO,
52
+ } from "../../src/components/apple-pad/constants";
53
+
54
+ // 响应式数据
55
+ const showAlertDialog = ref(false);
56
+ const alertMessage = ref("");
57
+
58
+ // 计算当前高度的缩放比例
59
+ const getScaleRatio = () => {
60
+ const currentHeight = HEIGHT_VALUES[props.height];
61
+ return currentHeight / 600;
62
+ };
63
+ </script>
64
+
65
+ <template>
66
+ <div
67
+ :class="['cosy:relative not-prose cosy:mx-auto', HEIGHT_CLASSES[height]]"
68
+ :style="{
69
+ aspectRatio: `${IPAD_FRAME_WIDTH}/${IPAD_FRAME_HEIGHT}`,
70
+ }"
71
+ apple-pad>
72
+ <!-- iPad 边框 -->
73
+ <PadFrame v-if="showFrame" />
74
+
75
+ <!-- 顶部状态栏 -->
76
+ <div
77
+ :style="{
78
+ position: 'absolute',
79
+ top: IPAD_FRAME_STATUS_BAR_TOP_ASPECT_RATIO * 100 + '%',
80
+ height: IPAD_FRAME_STATUS_BAR_HEIGHT_ASPECT_RATIO * 100 + '%',
81
+ width: MAIN_CONTENT_WIDTH_ASPECT_RATIO * 100 + '%',
82
+ left: '50%',
83
+ transform: 'translate(-50%, 0)',
84
+ paddingLeft: '5%',
85
+ paddingRight: '5%',
86
+ zIndex: 50,
87
+ }">
88
+ <StatusBarContent :scaleRatio="getScaleRatio()" />
89
+ </div>
90
+
91
+ <!-- 内容区域 -->
92
+ <div
93
+ class="cosy:inset-0 cosy:h-full cosy:flex cosy:flex-col"
94
+ :style="{
95
+ width: MAIN_CONTENT_WIDTH_ASPECT_RATIO * 100 + '%',
96
+ height: MAIN_CONTENT_HEIGHT_ASPECT_RATIO * 100 + '%',
97
+ left: '50%',
98
+ top: '50%',
99
+ transform: 'translate(-50%, -50%)',
100
+ position: 'absolute',
101
+ }">
102
+ <Container
103
+ rounded="lg"
104
+ height="full"
105
+ padding="none"
106
+ class="cosy:h-full cosy:overflow-y-auto cosy:overscroll-y-contain"
107
+ :background="backgroundColor || 'accent/90'">
108
+ <slot />
109
+ </Container>
110
+ </div>
111
+
112
+ <!-- iPad 边框(第二次渲染,盖住内容四角) -->
113
+ <PadFrame v-if="showFrame" />
114
+ </div>
115
+
116
+ <AlertDialog v-model="showAlertDialog" :message="alertMessage" />
117
+ </template>
@@ -0,0 +1,20 @@
1
+ <script setup lang="ts">
2
+ import ipadFrame from "../../src/components/apple-pad/assets/iPad Air 11\" - M2 - Purple - Portrait.png";
3
+
4
+ const ipadFrameSrc = (ipadFrame as any).src || ipadFrame;
5
+ </script>
6
+
7
+ <template>
8
+ <div
9
+ style="
10
+ max-width: 100%;
11
+ max-height: 100%;
12
+ position: absolute;
13
+ top: 0;
14
+ left: 0;
15
+ z-index: 10;
16
+ pointer-events: none;
17
+ ">
18
+ <img :src="ipadFrameSrc" alt="iPad frame" />
19
+ </div>
20
+ </template>
@@ -0,0 +1,153 @@
1
+ <script setup lang="ts">
2
+ import { computed, onMounted, onUnmounted, ref } from "vue";
3
+ import {
4
+ IPhoneBatteryIcon,
5
+ IPhoneSignalIcon,
6
+ IPhoneWifiIcon,
7
+ } from "../icons/index";
8
+
9
+ /**
10
+ * @component StatusBarContent
11
+ * @description StatusBarContent 组件显示 iPad 状态栏的内容,包括时间、信号、WiFi 和电池图标。
12
+ * 组件会自动更新时间显示,并支持根据设备大小进行缩放。
13
+ * @usage
14
+ * 基本用法:
15
+ * ```vue
16
+ * <StatusBarContent />
17
+ * ```
18
+ *
19
+ * 带缩放比例:
20
+ * ```vue
21
+ * <StatusBarContent :scaleRatio="1.5" />
22
+ * ```
23
+ * @props
24
+ * @prop {Number} [scaleRatio=1] - 缩放比例,用于根据设备大小调整文字和图标大小
25
+ */
26
+
27
+ // Props 定义
28
+ interface Props {
29
+ scaleRatio?: number;
30
+ }
31
+
32
+ const props = withDefaults(defineProps<Props>(), {
33
+ scaleRatio: 1,
34
+ });
35
+
36
+ // 响应式数据
37
+ const currentTime = ref("12:00");
38
+
39
+ // 更新时间的函数
40
+ const updateTime = () => {
41
+ const now = new Date();
42
+ const hours = now.getHours().toString().padStart(2, "0");
43
+ const minutes = now.getMinutes().toString().padStart(2, "0");
44
+ currentTime.value = `${hours}:${minutes}`;
45
+ };
46
+
47
+ // 计算缩放后的字体大小
48
+ const scaledFontSize = computed(() => {
49
+ const baseFontSize = 14;
50
+ return `${baseFontSize * props.scaleRatio}px`;
51
+ });
52
+
53
+ // 计算缩放后的图标尺寸
54
+ const scaledIconSize = computed(() => {
55
+ const baseIconSize = 15;
56
+ return `${baseIconSize * props.scaleRatio}px`;
57
+ });
58
+
59
+ // 计算缩放后的图标高度
60
+ const scaledIconHeight = computed(() => {
61
+ const baseIconSize = 15;
62
+ return `${baseIconSize * props.scaleRatio}px`;
63
+ });
64
+
65
+ // 设置定时器更新时间
66
+ let timeInterval: number;
67
+ onMounted(() => {
68
+ requestAnimationFrame(() => {
69
+ updateTime();
70
+ timeInterval = window.setInterval(updateTime, 60000);
71
+ });
72
+ });
73
+
74
+ onUnmounted(() => {
75
+ if (timeInterval) {
76
+ clearInterval(timeInterval);
77
+ }
78
+ });
79
+ </script>
80
+
81
+ <template>
82
+ <div class="cosy:flex cosy:items-center cosy:h-full cosy:justify-between">
83
+ <!-- 左侧时间 -->
84
+ <span
85
+ class="cosy:font-medium time-text"
86
+ :style="{ fontSize: scaledFontSize }">
87
+ {{ currentTime }}
88
+ </span>
89
+
90
+ <!-- 右侧状态图标 -->
91
+ <div
92
+ class="cosy:flex cosy:flex-row cosy:items-center cosy:space-x-1 cosy:h-full">
93
+ <!-- 信号图标 -->
94
+ <div
95
+ class="cosy:flex cosy:items-center cosy:justify-center"
96
+ :style="{
97
+ width: scaledIconSize,
98
+ height: scaledIconHeight,
99
+ minWidth: 0,
100
+ minHeight: 0,
101
+ }">
102
+ <IPhoneSignalIcon class="status-icon" />
103
+ </div>
104
+
105
+ <!-- WiFi图标 -->
106
+ <div
107
+ class="cosy:flex cosy:items-center cosy:justify-center"
108
+ :style="{
109
+ width: scaledIconSize,
110
+ height: scaledIconHeight,
111
+ minWidth: 0,
112
+ minHeight: 0,
113
+ }">
114
+ <IPhoneWifiIcon class="status-icon" />
115
+ </div>
116
+
117
+ <!-- 电池图标 -->
118
+ <div
119
+ class="cosy:flex cosy:items-center cosy:justify-center"
120
+ :style="{
121
+ width: scaledIconSize,
122
+ height: scaledIconHeight,
123
+ minWidth: 0,
124
+ minHeight: 0,
125
+ }">
126
+ <IPhoneBatteryIcon class="battery-icon" />
127
+ </div>
128
+ </div>
129
+ </div>
130
+ </template>
131
+
132
+ <style scoped>
133
+ svg {
134
+ shape-rendering: geometricPrecision;
135
+ }
136
+
137
+ .time-text {
138
+ line-height: 1;
139
+ transition: font-size 0.2s ease;
140
+ }
141
+
142
+ .status-icon,
143
+ .battery-icon {
144
+ color: #000000;
145
+ fill: currentColor;
146
+ }
147
+
148
+ .status-icon svg,
149
+ .battery-icon svg {
150
+ width: 100%;
151
+ height: 100%;
152
+ }
153
+ </style>
@@ -0,0 +1,2 @@
1
+ // 导出主组件
2
+ export { default as ApplePad } from "./ApplePad.vue";
@@ -0,0 +1,6 @@
1
+ import type { IApplePadPropsBase } from "../../src/components/apple-pad/applePadPropsBase";
2
+
3
+ /**
4
+ * ApplePad 组件的 Vue 版本属性接口(继承基础接口)
5
+ */
6
+ export interface IApplePadProps extends IApplePadPropsBase {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffic/cosy-ui",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "An astro component library",
5
5
  "author": {
6
6
  "name": "nookery",