WIP V improve UX [snapshot task 2]
Add the connections workspace (sidebar, editable slots, per-slot activity, removal dialog with focus wrapping), remove the downloadable local HTML and unreleased identity backup/restore, and start the 0.0.5 draft changelog. Restore the released 0.0.3/0.0.4 changelog entries. Enable focus emulation in browser checks so background tabs receive focus/blur events. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
58c3e2af86
commit
5f8c6a1916
21 files changed
+879
-306
No files matched your search
@@ -0,0 +1,64 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import TransferPanel from './TransferPanel.vue';
|
||||
import type { SavedConnection, ConnectionActivity } from '../lib/connections.ts';
|
||||
const props = defineProps<{ connection: SavedConnection }>();
|
||||
const emit = defineEmits<{
|
||||
status: [id: string, state: 'ready' | 'connecting' | 'connected'];
|
||||
activity: [id: string, item: ConnectionActivity];
|
||||
paired: [id: string, key: string];
|
||||
}>();
|
||||
const mode = ref<'send' | 'receive'>('send');
|
||||
const sessionActive = ref(false), connected = ref(false);
|
||||
const direction = ref<'send' | 'receive'>('send');
|
||||
const panel = ref<InstanceType<typeof TransferPanel> | null>(null);
|
||||
function status() { emit('status', props.connection.id, connected.value ? 'connected' : sessionActive.value ? 'connecting' : 'ready'); }
|
||||
function navigate(next: 'send' | 'receive') {
|
||||
if (connected.value) { direction.value = next; panel.value?.focusDirection(next); }
|
||||
else if (!sessionActive.value) mode.value = next;
|
||||
}
|
||||
function sizeLabel(size: number) {
|
||||
if (size < 1024) return `${size} B`;
|
||||
const index = Math.min(5, Math.floor(Math.log(size) / Math.log(1024)));
|
||||
return `${(size / 1024 ** index).toFixed(1)} ${['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'][index]}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="connection-workspace">
|
||||
<div class="session-column">
|
||||
<div class="workspace-intro">
|
||||
<h2>{{ connected ? 'Share files' : 'Start a session' }}</h2>
|
||||
<p>{{ connected ? 'Your connection is ready.' : 'Exchange connection codes with your peer to start sharing.' }} Each direction sends one file at a time; both people can send on this connection.</p>
|
||||
</div>
|
||||
<div class="tabs" role="group" :aria-label="connected ? 'Transfer sections' : 'Connection setup'">
|
||||
<button :disabled="sessionActive && !connected" :class="{ active: (connected ? direction : mode) === 'send' }" :aria-pressed="(connected ? direction : mode) === 'send'" @click="navigate('send')">Send</button>
|
||||
<button :disabled="sessionActive && !connected" :class="{ active: (connected ? direction : mode) === 'receive' }" :aria-pressed="(connected ? direction : mode) === 'receive'" @click="navigate('receive')">Receive</button>
|
||||
</div>
|
||||
<TransferPanel ref="panel" :key="mode" :sending="mode === 'send'" :preferred-device="connection.peerKey"
|
||||
@session-change="sessionActive = $event; status()" @connected-change="connected = $event; direction = mode; status()"
|
||||
@activity="emit('activity', connection.id, $event)" @paired="emit('paired', connection.id, $event)" />
|
||||
</div>
|
||||
<aside class="activity-panel" aria-labelledby="activity-heading">
|
||||
<div class="activity-heading"><h2 id="activity-heading">Activity</h2><span>{{ connection.history.length }}</span></div>
|
||||
<div v-if="!connection.history.length" class="empty-activity">
|
||||
<span class="empty-activity-icon" aria-hidden="true">↔</span>
|
||||
<h3>A fresh connection</h3>
|
||||
<p>Files you share here will appear in this timeline.</p>
|
||||
<p class="activity-note">History stays in this browser. File contents aren’t kept here.</p>
|
||||
</div>
|
||||
<ol v-else class="activity-list" aria-label="Recent file results">
|
||||
<li v-for="item in [...connection.history].reverse()" :key="item.id" class="activity-item">
|
||||
<span class="activity-icon" aria-hidden="true">{{ item.direction === 'send' ? '↗' : '↙' }}</span>
|
||||
<div>
|
||||
<p class="activity-filename">{{ item.name }}</p>
|
||||
<p class="activity-meta">{{ item.direction === 'send' ? 'Outgoing' : 'Incoming' }} · {{ sizeLabel(item.size) }}</p>
|
||||
<p class="activity-result">{{ item.result === 'complete' ? 'Transfer complete' : item.result === 'declined' ? 'Declined' : 'Interrupted' }}</p>
|
||||
<time :datetime="new Date(item.time).toISOString()">{{ new Date(item.time).toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }) }}</time>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
<p v-if="connection.history.length" class="activity-note">Last 50 transfers · Saved in this browser</p>
|
||||
</aside>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user