Tweaks, generating icons

This commit is contained in:
Dan 2026-02-21 19:44:52 +00:00
parent 38cf394916
commit 3757454f3a
9 changed files with 718 additions and 356 deletions

11
generate-icons.sh Normal file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Generates PNG icons from icon.svg using rsvg-convert.
# Run whenever icon.svg changes: bash generate-icons.sh
set -euo pipefail
cd "$(dirname "$0")"
rsvg-convert -w 192 -h 192 icon.svg -o icon-192.png
rsvg-convert -w 512 -h 512 icon.svg -o icon-512.png
echo "Generated icon-192.png and icon-512.png"

BIN
icon-192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
icon-512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -1,5 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<rect width="512" height="512" rx="115" fill="#7c3aed"/> <rect width="512" height="512" rx="115" fill="#ad7f58"/>
<!-- 4-pointed star (✦) --> <!-- Thought bubble main body -->
<path d="M256 76 L299 214 L436 256 L299 298 L256 436 L213 298 L76 256 L213 214 Z" fill="white"/> <rect x="72" y="52" width="368" height="252" rx="90" fill="white"/>
<!-- Thought bubble trailing dots -->
<circle cx="240" cy="350" r="38" fill="white"/>
<circle cx="196" cy="413" r="26" fill="white"/>
<circle cx="163" cy="458" r="17" fill="white"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 260 B

After

Width:  |  Height:  |  Size: 433 B

Before After
Before After

View file

@ -1,147 +1,274 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <meta
<meta name="description" content="Post status updates to status.lol"> name="viewport"
<meta name="theme-color" content="#7c3aed" media="(prefers-color-scheme: light)"> content="width=device-width, initial-scale=1, viewport-fit=cover"
<meta name="theme-color" content="#a78bfa" media="(prefers-color-scheme: dark)"> />
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="description" content="Post status updates to status.lol" />
<meta name="apple-mobile-web-app-status-bar-style" content="default"> <meta
<meta name="apple-mobile-web-app-title" content="Status Poster"> name="theme-color"
<link rel="manifest" href="manifest.json"> content="#ad7f58"
<link rel="stylesheet" href="style.css"> media="(prefers-color-scheme: light)"
<title>Status Poster</title> />
<meta
</head> name="theme-color"
<body> content="#ad7f58"
media="(prefers-color-scheme: dark)"
<div class="app"> />
<header> <meta name="apple-mobile-web-app-capable" content="yes" />
<div class="logo"> <meta name="apple-mobile-web-app-status-bar-style" content="default" />
<div class="logo-mark"></div> <meta name="apple-mobile-web-app-title" content="Status Poster" />
Status Poster <link rel="manifest" href="manifest.json" />
</div> <link rel="apple-touch-icon" href="icon-192.png" />
<button class="settings-btn" id="settings-btn" aria-label="Open settings"></button> <link rel="stylesheet" href="style.css" />
</header> <title>Post → status.lol</title>
</head>
<main> <body>
<!-- Emoji picker --> <div class="app">
<div class="emoji-section"> <header>
<div <div class="logo">
class="emoji-display" <img
id="emoji-display" src="icon.svg"
role="button" class="logo-mark"
tabindex="0" alt=""
aria-label="Current emoji — click to change" aria-hidden="true"
> width="30"
<span id="emoji-show">📝</span> height="30"
</div> />
<input Post → status.lol
type="text" </div>
id="emoji-input" <button
class="emoji-picker-input" class="settings-btn"
placeholder="Type or paste an emoji…" id="settings-btn"
autocomplete="off" aria-label="Open settings"
autocorrect="off"
autocapitalize="none"
spellcheck="false"
aria-label="Emoji input"
>
<span class="emoji-hint" id="emoji-hint">Click to change emoji</span>
</div>
<!-- Status text -->
<div class="field">
<label for="status-text">Status</label>
<textarea
id="status-text"
placeholder="What's on your mind?"
maxlength="5000"
rows="4"
aria-label="Status text"
></textarea>
<div class="char-count" id="char-count" aria-live="polite">0 / 5000</div>
</div>
<!-- Optional URL -->
<div class="field">
<label for="status-url">
Link <span style="font-weight:400;text-transform:none;letter-spacing:0;font-size:0.88em">(optional)</span>
</label>
<input
type="url"
id="status-url"
placeholder="https://example.com"
autocorrect="off"
autocapitalize="none"
spellcheck="false"
>
</div>
<!-- Post button -->
<button class="post-btn" id="post-btn">
<div class="spinner" aria-hidden="true"></div>
<span class="btn-label">Post Status</span>
</button>
</main>
</div>
<!-- Toast notification -->
<div id="toast" role="status" aria-live="polite" aria-atomic="true"></div>
<!-- Settings modal -->
<div class="overlay" id="overlay" role="dialog" aria-modal="true" aria-labelledby="modal-title">
<div class="modal">
<div class="modal-grip" aria-hidden="true"></div>
<div class="modal-header">
<span class="modal-title" id="modal-title">Settings</span>
<button class="close-btn" id="modal-close" aria-label="Close settings"></button>
</div>
<div class="modal-body">
<div class="privacy-notice" role="note">
<span class="privacy-icon">🔒</span>
<span>
Your username and API key are stored <strong>only in this browser's local storage</strong>
and are never sent anywhere except <strong>api.omg.lol</strong> when you post a status.
</span>
</div>
<div class="field">
<label for="s-username">omg.lol username</label>
<input
type="text"
id="s-username"
placeholder="yourname"
autocomplete="username"
autocorrect="off"
autocapitalize="none"
spellcheck="false"
> >
</div>
</button>
</header>
<div class="field"> <main>
<label for="s-apikey">API key</label> <!-- Emoji picker -->
<div class="input-wrap"> <div class="emoji-section">
<input <div
type="password" class="emoji-display"
id="s-apikey" id="emoji-display"
placeholder="Your omg.lol API key" role="button"
autocomplete="current-password" tabindex="0"
spellcheck="false" aria-label="Current emoji — click to change"
> >
<button class="eye-btn" id="eye-btn" aria-label="Show API key">👁</button> <span id="emoji-show">💬</span>
</div>
<input
type="text"
id="emoji-input"
class="emoji-picker-input"
placeholder="Type or paste an emoji…"
autocomplete="off"
autocorrect="off"
autocapitalize="none"
spellcheck="false"
aria-label="Emoji input"
/>
<span class="emoji-hint" id="emoji-hint">Click to change emoji</span>
</div>
<!-- Status text -->
<div class="field">
<label for="status-text">Status</label>
<textarea
id="status-text"
placeholder="What's on your mind?"
maxlength="5000"
rows="4"
aria-label="Status text"
></textarea>
<div class="char-count" id="char-count" aria-live="polite">
0 / 5000
</div>
</div>
<!-- Optional URL -->
<div class="field">
<label for="status-url">
Link
<span
style="
font-weight: 400;
text-transform: none;
letter-spacing: 0;
font-size: 0.88em;
"
>(optional)</span
>
</label>
<input
type="url"
id="status-url"
placeholder="https://example.com"
autocorrect="off"
autocapitalize="none"
spellcheck="false"
/>
</div>
<!-- Mastodon toggle -->
<div class="field toggle-row">
<label class="toggle-label" for="mastodon-toggle">
<input type="checkbox" id="mastodon-toggle" />
Post to Mastodon
</label>
</div>
<!-- Post button -->
<button class="post-btn" id="post-btn">
<div class="spinner" aria-hidden="true"></div>
<span class="btn-label">Post Status</span>
</button>
</main>
<footer>
<button class="footer-link" id="privacy-link" type="button">🔒 Privacy</button>
<a class="footer-link" href="https://git.bkr.im/ritual/status-poster" target="_blank" rel="noopener">🧑‍💻 Source Code</a>
<a class="footer-link" href="https://ritual.sh" target="_blank" rel="noopener">🖥️ By Ritual</a>
</footer>
</div>
<!-- Privacy modal -->
<div
class="overlay"
id="privacy-overlay"
role="dialog"
aria-modal="true"
aria-labelledby="privacy-modal-title"
>
<div class="modal">
<div class="modal-grip" aria-hidden="true"></div>
<div class="modal-header">
<span class="modal-title" id="privacy-modal-title">Privacy</span>
<button
class="close-btn"
id="privacy-modal-close"
aria-label="Close privacy notice"
>
</button>
</div>
<div class="modal-body">
<p style="font-size: 0.95rem; line-height: 1.7; margin: 0">
This app stores your <strong>omg.lol username</strong> and
<strong>API key</strong>
only in your browser's local storage. They are never sent to any
server other than
<strong>api.omg.lol</strong> at the moment you post a status.
</p>
<p style="font-size: 0.95rem; line-height: 1.7; margin: 0">
No analytics, no tracking, no third-party requests. The
<a href="https://git.bkr.im/ritual/status-poster"
>source code is available online</a
>
and you can take it and host your version if you want!
</p>
</div> </div>
</div> </div>
<button class="save-btn" id="save-btn">Save Settings</button>
</div> </div>
</div>
</div>
<script src="script.js"></script> <!-- Toast notification -->
<div id="toast" role="status" aria-live="polite" aria-atomic="true"></div>
</body> <!-- Settings modal -->
<div
class="overlay"
id="overlay"
role="dialog"
aria-modal="true"
aria-labelledby="modal-title"
>
<div class="modal">
<div class="modal-grip" aria-hidden="true"></div>
<div class="modal-header">
<span class="modal-title" id="modal-title">Settings</span>
<button
class="close-btn"
id="modal-close"
aria-label="Close settings"
>
</button>
</div>
<div class="modal-body">
<div class="field">
<label for="s-username">omg.lol username</label>
<input
type="text"
id="s-username"
placeholder="username"
autocomplete="username"
autocorrect="off"
autocapitalize="none"
spellcheck="false"
/>
</div>
<div class="field">
<label for="s-apikey">API key</label>
<div class="input-wrap">
<input
type="password"
id="s-apikey"
placeholder="Your omg.lol API key"
autocomplete="current-password"
spellcheck="false"
/>
<button class="eye-btn" id="eye-btn" aria-label="Show API key">
👁
</button>
</div>
</div>
<div class="field">
<label>Appearance</label>
<div
class="theme-toggle"
id="theme-toggle"
role="group"
aria-label="Color theme"
>
<button
class="theme-btn"
data-theme="light"
type="button"
aria-pressed="false"
>
☀ Light
</button>
<button
class="theme-btn"
data-theme="auto"
type="button"
aria-pressed="true"
>
Auto
</button>
<button
class="theme-btn"
data-theme="dark"
type="button"
aria-pressed="false"
>
☾ Dark
</button>
</div>
</div>
<button class="save-btn" id="save-btn">Save Settings</button>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html> </html>

View file

@ -6,19 +6,19 @@
"display": "standalone", "display": "standalone",
"orientation": "portrait", "orientation": "portrait",
"background_color": "#ffffff", "background_color": "#ffffff",
"theme_color": "#7c3aed", "theme_color": "#ad7f58",
"icons": [ "icons": [
{ {
"src": "icon.svg", "src": "icon-192.png",
"sizes": "any", "sizes": "192x192",
"type": "image/svg+xml", "type": "image/png",
"purpose": "any" "purpose": "any"
}, },
{ {
"src": "icon.svg", "src": "icon-512.png",
"sizes": "any", "sizes": "512x512",
"type": "image/svg+xml", "type": "image/png",
"purpose": "maskable" "purpose": "any maskable"
} }
] ]
} }

278
script.js
View file

@ -1,90 +1,146 @@
// ── State ──────────────────────────────────────────────────────────────────── // ── State ────────────────────────────────────────────────────────────────────
let emoji = '📝'; let emoji = "💬";
let settings = { username: '', apiKey: '' }; let settings = { username: "", apiKey: "", theme: "auto", mastodonPost: false };
// ── DOM ────────────────────────────────────────────────────────────────────── // ── DOM ──────────────────────────────────────────────────────────────────────
const $ = id => document.getElementById(id); const $ = (id) => document.getElementById(id);
const emojiDisplay = $('emoji-display'); const emojiDisplay = $("emoji-display");
const emojiShow = $('emoji-show'); const emojiShow = $("emoji-show");
const emojiInput = $('emoji-input'); const emojiInput = $("emoji-input");
const emojiSection = emojiDisplay.closest('.emoji-section'); const emojiSection = emojiDisplay.closest(".emoji-section");
const emojiHint = $('emoji-hint'); const emojiHint = $("emoji-hint");
const statusText = $('status-text'); const statusText = $("status-text");
const statusUrl = $('status-url'); const statusUrl = $("status-url");
const charCount = $('char-count'); const charCount = $("char-count");
const postBtn = $('post-btn'); const postBtn = $("post-btn");
const toast = $('toast'); const toast = $("toast");
const settingsBtn = $('settings-btn'); const settingsBtn = $("settings-btn");
const overlay = $('overlay'); const overlay = $("overlay");
const modalClose = $('modal-close'); const modalClose = $("modal-close");
const sUsername = $('s-username'); const sUsername = $("s-username");
const sApikey = $('s-apikey'); const sApikey = $("s-apikey");
const eyeBtn = $('eye-btn'); const eyeBtn = $("eye-btn");
const saveBtn = $('save-btn'); const saveBtn = $("save-btn");
const themeToggle = $("theme-toggle");
const mastodonToggle = $("mastodon-toggle");
// ── Settings ───────────────────────────────────────────────────────────────── // ── Settings ─────────────────────────────────────────────────────────────────
function applyTheme(theme) {
if (theme === "auto") {
delete document.documentElement.dataset.theme;
} else {
document.documentElement.dataset.theme = theme;
}
}
function updateThemeToggle(theme) {
themeToggle.querySelectorAll(".theme-btn").forEach((btn) => {
const active = btn.dataset.theme === theme;
btn.classList.toggle("active", active);
btn.setAttribute("aria-pressed", active ? "true" : "false");
});
}
function loadSettings() { function loadSettings() {
try { try {
const raw = localStorage.getItem('spo-settings'); const raw = localStorage.getItem("spo-settings");
if (raw) settings = { ...settings, ...JSON.parse(raw) }; if (raw) settings = { ...settings, ...JSON.parse(raw) };
} catch {} } catch {}
applyTheme(settings.theme);
updateBadge(); updateBadge();
mastodonToggle.checked = settings.mastodonPost ?? false;
} }
function saveSettings() { function saveSettings() {
settings.username = sUsername.value.trim().replace(/^@/, ''); settings.username = sUsername.value.trim().replace(/^@/, "");
settings.apiKey = sApikey.value.trim(); settings.apiKey = sApikey.value.trim();
try { try {
localStorage.setItem('spo-settings', JSON.stringify(settings)); localStorage.setItem("spo-settings", JSON.stringify(settings));
} catch { } catch {
showToast('Could not save — storage unavailable', 'error'); showToast("Could not save — storage unavailable", "error");
return; return;
} }
updateBadge(); updateBadge();
closeModal(); closeModal();
showToast('Settings saved', 'success'); showToast("Settings saved", "success");
} }
function updateBadge() { function updateBadge() {
settingsBtn.classList.toggle('needs-setup', !settings.username || !settings.apiKey); settingsBtn.classList.toggle(
"needs-setup",
!settings.username || !settings.apiKey,
);
} }
// ── Modal ──────────────────────────────────────────────────────────────────── // ── Modal ────────────────────────────────────────────────────────────────────
function openModal() { function openModal() {
sUsername.value = settings.username; sUsername.value = settings.username;
sApikey.value = settings.apiKey; sApikey.value = settings.apiKey;
overlay.classList.add('open'); updateThemeToggle(settings.theme);
document.body.style.overflow = 'hidden'; overlay.classList.add("open");
document.body.style.overflow = "hidden";
// Focus first empty field // Focus first empty field
if (!settings.username) sUsername.focus(); if (!settings.username) sUsername.focus();
else if (!settings.apiKey) sApikey.focus(); else if (!settings.apiKey) sApikey.focus();
} }
function closeModal() { function closeModal() {
overlay.classList.remove('open'); overlay.classList.remove("open");
document.body.style.overflow = ''; document.body.style.overflow = "";
} }
settingsBtn.addEventListener('click', openModal); const privacyOverlay = $("privacy-overlay");
modalClose.addEventListener('click', closeModal);
overlay.addEventListener('click', e => { if (e.target === overlay) closeModal(); }); function openPrivacy() {
saveBtn.addEventListener('click', saveSettings); privacyOverlay.classList.add("open");
document.body.style.overflow = "hidden";
}
function closePrivacy() {
privacyOverlay.classList.remove("open");
document.body.style.overflow = "";
}
settingsBtn.addEventListener("click", openModal);
$("privacy-link").addEventListener("click", openPrivacy);
$("privacy-modal-close").addEventListener("click", closePrivacy);
privacyOverlay.addEventListener("click", (e) => {
if (e.target === privacyOverlay) closePrivacy();
});
modalClose.addEventListener("click", closeModal);
overlay.addEventListener("click", (e) => {
if (e.target === overlay) closeModal();
});
saveBtn.addEventListener("click", saveSettings);
mastodonToggle.addEventListener("change", () => {
settings.mastodonPost = mastodonToggle.checked;
try { localStorage.setItem("spo-settings", JSON.stringify(settings)); } catch {}
});
themeToggle.addEventListener("click", (e) => {
const btn = e.target.closest(".theme-btn");
if (!btn) return;
settings.theme = btn.dataset.theme;
applyTheme(settings.theme);
updateThemeToggle(settings.theme);
});
// Eye toggle for API key // Eye toggle for API key
eyeBtn.addEventListener('click', () => { eyeBtn.addEventListener("click", () => {
const show = sApikey.type === 'password'; const show = sApikey.type === "password";
sApikey.type = show ? 'text' : 'password'; sApikey.type = show ? "text" : "password";
eyeBtn.textContent = show ? '🙈' : '👁'; eyeBtn.textContent = show ? "🙈" : "👁";
eyeBtn.setAttribute('aria-label', show ? 'Hide API key' : 'Show API key'); eyeBtn.setAttribute("aria-label", show ? "Hide API key" : "Show API key");
}); });
// ── Emoji picker ───────────────────────────────────────────────────────────── // ── Emoji picker ─────────────────────────────────────────────────────────────
function extractFirstEmoji(str) { function extractFirstEmoji(str) {
if (!str) return null; if (!str) return null;
if (typeof Intl?.Segmenter === 'function') { if (typeof Intl?.Segmenter === "function") {
const seg = new Intl.Segmenter(undefined, { granularity: 'grapheme' }); const seg = new Intl.Segmenter(undefined, { granularity: "grapheme" });
for (const { segment } of seg.segment(str)) { for (const { segment } of seg.segment(str)) {
if (/\p{Emoji}/u.test(segment) && segment.trim() !== '') return segment; if (/\p{Emoji}/u.test(segment) && segment.trim() !== "") return segment;
} }
return null; return null;
} }
@ -93,28 +149,36 @@ function extractFirstEmoji(str) {
} }
// Detect platform for hint text // Detect platform for hint text
const isMac = /Mac/.test(navigator.userAgent) && !/iPhone|iPad/.test(navigator.userAgent); const isMac =
const osHint = isMac ? ' · or ⌃⌘Space' : (navigator.userAgent.includes('Win') ? ' · or Win+.' : ''); /Mac/.test(navigator.userAgent) && !/iPhone|iPad/.test(navigator.userAgent);
const osHint = isMac
? " · or ⌃⌘Space"
: navigator.userAgent.includes("Win")
? " · or Win+."
: "";
function openEmojiPicker() { function openEmojiPicker() {
emojiSection.classList.add('picking'); emojiSection.classList.add("picking");
emojiInput.value = ''; emojiInput.value = "";
emojiInput.focus(); emojiInput.focus();
emojiHint.textContent = `Type, paste, or use your emoji keyboard${osHint}`; emojiHint.textContent = `Type, paste, or use your emoji keyboard${osHint}`;
} }
function closeEmojiPicker() { function closeEmojiPicker() {
emojiSection.classList.remove('picking'); emojiSection.classList.remove("picking");
emojiHint.textContent = 'Click to change emoji'; emojiHint.textContent = "Click to change emoji";
} }
emojiDisplay.addEventListener('click', openEmojiPicker); emojiDisplay.addEventListener("click", openEmojiPicker);
emojiDisplay.addEventListener('keydown', e => { emojiDisplay.addEventListener("keydown", (e) => {
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); openEmojiPicker(); } if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
openEmojiPicker();
}
}); });
emojiInput.addEventListener('input', () => { emojiInput.addEventListener("input", () => {
const found = extractFirstEmoji(emojiInput.value); const found = extractFirstEmoji(emojiInput.value);
if (found) { if (found) {
emoji = found; emoji = found;
@ -123,126 +187,116 @@ emojiInput.addEventListener('input', () => {
} }
}); });
emojiInput.addEventListener('blur', () => { emojiInput.addEventListener("blur", () => {
// Small delay so a click on the emoji-display doesn't flicker // Small delay so a click on the emoji-display doesn't flicker
setTimeout(() => { if (document.activeElement !== emojiInput) closeEmojiPicker(); }, 150); setTimeout(() => {
if (document.activeElement !== emojiInput) closeEmojiPicker();
}, 150);
}); });
// ── Keyboard shortcuts ──────────────────────────────────────────────────────── // ── Keyboard shortcuts ────────────────────────────────────────────────────────
document.addEventListener('keydown', e => { document.addEventListener("keydown", (e) => {
if (e.key === 'Escape') { if (e.key === "Escape") {
if (emojiSection.classList.contains('picking')) closeEmojiPicker(); if (emojiSection.classList.contains("picking")) closeEmojiPicker();
else if (overlay.classList.contains('open')) closeModal(); else if (overlay.classList.contains("open")) closeModal();
else if (privacyOverlay.classList.contains("open")) closePrivacy();
} }
}); });
// ── Character count ─────────────────────────────────────────────────────────── // ── Character count ───────────────────────────────────────────────────────────
statusText.addEventListener('input', () => { statusText.addEventListener("input", () => {
const n = statusText.value.length; const n = statusText.value.length;
charCount.textContent = `${n} / 5000`; charCount.textContent = `${n} / 5000`;
charCount.classList.toggle('warn', n > 4800); charCount.classList.toggle("warn", n > 4800);
}); });
// ── Post status ─────────────────────────────────────────────────────────────── // ── Post status ───────────────────────────────────────────────────────────────
async function postStatus() { async function postStatus() {
if (!settings.username || !settings.apiKey) { if (!settings.username || !settings.apiKey) {
showToast('Add your credentials in settings first', 'error'); showToast("Add your credentials in settings first", "error");
openModal(); openModal();
return; return;
} }
const content = statusText.value.trim(); const content = statusText.value.trim();
if (!content) { if (!content) {
showToast('Status text is required', 'error'); showToast("Status text is required", "error");
statusText.focus(); statusText.focus();
return; return;
} }
postBtn.classList.add('loading'); postBtn.classList.add("loading");
postBtn.disabled = true; postBtn.disabled = true;
const body = { emoji, content }; const body = { emoji, content };
const url = statusUrl.value.trim(); const url = statusUrl.value.trim();
if (url) body.external_url = url; if (url) body.external_url = url;
if (!mastodonToggle.checked) body.skip_mastodon_post = true;
try { try {
const res = await fetch( const res = await fetch(
`https://api.omg.lol/address/${encodeURIComponent(settings.username)}/statuses/`, `https://api.omg.lol/address/${encodeURIComponent(settings.username)}/statuses/`,
{ {
method: 'POST', method: "POST",
headers: { headers: {
'Authorization': `Bearer ${settings.apiKey}`, Authorization: `Bearer ${settings.apiKey}`,
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
body: JSON.stringify(body), body: JSON.stringify(body),
} },
); );
const data = await res.json().catch(() => ({})); const data = await res.json().catch(() => ({}));
if (res.ok || data?.request?.status_code === 200) { if (res.ok || data?.request?.status_code === 200) {
const msg = data?.response?.message ?? 'Status posted!'; const statusLink = data?.response?.url ?? null;
showToast(msg, 'success'); const msg = statusLink ? "Status posted · View ↗" : "Status posted";
statusText.value = ''; showToast(msg, "success", statusLink);
statusUrl.value = ''; statusText.value = "";
charCount.textContent = '0 / 5000'; statusUrl.value = "";
charCount.classList.remove('warn'); charCount.textContent = "0 / 5000";
emoji = '📝'; charCount.classList.remove("warn");
emojiShow.textContent = '📝'; emoji = "📝";
emojiShow.textContent = "📝";
} else { } else {
const msg = data?.response?.message ?? `Error ${res.status}`; const msg = data?.response?.message ?? `Error ${res.status}`;
showToast(msg, 'error'); showToast(msg, "error");
} }
} catch (err) { } catch (err) {
const msg = err?.message === 'Failed to fetch' const msg =
? 'Network error — check your connection' err?.message === "Failed to fetch"
: (err?.message ?? 'Something went wrong'); ? "Network error — check your connection"
showToast(msg, 'error'); : (err?.message ?? "Something went wrong");
showToast(msg, "error");
} finally { } finally {
postBtn.classList.remove('loading'); postBtn.classList.remove("loading");
postBtn.disabled = false; postBtn.disabled = false;
} }
} }
postBtn.addEventListener('click', postStatus); postBtn.addEventListener("click", postStatus);
// Ctrl/Cmd + Enter to post from textarea // Ctrl/Cmd + Enter to post from textarea
statusText.addEventListener('keydown', e => { statusText.addEventListener("keydown", (e) => {
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) postStatus(); if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) postStatus();
}); });
// ── Toast ──────────────────────────────────────────────────────────────────── // ── Toast ────────────────────────────────────────────────────────────────────
let toastTimer; let toastTimer;
function showToast(msg, type = '') { function showToast(msg, type = "", url = null) {
clearTimeout(toastTimer); clearTimeout(toastTimer);
toast.textContent = msg; toast.textContent = msg;
toast.className = `show ${type}`.trim(); toast.onclick = url ? () => window.open(url, "_blank", "noopener") : null;
toastTimer = setTimeout(() => { toast.className = ''; }, 4000); toast.className = `show ${type}${url ? " clickable" : ""}`.trim();
toastTimer = setTimeout(() => {
toast.className = "";
toast.onclick = null;
}, 4000);
} }
// ── Apple touch icon (generated at runtime — iOS doesn't support SVG icons) ──
try {
const c = document.createElement('canvas');
c.width = c.height = 192;
const ctx = c.getContext('2d');
ctx.fillStyle = '#7c3aed';
ctx.beginPath();
ctx.roundRect(0, 0, 192, 192, 38);
ctx.fill();
ctx.fillStyle = 'white';
ctx.font = '90px serif';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText('✦', 96, 98);
const link = document.createElement('link');
link.rel = 'apple-touch-icon';
link.href = c.toDataURL('image/png');
document.head.appendChild(link);
} catch {}
// ── Service worker ──────────────────────────────────────────────────────────── // ── Service worker ────────────────────────────────────────────────────────────
if ('serviceWorker' in navigator) { if ("serviceWorker" in navigator) {
navigator.serviceWorker.register('sw.js').catch(() => {}); navigator.serviceWorker.register("sw.js").catch(() => {});
} }
// ── Init ────────────────────────────────────────────────────────────────────── // ── Init ──────────────────────────────────────────────────────────────────────

356
style.css
View file

@ -1,46 +1,87 @@
/* ── Design tokens ─────────────────────────────────────────────────────── */ /* ── Design tokens ─────────────────────────────────────────────────────── */
/* Colours: Radix Sand (neutrals) + Radix Brown (accent) */
:root { :root {
--bg: #ffffff; --bg: #fdfdfc; /* sand-1 */
--surface: #f4f4f7; --surface: #f1f0ef; /* sand-3 */
--border: #e2e2ea; --border: #dad9d6; /* sand-6 */
--text: #18181b; --text: #21201c; /* sand-12 */
--muted: #71717a; --muted: #63635e; /* sand-11 */
--accent: #7c3aed; --accent: #ad7f58; /* brown-9 */
--accent-dim: #ede9fe; --accent-dim: #f6eee7; /* brown-3 */
--accent-fg: #ffffff; --accent-fg: #ffffff;
--danger: #dc2626; --danger: #dc2626;
--success: #16a34a; --success: #16a34a;
--r: 14px; --r: 14px;
--r-sm: 8px; --r-sm: 8px;
--safe-t: env(safe-area-inset-top, 0px); --safe-t: env(safe-area-inset-top, 0px);
--safe-b: env(safe-area-inset-bottom, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
:root { :root {
--bg: #0f0f13; --bg: #111110; /* sand-1 dark */
--surface: #17171f; --surface: #222221; /* sand-3 dark */
--border: #2a2a38; --border: #3b3a37; /* sand-6 dark */
--text: #f0f0f8; --text: #eeeeec; /* sand-12 dark */
--muted: #8b8ba0; --muted: #b5b3ad; /* sand-11 dark */
--accent: #a78bfa; --accent: #ad7f58; /* brown-9 (same in light/dark) */
--accent-dim: #2d1f5e; --accent-dim: #322922; /* brown-4 dark */
--accent-fg: #0f0f13; --accent-fg: #ffffff;
--danger: #f87171; --danger: #f87171;
--success: #4ade80; --success: #4ade80;
} }
} }
/* ── Reset & base ──────────────────────────────────────────────────────── */ /* Explicit theme overrides (beat the media query via attribute specificity) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } :root[data-theme="light"] {
--bg: #fdfdfc;
--surface: #f1f0ef;
--border: #dad9d6;
--text: #21201c;
--muted: #63635e;
--accent: #ad7f58;
--accent-dim: #f6eee7;
--accent-fg: #ffffff;
--danger: #dc2626;
--success: #16a34a;
}
html { height: 100%; } :root[data-theme="dark"] {
--bg: #111110;
--surface: #222221;
--border: #3b3a37;
--text: #eeeeec;
--muted: #b5b3ad;
--accent: #ad7f58;
--accent-dim: #322922;
--accent-fg: #ffffff;
--danger: #f87171;
--success: #4ade80;
}
/* ── Reset & base ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body { body {
min-height: 100%; min-height: 100%;
background: var(--bg); background: var(--bg);
color: var(--text); color: var(--text);
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
font-size: 16px; font-size: 16px;
line-height: 1.5; line-height: 1.5;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
@ -55,6 +96,30 @@ body {
margin: 0 auto; margin: 0 auto;
} }
/* ── Footer ────────────────────────────────────────────────────────────── */
footer {
padding: 12px 20px calc(12px + var(--safe-b));
display: flex;
justify-content: center;
}
.footer-link {
background: none;
border: none;
padding: 4px 8px;
font-size: 0.8rem;
font-weight: 700;
color: var(--muted);
cursor: pointer;
border-radius: 6px;
text-decoration: none;
-webkit-tap-highlight-color: transparent;
}
.footer-link:hover {
color: var(--text);
}
/* ── Header ────────────────────────────────────────────────────────────── */ /* ── Header ────────────────────────────────────────────────────────────── */
header { header {
display: flex; display: flex;
@ -80,13 +145,6 @@ header {
.logo-mark { .logo-mark {
width: 30px; width: 30px;
height: 30px; height: 30px;
background: var(--accent);
color: var(--accent-fg);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.9rem;
flex-shrink: 0; flex-shrink: 0;
} }
@ -102,16 +160,20 @@ header {
cursor: pointer; cursor: pointer;
font-size: 1.05rem; font-size: 1.05rem;
color: var(--muted); color: var(--muted);
transition: background 0.15s, color 0.15s; transition:
background 0.15s,
color 0.15s;
position: relative; position: relative;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
} }
.settings-btn:active { background: var(--border); } .settings-btn:active {
background: var(--border);
}
/* Red dot when credentials missing */ /* Red dot when credentials missing */
.settings-btn.needs-setup::after { .settings-btn.needs-setup::after {
content: ''; content: "";
position: absolute; position: absolute;
top: -3px; top: -3px;
right: -3px; right: -3px;
@ -151,13 +213,21 @@ main {
font-size: 3.25rem; font-size: 3.25rem;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
transition: transform 0.12s, border-color 0.15s, background 0.15s; transition:
transform 0.12s,
border-color 0.15s,
background 0.15s;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
position: relative; position: relative;
} }
.emoji-display:active { transform: scale(0.94); } .emoji-display:active {
.emoji-display:hover { border-color: var(--accent); background: var(--accent-dim); } transform: scale(0.94);
}
.emoji-display:hover {
border-color: var(--accent);
background: var(--accent-dim);
}
/* Visible emoji text input — slides in when picking */ /* Visible emoji text input — slides in when picking */
.emoji-picker-input { .emoji-picker-input {
@ -172,8 +242,11 @@ main {
opacity: 0; opacity: 0;
pointer-events: none; pointer-events: none;
border-color: transparent; border-color: transparent;
transition: max-height 0.2s ease, padding 0.18s ease, transition:
opacity 0.15s ease, border-color 0.15s ease; max-height 0.2s ease,
padding 0.18s ease,
opacity 0.15s ease,
border-color 0.15s ease;
} }
.emoji-section.picking .emoji-picker-input { .emoji-section.picking .emoji-picker-input {
@ -198,6 +271,29 @@ main {
gap: 7px; gap: 7px;
} }
.toggle-row {
padding-block: 2px;
}
.toggle-label {
display: flex;
align-items: center;
gap: 10px;
cursor: pointer;
font-size: 0.92rem;
font-weight: 400;
color: var(--text);
text-transform: none;
letter-spacing: 0;
user-select: none;
}
.toggle-label input[type="checkbox"] {
width: 20px;
height: 20px;
accent-color: var(--accent);
cursor: pointer;
flex-shrink: 0;
}
label { label {
font-size: 0.78rem; font-size: 0.78rem;
font-weight: 600; font-weight: 600;
@ -219,7 +315,9 @@ input[type="password"] {
padding: 13px 15px; padding: 13px 15px;
width: 100%; width: 100%;
outline: none; outline: none;
transition: border-color 0.15s, background 0.15s; transition:
border-color 0.15s,
background 0.15s;
-webkit-appearance: none; -webkit-appearance: none;
} }
@ -237,7 +335,9 @@ textarea {
} }
textarea::placeholder, textarea::placeholder,
input::placeholder { color: var(--muted); } input::placeholder {
color: var(--muted);
}
.char-count { .char-count {
font-size: 0.78rem; font-size: 0.78rem;
@ -246,7 +346,9 @@ input::placeholder { color: var(--muted); }
transition: color 0.15s; transition: color 0.15s;
} }
.char-count.warn { color: var(--danger); } .char-count.warn {
color: var(--danger);
}
/* ── Post button ───────────────────────────────────────────────────────── */ /* ── Post button ───────────────────────────────────────────────────────── */
.post-btn { .post-btn {
@ -264,12 +366,19 @@ input::placeholder { color: var(--muted); }
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 8px; gap: 8px;
transition: opacity 0.15s, transform 0.1s; transition:
opacity 0.15s,
transform 0.1s;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
} }
.post-btn:active:not(:disabled) { transform: scale(0.98); } .post-btn:active:not(:disabled) {
.post-btn:disabled { opacity: 0.5; cursor: not-allowed; } transform: scale(0.98);
}
.post-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.spinner { .spinner {
width: 18px; width: 18px;
@ -282,10 +391,18 @@ input::placeholder { color: var(--muted); }
flex-shrink: 0; flex-shrink: 0;
} }
.post-btn.loading .spinner { display: block; } .post-btn.loading .spinner {
.post-btn.loading .btn-label { display: none; } display: block;
}
.post-btn.loading .btn-label {
display: none;
}
@keyframes spin { to { transform: rotate(360deg); } } @keyframes spin {
to {
transform: rotate(360deg);
}
}
/* ── Toast ─────────────────────────────────────────────────────────────── */ /* ── Toast ─────────────────────────────────────────────────────────────── */
#toast { #toast {
@ -310,9 +427,23 @@ input::placeholder { color: var(--muted); }
text-overflow: ellipsis; text-overflow: ellipsis;
} }
#toast.show { transform: translateX(-50%) translateY(0); } #toast.show {
#toast.success { background: var(--success); color: #fff; } transform: translateX(-50%) translateY(0);
#toast.error { background: var(--danger); color: #fff; } }
#toast.success {
background: var(--success);
color: #fff;
}
#toast.error {
background: var(--danger);
color: #fff;
}
#toast.show.clickable {
pointer-events: auto;
cursor: pointer;
}
#toast.show.clickable:hover { filter: brightness(1.1); }
/* ── Settings modal ────────────────────────────────────────────────────── */ /* ── Settings modal ────────────────────────────────────────────────────── */
.overlay { .overlay {
@ -321,10 +452,12 @@ input::placeholder { color: var(--muted); }
background: rgba(0, 0, 0, 0.48); background: rgba(0, 0, 0, 0.48);
z-index: 50; z-index: 50;
display: flex; display: flex;
align-items: flex-end; align-items: center;
justify-content: center;
padding: 20px;
opacity: 0; opacity: 0;
pointer-events: none; pointer-events: none;
transition: opacity 0.25s; transition: opacity 0.2s;
} }
.overlay.open { .overlay.open {
@ -334,25 +467,25 @@ input::placeholder { color: var(--muted); }
.modal { .modal {
background: var(--bg); background: var(--bg);
border-radius: 22px 22px 0 0; border-radius: 22px;
width: 100%; width: 100%;
max-width: 480px; max-width: 440px;
margin: 0 auto; max-height: 90vh;
padding-bottom: calc(20px + var(--safe-b));
transform: translateY(100%);
transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
max-height: 92vh;
overflow-y: auto; overflow-y: auto;
transform: scale(0.95) translateY(8px);
opacity: 0;
transition:
transform 0.25s cubic-bezier(0.34, 1.2, 0.64, 1),
opacity 0.2s;
} }
.overlay.open .modal { transform: translateY(0); } .overlay.open .modal {
transform: scale(1) translateY(0);
opacity: 1;
}
.modal-grip { .modal-grip {
width: 40px; display: none;
height: 4px;
background: var(--border);
border-radius: 2px;
margin: 10px auto 0;
} }
.modal-header { .modal-header {
@ -382,7 +515,9 @@ input::placeholder { color: var(--muted); }
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
} }
.close-btn:active { background: var(--border); } .close-btn:active {
background: var(--border);
}
.modal-body { .modal-body {
padding: 20px; padding: 20px;
@ -405,7 +540,22 @@ input::placeholder { color: var(--muted); }
line-height: 1.6; line-height: 1.6;
} }
.privacy-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; } .privacy-icon {
font-size: 1.1rem;
flex-shrink: 0;
margin-top: 2px;
}
.modal-body a {
color: var(--accent);
text-decoration: underline;
text-underline-offset: 2px;
text-decoration-thickness: 1px;
}
.modal-body a:hover {
text-decoration-thickness: 2px;
}
/* API key with eye toggle */ /* API key with eye toggle */
.input-wrap { .input-wrap {
@ -413,7 +563,9 @@ input::placeholder { color: var(--muted); }
display: flex; display: flex;
} }
.input-wrap input { padding-right: 48px; } .input-wrap input {
padding-right: 48px;
}
.eye-btn { .eye-btn {
position: absolute; position: absolute;
@ -445,26 +597,40 @@ input::placeholder { color: var(--muted); }
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
} }
.save-btn:active { opacity: 0.8; } .save-btn:active {
opacity: 0.8;
/* ── Tablet / desktop ──────────────────────────────────────────────────── */ }
@media (min-width: 520px) {
.overlay { align-items: center; } /* ── Theme segmented control ───────────────────────────────────────────── */
.theme-toggle {
.modal { display: flex;
border-radius: 22px; background: var(--surface);
margin: 20px; border: 1.5px solid var(--border);
width: calc(100% - 40px); border-radius: var(--r);
max-height: 80vh; padding: 3px;
transform: scale(0.96) translateY(10px); gap: 3px;
opacity: 0; }
transition: transform 0.25s cubic-bezier(0.34, 1.2, 0.64, 1), opacity 0.2s;
} .theme-btn {
flex: 1;
.overlay.open .modal { padding: 8px 10px;
transform: scale(1) translateY(0); border: none;
opacity: 1; border-radius: calc(var(--r) - 5px);
} background: transparent;
color: var(--muted);
.modal-grip { display: none; } font-family: inherit;
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
transition:
background 0.15s,
color 0.15s,
box-shadow 0.15s;
-webkit-tap-highlight-color: transparent;
}
.theme-btn.active {
background: var(--bg);
color: var(--text);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
} }

2
sw.js
View file

@ -1,4 +1,4 @@
const CACHE = 'status-poster-v1'; const CACHE = 'status-poster-v9';
const PRECACHE = ['.', 'index.html', 'style.css', 'script.js', 'manifest.json', 'sw.js', 'icon.svg']; const PRECACHE = ['.', 'index.html', 'style.css', 'script.js', 'manifest.json', 'sw.js', 'icon.svg'];
self.addEventListener('install', e => { self.addEventListener('install', e => {