-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from karsonkalt/add-about
Add about
- Loading branch information
Showing
18 changed files
with
247 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const GITHUB_USERNAME = "karsonkalt"; | ||
|
||
type GitHubEvent = { | ||
actor: { | ||
id: number; | ||
login: string; | ||
display_login: string; | ||
gravatar_id: string; | ||
url: string; | ||
}; | ||
created_at: string; | ||
id: string; | ||
payload: { | ||
repository_id: number; | ||
push_id: number; | ||
size: number; | ||
distinct_size: number; | ||
ref: string; | ||
}; | ||
public: boolean; | ||
repo: { | ||
id: number; | ||
name: string; | ||
url: string; | ||
}; | ||
type: string; | ||
}; | ||
|
||
export const addGithubStatus = () => { | ||
const url = `https://api.github.com/users/${GITHUB_USERNAME}/events/public`; | ||
fetch(url) | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
if (data.length === 0) { | ||
return; | ||
} | ||
const latestEvent = data[0] as GitHubEvent; | ||
const latestGithubInteractionDate = new Date(latestEvent.created_at); | ||
const githubStatusElement = document.getElementById("github-status"); | ||
if (githubStatusElement) { | ||
const formattedDate = latestGithubInteractionDate.toLocaleString( | ||
"default", | ||
{ | ||
month: "long", | ||
day: "numeric", | ||
hour: "numeric", | ||
minute: "numeric", | ||
hour12: true, | ||
} | ||
); | ||
githubStatusElement.innerHTML = `Last GitHub Activity: ${formattedDate}`; | ||
} | ||
}) | ||
.catch((error) => { | ||
console.error("Error fetching activity", error.message); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { addGithubStatus } from "./githubStatus"; | ||
import { addTabs } from "./tabs"; | ||
import { addTerminal } from "./terminal/index"; | ||
|
||
document.addEventListener("DOMContentLoaded", () => { | ||
addTabs(); | ||
addTerminal(); | ||
addGithubStatus(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
export const addTabs = () => { | ||
const TAB_QUERY_SELECTOR = "[role='tab']"; | ||
|
||
const tabNodes = Array.from(document.querySelectorAll(TAB_QUERY_SELECTOR)); | ||
const bottomDrawerNode = document.querySelector(".bottom-drawer"); | ||
|
||
const promptElement = document.querySelector(".prompt") as HTMLInputElement; | ||
|
||
tabNodes.forEach((tab) => { | ||
tab.addEventListener("click", () => { | ||
history.replaceState(null, "", "#" + tab.id); | ||
applyChanges(tab); | ||
}); | ||
}); | ||
|
||
window.onhashchange = function () { | ||
const tab = document.querySelector(location.hash); | ||
if (tab) { | ||
applyChanges(tab); | ||
} | ||
}; | ||
|
||
function applyChanges(clickedTab: Element) { | ||
updateBadge(clickedTab.getAttribute("id") === "console"); | ||
|
||
tabNodes.forEach((tab) => { | ||
const isSelected = tab === clickedTab; | ||
tab.setAttribute("aria-selected", isSelected.toString()); | ||
|
||
const tabPanelId = tab.getAttribute("aria-controls"); | ||
const tabPanel = document.getElementById(tabPanelId || ""); | ||
|
||
if (!tabPanel) { | ||
return; | ||
} | ||
|
||
if (isSelected) { | ||
tabPanel.removeAttribute("hidden"); | ||
} else { | ||
tabPanel.setAttribute("hidden", ""); | ||
} | ||
}); | ||
|
||
if (clickedTab.getAttribute("id") === "console") { | ||
bottomDrawerNode?.setAttribute("open", ""); | ||
promptElement.focus(); | ||
} else { | ||
bottomDrawerNode?.removeAttribute("open"); | ||
promptElement.blur(); | ||
} | ||
} | ||
|
||
// duplicated from other | ||
function updateBadge(hasUnreadStdout: boolean) { | ||
const consoleTab = document.querySelector("#console"); | ||
const badge = consoleTab?.querySelector(".unread-badge"); | ||
|
||
if (hasUnreadStdout) { | ||
badge?.classList.remove("show"); | ||
} | ||
} | ||
|
||
if (location.hash) { | ||
const tab = document.querySelector(location.hash); | ||
if (tab) { | ||
applyChanges(tab); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { UserInputManager } from "./UserInputManager"; | ||
|
||
export const addTerminal = () => { | ||
const prompt = document.querySelector(".prompt") as HTMLInputElement; | ||
const mirrorElement = document.querySelector( | ||
".input-mirror" | ||
) as HTMLDivElement; | ||
const terminal = document.querySelector(".terminal") as HTMLDivElement; | ||
|
||
const userInputManager = new UserInputManager( | ||
prompt, | ||
terminal, | ||
mirrorElement | ||
); | ||
|
||
userInputManager.handleBashCommand("restore", false); // TODO I dont like this | ||
userInputManager.handleBashCommand("help", true); | ||
}; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.