docs/.vitepress/theme/components/GradientCard.vue
97 lines · 2720 bytes
1<script setup lang="ts">
2import { computed } from 'vue'
3
4const props = withDefaults(
5 defineProps<{
6 variant?: 'default' | 'thin'
7 tag?: string
8 link?: string
9 title: string
10 description: string
11 theme: string
12 }>(),
13 { variant: 'default' }
14)
15
16const theme = computed(() => {
17 return {
18 title: `text-${props.theme}-100`,
19 bgleft: `bg-${props.theme}-800`,
20 bgright: `bg-${props.theme}-700`,
21 tag: `text-${props.theme}-300`,
22 description: `text-${props.theme}-100`
23 }
24})
25
26const classes = computed(() => {
27 if (props.variant === 'thin') {
28 return {
29 container: 'h-40 text-sm',
30 bgleft: 'h-40 w-40 blur-2xl -left-20',
31 bgright: 'h-60 w-60 blur-2xl -top-24',
32 title: 'text-3xl',
33 icon: 'top-12 left-4',
34 description: 'mt-2 text-sm'
35 }
36 } else {
37 return {
38 container: 'h-96',
39 bgleft: 'h-80 w-80 blur-3xl -left-32',
40 bgright: 'h-96 w-96 blur-3xl -top-56',
41 title: 'text-6xl',
42 icon: 'top-36 left-6',
43 description: 'mt-4'
44 }
45 }
46})
47</script>
48
49<template>
50 <div
51 style="box-shadow: 0 10px 40px -12px rgba(16, 24, 40, 0.1)"
52 :class="classes.container"
53 class="rounded-2xl border-2 border-amber overflow-hidden flex flex-col relative text-color dark:bg-zinc-900 bg-zinc-100"
54 >
55 <div class="p-4 sticky top-0 z-10">
56 <div class="flex items-center gap-1.5">
57 <div :class="theme.tag" class="font-medium">
58 {{ props.tag }}
59 </div>
60 </div>
61 </div>
62 <div
63 :class="`${theme.bgleft} ${classes.bgleft} absolute top-1/3 -translate-y-1/2 rounded-full mix-blend`"
64 ></div>
65 <div
66 :class="`${theme.bgright} ${classes.bgright} absolute left-1/2 -translate-x-1/2 rounded-full mix-blend`"
67 ></div>
68 <div :class="`absolute ${classes.icon}`">
69 <div class="flex items-start">
70 <div
71 :class="classes.title"
72 class="font-normal tracking-tighter text-color-50"
73 >
74 {{ props.title }}
75 </div>
76 <a v-if="props.link" :href="props.link" target="_blank">
77 <svg
78 xmlns="http://www.w3.org/2000/svg"
79 viewBox="0 0 20 20"
80 fill="currentColor"
81 :class="theme.tag"
82 class="w-8 h-8 ml-3"
83 >
84 <path
85 fill-rule="evenodd"
86 d="M5.22 14.78a.75.75 0 001.06 0l7.22-7.22v5.69a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75h-7.5a.75.75 0 000 1.5h5.69l-7.22 7.22a.75.75 0 000 1.06z"
87 clip-rule="evenodd"
88 ></path>
89 </svg>
90 </a>
91 </div>
92 <div :class="`${theme.description} ${classes.description}`">
93 {{ props.description }}
94 </div>
95 </div>
96 </div>
97</template>