Rewrite website as a Hyprland desktop

This commit is contained in:
SirBlob committed 2026-10-26 14:33:05 -04:00
1 parent 7c52779cf6
commit 3065ad6092
197 files changed
+5609 -17779

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
<script lang="ts">
import { windowManager } from '#lib/desktop/windows.svelte';
import ChaiIcon from './ChaiIcon.svelte';
import Clock from './Clock.svelte';
import Workspaces from './Workspaces.svelte';
import ThemeMenu from './ThemeMenu.svelte';
import DiscordStatus from './DiscordStatus.svelte';
import Battery from './Battery.svelte';
</script>
<header class="bar">
<div class="bar-section left">
<button class="tray-button" title="Apps (Alt+Space)" onclick={() => (windowManager.launcherOpen = true)}>
<ChaiIcon size={18} />
</button>
<Workspaces />
</div>
<button class="clock-button" title="Open a terminal (Alt+Enter)" onclick={() => windowManager.openTerminal()}>
<Clock />
</button>
<div class="bar-section right">
<DiscordStatus />
<Battery />
<ThemeMenu />
</div>
</header>
<style>
.bar {
position: relative;
z-index: 30;
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
height: var(--bar-height);
padding: 0 8px;
background: var(--background);
color: var(--foreground);
font-size: 14px;
}
.bar-section {
display: flex;
align-items: center;
}
.right {
justify-content: flex-end;
}
.clock-button {
height: var(--bar-height);
padding: 0 0.5rem;
background: none;
border: none;
}
.clock-button:hover {
color: var(--accent);
}
.bar :global(.tray-button) {
display: grid;
place-items: center;
width: 32px;
height: var(--bar-height);
padding: 0;
background: none;
border: none;
color: var(--foreground);
}
.bar :global(.tray-button:hover) {
color: var(--accent);
}
@media (max-width: 640px) {
.bar {
font-size: 12px;
}
}
</style>
+50
View File
@@ -0,0 +1,50 @@
<script lang="ts">
import { onMount } from 'svelte';
import Icon from '@iconify/svelte';
import { batteryAt, batteryIcon, type BatteryState } from '#lib/desktop/battery';
let battery = $state<BatteryState | null>(null);
const isLow = $derived(!!battery && battery.level < 20 && !battery.charging);
onMount(() => {
battery = batteryAt(new Date());
const timer = setInterval(() => (battery = batteryAt(new Date())), 10000);
return () => clearInterval(timer);
});
</script>
{#if battery}
<span
class="battery"
class:low={isLow}
class:charging={battery.charging}
title="Battery {battery.level}% {battery.charging ? '(charging)' : ''}"
>
<Icon icon={batteryIcon(battery)} width="18" />
<span class="level">{battery.level}%</span>
</span>
{/if}
<style>
.battery {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0 0.4rem;
}
.charging {
color: var(--green);
}
.low {
color: var(--red);
}
@media (max-width: 640px) {
.level {
display: none;
}
}
</style>
+11
View File
@@ -0,0 +1,11 @@
<script lang="ts">
let { size = 14 }: { size?: number } = $props();
</script>
<svg viewBox="0 0 24 24" width={size} height={size} fill="currentColor" aria-hidden="true">
<rect x="8.6" y="1.6" width="1.3" height="4.6" rx="0.65" transform="rotate(-12 9.25 3.9)" />
<rect x="12.4" y="2.4" width="1.3" height="4.6" rx="0.65" transform="rotate(12 13.05 4.7)" />
<path d="M17.2 11 a3.4 3.4 0 0 1 0 6 v-1.7 a1.7 1.7 0 0 0 0 -2.6 z" />
<path d="M4 9 h14 l-2.5 9.2 a1.6 1.6 0 0 1 -1.55 1.2 h-5.9 a1.6 1.6 0 0 1 -1.55 -1.2 z" />
<rect x="3" y="20.4" width="18" height="2" rx="1" />
</svg>
+42
View File
@@ -0,0 +1,42 @@
<script lang="ts">
import { onMount } from 'svelte';
let now = $state<Date | null>(null);
onMount(() => {
now = new Date();
const timer = setInterval(() => (now = new Date()), 15000);
return () => clearInterval(timer);
});
function formatClock(date: Date): string {
const weekday = date.toLocaleDateString('en-US', { weekday: 'long' });
const day = date.toLocaleDateString('en-US', { day: '2-digit' });
const month = date.toLocaleDateString('en-US', { month: 'long' });
const time = date.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: false });
return `${weekday} ${day} ${month} ${time}`;
}
</script>
<span class="clock full">{now ? formatClock(now) : ''}</span>
<span class="clock short">{now ? formatClock(now).split(' ').slice(1).join(' ') : ''}</span>
<style>
.clock {
white-space: nowrap;
}
.short {
display: none;
}
@media (max-width: 640px) {
.full {
display: none;
}
.short {
display: inline;
}
}
</style>
@@ -0,0 +1,294 @@
<script lang="ts">
import Icon from '@iconify/svelte';
import { activityLabels, type DiscordPresence } from '#lib/discord/types';
let { presence, onclose }: { presence: DiscordPresence; onclose: () => void } = $props();
function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') onclose();
}
</script>
<svelte:window onkeydown={handleKeydown} />
<button class="backdrop" aria-label="Close Discord status" onclick={onclose}></button>
<div class="popover" role="dialog" aria-label="Discord status">
<div class="popover-surface">
<header class="profile">
<div class="avatar">
{#if presence.avatarUrl}
<img src={presence.avatarUrl} alt="" />
{:else}
<Icon icon="mdi:account-circle" width="52" />
{/if}
<span class="avatar-dot {presence.status}"></span>
</div>
<div class="identity">
<div class="name-row">
<span class="name">{presence.displayName}</span>
{#if presence.guildTag}
<span class="guild-tag">
{#if presence.guildTagBadgeUrl}
<img src={presence.guildTagBadgeUrl} alt="" />
{/if}
{presence.guildTag}
</span>
{/if}
</div>
<span class="status-label">{presence.status}</span>
</div>
<button class="close" aria-label="Close" onclick={onclose}>
<Icon icon="mdi:close" width="18" />
</button>
</header>
{#if presence.activities.length}
<div class="activities">
{#each presence.activities as activity, index (index)}
<div class="activity">
<div class="activity-label">{activityLabels[activity.type] ?? ''}</div>
<div class="activity-body">
{#if activity.largeImage}
<div class="activity-images">
<img class="large-image" src={activity.largeImage} alt="" />
{#if activity.smallImage}
<img class="small-image" src={activity.smallImage} alt="" />
{/if}
</div>
{/if}
<div class="activity-text">
<span class="activity-name">{activity.name}</span>
{#if activity.details}
<span class="activity-details">{activity.details}</span>
{/if}
</div>
</div>
</div>
{/each}
</div>
{:else}
<div class="no-activity">
<Icon icon="mdi:sleep" width="28" />
<span>No current activity</span>
</div>
{/if}
</div>
</div>
<style>
.backdrop {
position: fixed;
inset: 0;
z-index: 40;
background: none;
border: none;
cursor: default;
}
.popover {
position: absolute;
top: calc(100% + 8px);
right: 0;
z-index: 50;
width: 340px;
padding: var(--border-size);
background: var(--border-active);
animation: window-pop-in 0.15s ease-out;
}
.popover-surface {
background: var(--background);
}
.profile {
display: flex;
align-items: center;
gap: 0.9rem;
padding: 1rem;
background: color-mix(in srgb, var(--accent) 8%, var(--background));
}
.avatar {
position: relative;
flex-shrink: 0;
width: 52px;
height: 52px;
color: var(--muted);
}
.avatar img {
width: 52px;
height: 52px;
border-radius: 50%;
object-fit: cover;
}
.avatar-dot {
position: absolute;
right: 0;
bottom: 0;
width: 15px;
height: 15px;
border: 3px solid color-mix(in srgb, var(--accent) 8%, var(--background));
border-radius: 50%;
background: var(--muted);
}
.avatar-dot.online {
background: var(--green);
}
.avatar-dot.idle {
background: var(--yellow);
}
.avatar-dot.dnd {
background: var(--red);
}
.identity {
display: flex;
flex: 1;
flex-direction: column;
gap: 0.2rem;
min-width: 0;
}
.name-row {
display: flex;
align-items: center;
gap: 0.6rem;
min-width: 0;
}
.name {
overflow: hidden;
font-size: 1.1rem;
font-weight: 700;
white-space: nowrap;
text-overflow: ellipsis;
}
.guild-tag {
display: inline-flex;
flex-shrink: 0;
align-items: center;
gap: 0.35rem;
padding: 0.1rem 0.5rem;
background: color-mix(in srgb, var(--accent) 12%, transparent);
border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
color: var(--accent);
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.guild-tag img {
width: 16px;
height: 16px;
}
.status-label {
color: var(--muted);
}
.close {
align-self: flex-start;
padding: 0.15rem;
background: none;
border: none;
}
.close:hover {
color: var(--accent);
}
.activities {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 0.75rem;
}
.activity {
padding: 0.75rem;
background: var(--lighter-background);
}
.activity-label {
margin-bottom: 0.5rem;
color: var(--muted);
font-size: 0.75rem;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.activity-body {
display: flex;
gap: 0.75rem;
}
.activity-images {
position: relative;
flex-shrink: 0;
}
.large-image {
width: 64px;
height: 64px;
object-fit: cover;
}
.small-image {
position: absolute;
right: -5px;
bottom: -5px;
width: 26px;
height: 26px;
border: 3px solid var(--lighter-background);
border-radius: 50%;
}
.activity-text {
display: flex;
flex-direction: column;
justify-content: center;
gap: 0.2rem;
min-width: 0;
}
.activity-name,
.activity-details {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.activity-name {
font-weight: 700;
}
.activity-details {
color: var(--muted);
font-size: 0.85rem;
}
.no-activity {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
padding: 1.5rem;
color: var(--muted);
}
@media (max-width: 640px) {
.popover {
position: fixed;
top: calc(var(--bar-height) + 6px);
right: 8px;
left: 8px;
width: auto;
}
}
</style>
@@ -0,0 +1,97 @@
<script lang="ts">
import { onMount } from 'svelte';
import { profile } from '#lib/content';
import { offlinePresence, type DiscordPresence } from '#lib/discord/types';
import DiscordPopover from './DiscordPopover.svelte';
const refreshInterval = 30000;
let presence = $state<DiscordPresence>(offlinePresence);
let open = $state(false);
const displayName = $derived(presence.displayName ?? profile.displayName);
async function refresh() {
try {
const response = await fetch('/api/discord');
if (response.ok) presence = await response.json();
} catch {
presence = offlinePresence;
}
}
onMount(() => {
refresh();
const timer = setInterval(refresh, refreshInterval);
return () => clearInterval(timer);
});
</script>
<div class="discord-status">
<button
class="status-button"
title="{displayName} - {presence.status}"
aria-expanded={open}
onclick={() => (open = !open)}
>
<span class="status-dot {presence.status}"></span>
<span class="status-name">{displayName}</span>
</button>
{#if open}
<DiscordPopover presence={{ ...presence, displayName }} onclose={() => (open = false)} />
{/if}
</div>
<style>
.discord-status {
position: relative;
margin-right: 4px;
}
.status-button {
display: inline-flex;
align-items: center;
gap: 0.45rem;
height: calc(var(--bar-height) - 8px);
padding: 0 0.6rem;
background: var(--lighter-background);
border: 1px solid color-mix(in srgb, var(--foreground) 22%, transparent);
}
.status-button:hover {
border-color: var(--accent);
}
.status-name {
max-width: 9rem;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.status-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--muted);
}
.status-dot.online {
background: var(--green);
}
.status-dot.idle {
background: var(--yellow);
}
.status-dot.dnd {
background: var(--red);
}
@media (max-width: 640px) {
.status-name {
display: none;
}
}
</style>
+58
View File
@@ -0,0 +1,58 @@
<script lang="ts">
import type { Snippet } from 'svelte';
let { title, onclose, children }: { title: string; onclose: () => void; children: Snippet } = $props();
function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') onclose();
}
</script>
<svelte:window onkeydown={handleKeydown} />
<button class="backdrop" aria-label="Close {title}" onclick={onclose}></button>
<div class="popup" role="dialog" aria-label={title}>
<div class="popup-title">{title}</div>
<div class="popup-body">
{@render children()}
</div>
</div>
<style>
.backdrop {
position: fixed;
inset: 0;
z-index: 40;
background: none;
border: none;
cursor: default;
}
.popup {
position: absolute;
top: calc(100% + 6px);
right: 0;
z-index: 50;
width: 320px;
max-height: 70vh;
overflow-y: auto;
padding: var(--border-size);
background: var(--border-active);
animation: window-pop-in 0.15s ease-out;
}
.popup-title {
padding: 0.4rem 0.6rem;
background: var(--background);
color: var(--accent);
border-bottom: 1px solid color-mix(in srgb, var(--foreground) 15%, transparent);
}
.popup-body {
display: flex;
flex-direction: column;
gap: 2px;
padding: 0.4rem;
background: var(--background);
}
</style>
+79
View File
@@ -0,0 +1,79 @@
<script lang="ts">
import Icon from '@iconify/svelte';
import { themes } from '#lib/theme/themes';
import { themeState } from '#lib/theme/theme.svelte';
import PopupCard from './PopupCard.svelte';
let open = $state(false);
</script>
<div class="theme-menu">
<button class="tray-button" title="Theme" onclick={() => (open = !open)}>
<Icon icon="mdi:palette-outline" width="18" />
</button>
{#if open}
<PopupCard title="Themes" onclose={() => (open = false)}>
{#each themes as theme (theme.id)}
<button
class="theme-option"
class:selected={theme.id === themeState.currentId}
onclick={() => themeState.set(theme.id)}
>
<span class="swatches">
{#each [theme.colors.background, theme.colors.accent, theme.colors.red, theme.colors.green, theme.colors.foreground] as swatch, index (index)}
<span class="swatch" style="background: {swatch}"></span>
{/each}
</span>
<span class="theme-name">{theme.name}</span>
<span class="theme-mode">{theme.mode}</span>
</button>
{/each}
</PopupCard>
{/if}
</div>
<style>
.theme-menu {
position: relative;
}
.theme-option {
display: flex;
align-items: center;
gap: 0.6rem;
width: 100%;
padding: 0.35rem 0.5rem;
background: none;
border: 1px solid transparent;
text-align: left;
}
.theme-option:hover {
border-color: color-mix(in srgb, var(--foreground) 25%, transparent);
background: color-mix(in srgb, var(--foreground) 8%, transparent);
}
.theme-option.selected {
background: color-mix(in srgb, var(--foreground) 18%, transparent);
}
.swatches {
display: flex;
border: 1px solid color-mix(in srgb, var(--foreground) 30%, transparent);
}
.swatch {
width: 12px;
height: 18px;
}
.theme-name {
flex: 1;
}
.theme-mode {
color: var(--muted);
font-size: 0.75rem;
}
</style>
@@ -0,0 +1,81 @@
<script lang="ts">
import { page } from '$app/state';
import { desktop } from '#lib/content';
import { activeWorkspace, openPage } from '#lib/desktop/actions';
const workspaceSlots = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const currentWorkspace = $derived(activeWorkspace(page.url.pathname));
function workspaceFor(number: number) {
return desktop.workspaces.find((workspace) => workspace.number === number);
}
</script>
<div class="workspaces">
{#each workspaceSlots as number (number)}
{@const workspace = workspaceFor(number)}
{@const isFocused = currentWorkspace?.number === number}
<button
class="workspace"
class:occupied={!!workspace}
title={workspace?.name}
disabled={!workspace}
onclick={() => workspace && openPage(workspace.path)}
>
{#if isFocused}
<span class="focused-marker"></span>
{:else}
{number}
{/if}
</button>
{/each}
</div>
<style>
.workspaces {
display: flex;
align-items: center;
margin-left: 4px;
}
.workspace {
display: grid;
place-items: center;
width: 26px;
height: var(--bar-height);
padding: 0;
background: none;
border: none;
opacity: 0.5;
}
.workspace:disabled {
cursor: default;
}
.workspace.occupied {
opacity: 1;
}
.workspace.occupied:hover {
color: var(--accent);
}
@media (max-width: 640px) {
.workspace:not(.occupied) {
display: none;
}
.workspace {
width: 20px;
}
}
.focused-marker {
width: 12px;
height: 12px;
border-radius: 2px;
background: currentColor;
}
</style>