From 9282865a8c92de7a9dec30a4cb9ae5455d075b53 Mon Sep 17 00:00:00 2001 From: Schluffe Date: Fri, 23 Oct 2026 00:22:49 +0200 Subject: [PATCH] Add styling --- src/App.vue | 129 ++++++++++++------ src/style.css | 357 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 441 insertions(+), 45 deletions(-) diff --git a/src/App.vue b/src/App.vue index 99e0d9d..fc0d2de 100644 --- a/src/App.vue +++ b/src/App.vue @@ -45,6 +45,23 @@ function onPick(event: Event) { file.value = (event.target as HTMLInputElement).files?.[0]; } +const dragging = ref(false); + +function onDrop(event: DragEvent) { + dragging.value = false; + file.value = event.dataTransfer?.files[0] ?? file.value; +} + +function formatSize(bytes: number) { + const units = ['B', 'KB', 'MB', 'GB', 'TB']; + let unit = 0; + while (bytes >= 1024 && unit < units.length - 1) { + bytes /= 1024; + unit++; + } + return `${bytes.toFixed(unit ? 1 : 0)} ${units[unit]}`; +} + async function onCreateOffer() { const result = await createOffer(file.value!, events); offer.value = result.offer; @@ -69,52 +86,84 @@ function onReceive() { diff --git a/src/style.css b/src/style.css index 732138a..f513a4b 100644 --- a/src/style.css +++ b/src/style.css @@ -1,11 +1,358 @@ -:root { - color-scheme: light dark; - font-family: system-ui, sans-serif; +*, *::before, *::after { + box-sizing: border-box; +} + +*:not(dialog) { + margin: 0; +} + +@media (prefers-reduced-motion: no-preference) { + html { + interpolate-size: allow-keywords; + } } body { - margin: 0; + line-height: 1.5; + -webkit-font-smoothing: antialiased; +} + +img, picture, video, canvas, svg { + display: block; + max-width: 100%; +} + +input, button, textarea, select { + font: inherit; +} + +p, h1, h2, h3, h4, h5, h6 { + overflow-wrap: break-word; +} + +p { + text-wrap: pretty; +} + +h1, h2, h3, h4, h5, h6 { + text-wrap: balance; +} + +#app { + isolation: isolate; +} + +:root { + color-scheme: dark; + font-family: system-ui, sans-serif; + + --color-primary: #5865f2; + --color-primary-hover: #4752c4; + --color-secondary: #eb459e; + --color-success: #23a559; + + --color-bg: #313338; + --color-surface: #2b2d31; + --color-input: #1e1f22; + --color-border: #3f4147; + --color-text: #dbdee1; + --color-text-muted: #949ba4; + + --space-1: 0.25rem; + --space-2: 0.5rem; + --space-3: 0.75rem; + --space-4: 1rem; + --space-6: 1.5rem; + --space-8: 2rem; + + --text-sm: 0.875rem; + --text-lg: 1.125rem; + --text-xl: 1.25rem; + + --radius: 0.5rem; + --shadow: 0 1px 3px rgb(0 0 0 / 0.4), 0 1px 2px rgb(0 0 0 / 0.3); + --transition: 150ms ease; +} + +body { min-height: 100vh; + background: var(--color-bg); + color: var(--color-text); +} + +/* Layout */ + +header, main { + max-width: 64rem; + margin-inline: auto; + padding-inline: var(--space-4); +} + +header { + display: flex; + align-items: center; + gap: var(--space-3); + padding-block: var(--space-6); +} + +header h1 { + font-size: var(--text-xl); +} + +header label { + margin-left: auto; +} + +main { display: grid; - place-items: center; + grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); + align-items: start; + gap: var(--space-4); + padding-bottom: var(--space-8); +} + +main > aside, main > details { + grid-column: 1 / -1; +} + +/* Cards */ + +article, details { + background: var(--color-surface); + border: 1px solid var(--color-border); + border-radius: var(--radius); + box-shadow: var(--shadow); +} + +article { + display: flex; + flex-direction: column; + gap: var(--space-4); + padding: var(--space-6); +} + +article h2 { + font-size: var(--text-lg); +} + +section { + display: flex; + flex-direction: column; + align-items: start; + gap: var(--space-2); + padding-top: var(--space-4); + border-top: 1px solid var(--color-border); +} + +h3 { + font-size: var(--text-sm); + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.05em; + color: var(--color-text-muted); +} + +small { + font-weight: normal; + text-transform: none; + letter-spacing: normal; +} + +label, section p { + font-size: var(--text-sm); + color: var(--color-text-muted); +} + +header label { + color: var(--color-text); +} + +/* Forms */ + +input, textarea { + width: 100%; + padding: var(--space-2) var(--space-3); + background: var(--color-input); + border: 1px solid var(--color-border); + border-radius: var(--radius); + color: inherit; + transition: border-color var(--transition); +} + +input:focus, textarea:focus { + border-color: var(--color-secondary); + outline: none; +} + +::placeholder { + color: var(--color-text-muted); + opacity: 0.7; +} + +textarea { + min-height: 5rem; + resize: vertical; + font-family: ui-monospace, monospace; + font-size: var(--text-sm); +} + +button { + padding: var(--space-2) var(--space-4); + border: 1px solid transparent; + border-radius: var(--radius); + background: var(--color-primary); + color: var(--color-text); + font-weight: 500; + cursor: pointer; + transition: background-color var(--transition); +} + +button:hover:not(:disabled) { + background: var(--color-primary-hover); +} + +button:disabled { + opacity: 0.4; + cursor: not-allowed; +} + +:focus-visible { + outline: 2px solid var(--color-secondary); + outline-offset: 2px; +} + +[role='group'] { + display: flex; + width: 100%; +} + +[role='group'] > input { + border-start-end-radius: 0; + border-end-end-radius: 0; +} + +[role='group'] > button { + border-start-start-radius: 0; + border-end-start-radius: 0; +} + +/* Drop zone, the invisible file input covers the whole label */ + +label:has(> [type='file']) { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + gap: var(--space-1); + padding: var(--space-8) var(--space-4); + background: var(--color-input); + border: 2px dashed var(--color-border); + border-radius: var(--radius); + text-align: center; + transition: border-color var(--transition), background-color var(--transition); +} + +label:has(> [type='file']):hover, label[data-dragging] { + border-color: var(--color-primary); +} + +label[data-dragging] { + background: color-mix(in srgb, var(--color-primary) 10%, var(--color-input)); +} + +label:has(> [type='file']:focus-visible) { + outline: 2px solid var(--color-secondary); + outline-offset: 2px; +} + +[type='file'] { + position: absolute; + inset: 0; + opacity: 0; + cursor: pointer; +} + +label strong { + color: var(--color-text); + overflow-wrap: anywhere; +} + +/* Switch, like Pico's role="switch" */ + +label:has([role='switch']) { + display: flex; + align-items: center; + gap: var(--space-2); + cursor: pointer; +} + +[role='switch'] { + appearance: none; + width: 2.25rem; + height: 1.25rem; + padding: 0; + border-radius: 999px; + background: var(--color-border); + border: none; + cursor: pointer; + position: relative; + transition: background-color var(--transition); +} + +[role='switch']::before { + content: ''; + position: absolute; + inset: 0.125rem auto 0.125rem 0.125rem; + aspect-ratio: 1; + border-radius: 50%; + background: var(--color-text); + transition: translate var(--transition); +} + +[role='switch']:checked { + background: var(--color-success); +} + +[role='switch']:checked::before { + translate: 1rem 0; +} + +/* Security check callout */ + +[role='alert'] { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-4); + padding: var(--space-4) var(--space-6); + background: color-mix(in srgb, var(--color-secondary) 10%, var(--color-surface)); + border: 1px solid var(--color-secondary); + border-radius: var(--radius); +} + +[role='alert'] p { + flex: 1 1 20rem; +} + +output { + color: var(--color-secondary); + font-family: ui-monospace, monospace; + font-weight: 600; +} + +/* Log */ + +summary { + padding: var(--space-3) var(--space-6); + font-weight: 600; + cursor: pointer; +} + +pre { + max-height: 20rem; + overflow: auto; + padding: var(--space-4) var(--space-6); + border-top: 1px solid var(--color-border); + font-size: var(--text-sm); + color: var(--color-text-muted); }