-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
203 lines (200 loc) · 5.14 KB
/
index.html
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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carta Animada</title>
<style>
/* reset css */
* {
min-width: 0;
font: inherit;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
img,
video,
svg {
display: block;
height: auto;
max-width: 100%;
}
body {
margin: 0;
min-height: 140dvh;
}
h1,
h2,
h3 {
text-wrap: balance;
}
p {
text-wrap: pretty;
}
/* styles */
body {
background-color: #fad7df;
}
main {
display: flex;
flex-direction: column;
gap: 3rem;
justify-content: center;
align-items: center;
height: 120vh;
}
.container-letter {
position: relative;
}
.cover {
position: absolute;
border-left: 200px solid transparent;
border-right: 200px solid transparent;
border-top: 75px solid #fe3334;
border-bottom: 75px solid transparent;
transition: transform 0.75s;
transform-origin: top;
}
.paper {
position: absolute;
padding: 1.5rem;
line-height: 2rem;
right: 5px;
z-index: -1;
background: white;
width: 390px;
height: 250px;
transition: all 0.75s;
}
.letter {
border-left: 200px solid #ff989e;
border-right: 200px solid #ff989e;
border-top: 50px solid transparent;
border-bottom: 217px solid #ff858a;
}
.options {
display: flex;
gap: 5rem;
}
.options button {
color: #ff3234;
font-weight: 600;
border-radius: 3px;
background: #fad7df;
padding: 0.5rem 1rem;
border: 1px solid #fe3334;
cursor: pointer;
}
.options button:hover {
background: #ff989e;
color: white;
}
.open-cover {
transform: rotatex(180deg);
}
.open-paper {
animation: openPaper 0.5s forwards;
}
@keyframes openPaper {
0% {
top: 0;
}
100% {
top: -250px;
}
}
.close-paper {
animation: closePaper 0.5s forwards;
}
@keyframes closePaper {
0% {
top: -120px;
}
100% {
top: 0;
}
}
.heart {
display: none;
position: absolute;
top: 25%;
left: 46.5%;
margin: auto;
font-size: 3rem;
color: #fe3334;
animation: crecer 1s forwards;
}
@keyframes crecer {
0% {
scale: 1;
opacity: 1;
}
100% {
scale: 3;
opacity: 0;
}
}
</style>
</head>
<body>
<main>
<div class="container-letter">
<div class="cover"></div>
<span class="heart">♥</span>
<p class="paper" id="mainMessage">
<strong>Holis Princesa ❤️ </strong>,<br>
Linda si ves esto en la mañana, como mimiste ?? espero que hayas mimido muy bien, Hoy será un día mejor que ayer, ¡ya verás!.<br>
<strong> Me encantaaaaas</strong><br><em>Con cariño Juan Camilo</em>
</p>
<div class="letter"></div>
</div>
<div class="options">
<button id="open">Abrir</button>
<button id="close">Cerrar</button>
</div>
</main>
<script>
// read custom message from query strings
const urlSearchParams = new URLSearchParams(window.location.search);
const messageCustom = urlSearchParams.get('message');
if (messageCustom) {
const mainMessageElement = document.querySelector('#mainMessage');
mainMessageElement.textContent = decodeURI(messageCustom);
}
const btnOpenElement = document.querySelector('#open');
const btnCloseElement = document.querySelector('#close');
btnCloseElement.disabled = true;
btnOpenElement.addEventListener('click', () => {
btnOpenElement.disabled = true;
btnCloseElement.disabled = false;
const coverElement = document.querySelector('.cover');
coverElement.classList.add('open-cover');
setTimeout(() => {
coverElement.style.zIndex = -1;
const paperElement = document.querySelector('.paper');
paperElement.classList.remove('close-paper');
paperElement.classList.add('open-paper');
const heartElement = document.querySelector('.heart');
heartElement.style.display = 'block';
}, 500);
});
btnCloseElement.addEventListener('click', () => {
btnOpenElement.disabled = false;
btnCloseElement.disabled = true;
const coverElement = document.querySelector('.cover');
const paperElement = document.querySelector('.paper');
paperElement.classList.remove('open-paper');
paperElement.classList.add('close-paper');
setTimeout(() => {
coverElement.style.zIndex = 0;
coverElement.classList.remove('open-cover');
const heartElement = document.querySelector('.heart');
heartElement.style.display = 'none';
}, 500);
});
</script>
</body>
</html>