mirror of
https://github.com/YouHaveTrouble/youhavetrouble.github.io.git
synced 2026-05-11 22:06:56 +00:00
add my online status
This commit is contained in:
+67
-19
@@ -11,8 +11,13 @@ const permalink = Astro?.site?.href ?? '/';
|
|||||||
<div class="home-copy">
|
<div class="home-copy">
|
||||||
<h1>Welcome to my little corner of the interwebs</h1>
|
<h1>Welcome to my little corner of the interwebs</h1>
|
||||||
<p>Feel free to check out what I got in store!</p>
|
<p>Feel free to check out what I got in store!</p>
|
||||||
|
<div class="status">
|
||||||
|
<div class="wrap">
|
||||||
|
<span>My online status:</span>
|
||||||
|
<span id="online-status">Unknown</span><span id="online-game"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hero-socials">
|
<div class="hero-socials">
|
||||||
<h2>Socials</h2>
|
<h2>Socials</h2>
|
||||||
<div class="hero-socials-grid">
|
<div class="hero-socials-grid">
|
||||||
@@ -33,18 +38,19 @@ const permalink = Astro?.site?.href ?? '/';
|
|||||||
<span>Steam</span>
|
<span>Steam</span>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.youtube.com/@YouHaveTrouble" class="social-link" target="_blank" rel="external">
|
<a href="https://www.youtube.com/@YouHaveTrouble" class="social-link" target="_blank" rel="external">
|
||||||
<img src="/assets/icons/youtube.svg" alt="" aria-hidden="true" draggable="false" loading="eager">
|
<img src="/assets/icons/youtube.svg" alt="" aria-hidden="true" draggable="false" loading="eager">
|
||||||
<span>YouTube</span>
|
<span>YouTube</span>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://modrinth.com/user/YouHaveTrouble" class="social-link" target="_blank" rel="external">
|
<a href="https://modrinth.com/user/YouHaveTrouble" class="social-link" target="_blank" rel="external">
|
||||||
<img src="/assets/icons/modrinth.svg" alt="" aria-hidden="true" draggable="false" loading="eager">
|
<img src="/assets/icons/modrinth.svg" alt="" aria-hidden="true" draggable="false" loading="eager">
|
||||||
<span>Modrinth</span>
|
<span>Modrinth</span>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://wakatime.com/@YouHaveTrouble" class="social-link" target="_blank" rel="external">
|
<a href="https://wakatime.com/@YouHaveTrouble" class="social-link" target="_blank" rel="external">
|
||||||
<img src="/assets/icons/wakatime.svg" alt="" aria-hidden="true" draggable="false" loading="eager">
|
<img src="/assets/icons/wakatime.svg" alt="" aria-hidden="true" draggable="false" loading="eager">
|
||||||
<span>WakaTime</span>
|
<span>WakaTime</span>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.linkedin.com/in/pawel-youhavetrouble-michalewski/" class="social-link" target="_blank" rel="external">
|
<a href="https://www.linkedin.com/in/pawel-youhavetrouble-michalewski/" class="social-link" target="_blank"
|
||||||
|
rel="external">
|
||||||
<img src="/assets/icons/linkedin.svg" alt="" aria-hidden="true" draggable="false" loading="eager">
|
<img src="/assets/icons/linkedin.svg" alt="" aria-hidden="true" draggable="false" loading="eager">
|
||||||
<span>LinkedIn</span>
|
<span>LinkedIn</span>
|
||||||
</a>
|
</a>
|
||||||
@@ -54,11 +60,29 @@ const permalink = Astro?.site?.href ?? '/';
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
|
|
||||||
<style>
|
<script lang="ts" client:load>
|
||||||
|
const status = document.querySelector("#online-status");
|
||||||
|
const game = document.querySelector("#online-game");
|
||||||
|
|
||||||
|
updateOnlineStatus();
|
||||||
|
|
||||||
|
async function updateOnlineStatus() {
|
||||||
|
console.debug("Updating online status...");
|
||||||
|
const response = await fetch("https://api.youhavetrouble.me/online");
|
||||||
|
const data = await response.json();
|
||||||
|
const online = data.discord !== "OFFLINE" || data.steam !== "OFFLINE";
|
||||||
|
const gameName = data.steam.game;
|
||||||
|
status.textContent = online ? "Online" : "Offline";
|
||||||
|
status.classList.value = online ? "online" : "offline";
|
||||||
|
game.textContent = gameName ? `, playing: ${gameName}` : "";
|
||||||
|
setTimeout(updateOnlineStatus, 10000);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
.home-container {
|
.home-container {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -66,21 +90,42 @@ const permalink = Astro?.site?.href ?? '/';
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin: 2em 0;
|
margin: 2em 0;
|
||||||
min-height: 400px;
|
min-height: 400px;
|
||||||
|
|
||||||
|
.home-copy {
|
||||||
|
flex: 1;
|
||||||
|
padding: 0 1em;
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 1.4em;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.home-copy {
|
#online-status {
|
||||||
flex: 1;
|
&::before {
|
||||||
padding: 0 1em;
|
content: '';
|
||||||
}
|
display: inline-block;
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-inline-end: 0.2rem;
|
||||||
|
transform: translateY(0.1rem);
|
||||||
|
background-color: #cc8d2e;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
&.online::before {
|
||||||
|
background-color: #2ecc71;
|
||||||
|
}
|
||||||
|
&.offline::before {
|
||||||
|
background-color: #e74c3c;
|
||||||
|
}
|
||||||
|
|
||||||
.home-copy h1 {
|
|
||||||
font-weight: 700;
|
|
||||||
margin-bottom: 0.5em;
|
|
||||||
line-height: 1.3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.home-copy p {
|
|
||||||
font-size: 1.4em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hero-socials {
|
.hero-socials {
|
||||||
@@ -89,6 +134,7 @@ const permalink = Astro?.site?.href ?? '/';
|
|||||||
max-width: min(100%, 450px);
|
max-width: min(100%, 450px);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
gap: 1.5rem;
|
gap: 1.5rem;
|
||||||
|
|
||||||
.hero-socials-grid {
|
.hero-socials-grid {
|
||||||
margin: 0 1em;
|
margin: 0 1em;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -97,6 +143,7 @@ const permalink = Astro?.site?.href ?? '/';
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
gap: 0.75rem;
|
gap: 0.75rem;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -111,6 +158,7 @@ const permalink = Astro?.site?.href ?? '/';
|
|||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: var(--text-main);
|
color: var(--text-main);
|
||||||
border-color: var(--text-main);
|
border-color: var(--text-main);
|
||||||
|
|||||||
Reference in New Issue
Block a user