Skip to content

chore: Remove long typewriter sentence #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 84 additions & 74 deletions src/components/HeroTypewriter.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,90 +3,100 @@
---

<div class="container">
<span id="text"></span><span class="cursor"></span>
<span id="text"></span><span class="cursor"></span>
</div>

<script>
function setupTypewriter() {
const typewriterElement = document.getElementById("text");

const texts = [
"Tech Meetups",
"JavaScript Community",
"Networking & Social Events",
"Community since 2018",
"Connect with Local Developers",
];
const typingSpeed = 100;
const delayBetweenTexts = 2000;

let currentIndex = 0;
let charIndex = 0;

async function cycleTexts() {
while (true && typewriterElement) {
const text = texts[currentIndex];

// Typing animation
while (charIndex < text.length) {
typewriterElement.textContent += text.charAt(charIndex);
charIndex++;
await new Promise((resolve) => setTimeout(resolve, typingSpeed));
function setupTypewriter() {
const typewriterElement = document.getElementById("text");

const texts = [
"Tech Meetups",
"JavaScript Community",
"Networking & Social Events",
"Community since 2018",
];
const typingSpeed = 100;
const delayBetweenTexts = 2000;

let currentIndex = 0;
let charIndex = 0;

async function cycleTexts() {
while (true && typewriterElement) {
const text = texts[currentIndex];

// Typing animation
while (charIndex < text.length) {
typewriterElement.textContent += text.charAt(charIndex);
charIndex++;
await new Promise((resolve) =>
setTimeout(resolve, typingSpeed),
);
}

// Wait before deleting
await new Promise((resolve) =>
setTimeout(resolve, delayBetweenTexts),
);

// Deleting animation
while (charIndex > 0) {
typewriterElement.textContent = text.substring(
0,
charIndex - 1,
);
charIndex--;
await new Promise((resolve) =>
setTimeout(resolve, typingSpeed / 2),
);
}

currentIndex = (currentIndex + 1) % texts.length;
charIndex = 0;

// Small pause before starting next text
await new Promise((resolve) =>
setTimeout(resolve, typingSpeed),
);
}
}

// Wait before deleting
await new Promise((resolve) => setTimeout(resolve, delayBetweenTexts));

// Deleting animation
while (charIndex > 0) {
typewriterElement.textContent = text.substring(0, charIndex - 1);
charIndex--;
await new Promise((resolve) => setTimeout(resolve, typingSpeed / 2));
}

currentIndex = (currentIndex + 1) % texts.length;
charIndex = 0;

// Small pause before starting next text
await new Promise((resolve) => setTimeout(resolve, typingSpeed));
}
cycleTexts();
}

cycleTexts();
}

setupTypewriter();
setupTypewriter();
</script>

<style>
.container {
display: flex;
flex-direction: row;
align-items: center;
height: 2rem;
}

#text {
font-size: 1.5rem;
font-family: monospace;
}

.cursor {
display: inline-block;
width: 4px;
height: 1.5rem;
background-color: #000;
margin-left: 6px;
animation: blink 1s step-end infinite;
}

@keyframes blink {
0%,
100% {
opacity: 1;
.container {
display: flex;
flex-direction: row;
align-items: center;
height: 2rem;
}

#text {
font-size: 1.5rem;
font-family: monospace;
}

.cursor {
display: inline-block;
width: 4px;
height: 1.5rem;
background-color: #000;
margin-left: 6px;
animation: blink 1s step-end infinite;
}
50% {
opacity: 0;

@keyframes blink {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0;
}
}
}
</style>