fix: button code on mobile

also change /status to /activity and also mess up linting (lol)
This commit is contained in:
trafficlunar 2026-02-14 22:16:28 +00:00
parent 133486724a
commit 508731facb
7 changed files with 48 additions and 169 deletions

View file

@ -1,14 +1,6 @@
<script lang="ts">
import { onMount } from "svelte";
import {
Area,
Axis,
Chart,
Highlight,
LinearGradient,
Svg,
Tooltip,
} from "layerchart";
import { Area, Axis, Chart, Highlight, LinearGradient, Svg, Tooltip } from "layerchart";
import { scaleTime } from "d3-scale";
import { curveCatmullRom } from "d3-shape";
import { computerData } from "../states.svelte";
@ -78,19 +70,14 @@
ram: point.ram / 100,
}));
const totalClicks = chartData.reduce(
(sum, point) => sum + point.clicks,
0
);
const totalClicks = chartData.reduce((sum, point) => sum + point.clicks, 0);
const totalKeys = chartData.reduce((sum, point) => sum + point.keys, 0);
clicksPerMinute = totalClicks / 60; // 60 minutes (max graph data)
keysPerMinute = totalKeys / 60;
// Uptime
const diff = data.online
? Math.floor((Date.now() - data.uptimeStart * 1000) / 1000)
: 0;
const diff = data.online ? Math.floor((Date.now() - data.uptimeStart * 1000) / 1000) : 0;
const allTime = diff + data.totals.uptime;
allTimeUptime = formatTime(allTime);
@ -111,16 +98,10 @@
});
</script>
<div
class="relative transition-all duration-300 delay-200 starting:opacity-0 starting:translate-y-4"
>
<div class="relative transition-all duration-300 delay-200 starting:opacity-0 starting:translate-y-4">
<div class="flex justify-center items-center absolute -top-2 right-2 z-0">
<div class="w-4 h-4 rounded-full {online ? 'bg-green' : 'bg-red'}"></div>
<div
class="w-4 h-4 rounded-full absolute animate-duration-2s animate-delay-2s {online
? 'bg-green animate-ping'
: 'bg-red'}"
></div>
<div class="w-4 h-4 rounded-full absolute animate-duration-2s animate-delay-2s {online ? 'bg-green animate-ping' : 'bg-red'}"></div>
</div>
<section class="mb-0!">
@ -135,10 +116,7 @@
<span class="text-xs font-bold text-peach">{currentCPU}%</span>
</div>
<div class="h-1.5 w-full rounded-full overflow-hidden bg-surface0/50">
<div
class="h-full rounded-full bg-peach transition-all duration-300"
style="width: {Math.min(100, currentCPU)}%;"
></div>
<div class="h-full rounded-full bg-peach transition-all duration-300" style="width: {Math.min(100, currentCPU)}%;"></div>
</div>
</div>
@ -148,10 +126,7 @@
<span class="text-xs font-bold text-yellow">{currentRAM}%</span>
</div>
<div class="h-1.5 w-full rounded-full overflow-hidden bg-surface0/50">
<div
class="h-full rounded-full bg-yellow transition-all duration-300"
style="width: {Math.min(100, currentRAM)}%;"
></div>
<div class="h-full rounded-full bg-yellow transition-all duration-300" style="width: {Math.min(100, currentRAM)}%;"></div>
</div>
</div>
</div>
@ -159,32 +134,19 @@
<!-- Stats Grid -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<!-- Uptime Card -->
<div
class="bg-surface0/30 rounded-lg p-3 border border-surface0 shadow-sm"
>
<div class="bg-surface0/30 rounded-lg p-3 border border-surface0 shadow-sm">
<div class="flex mb-1">
<div class="relative">
<svg
width="20"
height="20"
viewBox="0 0 20 20"
fill-rule="evenodd"
class="absolute -bottom-0.5 fill-overlay1"
>
<path
d="M10 5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11M2.5 11a7.5 7.5 0 1 1 15 0 7.5 7.5 0 0 1-15 0"
/>
<svg width="20" height="20" viewBox="0 0 20 20" fill-rule="evenodd" class="absolute -bottom-0.5 fill-overlay1">
<path d="M10 5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11M2.5 11a7.5 7.5 0 1 1 15 0 7.5 7.5 0 0 1-15 0" />
<path
d="M2.793 3.793a1 1 0 0 1 1.414 0l1.5 1.5c.91.943-.471 2.324-1.414 1.414l-1.5-1.5a1 1 0 0 1 0-1.414m11.5 2.914a1 1 0 0 0 1.414 0l1.5-1.5c.91-.943-.471-2.324-1.414-1.414l-1.5 1.5a1 1 0 0 0 0 1.414M9 4V2h2v2z"
/>
<path
d="M7.5 2a1 1 0 0 1 1-1h3a1 1 0 1 1 0 2h-3a1 1 0 0 1-1-1"
/>
<path d="M7.5 2a1 1 0 0 1 1-1h3a1 1 0 1 1 0 2h-3a1 1 0 0 1-1-1" />
<!-- Hand -->
<path
d="m 13.28,8.375 c 0.345578,0.4310223 0.276171,1.0606079 -0.155,1.406 l -2.5,2 C 9.583667,12.614333 8.333667,11.052333 9.375,10.219 l 2.5,-2 c 0.431286,-0.3453463 1.060907,-0.2754879 1.406,0.156"
style="transform: rotate({stopwatchDeg -
52}deg); transform-origin: 10px 11px; transition: transform 1s linear;"
style="transform: rotate({stopwatchDeg - 52}deg); transform-origin: 10px 11px; transition: transform 1s linear;"
/>
</svg>
</div>
@ -195,32 +157,22 @@
</div>
<!-- Activity Card -->
<div
class="bg-surface0/30 rounded-lg p-3 border border-surface0 shadow-sm"
>
<div class="font-black text-xs text-overlay1 mb-2">
ACTIVITY / MIN
</div>
<div class="bg-surface0/30 rounded-lg p-3 border border-surface0 shadow-sm">
<div class="font-black text-xs text-overlay1 mb-2">ACTIVITY / MIN</div>
<div class="space-y-1.5">
<div class="flex justify-between items-center">
<span class="text-xs text-overlay1">Clicks</span>
<span class="font-bold text-teal"
>{clicksPerMinute.toFixed(1)}</span
>
<span class="font-bold text-teal">{clicksPerMinute.toFixed(1)}</span>
</div>
<div class="flex justify-between items-center">
<span class="text-xs text-overlay1">Keys</span>
<span class="font-bold text-green"
>{keysPerMinute.toFixed(1)}</span
>
<span class="font-bold text-green">{keysPerMinute.toFixed(1)}</span>
</div>
</div>
</div>
<!-- All Time Card -->
<div
class="bg-surface0/30 rounded-lg p-3 border border-surface0 shadow-sm"
>
<div class="bg-surface0/30 rounded-lg p-3 border border-surface0 shadow-sm">
<div class="font-black text-xs text-overlay1 mb-2">ALL TIME</div>
<div class="space-y-1.5">
<div class="flex justify-between items-center">
@ -236,9 +188,7 @@
</div>
</div>
<div
class="relative h-96 rounded-md bg-mantle border border-surface0 p-2 shadow-sm"
>
<div class="relative h-96 rounded-md bg-mantle border border-surface0 p-2 shadow-sm">
<Chart
data={chartData}
x="timestamp"
@ -274,65 +224,35 @@
<!-- RAM -->
<LinearGradient class="from-peach/50 to-peach/1" vertical>
{#snippet children({ gradient })}
<Area
y1={(d) => d.ram}
fill={gradient}
line={{ class: "stroke-2 stroke-peach" }}
curve={curveCatmullRom}
/>
<Area y1={(d) => d.ram} fill={gradient} line={{ class: "stroke-2 stroke-peach" }} curve={curveCatmullRom} />
{/snippet}
</LinearGradient>
<!-- CPU -->
<LinearGradient class="from-yellow/50 to-yellow/1" vertical>
{#snippet children({ gradient })}
<Area
y1={(d) => d.cpu}
fill={gradient}
line={{ class: "stroke-2 stroke-yellow" }}
curve={curveCatmullRom}
/>
<Area y1={(d) => d.cpu} fill={gradient} line={{ class: "stroke-2 stroke-yellow" }} curve={curveCatmullRom} />
{/snippet}
</LinearGradient>
<Highlight
lines={{ class: "stroke-peach [stroke-dasharray:unset]" }}
/>
<Highlight lines={{ class: "stroke-peach [stroke-dasharray:unset]" }} />
<Highlight y={(d) => d.ram} points={{ class: "fill-peach" }} />
<Highlight y={(d) => d.cpu} points={{ class: "fill-yellow" }} />
</Svg>
<Tooltip.Root
class="border border-peach bg-peach/10! text-white/85 backdrop-blur-lg!"
>
<Tooltip.Root class="border border-peach bg-peach/10! text-white/85 backdrop-blur-lg!">
{#snippet children({ data })}
<Tooltip.Header
value={data.timestamp}
format="time"
classes={{ root: "border-peach" }}
/>
<Tooltip.Header value={data.timestamp} format="time" classes={{ root: "border-peach" }} />
<Tooltip.List>
<Tooltip.Item
label="RAM (%)"
value={data.ram}
format="percentRound"
classes={{ value: "font-mono font-black text-peach" }}
/>
<Tooltip.Item
label="CPU (%)"
value={data.cpu}
format="percentRound"
classes={{ value: "font-mono font-black text-yellow" }}
/>
<Tooltip.Item label="RAM (%)" value={data.ram} format="percentRound" classes={{ value: "font-mono font-black text-peach" }} />
<Tooltip.Item label="CPU (%)" value={data.cpu} format="percentRound" classes={{ value: "font-mono font-black text-yellow" }} />
</Tooltip.List>
{/snippet}
</Tooltip.Root>
</Chart>
</div>
<div
class="relative h-48 rounded-md bg-mantle border border-surface0 p-2 mt-2 shadow-sm"
>
<div class="relative h-48 rounded-md bg-mantle border border-surface0 p-2 mt-2 shadow-sm">
<Chart
data={chartData}
x="timestamp"
@ -367,61 +287,38 @@
<!-- Keys -->
<LinearGradient class="from-green/50 to-green/1" vertical>
{#snippet children({ gradient })}
<Area
y1={(d) => d.keys}
fill={gradient}
line={{ class: "stroke-2 stroke-green" }}
curve={curveCatmullRom}
/>
<Area y1={(d) => d.keys} fill={gradient} line={{ class: "stroke-2 stroke-green" }} curve={curveCatmullRom} />
{/snippet}
</LinearGradient>
<!-- Clicks -->
<LinearGradient class="from-teal/50 to-teal/1" vertical>
{#snippet children({ gradient })}
<Area
y1={(d) => d.clicks}
fill={gradient}
line={{ class: "stroke-2 stroke-teal" }}
curve={curveCatmullRom}
/>
<Area y1={(d) => d.clicks} fill={gradient} line={{ class: "stroke-2 stroke-teal" }} curve={curveCatmullRom} />
{/snippet}
</LinearGradient>
<Highlight
lines={{ class: "stroke-peach [stroke-dasharray:unset]" }}
/>
<Highlight lines={{ class: "stroke-peach [stroke-dasharray:unset]" }} />
<Highlight y={(d) => d.keys} points={{ class: "fill-green" }} />
<Highlight y={(d) => d.clicks} points={{ class: "fill-teal" }} />
</Svg>
<Tooltip.Root
classes={{
container:
"border border-peach bg-peach/10! text-white/85 backdrop-blur-lg!",
container: "border border-peach bg-peach/10! text-white/85 backdrop-blur-lg!",
}}
>
{#snippet children({ data })}
<Tooltip.Header
value={data.timestamp}
format="time"
classes={{ root: "border-peach" }}
/>
<Tooltip.Header value={data.timestamp} format="time" classes={{ root: "border-peach" }} />
<Tooltip.List>
<Tooltip.Item
label="Keys"
value={data.keys}
classes={{ value: "font-mono font-black text-green" }}
/>
<Tooltip.Item
label="Clicks"
value={data.clicks}
classes={{ value: "font-mono font-black text-teal" }}
/>
<Tooltip.Item label="Keys" value={data.keys} classes={{ value: "font-mono font-black text-green" }} />
<Tooltip.Item label="Clicks" value={data.clicks} classes={{ value: "font-mono font-black text-teal" }} />
</Tooltip.List>
{/snippet}
</Tooltip.Root>
</Chart>
</div>
<p class="text-xs text-overlay1 mt-2">* Since 9 November 2025</p>
</section>
</div>

View file

@ -1,7 +1,7 @@
<script lang="ts">
const links = [
{ name: "home", url: "/" },
{ name: "status", url: "/status/" },
{ name: "activity", url: "/activity/" },
{ name: "buttons", url: "/buttons/" },
];

View file

@ -37,14 +37,7 @@
<a href={url} class="block relative h-24 group">
<div class="absolute p-2 flex gap-2 z-30 w-full">
<img
src={image}
width="80"
height="80"
fetchpriority="high"
alt="album cover"
class="size-20 rounded-full animate-spin animate-duration-30s"
/>
<img src={image} width="80" height="80" fetchpriority="high" alt="album cover" class="size-20 rounded-full animate-spin animate-duration-30s" />
<div class="flex flex-col w-full min-w-0">
<h1 class="font-medium text-lg truncate">{song}</h1>