All files / islands / ComponentsDemo.tsx

100.00% Branches 0/0
4.37% Lines 9/206
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
x1
x1
x1
x1
x1
x1
x1
x1
x1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



































































































































































































































































































































































































































import Button from "@components/ui/Button.tsx";
import Card, {
  CardContent,
  CardHeader,
  CardTitle,
} from "@components/ui/Card.tsx";
import Input from "@components/ui/Input.tsx";
import Modal, { ModalBody, ModalFooter } from "@components/ui/Modal.tsx";
import { useState } from "preact/hooks";

export default function ComponentsDemo() {
  const [modalOpen, setModalOpen] = useState(false);
  const [inputValue, setInputValue] = useState("");
  const [floatingValue, setFloatingValue] = useState("");

  return (
    <div className="space-y-16">
      {/* 按钮组件 */}
      <div id="buttons" className="group relative">
        <div className="absolute inset-0 bg-gradient-to-br from-pink-500/10 via-rose-500/8 to-red-500/10 rounded-4xl blur-2xl group-hover:blur-3xl transition-all duration-700 group-hover:scale-105">
        </div>
        <div className="relative bg-white/90 dark:bg-gray-800/90 backdrop-blur-lg p-10 rounded-4xl shadow-2xl border border-white/60 dark:border-gray-700/60 hover:shadow-3xl transition-all duration-700 group-hover:-translate-y-2">
          <div className="flex items-center mb-8">
            <div className="w-16 h-16 bg-gradient-to-br from-pink-500 via-rose-500 to-red-500 rounded-2xl flex items-center justify-center text-white text-3xl font-bold mr-6 shadow-lg">
              🔘
            </div>
            <div>
              <h3 className="text-3xl font-bold text-gray-900 dark:text-white mb-2">
                按钮组件 (Button)
              </h3>
              <p className="text-gray-600 dark:text-gray-300">
                多种样式、尺寸和状态的按钮组件
              </p>
            </div>
          </div>

          <div className="space-y-10">
            {/* 按钮变体 */}
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-pink-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  变体样式
                </h4>
              </div>
              <div className="p-6 bg-gray-50/50 dark:bg-gray-900/30 rounded-2xl border border-gray-200/50 dark:border-gray-700/50">
                <div className="flex flex-wrap gap-4">
                  <Button variant="primary">Primary</Button>
                  <Button variant="secondary">Secondary</Button>
                  <Button variant="outline">Outline</Button>
                  <Button variant="ghost">Ghost</Button>
                  <Button variant="gradient">Gradient</Button>
                  <Button variant="glass">Glass</Button>
                </div>
              </div>
            </div>

            {/* 按钮尺寸 */}
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-rose-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  尺寸大小
                </h4>
              </div>
              <div className="p-6 bg-gray-50/50 dark:bg-gray-900/30 rounded-2xl border border-gray-200/50 dark:border-gray-700/50">
                <div className="flex items-center gap-4">
                  <Button size="sm">Small</Button>
                  <Button size="md">Medium</Button>
                  <Button size="lg">Large</Button>
                </div>
              </div>
            </div>

            {/* 按钮状态 */}
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-red-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  交互状态
                </h4>
              </div>
              <div className="p-6 bg-gray-50/50 dark:bg-gray-900/30 rounded-2xl border border-gray-200/50 dark:border-gray-700/50">
                <div className="flex gap-4">
                  <Button loading>Loading</Button>
                  <Button disabled>Disabled</Button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      {/* 卡片组件 */}
      <div id="cards" className="group relative">
        <div className="absolute inset-0 bg-gradient-to-br from-purple-500/10 via-violet-500/8 to-indigo-500/10 rounded-4xl blur-2xl group-hover:blur-3xl transition-all duration-700 group-hover:scale-105">
        </div>
        <div className="relative bg-white/90 dark:bg-gray-800/90 backdrop-blur-lg p-10 rounded-4xl shadow-2xl border border-white/60 dark:border-gray-700/60 hover:shadow-3xl transition-all duration-700 group-hover:-translate-y-2">
          <div className="flex items-center mb-8">
            <div className="w-16 h-16 bg-gradient-to-br from-purple-500 via-violet-500 to-indigo-500 rounded-2xl flex items-center justify-center text-white text-3xl font-bold mr-6 shadow-lg">
              📋
            </div>
            <div>
              <h3 className="text-3xl font-bold text-gray-900 dark:text-white mb-2">
                卡片组件 (Card)
              </h3>
              <p className="text-gray-600 dark:text-gray-300">
                灵活的卡片容器,支持多种变体和内边距
              </p>
            </div>
          </div>

          <div className="space-y-8">
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-purple-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  卡片变体
                </h4>
              </div>
              <div className="grid grid-cols-1 md:grid-cols-3 gap-6">
                <Card
                  variant="default"
                  padding="sm"
                  className="hover:shadow-lg transition-shadow duration-300"
                >
                  <CardHeader>
                    <CardTitle as="h4" className="text-lg">默认卡片</CardTitle>
                  </CardHeader>
                  <CardContent>
                    <p className="text-sm text-gray-600 dark:text-gray-300">
                      这是一个默认样式的卡片组件,适用于大多数场景。
                    </p>
                  </CardContent>
                </Card>

                <Card
                  variant="hover"
                  padding="md"
                  className="transition-all duration-300"
                >
                  <CardHeader>
                    <CardTitle as="h4" className="text-lg">悬浮卡片</CardTitle>
                  </CardHeader>
                  <CardContent>
                    <p className="text-sm text-gray-600 dark:text-gray-300">
                      鼠标悬浮时会有优雅的动画效果和阴影变化。
                    </p>
                  </CardContent>
                </Card>

                <Card variant="glass" padding="lg" className="backdrop-blur-sm">
                  <CardHeader>
                    <CardTitle as="h4" className="text-lg">
                      玻璃态卡片
                    </CardTitle>
                  </CardHeader>
                  <CardContent>
                    <p className="text-sm text-gray-600 dark:text-gray-300">
                      具有现代化玻璃态毛玻璃效果的卡片样式。
                    </p>
                  </CardContent>
                </Card>
              </div>
            </div>
          </div>
        </div>
      </div>

      {/* 输入框组件 */}
      <div id="inputs" className="group relative">
        <div className="absolute inset-0 bg-gradient-to-br from-blue-500/10 via-indigo-500/8 to-cyan-500/10 rounded-4xl blur-2xl group-hover:blur-3xl transition-all duration-700 group-hover:scale-105">
        </div>
        <div className="relative bg-white/90 dark:bg-gray-800/90 backdrop-blur-lg p-10 rounded-4xl shadow-2xl border border-white/60 dark:border-gray-700/60 hover:shadow-3xl transition-all duration-700 group-hover:-translate-y-2">
          <div className="flex items-center mb-8">
            <div className="w-16 h-16 bg-gradient-to-br from-blue-500 via-indigo-500 to-cyan-500 rounded-2xl flex items-center justify-center text-white text-3xl font-bold mr-6 shadow-lg">
              ✏️
            </div>
            <div>
              <h3 className="text-3xl font-bold text-gray-900 dark:text-white mb-2">
                输入框组件 (Input)
              </h3>
              <p className="text-gray-600 dark:text-gray-300">
                功能强大的表单输入组件,支持多种类型和样式
              </p>
            </div>
          </div>

          <div className="space-y-10">
            {/* 基础输入框 */}
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-blue-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  基础输入框
                </h4>
              </div>
              <div className="p-6 bg-gray-50/50 dark:bg-gray-900/30 rounded-2xl border border-gray-200/50 dark:border-gray-700/50">
                <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
                  <Input
                    label="用户名"
                    placeholder="请输入用户名"
                    value={inputValue}
                    onChange={(e) => setInputValue(e.currentTarget.value)}
                  />
                  <Input
                    label="密码"
                    type="password"
                    placeholder="请输入密码"
                    helperText="密码至少8位字符"
                  />
                </div>
              </div>
            </div>

            {/* 浮动标签输入框 */}
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-indigo-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  浮动标签样式
                </h4>
              </div>
              <div className="p-6 bg-gray-50/50 dark:bg-gray-900/30 rounded-2xl border border-gray-200/50 dark:border-gray-700/50">
                <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
                  <Input
                    variant="floating"
                    label="邮箱地址"
                    type="email"
                    value={floatingValue}
                    onChange={(e) => setFloatingValue(e.currentTarget.value)}
                  />
                  <Input
                    variant="floating"
                    label="手机号码"
                    type="tel"
                    error="手机号码格式不正确"
                  />
                </div>
              </div>
            </div>

            {/* 输入框尺寸 */}
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-cyan-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  尺寸变化
                </h4>
              </div>
              <div className="p-6 bg-gray-50/50 dark:bg-gray-900/30 rounded-2xl border border-gray-200/50 dark:border-gray-700/50">
                <div className="space-y-4">
                  <Input size="sm" placeholder="小尺寸输入框" />
                  <Input size="md" placeholder="中等尺寸输入框" />
                  <Input size="lg" placeholder="大尺寸输入框" />
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      {/* 模态框组件 */}
      <div id="modals" className="group relative">
        <div className="absolute inset-0 bg-gradient-to-br from-emerald-500/10 via-teal-500/8 to-green-500/10 rounded-4xl blur-2xl group-hover:blur-3xl transition-all duration-700 group-hover:scale-105">
        </div>
        <div className="relative bg-white/90 dark:bg-gray-800/90 backdrop-blur-lg p-10 rounded-4xl shadow-2xl border border-white/60 dark:border-gray-700/60 hover:shadow-3xl transition-all duration-700 group-hover:-translate-y-2">
          <div className="flex items-center mb-8">
            <div className="w-16 h-16 bg-gradient-to-br from-emerald-500 via-teal-500 to-green-500 rounded-2xl flex items-center justify-center text-white text-3xl font-bold mr-6 shadow-lg">
              🗂️
            </div>
            <div>
              <h3 className="text-3xl font-bold text-gray-900 dark:text-white mb-2">
                模态框组件 (Modal)
              </h3>
              <p className="text-gray-600 dark:text-gray-300">
                可自定义的对话框组件,支持多种尺寸和功能
              </p>
            </div>
          </div>

          <div className="space-y-8">
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-emerald-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  交互演示
                </h4>
              </div>
              <div className="p-6 bg-gray-50/50 dark:bg-gray-900/30 rounded-2xl border border-gray-200/50 dark:border-gray-700/50">
                <div className="space-y-4">
                  <p className="text-gray-600 dark:text-gray-300">
                    点击下方按钮体验模态框的打开和关闭效果
                  </p>
                  <Button
                    onClick={() => setModalOpen(true)}
                    variant="gradient"
                    className="bg-gradient-to-r from-emerald-500 to-teal-500"
                  >
                    打开模态框演示
                  </Button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      {/* 工具类演示 */}
      <div className="group relative">
        <div className="absolute inset-0 bg-gradient-to-br from-orange-500/10 via-amber-500/8 to-yellow-500/10 rounded-4xl blur-2xl group-hover:blur-3xl transition-all duration-700 group-hover:scale-105">
        </div>
        <div className="relative bg-white/90 dark:bg-gray-800/90 backdrop-blur-lg p-10 rounded-4xl shadow-2xl border border-white/60 dark:border-gray-700/60 hover:shadow-3xl transition-all duration-700 group-hover:-translate-y-2">
          <div className="flex items-center mb-8">
            <div className="w-16 h-16 bg-gradient-to-br from-orange-500 via-amber-500 to-yellow-500 rounded-2xl flex items-center justify-center text-white text-3xl font-bold mr-6 shadow-lg">
              🛠️
            </div>
            <div>
              <h3 className="text-3xl font-bold text-gray-900 dark:text-white mb-2">
                样式工具类
              </h3>
              <p className="text-gray-600 dark:text-gray-300">
                预定义的工具类和动画效果
              </p>
            </div>
          </div>

          <div className="space-y-10">
            {/* 动画效果 */}
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-orange-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  动画效果
                </h4>
              </div>
              <div className="p-6 bg-gray-50/50 dark:bg-gray-900/30 rounded-2xl border border-gray-200/50 dark:border-gray-700/50">
                <div className="flex gap-6">
                  <div className="animate-fade-in p-6 bg-blue-100 dark:bg-blue-900/50 rounded-xl border border-blue-200 dark:border-blue-800">
                    <div className="text-blue-800 dark:text-blue-200 font-semibold">
                      淡入动画
                    </div>
                  </div>
                  <div className="animate-slide-up p-6 bg-green-100 dark:bg-green-900/50 rounded-xl border border-green-200 dark:border-green-800">
                    <div className="text-green-800 dark:text-green-200 font-semibold">
                      滑入动画
                    </div>
                  </div>
                </div>
              </div>
            </div>

            {/* 文本渐变 */}
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-amber-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  文本渐变
                </h4>
              </div>
              <div className="p-6 bg-gray-50/50 dark:bg-gray-900/30 rounded-2xl border border-gray-200/50 dark:border-gray-700/50">
                <h2 className="text-3xl font-bold text-gradient">
                  这是美丽的渐变文本效果
                </h2>
              </div>
            </div>

            {/* 玻璃态效果 */}
            <div className="space-y-6">
              <div className="flex items-center gap-3">
                <div className="w-3 h-3 bg-yellow-500 rounded-full"></div>
                <h4 className="text-lg font-semibold text-gray-800 dark:text-gray-200">
                  玻璃态效果
                </h4>
              </div>
              <div className="p-6 bg-gray-50/50 dark:bg-gray-900/30 rounded-2xl border border-gray-200/50 dark:border-gray-700/50">
                <div className="glass-effect p-6 rounded-xl">
                  <div className="text-gray-700 dark:text-gray-300 font-semibold">
                    这是现代化的玻璃态背景效果
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      {/* 模态框 */}
      <Modal
        isOpen={modalOpen}
        onClose={() => setModalOpen(false)}
        title="模态框演示"
        size="md"
      >
        <ModalBody>
          <div className="space-y-4">
            <p className="text-gray-600 dark:text-gray-300">
              这是一个功能完整的模态框组件演示。
            </p>
            <p className="text-gray-600 dark:text-gray-300">
              您可以在这里放置任何内容,比如表单、图片、视频或其他复杂的组件结构。
            </p>
            <div className="p-4 bg-blue-50 dark:bg-blue-900/30 rounded-lg border border-blue-200 dark:border-blue-800">
              <p className="text-blue-800 dark:text-blue-200 text-sm">
                💡 提示:模态框支持多种尺寸和自定义样式
              </p>
            </div>
          </div>
        </ModalBody>
        <ModalFooter>
          <Button variant="outline" onClick={() => setModalOpen(false)}>
            取消
          </Button>
          <Button variant="primary" onClick={() => setModalOpen(false)}>
            确认
          </Button>
        </ModalFooter>
      </Modal>
    </div>
  );
}