Skip to content

Commit 8654351

Browse files
committed
feat: Add typewriter effect cycling through 4 Sanskrit sandhi states
1 parent abf7b28 commit 8654351

File tree

1 file changed

+58
-20
lines changed

1 file changed

+58
-20
lines changed

portfolio.md

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -255,26 +255,17 @@ full-width: true
255255
position: relative;
256256
}
257257

258-
.quote-sandhi, .quote-pada {
259-
position: absolute;
260-
left: 0;
261-
right: 0;
262-
animation: quoteTransition 8s ease-in-out infinite;
263-
}
264-
265-
.quote-sandhi {
266-
animation-delay: 0s;
267-
}
268-
269-
.quote-pada {
270-
animation-delay: 4s;
271-
opacity: 0;
258+
.typewriter-text {
259+
display: inline-block;
260+
border-right: 3px solid white;
261+
animation: blink 0.7s step-end infinite;
262+
white-space: nowrap;
263+
overflow: hidden;
272264
}
273265

274-
@keyframes quoteTransition {
275-
0%, 45% { opacity: 1; }
276-
50%, 95% { opacity: 0; }
277-
100% { opacity: 1; }
266+
@keyframes blink {
267+
0%, 100% { border-color: white; }
268+
50% { border-color: transparent; }
278269
}
279270

280271
.quote-section cite {
@@ -1130,12 +1121,59 @@ full-width: true
11301121

11311122
<div class="quote-section">
11321123
<blockquote class="sanskrit-quote">
1133-
<span class="quote-sandhi">यदिहास्ति तदन्यत्र यन्नेहास्ति न तत्क्वचित्</span>
1134-
<span class="quote-pada">यत् इह अस्ति तत् अन्यत्र यत् न इह अस्ति न तत् क्वचित्</span>
1124+
<span class="typewriter-text" id="sanskrit-typewriter"></span>
11351125
</blockquote>
11361126
<cite>— What exists here may be found elsewhere; what does not exist here exists nowhere.</cite>
11371127
</div>
11381128

1129+
<script>
1130+
(function() {
1131+
const quotes = [
1132+
'यत् इह अस्ति तत् अन्यत्र यत् न अस्ति न तत् क्वचित्',
1133+
'यद् इह अस्ति तद् अन्यत्र यद् न अस्ति न तद् क्वचित्',
1134+
'यदिह अस्ति तदन्यत्र यद्न अस्ति न तद्क्वचित्',
1135+
'यदिहास्ति तदन्यत्र यद्नास्ति न तद्क्वचित्'
1136+
];
1137+
1138+
let quoteIndex = 0;
1139+
let charIndex = 0;
1140+
let isDeleting = false;
1141+
const element = document.getElementById('sanskrit-typewriter');
1142+
const typeSpeed = 80;
1143+
const deleteSpeed = 40;
1144+
const pauseTime = 2000;
1145+
1146+
function typeWriter() {
1147+
const currentQuote = quotes[quoteIndex];
1148+
1149+
if (isDeleting) {
1150+
element.textContent = currentQuote.substring(0, charIndex - 1);
1151+
charIndex--;
1152+
} else {
1153+
element.textContent = currentQuote.substring(0, charIndex + 1);
1154+
charIndex++;
1155+
}
1156+
1157+
let delay = isDeleting ? deleteSpeed : typeSpeed;
1158+
1159+
if (!isDeleting && charIndex === currentQuote.length) {
1160+
delay = pauseTime;
1161+
isDeleting = true;
1162+
} else if (isDeleting && charIndex === 0) {
1163+
isDeleting = false;
1164+
quoteIndex = (quoteIndex + 1) % quotes.length;
1165+
delay = 500;
1166+
}
1167+
1168+
setTimeout(typeWriter, delay);
1169+
}
1170+
1171+
if (element) {
1172+
typeWriter();
1173+
}
1174+
})();
1175+
</script>
1176+
11391177
<div class="contact-cta">
11401178
<h3>Let's Build Something Together</h3>
11411179
<p>Interested in collaborating on open source, NLP, or Sanskrit computational linguistics?</p>

0 commit comments

Comments
 (0)