-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage2.html
More file actions
207 lines (189 loc) · 5.8 KB
/
page2.html
File metadata and controls
207 lines (189 loc) · 5.8 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Minimalist Typing Experience</title>
<style>
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap");
body {
font-family: "Helvetica", sans-serif;
background-color: black;
color: #333;
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
transition: background-color 0.5s ease-in-out;
overflow: hidden;
}
.fixed-text input {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
z-index: 10;
height: 60px;
width: 400px;
background-color: #ffffff;
border: 2px solid #e0e0e0;
border-radius: 20px;
text-align: center;
font-size: 18px;
outline: none;
color: #333;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
transition: all 0.2s ease-in-out;
}
.fixed-text input:focus {
border-color: #007bff;
box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
}
.bgcolortext {
color: whitesmoke;
position: absolute;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-size: 24px;
padding-bottom: 20px;
font-weight: 300;
flex-direction: column;
}
.popoutlettrs {
position: absolute;
width: 100%;
height: 50vh; /* Lower half of the screen */
bottom: 0;
left: 0;
}
#heroText {
font-size: 5rem;
font-weight: 700;
text-transform: uppercase;
transition: all 0.5s ease-in-out;
letter-spacing: 2px;
color: rgba(0, 0, 0, 0.8);
animation: fadeIn 0.5s ease-in-out;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
</head>
<body>
<div class="fixed-text">
<input type="text" placeholder="Start typing..." id="textInput" />
</div>
<div class="bgcolortext">
<h1 id="heroText" style="color: whitesmoke">Typing Experience</h1>
<p id="tobeerased">Enter a color name to change background</p>
</div>
<div class="popoutlettrs"></div>
<script>
const inputField = document.getElementById("textInput");
const body = document.body;
const popoutContainer = document.querySelector(".popoutlettrs");
const colors = {
red: "#F28B82",
blue: "#AECBFA",
green: "#CCFF90",
yellow: "#FFF475",
gray: "#E0E0E0",
white: "#FFFFFF",
black: "#202124",
pink: "#FDCFE8",
purple: "#D7AEFB",
cyan: "#A7FFEB",
};
function findClosestColor(text) {
const words = text.toLowerCase().split(/\s+/);
for (let word of words) {
if (colors[word]) {
return colors[word];
}
}
return "black"; // Default background color
}
inputField.addEventListener("input", () => {
const enteredText = inputField.value.trim();
body.style.backgroundColor = findClosestColor(enteredText);
popout(enteredText);
});
function popout(text) {
const bubbleColors = [
"#FFADAD",
"#FFD6A5",
"#FDFFB6",
"#CAFFBF",
"#9BF6FF",
"#A0C4FF",
"#BDB2FF",
];
text.split(" ").forEach((word, index) => {
word.split("").forEach((char) => {
const span = document.createElement("span");
span.textContent = char;
span.style.position = "absolute";
span.style.left = `${Math.random() * 90}%`;
span.style.bottom = `${Math.random() * 50}vh`; /* Spread across lower half */
span.style.color = "#333";
span.style.backgroundColor =
bubbleColors[Math.floor(Math.random() * bubbleColors.length)];
span.style.fontSize = "1.5rem";
span.style.fontWeight = "bold";
span.style.display = "flex";
span.style.alignItems = "center";
span.style.justifyContent = "center";
span.style.width = "40px";
span.style.height = "40px";
span.style.borderRadius = "8px";
span.style.opacity = "0";
span.style.transition =
"opacity 0.3s ease-in-out, transform 0.5s ease-in-out";
popoutContainer.appendChild(span);
setTimeout(() => {
span.style.opacity = "1";
span.style.transform = "translateY(-10px)";
}, index * 50);
setTimeout(() => {
span.style.opacity = "0";
setTimeout(() => {
span.remove();
}, 500);
}, 1000);
});
});
}
const heroText = document.getElementById("heroText");
const tobeerased = document.getElementById("tobeerased");
let charCount = 0;
const sound = new Audio("cool-music.mp3");
const sound2 = new Audio("pop-mf.mp3");
inputField.addEventListener("input", () => {
const enteredText = inputField.value.trim();
heroText.innerHTML = enteredText || "Typing Experience"; // Default text if empty
tobeerased.innerHTML = "";
charCount++;
if (charCount % 15 === 0) {
sound.play();
}
if (charCount % 2 === 0) {
sound2.play();
}
});
</script>
</body>
</html>