From 98119d8fb55e1633d7bdd79db30fd5caea9ee641 Mon Sep 17 00:00:00 2001 From: Jason McCormick Date: Fri, 16 Oct 2026 16:57:47 -0400 Subject: feat: add private image upload service --- static/app.js | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ static/index.html | 70 +++++++++++++++++++++++++++++++ static/styles.css | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 298 insertions(+) create mode 100644 static/app.js create mode 100644 static/index.html create mode 100644 static/styles.css (limited to 'static') diff --git a/static/app.js b/static/app.js new file mode 100644 index 0000000..bb09c86 --- /dev/null +++ b/static/app.js @@ -0,0 +1,108 @@ +const MAX_BYTES = 10 * 1024 * 1024; +const ALLOWED_EXTENSIONS = /\.(jpe?g|png|heic)$/i; + +const form = document.querySelector('#upload-form'); +const input = document.querySelector('#image-input'); +const dropZone = document.querySelector('#drop-zone'); +const fileRow = document.querySelector('#file-row'); +const fileName = document.querySelector('#file-name'); +const fileSize = document.querySelector('#file-size'); +const preview = document.querySelector('#preview'); +const removeButton = document.querySelector('#remove-button'); +const submitButton = document.querySelector('#submit-button'); +const status = document.querySelector('#status'); +let previewUrl = null; + +function setStatus(message = '', type = '') { + status.textContent = message; + status.className = `status ${type}`.trim(); +} + +function clearSelection() { + input.value = ''; + fileRow.hidden = true; + dropZone.hidden = false; + submitButton.disabled = true; + if (previewUrl) URL.revokeObjectURL(previewUrl); + previewUrl = null; + preview.removeAttribute('src'); +} + +function validate(file) { + if (!file) return 'Choose an image to continue.'; + if (!ALLOWED_EXTENSIONS.test(file.name)) return 'Choose a JPG, PNG, or HEIC image.'; + if (file.size === 0) return 'The selected image is empty.'; + if (file.size > MAX_BYTES) return 'The image must be 10 MB or smaller.'; + return ''; +} + +function showFile(file) { + const error = validate(file); + if (error) { + clearSelection(); + setStatus(error, 'error'); + return; + } + setStatus(); + fileName.textContent = file.name; + fileSize.textContent = `${(file.size / 1024 / 1024).toFixed(2)} MB`; + if (previewUrl) URL.revokeObjectURL(previewUrl); + previewUrl = URL.createObjectURL(file); + preview.src = previewUrl; + fileRow.hidden = false; + dropZone.hidden = true; + submitButton.disabled = false; +} + +input.addEventListener('change', () => showFile(input.files[0])); +removeButton.addEventListener('click', () => { clearSelection(); setStatus(); }); + +for (const eventName of ['dragenter', 'dragover']) { + dropZone.addEventListener(eventName, (event) => { + event.preventDefault(); + dropZone.classList.add('is-dragging'); + }); +} +for (const eventName of ['dragleave', 'drop']) { + dropZone.addEventListener(eventName, (event) => { + event.preventDefault(); + dropZone.classList.remove('is-dragging'); + }); +} +dropZone.addEventListener('drop', (event) => { + const files = event.dataTransfer.files; + if (files.length !== 1) { + setStatus('Drop exactly one image.', 'error'); + return; + } + const transfer = new DataTransfer(); + transfer.items.add(files[0]); + input.files = transfer.files; + showFile(files[0]); +}); + +form.addEventListener('submit', async (event) => { + event.preventDefault(); + const file = input.files[0]; + const error = validate(file); + if (error) { setStatus(error, 'error'); return; } + + submitButton.disabled = true; + submitButton.querySelector('span').textContent = 'Submitting…'; + setStatus('Securely sending your image…'); + const body = new FormData(); + body.append('image', file); + + try { + const response = await fetch(window.location.pathname, { method: 'POST', body }); + const result = await response.json(); + if (!response.ok) throw new Error(result.message || 'Upload failed.'); + clearSelection(); + setStatus(`${result.message} Receipt: ${result.receipt}`, 'success'); + } catch (error) { + submitButton.disabled = false; + setStatus(error.message || 'Upload failed. Please try again.', 'error'); + } finally { + submitButton.querySelector('span').textContent = 'Submit image'; + } +}); diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..3100128 --- /dev/null +++ b/static/index.html @@ -0,0 +1,70 @@ + + + + + + + Private Drop + + + +
+
+ + + Private Drop + + Private intake +
+ +
+

Secure image submission

+

Send one image.
Nothing more.

+

Your image is delivered directly to our private review queue. It is never published or made available through a public link.

+
+ +
+
+
+

01 / Upload

+

Choose your image

+
+

JPG · PNG · HEIC
10 MB maximum

+
+ +
+ + + + + +

+ +
+
+ + + +
Private DropConfidential image intake
+
+ + + diff --git a/static/styles.css b/static/styles.css new file mode 100644 index 0000000..b59e7a3 --- /dev/null +++ b/static/styles.css @@ -0,0 +1,120 @@ +:root { + --ink: #191815; + --paper: #f3efe6; + --card: #fbf8f1; + --accent: #ddff4f; + --muted: #756f64; + --line: #d5cfc2; + --error: #a63b2b; + --success: #336440; +} + +* { box-sizing: border-box; } + +body { + margin: 0; + min-width: 320px; + color: var(--ink); + background: + radial-gradient(circle at 84% 12%, rgba(221, 255, 79, .22), transparent 23rem), + var(--paper); + font-family: Arial, Helvetica, sans-serif; + min-height: 100vh; +} + +body::before { + content: ""; + position: fixed; + inset: 0; + pointer-events: none; + opacity: .24; + background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.14'/%3E%3C/svg%3E"); +} + +button, input { font: inherit; } + +.shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; position: relative; } + +.masthead { + height: 90px; + display: flex; + align-items: center; + justify-content: space-between; + border-bottom: 1px solid var(--ink); +} + +.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-weight: 800; letter-spacing: -.03em; } +.brand-mark { width: 19px; height: 19px; background: var(--ink); border-radius: 50% 50% 2px 50%; transform: rotate(45deg); } +.privacy-label { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; } +.privacy-label span { color: #83a400; margin-right: 7px; } + +.intro { padding: 76px 0 58px; display: grid; grid-template-columns: 1.45fr .72fr; gap: 8vw; align-items: end; } +.eyebrow, .step { text-transform: uppercase; letter-spacing: .16em; font-size: .68rem; font-weight: 800; margin: 0 0 22px; } +h1 { font-family: Georgia, 'Times New Roman', serif; font-size: clamp(3.35rem, 7vw, 6.5rem); line-height: .86; letter-spacing: -.065em; font-weight: 400; margin: 0; } +h1 em { color: transparent; -webkit-text-stroke: 1.5px var(--ink); font-weight: 400; } +.lede { font-family: Georgia, 'Times New Roman', serif; font-size: 1.18rem; line-height: 1.55; margin: 0 0 3px; max-width: 29rem; } + +.upload-card { background: var(--card); border: 1px solid var(--ink); box-shadow: 10px 10px 0 var(--ink); padding: clamp(24px, 4vw, 50px); } +.card-heading { display: flex; justify-content: space-between; gap: 30px; align-items: start; margin-bottom: 34px; } +.step { margin-bottom: 8px; color: var(--muted); } +h2 { font-family: Georgia, 'Times New Roman', serif; font-size: clamp(1.85rem, 3.5vw, 2.65rem); margin: 0; font-weight: 400; letter-spacing: -.035em; } +.formats { margin: 0; text-align: right; font-size: .69rem; line-height: 1.55; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); } +#image-input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; } + +.drop-zone { + min-height: 250px; + border: 1px dashed #928b80; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + text-align: center; + cursor: pointer; + transition: background .18s, border-color .18s, transform .18s; + background: rgba(243, 239, 230, .55); +} +.drop-zone:hover, .drop-zone.is-dragging, #image-input:focus-visible + .drop-zone { background: rgba(221, 255, 79, .16); border-color: var(--ink); outline: none; } +.drop-zone.is-dragging { transform: scale(.992); } +.upload-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; margin-bottom: 20px; } +.upload-icon svg { width: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; } +.drop-title { font-family: Georgia, 'Times New Roman', serif; font-size: 1.55rem; margin-bottom: 8px; } +.drop-copy { color: var(--muted); font-size: .82rem; } + +.file-row { min-height: 104px; align-items: center; border: 1px solid var(--line); padding: 12px; gap: 16px; background: white; } +.file-row:not([hidden]) { display: flex; } +.thumb-wrap { width: 78px; height: 78px; background: #e8e3d9; overflow: hidden; flex: 0 0 auto; } +.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; } +.file-details { min-width: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; } +.file-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.file-details span { font-size: .73rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; } +.remove-button { background: transparent; border: 0; font-size: 1.8rem; cursor: pointer; width: 44px; height: 44px; } +.status { min-height: 22px; margin: 16px 0 10px; font-size: .82rem; color: var(--muted); } +.status.error { color: var(--error); } +.status.success { color: var(--success); font-weight: 700; } + +.submit-button { width: 100%; min-height: 62px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--ink); background: var(--accent); color: var(--ink); font-weight: 800; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; } +.submit-button:not(:disabled):hover { transform: translate(-3px, -3px); box-shadow: 4px 4px 0 var(--ink); } +.submit-button:disabled { background: #ded9cf; color: #8d877c; border-color: #b5afa4; cursor: not-allowed; } + +.privacy-note { display: grid; grid-template-columns: 42px 1fr; gap: 16px; max-width: 600px; margin: 48px auto 88px; } +.lock { border: 1px solid var(--ink); width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; font-size: 1.3rem; } +.privacy-note strong { font-size: .72rem; text-transform: uppercase; letter-spacing: .13em; } +.privacy-note p { margin: 7px 0 0; font-family: Georgia, 'Times New Roman', serif; color: var(--muted); line-height: 1.45; } +footer { border-top: 1px solid var(--ink); height: 80px; display: flex; justify-content: space-between; align-items: center; font-size: .65rem; letter-spacing: .13em; text-transform: uppercase; } + +@media (max-width: 720px) { + .shell { width: min(100% - 24px, 1120px); } + .masthead { height: 70px; } + .privacy-label { font-size: .61rem; } + .intro { padding: 52px 0 40px; grid-template-columns: 1fr; gap: 32px; } + .lede { font-size: 1.05rem; max-width: 34rem; } + .upload-card { box-shadow: 5px 5px 0 var(--ink); } + .card-heading { display: block; } + .formats { text-align: left; margin-top: 18px; } + .drop-zone { min-height: 220px; } + footer { align-items: start; flex-direction: column; justify-content: center; gap: 8px; } +} + +@media (prefers-reduced-motion: reduce) { + * { scroll-behavior: auto !important; transition: none !important; } +} -- cgit v1.2.3