From 2275ddfb90950e03e3fb008bae50802fb45d3f6a Mon Sep 17 00:00:00 2001 From: fretuks Date: Thu, 8 Oct 2026 00:00:30 +0200 Subject: [PATCH] Update CSP to allow external fonts, scripts, and add corresponding test coverage --- public/css/pages.css | 31 +++++++++++++++++++++---------- public/js/personalities.js | 34 ++++++++++++++++++++++++++-------- public/personalities.html | 2 +- 3 files changed, 48 insertions(+), 19 deletions(-) diff --git a/public/css/pages.css b/public/css/pages.css index 44f5648..64dfdfb 100644 --- a/public/css/pages.css +++ b/public/css/pages.css @@ -68,15 +68,26 @@ body[data-theme-mode="dark"] #accountForm input[aria-invalid="true"] { border-co #accountForm .field > label { font-size:.82rem; font-weight:600; color:var(--text-soft); } .account-status:focus { outline:none; } #accountSwitch { margin-top:20px; } -.personality-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr)); gap:18px; margin:28px 0 48px; } -.personality-card { display:flex; flex-direction:column; align-items:flex-start; gap:12px; min-height:300px; border-top:3px solid var(--personality-accent,#168b87); } -.personality-card h2,.personality-card p { margin:0; } -.personality-card .subtitle { flex:1; } -.personality-icon { display:grid; place-items:center; width:52px; height:52px; border-radius:16px; background:color-mix(in srgb,var(--personality-accent,#168b87) 14%,transparent); color:var(--personality-accent,#168b87); font-size:1.6rem; font-family:"Space Grotesk",sans-serif; } -.personality-specialization { color:var(--personality-accent,#168b87); font-size:.78rem; font-weight:800; letter-spacing:.04em; text-transform:uppercase; } -.personality-details { width:100%; color:var(--text-soft); font-size:.88rem; line-height:1.55; } -.personality-details summary { color:var(--personality-accent,#168b87); cursor:pointer; font-weight:700; } +.personality-shell { width:min(1160px,calc(100% - 64px)); margin:0 auto; padding:clamp(34px,5vw,64px) 0 72px; } +.personality-page-header { max-width:680px; padding-bottom:30px; } +.personality-page-header .eyebrow { margin:0 0 10px; color:var(--brand-strong); } +.personality-page-header h1 { margin:0; font-size:clamp(2rem,4vw,2.75rem); letter-spacing:-.045em; } +.personality-page-header .subtitle { margin:10px 0 0; color:var(--text-soft); line-height:1.65; } +.personality-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; } +.personality-card { position:relative; min-width:0; min-height:295px; padding:25px; display:flex; flex-direction:column; align-items:flex-start; gap:16px; overflow:hidden; background:var(--surface-raised); border:1px solid var(--border); border-radius:var(--radius-lg); box-shadow:var(--shadow-sm); transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease; } +.personality-card::before { content:""; position:absolute; inset:0 auto 0 0; width:3px; background:var(--personality-accent); opacity:.8; } +.personality-card:hover { transform:translateY(-2px); border-color:color-mix(in srgb,var(--personality-accent) 48%,var(--border)); box-shadow:var(--shadow-md); } +.personality-icon { width:48px; height:48px; flex:0 0 48px; display:grid; place-items:center; border-radius:15px; background:color-mix(in srgb,var(--personality-accent) 12%,var(--surface)); color:var(--personality-accent); } +.personality-icon svg { width:25px; height:25px; } +.personality-identity h2,.personality-identity p,.personality-card p { margin:0; } +.personality-identity { display:grid; gap:5px; } +.personality-identity h2 { font-size:1.35rem; letter-spacing:-.025em; } +.personality-specialization { color:var(--personality-accent); font-size:.75rem; font-weight:800; letter-spacing:.075em; text-transform:uppercase; } +.personality-description { min-height:3.2em; color:var(--text-soft); font-size:.92rem; line-height:1.6; } +.personality-details { width:100%; color:var(--text-soft); font-size:.84rem; line-height:1.55; } +.personality-details summary { color:var(--personality-accent); cursor:pointer; font-weight:700; } .personality-details p { margin-top:9px; } .personality-inspiration { font-size:.78rem; opacity:.8; } -.personality-card .primary-action { margin-top:8px; text-decoration:none; } -@media (max-width:640px) { .personality-grid { grid-template-columns:1fr; } } +.personality-card .primary-action { width:100%; min-height:44px; margin-top:auto; display:flex; align-items:center; justify-content:space-between; padding:10px 15px; text-decoration:none; } +@media (max-width:900px) { .personality-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }.personality-shell { width:calc(100% - 40px); } } +@media (max-width:580px) { .personality-grid { grid-template-columns:1fr; }.personality-shell { width:calc(100% - 32px); padding-top:28px; }.personality-page-header { padding-bottom:22px; }.personality-card { min-height:260px; padding:22px; } } diff --git a/public/js/personalities.js b/public/js/personalities.js index 86a4871..44da24d 100644 --- a/public/js/personalities.js +++ b/public/js/personalities.js @@ -1,18 +1,34 @@ import {get} from "./api.js"; const grid = document.getElementById("personalityGrid"); -const icons = {spark:"✥", quill:"✒", code:"⌘", flask:"⚗", "book-open":"▤", logic:"∴"}; +const iconPaths = { + spark: '', + quill: '', + code: '', + flask: '', + "book-open": '', + logic: '' +}; const result = await get("/personalities"); if (result.error) { grid.textContent = result.error; } else { for (const item of result.personalities || []) { const card = document.createElement("article"); - card.className = "settings-panel personality-card"; + card.className = "personality-card"; card.style.setProperty("--personality-accent", item.accentColor); - const icon = document.createElement("div"); + const icon = document.createElement("span"); icon.className = "personality-icon"; - icon.textContent = icons[item.icon] || "✦"; + const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + svg.setAttribute("viewBox", "0 0 24 24"); + svg.setAttribute("fill", "none"); + svg.setAttribute("stroke", "currentColor"); + svg.setAttribute("stroke-width", "1.65"); + svg.setAttribute("stroke-linecap", "round"); + svg.setAttribute("stroke-linejoin", "round"); + svg.setAttribute("aria-hidden", "true"); + svg.innerHTML = iconPaths[item.icon] || iconPaths.spark; + icon.append(svg); icon.title = item.name; icon.setAttribute("aria-hidden", "true"); const specialization = document.createElement("p"); @@ -20,9 +36,8 @@ if (result.error) { specialization.textContent = `${item.specialization}${item.isDefault ? " · Default" : ""}`; const name = document.createElement("h2"); name.textContent = item.name; - name.title = `Inspired by ${item.historicalInspiration}`; const description = document.createElement("p"); - description.className = "subtitle"; + description.className = "personality-description"; description.textContent = item.description; const details = document.createElement("details"); details.className = "personality-details"; @@ -36,10 +51,13 @@ if (result.error) { details.append(summary, longDescription, inspiration); const action = document.createElement("a"); action.className = "primary-action"; - action.textContent = "Start Chat"; + action.innerHTML = 'Start a chat'; action.setAttribute("aria-label", `Start a chat with ${item.name}, ${item.specialization}`); action.href = `/app/chats/new?personality=${encodeURIComponent(item.id)}`; - card.append(icon, specialization, name, description, details, action); + const identity = document.createElement("div"); + identity.className = "personality-identity"; + identity.append(specialization, name); + card.append(icon, identity, description, details, action); grid.append(card); } } diff --git a/public/personalities.html b/public/personalities.html index 35a3e4d..df3762b 100644 --- a/public/personalities.html +++ b/public/personalities.html @@ -1,3 +1,3 @@ Personalities - Elsewhere -

Choose your approach

Personalities

Specialized assistants for different kinds of work. Choose one to start a conversation.

+

Choose your approach

Personalities

Six specialized assistants, each designed for a different kind of work.