-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathThemeCard.svelte
More file actions
246 lines (235 loc) · 6.11 KB
/
ThemeCard.svelte
File metadata and controls
246 lines (235 loc) · 6.11 KB
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
<script lang="ts">
import type { ThemeData } from "./types";
import { is_color_dark } from "./utils";
export let theme: ThemeData;
export let on_click: () => void;
export let dark: boolean = false;
$: current_bg = dark ? theme.colors.background_dark : theme.colors.background;
$: is_dark = is_color_dark(current_bg);
$: is_btn_dark = is_color_dark(theme.colors.button_primary);
$: is_block_dark = is_color_dark(theme.colors.block_background);
$: card_text = is_dark ? "#ffffff" : theme.colors.text_color;
$: block_text = is_block_dark ? "#ffffff" : theme.colors.text_color;
$: label_color = is_block_dark ? "rgba(255,255,255,0.6)" : "rgba(0,0,0,0.45)";
$: track_color = is_block_dark ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.08)";
function mix_color(hex: string, opacity: number): string {
return `${hex}${Math.round(opacity * 255)
.toString(16)
.padStart(2, "0")}`;
}
</script>
<div
on:click={(event) => {
on_click();
event.stopPropagation();
}}
on:keydown={(event) => {
if (event.key === "Enter" || event.key === " ") {
on_click();
event.preventDefault();
}
}}
role="button"
tabindex="0"
class="card-container cursor-pointer group relative rounded-xl overflow-hidden border"
style="
background: {current_bg};
border-color: {is_dark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.08)'};
"
>
<div class="p-2.5">
<div
class="text-[11px] font-semibold truncate mb-2"
style="color: {card_text}; font-family: '{theme.fonts.main}', sans-serif;"
>
{theme.name}
</div>
<div class="flex gap-2">
<div class="flex-1 space-y-1.5">
<div
class="rounded p-1.5 border"
style="
background: {theme.colors.block_background};
border-color: {theme.colors.block_border};
"
>
<div
class="text-[8px] font-medium mb-0.5"
style="color: {label_color};"
>
Prompt
</div>
<div
class="text-[9px] leading-tight"
style="color: {block_text}; font-family: '{theme.fonts.main}', sans-serif;"
>
A serene mountain...
</div>
</div>
<div
class="rounded p-1.5 border"
style="
background: {theme.colors.block_background};
border-color: {theme.colors.block_border};
"
>
<div class="flex justify-between items-center mb-1">
<span
class="text-[8px] font-medium"
style="color: {label_color};"
>
Steps
</span>
<span
class="text-[8px] font-mono"
style="color: {theme.colors.primary};"
>
25
</span>
</div>
<div
class="h-1 rounded-full relative"
style="background: {track_color};"
>
<div
class="absolute left-0 top-0 h-full rounded-full"
style="background: {theme.colors.primary}; width: 50%;"
></div>
</div>
</div>
<button
class="w-full py-1 rounded text-[9px] font-semibold"
style="
background: {theme.colors.button_primary};
color: {is_btn_dark ? '#ffffff' : '#000000'};
"
>
Generate
</button>
</div>
<div class="flex-1 space-y-1.5">
<div
class="rounded p-1.5 border"
style="
background: {theme.colors.block_background};
border-color: {theme.colors.block_border};
"
>
<div
class="text-[7px] mb-0.5"
style="color: {label_color};"
>
Font
</div>
<div
class="text-[10px] font-medium leading-tight"
style="color: {block_text}; font-family: '{theme.fonts.main}', sans-serif;"
>
{theme.fonts.main}
</div>
</div>
<div
class="rounded p-1.5 border flex items-center gap-1.5"
style="
background: {theme.colors.block_background};
border-color: {theme.colors.block_border};
"
>
<div
class="w-3 h-3 rounded-sm flex items-center justify-center"
style="background: {theme.colors.primary};"
>
<svg
class="w-2 h-2 text-white"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="3"
d="M5 13l4 4L19 7"
/>
</svg>
</div>
<span
class="text-[8px]"
style="color: {block_text};">Enabled</span
>
</div>
<button
class="w-full py-1 rounded text-[8px] font-medium border"
style="
background: transparent;
border-color: {theme.colors.button_secondary_border};
color: {theme.colors.button_secondary_text};
"
>
Secondary
</button>
</div>
</div>
</div>
<div
class="px-2.5 py-1.5 flex items-center justify-between border-t"
style="
background: {is_dark ? 'rgba(255,255,255,0.02)' : 'rgba(0,0,0,0.02)'};
border-color: {is_dark ? 'rgba(255,255,255,0.05)' : 'rgba(0,0,0,0.05)'};
"
>
<div class="flex items-center gap-1.5">
{#if theme.is_official}
<span
class="px-1 py-0.5 rounded text-[8px] font-medium"
style="
background: {mix_color(theme.colors.primary, 0.15)};
color: {theme.colors.primary};
"
>
Official
</span>
{:else if theme.likes > 0}
<span
class="flex items-center gap-0.5 text-[8px]"
style="color: {label_color};"
>
<svg class="w-2 h-2" fill="currentColor" viewBox="0 0 20 20">
<path
fill-rule="evenodd"
d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z"
clip-rule="evenodd"
/>
</svg>
{theme.likes}
</span>
{/if}
</div>
<div class="flex items-center gap-1">
<div
class="w-2.5 h-2.5 rounded-full"
style="background: {theme.colors.button_primary}; box-shadow: 0 0 0 1px {is_dark
? 'rgba(255,255,255,0.1)'
: 'rgba(0,0,0,0.1)'};"
></div>
<div
class="w-2.5 h-2.5 rounded-full"
style="background: {theme.colors
.neutral}; box-shadow: 0 0 0 1px {is_dark
? 'rgba(255,255,255,0.1)'
: 'rgba(0,0,0,0.1)'};"
></div>
</div>
</div>
</div>
<style>
.card-container {
transition:
transform 0.2s ease,
box-shadow 0.2s ease;
}
.card-container:hover {
transform: translateY(-4px);
box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.25);
}
</style>