docs/.vitepress/theme/components/ChristmasCard.vue
326 lines · 7022 bytes
1<!--
2 Copyright (c) 2024 taskylizard
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
16<script setup lang="ts">
17import { ref } from 'vue'
18
19const clickIcon = ref<HTMLSpanElement>()
20const card = ref<HTMLDivElement>()
21
22const handleClick = () => {
23 card.value?.classList.toggle('is-opened')
24 clickIcon.value?.classList.toggle('is-hidden')
25}
26</script>
27
28<template>
29 <div class="h-xl" />
30 <div class="card" ref="card" :onClick="handleClick">
31 <div class="card-page cart-page-front">
32 <div class="card-page cart-page-outside"></div>
33 <div class="card-page cart-page-inside"></div>
34 </div>
35 <div class="card-page cart-page-bottom">
36 <p class="card-text">Merry Christmas from the Wotaku team!</p>
37 </div>
38 </div>
39 <span class="click-icon" ref="clickIcon">
40 <svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
41 <path
42 fill="#fff"
43 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"
44 />
45 </svg>
46 </span>
47</template>
48
49<style scoped>
50.card {
51 perspective: 1500px;
52 position: absolute;
53 left: calc(50% - 175px);
54 top: calc(50% - 250px);
55 transition-property: transform;
56 transition-duration: 1s;
57 transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
58 transition-delay: initial;
59 transform: rotate(-10deg) translate(0, 0);
60 -webkit-animation: cardIn 1s alternate cubic-bezier(0.87, -0.41, 0.19, 1.44);
61 animation: cardIn 1s alternate cubic-bezier(0.87, -0.41, 0.19, 1.44);
62}
63
64@media (max-width: 767px) {
65 .card {
66 left: calc(50% - 115px);
67 top: calc(50% - 164.5px);
68 }
69}
70
71@media (max-width: 479px) {
72 .card {
73 left: calc(50% - 75px);
74 top: calc(50% - 107px);
75 }
76}
77
78.card:before {
79 content: '';
80 display: block;
81 position: absolute;
82 left: 0;
83 top: 0;
84 width: 100%;
85 height: 100%;
86 box-shadow: 0 0 50px #000;
87 transition: all 0.5s ease-in-out;
88}
89
90.card.is-opened {
91 transform: rotate(0deg) translate(175px, 0);
92}
93
94@media (max-width: 767px) {
95 .card.is-opened {
96 transform: rotate(0deg) translate(115px, 0);
97 }
98}
99
100@media (max-width: 479px) {
101 .card.is-opened {
102 transform: rotate(0deg) translate(75px, 0);
103 }
104}
105
106.card.is-opened .cart-page-front {
107 transform: rotateY(-180deg);
108}
109
110@-webkit-keyframes cardIn {
111 0% {
112 opacity: 0;
113 transform: rotate(-10deg) translate(0, -100%);
114 }
115
116 25% {
117 opacity: 1;
118 }
119
120 100% {
121 opacity: 1;
122 transform: rotate(-10deg) translate(0, 0);
123 }
124}
125
126@keyframes cardIn {
127 0% {
128 opacity: 0;
129 transform: rotate(-10deg) translate(0, -100%);
130 }
131
132 25% {
133 opacity: 1;
134 }
135
136 100% {
137 opacity: 1;
138 transform: rotate(-10deg) translate(0, 0);
139 }
140}
141
142.card,
143.card-page {
144 width: 350px;
145 height: 500px;
146}
147
148@media (max-width: 767px) {
149 .card,
150 .card-page {
151 width: 230px;
152 height: 329px;
153 }
154}
155
156@media (max-width: 479px) {
157 .card,
158 .card-page {
159 width: 150px;
160 height: 214px;
161 }
162}
163
164.card-page {
165 transition: transform 1s ease-in-out;
166 cursor: pointer;
167 position: absolute;
168 outline: 1px solid transparent;
169}
170
171.cart-page-front {
172 transform-origin: 0 50% 0;
173 transform-style: preserve-3d;
174 transform: rotateY(-20deg);
175 z-index: 2;
176}
177
178.cart-page-outside,
179.cart-page-inside {
180 position: absolute;
181 -webkit-backface-visibility: hidden;
182 backface-visibility: hidden;
183}
184
185.cart-page-outside {
186 border: 10px solid #fbfbfb;
187 background: #c72320 url('/christmas/front.png') no-repeat center;
188 background-size: cover;
189 width: 100%;
190 height: 100%;
191}
192
193@media (max-width: 767px) {
194 .cart-page-outside {
195 border: 5px solid #fbfbfb;
196 }
197}
198
199.cart-page-inside {
200 background: #c72320 url('/christmas/out.jpg') no-repeat center;
201 background-size: cover;
202 width: 100%;
203 height: 100%;
204}
205
206.cart-page-bottom {
207 background-color: #d4d1d0;
208 background-image: url('/christmas/pattern.png');
209 border: 20px solid #d4d1d0;
210 display: -webkit-box;
211 display: -moz-box;
212 display: box;
213 display: -moz-flex;
214 display: flex;
215 box-pack: center;
216 -moz-justify-content: center;
217 -ms-justify-content: center;
218 -o-justify-content: center;
219 justify-content: center;
220 -ms-flex-pack: center;
221 box-align: center;
222 -moz-align-items: center;
223 -ms-align-items: center;
224 -o-align-items: center;
225 align-items: center;
226 -ms-flex-align: center;
227 text-align: center;
228}
229
230@media (max-width: 767px) {
231 .cart-page-bottom {
232 border: 10px solid #d4d1d0;
233 }
234}
235
236.cart-page-bottom {
237 z-index: 1;
238 border-left: none !important;
239 background-position: -22px 80px;
240}
241
242@media (max-width: 767px) {
243 .cart-page-bottom {
244 background-position: 85px 30px;
245 }
246}
247
248@media (max-width: 479px) {
249 .cart-page-bottom {
250 background-position: 0px 30px;
251 }
252}
253
254.click-icon {
255 position: absolute;
256 left: 50%;
257 transform: translate(-50%, 0);
258 bottom: 20px;
259 -webkit-animation: iconAnimation 1s infinite alternate ease-in-out;
260 animation: iconAnimation 1s infinite alternate ease-in-out;
261 transition: opacity 0.5s ease-in-out;
262 opacity: 1;
263}
264
265.click-icon svg {
266 width: 96px;
267 height: 96px;
268}
269
270@media (max-width: 767px) {
271 .click-icon svg {
272 width: 72px;
273 height: 72px;
274 }
275}
276
277@media (max-width: 479px) {
278 .click-icon svg {
279 width: 48px;
280 height: 48px;
281 }
282}
283
284.click-icon.is-hidden {
285 opacity: 0;
286}
287
288@-webkit-keyframes iconAnimation {
289 0% {
290 transform: translate(-50%, 0);
291 }
292
293 100% {
294 transform: translate(-50%, 10px);
295 }
296}
297
298@keyframes iconAnimation {
299 0% {
300 transform: translate(-50%, 0);
301 }
302
303 100% {
304 transform: translate(-50%, 10px);
305 }
306}
307
308.card-text {
309 color: #3c3c43;
310 font-size: 36px;
311 line-height: 1.2em;
312 padding-left: 10px;
313}
314
315@media (max-width: 767px) {
316 .card-text {
317 font-size: 24px;
318 }
319}
320
321@media (max-width: 479px) {
322 .card-text {
323 font-size: 20px;
324 }
325}
326</style>