first draft

This commit is contained in:
Barrett Ruth 2024-06-08 18:41:11 -05:00
parent 005ea8d7d9
commit ccdb46c7a7
3 changed files with 38 additions and 17 deletions

View file

@ -102,6 +102,12 @@ a {
.topics {
font-size: 3em;
flex: 1;
justify-content: space-between;
}
.post {
font-size: 2em;
}
.software a:hover {
@ -113,14 +119,10 @@ a {
.trading a:hover {
color: #d50032;
}
.interview-problems a:hover {
.algorithms a:hover {
color: #6a0dad;
}
.logo {
height: 40px;
}
.topic a {
position: relative;
display: inline-block;

View file

@ -32,10 +32,11 @@
<li class="topic trading">
<a href="/trading" onclick="typechars(event)">Trading</a>
</li>
<li class="topic interview-problems">
<li class="topic algorithms">
<a href="/algorithms" onclick="typechars(event)">Algorithms</a>
</li>
</ul>
<div class="posts" id="posts"></div>
</main>
<footer>
<div class="footer-links">

View file

@ -1,20 +1,39 @@
function typechars(e, url = "wip.html") {
const postMapping = new Map([
["Software", ["Post 1", "Post 2", "Post 3"]],
["Economics", ["Economy 1", "Economy 2"]],
["Trading", ["Trade Secrets", "Market Trends"]],
["Algorithms", ["Algorithm Challenges", "Data Structures 101"]],
]);
// TODO: ensure handling multiple clicks
function renderPosts(topic) {
const posts = document.getElementById("posts");
posts.innerHTML = "";
postMapping.get(topic).forEach((postName) => {
const post = document.createElement("div");
post.classList.add("post");
post.textContent = postName;
posts.appendChild(post);
});
}
function typechars(e) {
e.preventDefault();
const text = ` ${e.target.textContent.toLowerCase()}/`;
const topic = e.target.textContent;
const terminalText = ` ${topic.toLowerCase()}/`;
const terminalPrompt = document.querySelector(".prompt");
terminalPrompt.innerHTML = "barrett@ruth:~$ ";
let i = 0;
function typechar() {
if (i < text.length) {
terminalPrompt.innerHTML += text.charAt(i);
i++;
setTimeout(typechar, 1000 / text.length);
if (i < terminalText.length) {
terminalPrompt.innerHTML += terminalText.charAt(i++);
setTimeout(typechar, 1000 / terminalText.length);
} else {
setTimeout(() => {
window.location.href = url;
}, 500);
renderPosts(topic);
}
}
@ -22,6 +41,5 @@ function typechars(e, url = "wip.html") {
}
window.addEventListener("beforeunload", () => {
const terminalPrompt = document.querySelector(".prompt");
terminalPrompt.innerHTML = "barrett@ruth:~$ ";
document.querySelector(".prompt").innerHTML = "barrett@ruth:~$ ";
});