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];
}
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() {
</script>
<template>
<main>
<header>
<img src="/HellNet_alt.png" alt="" width="40" height="40" />
<h1>HellCon</h1>
<label>
<input id="stun" v-model="settings.stun" type="checkbox" />
<input id="stun" v-model="settings.stun" type="checkbox" role="switch" />
Use STUN
</label>
</header>
<h2>Send</h2>
<input type="file" @change="onPick" />
<h3>Manual</h3>
<button id="create-offer" :disabled="!file" @click="onCreateOffer">Create offer</button>
<template v-if="offer">
<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.
<main>
<aside v-if="check" role="alert">
<p>
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.
</p>
<button v-if="confirmCheck" id="confirm" @click="onConfirm">Codes match</button>
</p>
</aside>
<h2>Log</h2>
<pre id="log">{{ log.join('\n') }}</pre>
<article>
<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>
</template>