feat: polish speaker material upload control
Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
68fecc2ad1
commit
15789ab04d
6 files changed
+180
-10
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState, type FormEvent } from 'react';
|
||||
import type { Session } from '@supabase/supabase-js';
|
||||
import { LoaderCircle, Paperclip } from 'lucide-react';
|
||||
import { supabase } from '../lib/supabase';
|
||||
import { getSpeakerPortalSessions, speakerPortalSession, type SpeakerSession } from '../lib/speakerPortal';
|
||||
import { removeSessionMaterial, sessionMaterialUrl, uploadSessionMaterial } from '../lib/api';
|
||||
@@ -110,13 +111,16 @@ export function SpeakerPortal() {
|
||||
<h3 className="h2">{talk.title}</h3>
|
||||
<p className="small">{talk.slot_date} · {talk.start_time.slice(0, 5)} - {talk.end_time.slice(0, 5)}{talk.room && ` · ${talk.room}`}</p>
|
||||
{talk.material_path ? <a className="speaker-download" href={sessionMaterialUrl(talk.material_path)} target="_blank" rel="noreferrer">Download material</a> : <p className="small muted">No material uploaded</p>}
|
||||
<label className="small" htmlFor={`material-${talk.session_id}`}>{talk.material_path ? 'Replace material' : 'Upload material'}</label>
|
||||
<input className="input" id={`material-${talk.session_id}`} aria-label={`${talk.material_path ? 'Replace' : 'Upload'} material for ${talk.title}`} type="file" accept={FILE_TYPES} disabled={!!workingTalk || busy} onChange={(event) => {
|
||||
const file = event.target.files?.[0];
|
||||
event.target.value = '';
|
||||
if (file) void changeMaterial(talk, file);
|
||||
}} />
|
||||
<p className="small muted">PDF, PowerPoint, ODP, ZIP, TXT · Max 50 MB</p>
|
||||
<label className="speaker-upload" htmlFor={`material-${talk.session_id}`}>
|
||||
{workingTalk === talk.session_id ? <LoaderCircle aria-hidden="true" className="speaker-upload-spinner" /> : <Paperclip aria-hidden="true" />}
|
||||
<span>{workingTalk === talk.session_id ? 'Saving material...' : talk.material_path ? 'Replace material' : 'Upload material'}</span>
|
||||
<input className="input" id={`material-${talk.session_id}`} aria-label={`${talk.material_path ? 'Replace' : 'Upload'} material for ${talk.title}`} aria-describedby={`material-help-${talk.session_id}`} type="file" accept={FILE_TYPES} disabled={!!workingTalk || busy} onChange={(event) => {
|
||||
const file = event.target.files?.[0];
|
||||
event.target.value = '';
|
||||
if (file) void changeMaterial(talk, file);
|
||||
}} />
|
||||
</label>
|
||||
<p id={`material-help-${talk.session_id}`} className="small muted">PDF, PowerPoint, ODP, ZIP, TXT · Max 50 MB</p>
|
||||
{workingTalk === talk.session_id && <><progress aria-label="Saving material" /><p role="status">Saving material...</p></>}
|
||||
{talk.material_path && <button className="btn small danger" disabled={!!workingTalk || busy} onClick={() => void changeMaterial(talk)}>Remove material</button>}
|
||||
</article>)}
|
||||
@@ -126,4 +130,4 @@ export function SpeakerPortal() {
|
||||
<button className="btn primary" type="submit" disabled={busy}>{busy ? 'Sending...' : 'Send sign-in link'}</button>
|
||||
</form>}
|
||||
</main></div>;
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,72 @@
|
||||
.speaker-portal p, .speaker-portal h3, .speaker-download { overflow-wrap: anywhere; }
|
||||
.speaker-talk { display: grid; gap: 10px; padding: 18px 0; border-top: 1px solid var(--line); }
|
||||
.speaker-portal input { width: 100%; min-width: 0; }
|
||||
.speaker-portal input[type="file"] { font-size: 12px; padding: 10px; }
|
||||
.speaker-portal progress { width: 100%; accent-color: var(--accent-2); }
|
||||
.speaker-download { color: var(--accent-2); }
|
||||
.speaker-upload {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 46px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--accent);
|
||||
border-radius: 8px;
|
||||
background: var(--accent-soft);
|
||||
color: var(--accent);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.speaker-upload svg {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.speaker-upload span {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.speaker-portal .speaker-upload input[type="file"] {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.speaker-upload:focus-within {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
.speaker-upload:has(input:disabled) {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.speaker-upload:has(input:disabled) input[type="file"] {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.speaker-upload-spinner {
|
||||
animation: speaker-upload-rotate 900ms linear infinite;
|
||||
}
|
||||
|
||||
@keyframes speaker-upload-rotate {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.speaker-upload-spinner {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
:root {
|
||||
--bg: #f0f2f6; --phone-bg: #ffffff; --surface: #ffffff; --surface-2: #f4f5f9;
|
||||
--line: #e4e6ee; --text: #423c3c; --muted: #8a8484;
|
||||
|
||||
Reference in new issue
Block a user