Add styling

This commit is contained in:
Schluffe committed 2026-10-23 00:22:49 +02:00
1 parent 1bfeb9843a
commit 9282865a8c
2 files changed
+441 -45

No files matched your search

+89 -40
View File
@@ -45,6 +45,23 @@ function onPick(event: Event) {
file.value = (event.target as HTMLInputElement).files?.[0]; 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() { async function onCreateOffer() {
const result = await createOffer(file.value!, events); const result = await createOffer(file.value!, events);
offer.value = result.offer; offer.value = result.offer;
@@ -69,52 +86,84 @@ function onReceive() {
</script> </script>
<template> <template>
<main> <header>
<img src="/HellNet_alt.png" alt="" width="40" height="40" />
<h1>HellCon</h1> <h1>HellCon</h1>
<label> <label>
<input id="stun" v-model="settings.stun" type="checkbox" /> <input id="stun" v-model="settings.stun" type="checkbox" role="switch" />
Use STUN Use STUN
</label> </label>
</header>
<h2>Send</h2> <main>
<input type="file" @change="onPick" /> <aside v-if="check" role="alert">
<p>
<h3>Manual</h3> Security check, you: <output id="check-local">{{ check.local }}</output>, peer:
<button id="create-offer" :disabled="!file" @click="onCreateOffer">Create offer</button> <output id="check-remote">{{ check.remote }}</output>. The other side must show the same two codes swapped. Both sides confirm, nothing is transferred before.
<template v-if="offer"> </p>
<p>Offer, send this to the receiver:</p>
<textarea id="offer" readonly :value="offer"></textarea>
<p>Answer from the receiver:</p>
<textarea id="answer-input" v-model="answerInput"></textarea>
<button id="accept-answer" @click="onAcceptAnswer">Connect</button>
</template>
<h3>Tracker (optional)</h3>
<button id="share" :disabled="!file" @click="onShare">Share via tracker</button>
<p v-if="sendCode">Code: <output id="send-code">{{ sendCode }}</output></p>
<h2>Receive</h2>
<h3>Manual</h3>
<textarea id="offer-input" v-model="offerInput" placeholder="offer"></textarea>
<button id="create-answer" @click="onCreateAnswer">Create answer</button>
<template v-if="answer">
<p>Answer, send this back to the sender:</p>
<textarea id="answer" readonly :value="answer"></textarea>
</template>
<h3>Tracker (optional)</h3>
<input id="receive-code" v-model="receiveCode" placeholder="code" />
<button id="receive" @click="onReceive">Receive</button>
<p v-if="check">
Security check, you: <output id="check-local">{{ check.local }}</output>, peer:
<output id="check-remote">{{ check.remote }}</output>. The other side must show the same two codes swapped. Both sides confirm, nothing is transferred before.
<button v-if="confirmCheck" id="confirm" @click="onConfirm">Codes match</button> <button v-if="confirmCheck" id="confirm" @click="onConfirm">Codes match</button>
</p> </aside>
<h2>Log</h2> <article>
<pre id="log">{{ log.join('\n') }}</pre> <h2>Send</h2>
<label
:data-dragging="dragging || undefined"
@dragover.prevent="dragging = true"
@dragleave="dragging = false"
@drop.prevent="onDrop"
>
<input type="file" @change="onPick" />
<template v-if="file">
<strong>{{ file.name }}</strong>
{{ formatSize(file.size) }}
</template>
<template v-else>Drop a file or click to choose</template>
</label>
<section>
<h3>Manual</h3>
<button id="create-offer" :disabled="!file" @click="onCreateOffer">Create offer</button>
<template v-if="offer">
<label for="offer">Offer, send this to the receiver:</label>
<textarea id="offer" readonly :value="offer"></textarea>
<label for="answer-input">Answer from the receiver:</label>
<textarea id="answer-input" v-model="answerInput"></textarea>
<button id="accept-answer" @click="onAcceptAnswer">Connect</button>
</template>
</section>
<section>
<h3>Tracker</h3>
<button id="share" :disabled="!file" @click="onShare">Share via tracker</button>
<p v-if="sendCode">Code: <output id="send-code">{{ sendCode }}</output></p>
</section>
</article>
<article>
<h2>Receive</h2>
<section>
<h3>Manual</h3>
<textarea id="offer-input" v-model="offerInput" placeholder="Paste the offer"></textarea>
<button id="create-answer" @click="onCreateAnswer">Create answer</button>
<template v-if="answer">
<label for="answer">Answer, send this back to the sender:</label>
<textarea id="answer" readonly :value="answer"></textarea>
</template>
</section>
<section>
<h3>Tracker <small>optional</small></h3>
<div role="group">
<input id="receive-code" v-model="receiveCode" placeholder="Code" />
<button id="receive" @click="onReceive">Receive</button>
</div>
</section>
</article>
<details>
<summary>Log</summary>
<pre id="log">{{ log.join('\n') }}</pre>
</details>
</main> </main>
</template> </template>
+352 -5
View File
@@ -1,11 +1,358 @@
:root { *, *::before, *::after {
color-scheme: light dark; box-sizing: border-box;
font-family: system-ui, sans-serif; }
*:not(dialog) {
margin: 0;
}
@media (prefers-reduced-motion: no-preference) {
html {
interpolate-size: allow-keywords;
}
} }
body { 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; 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; 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);
} }