@coffic/cosy-ui 1.0.11 → 1.0.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/app.css +1 -1
- package/dist/index-astro.ts +1 -0
- package/dist/index-vue.ts +1 -0
- package/dist/src/assets/iconData.js +3 -0
- package/dist/src/assets/icons-data/arrowDownS.d.ts +2 -0
- package/dist/src/assets/icons-data/arrowDownS.js +3 -0
- package/dist/src/assets/icons-data/arrowUpS.d.ts +2 -0
- package/dist/src/assets/icons-data/arrowUpS.js +3 -0
- package/dist/src/assets/icons-data/function.d.ts +2 -0
- package/dist/src/assets/icons-data/function.js +3 -0
- package/dist/src/assets/icons-data/index.d.ts +3 -0
- package/dist/src/assets/icons-data/index.js +3 -0
- package/dist/src-astro/icons/ArrowDownSIcon.astro +28 -0
- package/dist/src-astro/icons/ArrowUpSIcon.astro +28 -0
- package/dist/src-astro/icons/FunctionIcon.astro +28 -0
- package/dist/src-astro/icons/index.ts +3 -0
- package/dist/src-astro/mac-window/MacWindow.astro +7 -34
- package/dist/src-astro/math-formula/MathFormula.astro +463 -0
- package/dist/src-astro/math-formula/index.ts +3 -0
- package/dist/src-astro/math-formula/props.ts +11 -0
- package/dist/src-astro/math-formula/types.ts +46 -0
- package/dist/src-astro/products/ProductCard.astro +12 -6
- package/dist/src-astro/products/ProductHero.astro +0 -3
- package/dist/src-astro/products/ProductHeroContent.astro +0 -3
- package/dist/src-astro/products/ProductHeroImage.astro +0 -3
- package/dist/src-astro/products/Products.astro +8 -3
- package/dist/src-vue/math-formula/MathFormula.vue +198 -0
- package/dist/src-vue/math-formula/index.ts +2 -0
- package/dist/src-vue/math-formula/types.ts +18 -0
- package/dist/src-vue/products/ProductCard.vue +14 -2
- package/package.json +1 -1
- /package/dist/{src-astro/products → src/styles}/product-card.css +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
|
3
|
+
import type { IMathFormulaProps, MathFormulaVariant } from "./types";
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(defineProps<IMathFormulaProps>(), {
|
|
6
|
+
variant: "gradient",
|
|
7
|
+
symbolsCollapsed: true,
|
|
8
|
+
class: "",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const showTooltip = ref(false);
|
|
12
|
+
const showDetails = ref(false);
|
|
13
|
+
const containerRef = ref<HTMLElement | null>(null);
|
|
14
|
+
|
|
15
|
+
const baseClasses =
|
|
16
|
+
"cosy:my-6 cosy:p-4 cosy:rounded-lg cosy:relative cosy:transition-all cosy:duration-300";
|
|
17
|
+
|
|
18
|
+
const variantClassMap: Record<MathFormulaVariant, string> = {
|
|
19
|
+
default:
|
|
20
|
+
"cosy:bg-base-200/80 cosy:border-l-2 cosy:border-accent cosy:rounded-r-lg cosy:shadow cosy:hover:shadow-lg",
|
|
21
|
+
gradient:
|
|
22
|
+
"cosy:bg-linear-to-br cosy:from-accent/10 cosy:via-base-200/80 cosy:to-primary/10 cosy:border cosy:border-accent/30 cosy:shadow-inner cosy:hover:border-accent/50 cosy:backdrop-blur-sm",
|
|
23
|
+
glass:
|
|
24
|
+
"cosy:bg-base-100/40 cosy:backdrop-blur-md cosy:border cosy:border-base-300/50 cosy:shadow-xl cosy:hover:bg-base-100/50",
|
|
25
|
+
neon: "cosy:bg-base-200/50 cosy:border-2 cosy:border-accent cosy:shadow-[0_0_15px_rgba(var(--a),0.3)] cosy:hover:shadow-[0_0_25px_rgba(var(--a),0.5)] cosy:backdrop-blur-sm",
|
|
26
|
+
card: "cosy:bg-base-100 cosy:border-2 cosy:border-l-8 cosy:border-accent cosy:shadow-lg cosy:hover:shadow-2xl cosy:hover:-translate-y-1",
|
|
27
|
+
spotlight:
|
|
28
|
+
"cosy:bg-base-200/80 cosy:border cosy:border-accent/20 cosy:shadow-lg cosy:hover:shadow-xl cosy:overflow-hidden",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const containerClass = computed(
|
|
32
|
+
() => `${baseClasses} ${variantClassMap[props.variant]} ${props.class || ""}`.trim(),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const spotlightStyle = ref<Record<string, string>>({});
|
|
36
|
+
|
|
37
|
+
const handleMouseMove = (e: MouseEvent) => {
|
|
38
|
+
if (props.variant !== "spotlight" || !containerRef.value) return;
|
|
39
|
+
const rect = containerRef.value.getBoundingClientRect();
|
|
40
|
+
const x = ((e.clientX - rect.left) / rect.width) * 100;
|
|
41
|
+
const y = ((e.clientY - rect.top) / rect.height) * 100;
|
|
42
|
+
spotlightStyle.value = { "--mouse-x": `${x}%`, "--mouse-y": `${y}%` } as Record<
|
|
43
|
+
string,
|
|
44
|
+
string
|
|
45
|
+
>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleClickOutside = (e: MouseEvent) => {
|
|
49
|
+
const target = e.target as HTMLElement;
|
|
50
|
+
if (!target.closest("[data-math-tooltip]")) {
|
|
51
|
+
showTooltip.value = false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
onMounted(() => {
|
|
56
|
+
document.addEventListener("click", handleClickOutside);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
onBeforeUnmount(() => {
|
|
60
|
+
document.removeEventListener("click", handleClickOutside);
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<template>
|
|
65
|
+
<div
|
|
66
|
+
ref="containerRef"
|
|
67
|
+
class="formula-container"
|
|
68
|
+
:class="containerClass"
|
|
69
|
+
:data-variant="variant"
|
|
70
|
+
:style="spotlightStyle"
|
|
71
|
+
@mousemove="handleMouseMove">
|
|
72
|
+
<div v-if="variant === 'spotlight'" class="spotlight-effect cosy:absolute cosy:inset-0 cosy:pointer-events-none" />
|
|
73
|
+
|
|
74
|
+
<div class="cosy:absolute cosy:top-2 cosy:right-2 cosy:z-10" data-math-tooltip>
|
|
75
|
+
<button
|
|
76
|
+
type="button"
|
|
77
|
+
class="cosy:w-5 cosy:h-5 cosy:text-accent cosy:hover:text-accent-focus cosy:hover:scale-110 cosy:transition-all cosy:duration-200"
|
|
78
|
+
@click.stop="showTooltip = !showTooltip">
|
|
79
|
+
<span aria-hidden="true" class="cosy:inline-block cosy:w-4 cosy:h-4">ℹ️</span>
|
|
80
|
+
</button>
|
|
81
|
+
<div
|
|
82
|
+
v-if="showTooltip"
|
|
83
|
+
class="cosy:absolute cosy:top-6 cosy:right-0 cosy:w-64 cosy:p-3 cosy:bg-base-100 cosy:border cosy:border-base-300 cosy:rounded-lg cosy:shadow-xl cosy:z-20 cosy:text-sm cosy:animate-fade-in">
|
|
84
|
+
<div class="cosy:flex cosy:items-start cosy:gap-2">
|
|
85
|
+
<span class="cosy:w-4 cosy:h-4 cosy:text-accent cosy:mt-0.5 cosy:shrink-0">ℹ️</span>
|
|
86
|
+
<div class="cosy:text-base-content">
|
|
87
|
+
<p class="cosy:font-medium cosy:mb-1 not-prose">数学公式</p>
|
|
88
|
+
<p class="cosy:text-xs cosy:leading-relaxed not-prose cosy:opacity-70">
|
|
89
|
+
公式是数学中表达数量关系、结构规律的符号表达式,是解决数学问题的重要工具。
|
|
90
|
+
</p>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
<div class="cosy:absolute cosy:-top-1 cosy:right-3 cosy:w-2 cosy:h-2 cosy:bg-base-100 cosy:border-l cosy:border-t cosy:border-base-300 cosy:transform cosy:rotate-45" />
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<div v-if="title || number" class="cosy:flex cosy:items-center cosy:mb-2 cosy:relative cosy:z-1">
|
|
98
|
+
<span
|
|
99
|
+
class="cosy:text-accent cosy:mr-2 cosy:text-lg"
|
|
100
|
+
:class="variant === 'neon' ? 'cosy:drop-shadow-[0_0_8px_rgba(var(--a),0.8)]' : ''">
|
|
101
|
+
fx
|
|
102
|
+
</span>
|
|
103
|
+
<span
|
|
104
|
+
v-if="title"
|
|
105
|
+
class="cosy:font-bold cosy:text-base-content"
|
|
106
|
+
:class="variant === 'neon' ? 'cosy:drop-shadow-[0_0_4px_rgba(var(--a),0.3)]' : ''">
|
|
107
|
+
{{ title }}
|
|
108
|
+
</span>
|
|
109
|
+
<span
|
|
110
|
+
v-if="number"
|
|
111
|
+
class="cosy:ml-2 cosy:text-xs cosy:text-base-content/70 cosy:px-2 cosy:py-0.5 cosy:rounded-full"
|
|
112
|
+
:class="variant !== 'default' ? 'cosy:bg-accent/20' : 'cosy:bg-base-300'">
|
|
113
|
+
公式{{ number }}
|
|
114
|
+
</span>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<div class="cosy:overflow-x-auto cosy:text-lg cosy:text-base-content formula-block cosy:relative cosy:z-1">
|
|
118
|
+
<slot />
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<div
|
|
122
|
+
v-if="$slots.desc"
|
|
123
|
+
class="cosy:mt-2 cosy:text-sm cosy:text-base-content/70 cosy:border-t cosy:border-base-content/10 cosy:pt-2 cosy:relative cosy:z-1">
|
|
124
|
+
<slot name="desc" />
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<div
|
|
128
|
+
v-if="$slots.symbols"
|
|
129
|
+
class="cosy:mt-2 cosy:pt-3 cosy:border-t cosy:border-base-content/10 cosy:relative cosy:z-1"
|
|
130
|
+
:class="variant === 'default' ? 'cosy:border-base-300' : 'cosy:border-accent/20'">
|
|
131
|
+
<details class="group" :open="!symbolsCollapsed">
|
|
132
|
+
<summary
|
|
133
|
+
class="cosy:cursor-pointer cosy:text-sm cosy:font-medium cosy:flex cosy:items-center cosy:gap-1 cosy:transition-colors"
|
|
134
|
+
:class="variant === 'neon' ? 'cosy:text-accent cosy:hover:text-accent cosy:drop-shadow-[0_0_4px_rgba(var(--a),0.5)]' : 'cosy:text-accent cosy:hover:text-accent-focus'">
|
|
135
|
+
<span class="cosy:w-4 cosy:h-4 group-open:cosy:rotate-180 cosy:transition-transform cosy:duration-200">ℹ️</span>
|
|
136
|
+
符号说明
|
|
137
|
+
</summary>
|
|
138
|
+
<div class="cosy:mt-2 cosy:text-sm cosy:text-base-content/70">
|
|
139
|
+
<slot name="symbols" />
|
|
140
|
+
</div>
|
|
141
|
+
</details>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<div v-if="$slots.details" class="cosy:mt-2 cosy:border-t cosy:border-base-content/10 cosy:pt-2 cosy:relative cosy:z-1">
|
|
145
|
+
<div class="cosy:flex cosy:justify-end">
|
|
146
|
+
<button
|
|
147
|
+
type="button"
|
|
148
|
+
class="cosy:flex cosy:items-center cosy:gap-2 cosy:text-sm cosy:font-medium cosy:text-accent cosy:hover:text-accent-focus cosy:transition-colors cosy:duration-200"
|
|
149
|
+
@click="showDetails = !showDetails">
|
|
150
|
+
<span class="cosy:w-4 cosy:h-4 cosy:transition-transform cosy:duration-200" :class="showDetails ? 'cosy:rotate-180' : ''">⌄</span>
|
|
151
|
+
<span class="cosy:w-4 cosy:h-4 cosy:transition-transform cosy:duration-200 cosy:hidden" />
|
|
152
|
+
</button>
|
|
153
|
+
</div>
|
|
154
|
+
<div
|
|
155
|
+
v-show="showDetails"
|
|
156
|
+
class="cosy:mt-2 cosy:text-sm cosy:text-base-content/80 cosy:animate-fade-in">
|
|
157
|
+
<slot name="details" />
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
</template>
|
|
162
|
+
|
|
163
|
+
<style scoped>
|
|
164
|
+
.formula-block {
|
|
165
|
+
font-family: "KaTeX_Main", "Times New Roman", Times, serif;
|
|
166
|
+
word-break: break-word;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.spotlight-effect {
|
|
170
|
+
background: radial-gradient(
|
|
171
|
+
circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
|
|
172
|
+
rgba(var(--a), 0.15) 0%,
|
|
173
|
+
transparent 50%
|
|
174
|
+
);
|
|
175
|
+
opacity: 0;
|
|
176
|
+
transition: opacity 0.3s ease;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.formula-container:hover .spotlight-effect {
|
|
180
|
+
opacity: 1;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
@keyframes fade-in {
|
|
184
|
+
from {
|
|
185
|
+
opacity: 0;
|
|
186
|
+
transform: translateY(-10px);
|
|
187
|
+
}
|
|
188
|
+
to {
|
|
189
|
+
opacity: 1;
|
|
190
|
+
transform: translateY(0);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.animate-fade-in {
|
|
195
|
+
animation: fade-in 0.2s ease-out;
|
|
196
|
+
}
|
|
197
|
+
</style>
|
|
198
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MathFormula Vue 版本的属性类型
|
|
3
|
+
*/
|
|
4
|
+
export type MathFormulaVariant =
|
|
5
|
+
| "default"
|
|
6
|
+
| "gradient"
|
|
7
|
+
| "glass"
|
|
8
|
+
| "neon"
|
|
9
|
+
| "card"
|
|
10
|
+
| "spotlight";
|
|
11
|
+
|
|
12
|
+
export interface IMathFormulaProps {
|
|
13
|
+
title?: string;
|
|
14
|
+
number?: string | number;
|
|
15
|
+
variant?: MathFormulaVariant;
|
|
16
|
+
symbolsCollapsed?: boolean;
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
@@ -61,6 +61,12 @@ interface Props {
|
|
|
61
61
|
* GitHub按钮文本
|
|
62
62
|
*/
|
|
63
63
|
githubButtonText?: string;
|
|
64
|
+
/**
|
|
65
|
+
* 语言设置,影响默认按钮文本
|
|
66
|
+
* - zh-cn: 中文默认(访问官网)
|
|
67
|
+
* - en: 英文默认(Visit Website)
|
|
68
|
+
*/
|
|
69
|
+
lang?: string;
|
|
64
70
|
/**
|
|
65
71
|
* 按钮布局方向
|
|
66
72
|
* - row: 水平布局(默认)
|
|
@@ -103,7 +109,7 @@ interface Props {
|
|
|
103
109
|
|
|
104
110
|
const props = withDefaults(defineProps<Props>(), {
|
|
105
111
|
size: "md",
|
|
106
|
-
primaryButtonText:
|
|
112
|
+
primaryButtonText: undefined,
|
|
107
113
|
secondaryButtonText: "App Store",
|
|
108
114
|
githubButtonText: "GitHub",
|
|
109
115
|
buttonLayout: "row",
|
|
@@ -118,6 +124,12 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
118
124
|
githubUrl: undefined,
|
|
119
125
|
});
|
|
120
126
|
|
|
127
|
+
const effectivePrimaryButtonText = computed(
|
|
128
|
+
() =>
|
|
129
|
+
props.primaryButtonText ??
|
|
130
|
+
(props.lang === "en" ? "Visit Website" : "访问官网"),
|
|
131
|
+
);
|
|
132
|
+
|
|
121
133
|
// 尺寸样式映射
|
|
122
134
|
const sizeStyles = {
|
|
123
135
|
xs: {
|
|
@@ -320,7 +332,7 @@ const description = computed(() => props.description);
|
|
|
320
332
|
">
|
|
321
333
|
<LinkIcon class="cosy:w-4 cosy:h-4" />
|
|
322
334
|
<a :href="productUrl" target="_blank" rel="noopener noreferrer">
|
|
323
|
-
{{
|
|
335
|
+
{{ effectivePrimaryButtonText }}
|
|
324
336
|
</a>
|
|
325
337
|
</Button>
|
|
326
338
|
|
package/package.json
CHANGED
|
File without changes
|