docs/.vitepress/theme/components/ChristmasCard.vue
318 lines · 6710 bytes
1<!--
2 All Rights Reserved
3
4 Copyright (c) 2025 taskylizard
5
6 All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder.
7-->
8<script setup lang="ts">
9import { ref } from 'vue'
10
11const clickIcon = ref<HTMLSpanElement>()
12const card = ref<HTMLDivElement>()
13
14const handleClick = () => {
15 card.value?.classList.toggle('is-opened')
16 clickIcon.value?.classList.toggle('is-hidden')
17}
18</script>
19
20<template>
21 <div class="h-xl" />
22 <div class="card" ref="card" :onClick="handleClick">
23 <div class="card-page cart-page-front">
24 <div class="card-page cart-page-outside"></div>
25 <div class="card-page cart-page-inside"></div>
26 </div>
27 <div class="card-page cart-page-bottom">
28 <p class="card-text">Merry Christmas from the Wotaku team!</p>
29 </div>
30 </div>
31 <span class="click-icon" ref="clickIcon">
32 <svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
33 <path fill="#fff"
34 d="M31.6 17.7V26c0 1.9-.7 3.7-2 5.1v.9c0 1.6-1.3 3-3 3h-8.4c-1.6 0-3-1.3-3-3 0-.6.5-1 1-1s1 .4 1 1c0 .5.4 1 1 1h8.4c.5 0 1-.4 1-1v-1.2-.3-.1c0-.1.1-.2.2-.3 1.1-1.1 1.7-2.5 1.7-4v-8.3c0-.3-.1-.5-.3-.7-.1-.1-.5-.4-1-.3-.4.1-.8.6-.8 1.1v2.4c0 .6-.5 1-1 1s-1-.4-1-1v-5.5c0-.3-.1-.5-.3-.7s-.4-.3-.7-.3c-.5 0-1 .5-1 1v5.5c0 .6-.5 1-1 1s-1-.4-1-1v-8.5c0-.3-.1-.5-.3-.7s-.4-.3-.7-.3c-.5 0-1 .5-1 1v8.5c0 .6-.5 1-1 1s-1-.4-1-1V7.7c0-.3-.1-.5-.3-.7-.1-.1-.5-.4-1-.3-.4.1-.8.6-.8 1.1V20c0 .4-.2.8-.6.9-.4.2-.8.1-1.1-.2L11 18.1c-.6-.6-1.6-.6-2.2.1-.5.6-.4 1.5.2 2.1l7 7c.4.4.4 1 0 1.4-.2.2-.5.3-.7.3-.3 0-.5-.1-.7-.3l-7-7.1c-1.3-1.3-1.5-3.5-.3-4.8C8 16 9 15.5 10 15.5c.9 0 1.8.4 2.5 1l.9.9V7.9c0-1.4.9-2.7 2.3-3 1-.3 2.1 0 2.8.8.6.6.9 1.3.9 2.1V9c.3-.1.7-.2 1-.2.8 0 1.5.3 2.1.9s.9 1.3.9 2.1v.2c.3-.1.7-.2 1-.2.8 0 1.5.3 2.1.9s.9 1.3.9 2.1v.2c.1 0 .2-.1.3-.1 1-.3 2.1 0 2.8.8.8.5 1.1 1.3 1.1 2z" />
35 </svg>
36 </span>
37</template>
38
39<style scoped>
40.card {
41 perspective: 1500px;
42 position: absolute;
43 left: calc(50% - 175px);
44 top: calc(50% - 250px);
45 transition-property: transform;
46 transition-duration: 1s;
47 transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
48 transition-delay: initial;
49 transform: rotate(-10deg) translate(0, 0);
50 -webkit-animation: cardIn 1s alternate cubic-bezier(0.87, -0.41, 0.19, 1.44);
51 animation: cardIn 1s alternate cubic-bezier(0.87, -0.41, 0.19, 1.44);
52}
53
54@media (max-width: 767px) {
55 .card {
56 left: calc(50% - 115px);
57 top: calc(50% - 164.5px);
58 }
59}
60
61@media (max-width: 479px) {
62 .card {
63 left: calc(50% - 75px);
64 top: calc(50% - 107px);
65 }
66}
67
68.card:before {
69 content: '';
70 display: block;
71 position: absolute;
72 left: 0;
73 top: 0;
74 width: 100%;
75 height: 100%;
76 box-shadow: 0 0 50px #000;
77 transition: all 0.5s ease-in-out;
78}
79
80.card.is-opened {
81 transform: rotate(0deg) translate(175px, 0);
82}
83
84@media (max-width: 767px) {
85 .card.is-opened {
86 transform: rotate(0deg) translate(115px, 0);
87 }
88}
89
90@media (max-width: 479px) {
91 .card.is-opened {
92 transform: rotate(0deg) translate(75px, 0);
93 }
94}
95
96.card.is-opened .cart-page-front {
97 transform: rotateY(-180deg);
98}
99
100@-webkit-keyframes cardIn {
101 0% {
102 opacity: 0;
103 transform: rotate(-10deg) translate(0, -100%);
104 }
105
106 25% {
107 opacity: 1;
108 }
109
110 100% {
111 opacity: 1;
112 transform: rotate(-10deg) translate(0, 0);
113 }
114}
115
116@keyframes cardIn {
117 0% {
118 opacity: 0;
119 transform: rotate(-10deg) translate(0, -100%);
120 }
121
122 25% {
123 opacity: 1;
124 }
125
126 100% {
127 opacity: 1;
128 transform: rotate(-10deg) translate(0, 0);
129 }
130}
131
132.card,
133.card-page {
134 width: 350px;
135 height: 500px;
136}
137
138@media (max-width: 767px) {
139
140 .card,
141 .card-page {
142 width: 230px;
143 height: 329px;
144 }
145}
146
147@media (max-width: 479px) {
148
149 .card,
150 .card-page {
151 width: 150px;
152 height: 214px;
153 }
154}
155
156.card-page {
157 transition: transform 1s ease-in-out;
158 cursor: pointer;
159 position: absolute;
160 outline: 1px solid transparent;
161}
162
163.cart-page-front {
164 transform-origin: 0 50% 0;
165 transform-style: preserve-3d;
166 transform: rotateY(-20deg);
167 z-index: 2;
168}
169
170.cart-page-outside,
171.cart-page-inside {
172 position: absolute;
173 -webkit-backface-visibility: hidden;
174 backface-visibility: hidden;
175}
176
177.cart-page-outside {
178 border: 10px solid #fbfbfb;
179 background: #c72320 url('/christmas/front.png') no-repeat center;
180 background-size: cover;
181 width: 100%;
182 height: 100%;
183}
184
185@media (max-width: 767px) {
186 .cart-page-outside {
187 border: 5px solid #fbfbfb;
188 }
189}
190
191.cart-page-inside {
192 background: #c72320 url('/christmas/out.jpg') no-repeat center;
193 background-size: cover;
194 width: 100%;
195 height: 100%;
196}
197
198.cart-page-bottom {
199 background-color: #d4d1d0;
200 background-image: url('/christmas/pattern.png');
201 border: 20px solid #d4d1d0;
202 display: -webkit-box;
203 display: -moz-box;
204 display: box;
205 display: -moz-flex;
206 display: flex;
207 box-pack: center;
208 -moz-justify-content: center;
209 -ms-justify-content: center;
210 -o-justify-content: center;
211 justify-content: center;
212 -ms-flex-pack: center;
213 box-align: center;
214 -moz-align-items: center;
215 -ms-align-items: center;
216 -o-align-items: center;
217 align-items: center;
218 -ms-flex-align: center;
219 text-align: center;
220}
221
222@media (max-width: 767px) {
223 .cart-page-bottom {
224 border: 10px solid #d4d1d0;
225 }
226}
227
228.cart-page-bottom {
229 z-index: 1;
230 border-left: none !important;
231 background-position: -22px 80px;
232}
233
234@media (max-width: 767px) {
235 .cart-page-bottom {
236 background-position: 85px 30px;
237 }
238}
239
240@media (max-width: 479px) {
241 .cart-page-bottom {
242 background-position: 0px 30px;
243 }
244}
245
246.click-icon {
247 position: absolute;
248 left: 50%;
249 transform: translate(-50%, 0);
250 bottom: 20px;
251 -webkit-animation: iconAnimation 1s infinite alternate ease-in-out;
252 animation: iconAnimation 1s infinite alternate ease-in-out;
253 transition: opacity 0.5s ease-in-out;
254 opacity: 1;
255}
256
257.click-icon svg {
258 width: 96px;
259 height: 96px;
260}
261
262@media (max-width: 767px) {
263 .click-icon svg {
264 width: 72px;
265 height: 72px;
266 }
267}
268
269@media (max-width: 479px) {
270 .click-icon svg {
271 width: 48px;
272 height: 48px;
273 }
274}
275
276.click-icon.is-hidden {
277 opacity: 0;
278}
279
280@-webkit-keyframes iconAnimation {
281 0% {
282 transform: translate(-50%, 0);
283 }
284
285 100% {
286 transform: translate(-50%, 10px);
287 }
288}
289
290@keyframes iconAnimation {
291 0% {
292 transform: translate(-50%, 0);
293 }
294
295 100% {
296 transform: translate(-50%, 10px);
297 }
298}
299
300.card-text {
301 color: #3c3c43;
302 font-size: 36px;
303 line-height: 1.2em;
304 padding-left: 10px;
305}
306
307@media (max-width: 767px) {
308 .card-text {
309 font-size: 24px;
310 }
311}
312
313@media (max-width: 479px) {
314 .card-text {
315 font-size: 20px;
316 }
317}
318</style>