status bar

This commit is contained in:
2026-11-04 00:01:11 +01:00
parent d6cfab838f
commit 2a0d54c19e
11 changed files with 460 additions and 208 deletions
+41
View File
@@ -1,6 +1,47 @@
@import './style/global.css';
@import './style/themes.css';
@import 'tailwindcss';
.crt-vignette {
position: fixed;
inset: 0;
z-index: 898;
pointer-events: none;
background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.3) 100%);
}
/* scanlines — your existing rule, unchanged */
.crt-scanlines {
display: block;
position: fixed;
inset: 0;
pointer-events: none;
z-index: 900;
background:
linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
background-size:
100% 2px,
3px 100%;
}
/* grain — SVG fractal noise, tiled, topmost */
.crt-grain {
position: fixed;
inset: 0;
z-index: 902;
pointer-events: none;
opacity: 0.035;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* single toggle — hides all three when data-crt="false" */
:root[data-crt='false'] #crt-vignette,
:root[data-crt='false'] #crt-scanlines,
:root[data-crt='false'] #crt-grain {
display: none;
}
:root {
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
+4 -1
View File
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="en" data-theme="gruvbox">
<head>
<script>
// Immediately apply saved or system theme – no flash
@@ -19,5 +19,8 @@
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
<div id="crt-vignette" class="crt-vignette" aria-hidden="true"></div>
<div id="crt-scanlines" class="crt-scanlines" aria-hidden="true"></div>
<div id="crt-grain" class="crt-grain" aria-hidden="true"></div>
</body>
</html>
+19 -9
View File
@@ -1,17 +1,18 @@
<script lang="ts">
import { petals } from '#lib/stores/petals.ts';
import { onMount } from 'svelte';
let {
value = $bindable(''),
blinkDelay = 250,
autofocus = true,
oninput = () => {}
oninput = () => {},
onsubmit = () => {}
}: {
value?: string;
blinkDelay?: number;
autofocus?: boolean;
oninput?: (value: string) => void;
onsubmit?: (value: string) => void;
} = $props();
let container: HTMLElement;
@@ -46,7 +47,7 @@
e.ctrlKey ? moveTo(nextWordBoundary(cursorPos), e.shiftKey) : moveCursor(1, e.shiftKey),
Backspace: () => deleteCharBefore(),
Delete: () => deleteCharAfter(),
Enter: () => gust()
Enter: () => submit()
};
let selection = $derived.by(() => {
@@ -64,9 +65,16 @@
return selection.active && i >= selection.start && i < selection.end;
}
function submit(): void {
onsubmit?.(value);
value = '';
cursorPos = 0;
anchorPos = null;
}
function gust(): void {
if (!container) return;
petals(container, { duration: 4000, swayAmp: 26, hideOriginals: false });
//petals(container, { duration: 4000, swayAmp: 26, hideOriginals: false });
value = '';
cursorPos = 0;
anchorPos = null;
@@ -237,6 +245,7 @@
function handleMouseDown(e: MouseEvent): void {
e.preventDefault();
container?.focus();
const idx = charIndexFromEvent(e);
const clickPos = idx ?? value.length;
@@ -294,7 +303,7 @@
<div
id="terminal-input"
class="font-terminal relative inline-block whitespace-nowrap outline-none select-none"
class="relative inline-block font-mono whitespace-nowrap outline-none select-none"
bind:this={container}
tabindex="1"
role="textbox"
@@ -306,11 +315,12 @@
onmousedown={handleMouseDown}
style="--cursor-index: {cursorPos};"
>
<span class="prompt inline-block w-[1ch] text-center">$</span>
<!-- <span class="text-fg-dim inline-block">~/Downloads</span> -->
<span class="prompt text-fg inline-block w-[1ch] text-center">$</span>
<span class="inline cursor-text" aria-hidden="true">
{#each value.split('') as char, i}
<span
class="char inline-block w-[1ch] text-center whitespace-pre"
class="char text-glow inline-block w-[1ch] text-center leading-relaxed whitespace-pre-wrap"
class:selected={isSelected(i)}
data-char-index={i}>{char}</span
>
@@ -318,7 +328,7 @@
</span>
<div
id="curs"
class="cursor bg-text-primary absolute bottom-[0.2rem] h-px w-[1ch]"
class="cursor bg-fg absolute bottom-1 h-px w-[1ch]"
class:animate-cursor-blink={!blinkPaused && !selection.active}
></div>
</div>
@@ -334,7 +344,7 @@
.char.selected {
transition: none;
background-color: var(--color-highlight);
background-color: var(--);
border-radius: 2px;
}
+118
View File
@@ -0,0 +1,118 @@
<script lang="ts">
let { username, theme, windowCount, version, hash } = $props();
// Internal clock — ticked every 30s so it doesn't go stale if mounted long.
let now = $state(new Date());
let init = new Date().getTime();
let ms = $state(new Date().getTime());
function formatUptime(ms: number): string {
const totalSec = Math.floor(ms / 1000);
const d = Math.floor(totalSec / 86400);
const h = Math.floor((totalSec % 86400) / 3600);
const m = Math.floor((totalSec % 3600) / 60);
const s = totalSec % 60;
const pad = (n: number) => String(n).padStart(2, '0');
return d > 0 ? `${d}d ${h}:${pad(m)}:${pad(s)}` : `${h}:${pad(m)}:${pad(s)}`;
}
$effect(() => {
const id = setInterval(() => (now = new Date()), 1000);
return () => clearInterval(id);
});
const weekday = $derived(now.toLocaleDateString('en-US', { weekday: 'short' }));
const time = $derived(
`${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`
);
const uptime = $derived(`up ${formatUptime(now.getTime() - init)}`);
</script>
{#snippet sep(cls: string = '')}
<span
aria-hidden="true"
class="text-bg3 text-[12px] leading-none {cls}"
style="font-family:ui-monospace,monospace">·</span
>
{/snippet}
{#snippet shortcut(keys: string, label: string)}
<span class="text-bg4 inline-flex items-center gap-0.75 whitespace-nowrap">
<kbd
class="border-bg1 text-fg2 inline-flex h-3.25 min-w-3.25 items-center justify-center rounded-[3px] border bg-black/25 px-1 text-[8.5px] leading-none font-medium"
>{keys}</kbd
>
<span class="text-fg4">{label}</span>
</span>
{/snippet}
<div
class="bg-bg-soft text-fg3 border-bg3 grid w-full grid-cols-[auto_1fr_auto_auto_auto] gap-x-2 overflow-hidden rounded-b-lg border-t text-[11px]"
style="font-family:-apple-system,BlinkMacSystemFont,system-ui,sans-serif; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 -2px 0 0 rgba(0,0,0,0.1), 0 -6px 20px -4px rgba(0,0,0,0.5), 0 -16px 40px -12px rgba(0,0,0,0.65);"
role="region"
aria-label="System status bar"
>
<!-- Top row: user · theme · settings · time -->
<div
class="col-span-full grid h-[22px] grid-cols-subgrid items-center px-4.5 shadow-[inset_0_-1px_0_var(--bg2)]"
>
<div class="flex items-center gap-2 justify-self-end">
<span aria-hidden="true" class="bg-tgreen h-1.25 w-1.25 shrink-0 rounded-full"></span>
<span class="text-fg2 text-[10.5px] font-medium whitespace-nowrap">{username}</span>
</div>
<div class="flex min-w-0 items-center gap-2">
{@render sep()}
<span
class="text-fg3 hover:text-fg2 cursor-pointer text-[9.5px] whitespace-nowrap"
style="font-family:ui-monospace,monospace"
title="switch theme">{theme}</span
>
</div>
<button
type="button"
aria-label="Settings"
class="text-bg4 flex h-5 w-5 shrink-0 items-center justify-center justify-self-end rounded border-0 bg-transparent p-0 text-[12px]"
>⚙</button
>
{@render sep('justify-self-center')}
<time
datetime={now.toISOString()}
class="text-bg4 justify-self-start text-[9.5px] whitespace-nowrap"
style="font-family:ui-monospace,monospace"
>
<span class="text-fg3 font-medium">{weekday}</span>
{time}
</time>
</div>
<!-- Bottom row: windows · shortcuts · build · uptime -->
<div
class="col-span-full grid h-[22px] grid-cols-subgrid items-center rounded-b-lg px-4.5 text-[9.5px] whitespace-nowrap"
style="font-family:ui-monospace,monospace"
>
<span class="text-fg3 justify-self-end whitespace-nowrap"
><span class="font-medium">{windowCount}</span> window{windowCount === 1 ? '' : 's'}</span
>
<div class="flex min-w-0 items-center gap-2">
{@render sep()}
{@render shortcut('⌘N', 'new terminal')}
{@render sep()}
{@render shortcut('⌘,', 'settings')}
</div>
<span class="inline-flex items-center gap-1.25 justify-self-end">
<span class="text-fg3">{version}</span>
{@render sep()}
<span class="text-bg4">{hash}</span>
</span>
{@render sep('justify-self-center')}
<span class="text-bg4 justify-self-start">{uptime}</span>
</div>
</div>
+1 -28
View File
@@ -2,37 +2,10 @@
import favicon from '#lib/assets/favicon.svg';
import ToastsModule from '#lib/modules/ToastsModule.svelte';
import { theme } from '#lib/stores/theme.ts';
import { onMount } from 'svelte';
import '../app.css';
import type { LayoutProps } from './$types';
let { children }: LayoutProps = $props();
let bg1: string | null;
let bg2: string | null;
onMount(() => {
const style = window.getComputedStyle(document.documentElement);
bg1 = style.getPropertyValue('--dots-bg-1');
bg2 = style.getPropertyValue('--dots-bg-2');
if (bg2 && bg1) {
window.CSS.registerProperty({
name: '--dots-bg-2',
syntax: '<color>',
inherits: true,
initialValue: bg2
});
window.CSS.registerProperty({
name: '--dots-bg-1',
syntax: '<color>',
inherits: true,
initialValue: bg1
});
}
});
</script>
<svelte:head>
@@ -40,7 +13,7 @@
</svelte:head>
<main
class="text-text bg-pattern-gradient m-auto flex min-h-dvh w-full flex-col items-center justify-center overflow-hidden"
class="text-text bg-bg-base m-auto flex min-h-dvh w-full flex-col items-center justify-center overflow-hidden"
class:dark={$theme === 'dark'}
class:light={$theme === 'light'}
>
+11 -2
View File
@@ -61,7 +61,7 @@
class=" fixed top-0 left-0 z-200 m-auto grid h-10 w-full grid-cols-[1fr_auto_1fr] items-center"
>
<div class="flex flex-row items-center gap-2 pl-3">
<button onclick={() => add()}>
<button>
<Shell size={18} />
</button>
<div bind:this={tray}></div>
@@ -103,4 +103,13 @@
id="terminal-wrapper"
bind:this={wrapper}
class=" relative flex h-screen w-full flex-col items-center justify-center"
></div>
>
<Terminal
id={10}
wrapper="#terminal-wrapper"
username="gornodox"
hostname="termos"
working_dir="~"
mwin={api}
/>
</div>
+57 -69
View File
@@ -1,77 +1,65 @@
<script lang="ts">
import Movable from '#lib/modules/Movable.svelte';
import type { MWinParams } from '#lib/mwinlib/mwin_util.ts';
import { createRawSnippet, mount, unmount } from 'svelte';
import Input from '#lib/modules/Input.svelte';
import StatusBar from '#lib/modules/StatusBar.svelte';
const mwinoptions: Partial<MWinParams> = {
resizable: { threshold: 10, minWidth: 300, minHeight: 200 }
};
let value = $state('');
let input: Input | undefined = $state();
let wrapper: HTMLElement;
let count: number = $state(-1);
const movables = new Map<number, ReturnType<typeof mount>>();
let date = $state(new Date());
createRawSnippet(() => {
return {
render: () =>
`<div class="size-full bg-[${Math.floor(Math.random() * 16777215).toString(16)}]"></div>`
};
$effect(() => {
setInterval(() => {
date = new Date();
}, 1000);
});
function remove(id: number) {
const m = movables.get(id);
if (!m) return;
unmount(m);
movables.delete(id);
}
function add() {
count++;
const id = count;
const child = createRawSnippet(() => {
return {
render: () =>
`<div class="size-full" style="background-color: #${Math.floor(Math.random() * 16777215).toString(16)}">
<button class="bg-emerald-700" type="button" data-remove-btn>Bye</button>
</div>`
};
});
const movable = mount(Movable, {
target: wrapper,
props: {
class: 'size-100',
id: 'movable-' + id.toString(),
'data-movable-id': String(id),
wrapper,
mwinoptions: { ...mwinoptions, handle: '#movable-' + id.toString() },
children: child
}
});
movables.set(id, movable);
const btn = wrapper.querySelector<HTMLButtonElement>(`#movable-${id} [data-remove-btn]`);
if (btn) {
// Prevent the drag from starting when clicking the button.
btn.addEventListener('mousedown', (e) => e.stopPropagation());
btn.addEventListener('pointerdown', (e) => e.stopPropagation());
// Direct call — no bubbling required.
btn.addEventListener('click', (e) => {
e.stopPropagation();
remove(id);
});
} else {
console.warn('remove button not found for movable', id);
}
}
</script>
<button onclick={() => add()} class="bg-[#c08f58]">Add component</button>
<div class="h-dvh w-full p-4">
<div class=" bg-pattern flex h-full flex-col rounded-md">
<div class="relative flex flex-1"></div>
<div class="bg-bg-soft border-bg3 w-full rounded-b-md border-t text-xs">
<StatusBar
username="gornodox"
theme="gruvbox"
windowCount="no"
version="v0.0.1_alpha"
hash="a3d5b1c"
/>
</div>
</div>
</div>
<div
bind:this={wrapper}
id="mwin-wrapper"
class=" relative flex h-screen w-full flex-col items-center justify-center"
></div>
<!-- <div class="h-dvh w-full p-4">
<div class="bg-bg-soft border-border text-glow size-full rounded-xl font-mono tracking-widest">
<div class=" border-border grid grid-cols-[1fr_auto_1fr] rounded-t-xl border-b px-2 py-1.5">
<div></div>
<div class="text-fg text-[10px] uppercase">
<span class="">gornodox@termos</span>
<span class=" normal-case"> — ~/Downloads</span>
</div>
<div></div>
</div>
<div
class=" bg-bg border-border fixed bottom-full grid grid-cols-[1fr_auto_1fr] rounded-b-xl border-b px-2 py-1.5"
>
<div></div>
<div class="text-fg text-[10px] uppercase">
<span class="">gornodox@termos</span>
<span class=" normal-case"> — ~/Downloads</span>
</div>
<div></div>
</div>
</div>
</div> -->
<!-- <div
onclick={() => input?.focusInput()}
onkeydown={() => input?.focusInput()}
role="textbox"
tabindex="-1"
class=" bg-bg-base scroll-hidden text-glow relative h-screen w-full overflow-y-auto p-4 text-sm"
>
<Input bind:value blinkDelay={500} bind:this={input} />
</div>
<div class="bg-bg fixed bottom-0 flex w-full flex-row px-3">
<p class="text-md">Uptime: 09:10:01</p>
</div> -->
+6
View File
@@ -132,6 +132,11 @@
/* Font variables (unchanged) */
--font-primary: 'Space Mono', monospace;
--font-terminal: 'JetBrains Mono', monospace;
--font-ibm: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@utility glow {
text-shadow: 0 0 6px var(--glow-color);
}
@utility bg-pattern-dots {
@@ -244,6 +249,7 @@
DARK THEME OVERRIDES
================================================================
*/
:root[data-theme='dark'] {
--color-primary: var(--color-lavender-300);
--color-primary-variant: var(--color-lavender-400);
+104
View File
@@ -0,0 +1,104 @@
@import 'tailwindcss';
/* ---------- palette tokens → Tailwind utilities ---------- */
@theme inline {
--color-bg-hard: var(--bg-hard);
--color-bg: var(--bg);
--color-bg-soft: var(--bg-soft);
--color-bg1: var(--bg1);
--color-bg2: var(--bg2);
--color-bg3: var(--bg3);
--color-bg4: var(--bg4);
--color-fg0: var(--fg0);
--color-fg1: var(--fg1);
--color-fg2: var(--fg2);
--color-fg3: var(--fg3);
--color-fg4: var(--fg4);
--color-tyellow: var(--tyellow);
--color-tgreen: var(--tgreen);
--color-tred: var(--tred);
--color-tblue: var(--tblue);
--color-torange: var(--torange);
--color-tpurple: var(--tpurple);
--color-tl-yellow: var(--tl-yellow);
--color-tl-green: var(--tl-green);
--color-tl-red: var(--tl-red);
}
@utility bg-pattern {
background-image: var(--bg-pattern);
}
/* ---------- gruvbox (default) ---------- */
:root,
:root[data-theme='gruvbox'] {
--bg-hard: #1d2021;
--bg: #282828;
--bg-soft: #32302f;
--bg1: #3c3836;
--bg2: #504945;
--bg3: #665c54;
--bg4: #7c6f64;
--fg0: #fbf1c7;
--fg1: #ebdbb2;
--fg2: #d5c4a1;
--fg3: #bdae93;
--fg4: #a89984;
--tyellow: #fabd2f;
--tgreen: #b8bb26;
--tred: #fb4934;
--tblue: #83a598;
--torange: #fe8019;
--tpurple: #d3869b;
--tl-red: #ff5f57;
--tl-yellow: #febc2e;
--tl-green: #28c840;
--bg-pattern: repeating-linear-gradient(45deg, var(--bg-hard) 0 8px, var(--bg) 8px 16px);
}
/* ---------- ayu dark ---------- */
:root[data-theme='ayu'] {
--bg: #0a0e14;
--bg-soft: #0f1419;
--bg-sel: #1a1f29;
--fg: #b3b1ad;
--fg-dim: #4d5566;
--fg-bright: #e6e1cf;
--border: #1a1f29;
--accent: #ff8f40;
--secondary: #59c2ff;
--ok: #aad94c;
--err: #f07178;
--glow: rgba(255, 143, 64, 0.32);
}
/* ---------- monokai pro ---------- */
root[data-theme='monokai'] {
--bg: #2d2a2e;
--bg-soft: #353237;
--bg-sel: #444247;
--fg: #fcfcfa;
--fg-dim: #939293;
--fg-bright: #ffffff;
--border: #4a474c;
--accent: #ffd866;
--secondary: #78dce8;
--ok: #a9dc76;
--err: #ff6188;
--glow: rgba(255, 216, 102, 0.32);
}
/* ---------- optional glow utilities ---------- */
@utility shadow-glow {
box-shadow: 0 0 6px var(--glow);
}
@utility text-glow {
text-shadow: 0 0 6px var(--glow);
}