Update CSP to allow external fonts, scripts, and add corresponding test coverage
This commit is contained in:
+21
-10
@@ -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); }
|
#accountForm .field > label { font-size:.82rem; font-weight:600; color:var(--text-soft); }
|
||||||
.account-status:focus { outline:none; }
|
.account-status:focus { outline:none; }
|
||||||
#accountSwitch { margin-top:20px; }
|
#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-shell { width:min(1160px,calc(100% - 64px)); margin:0 auto; padding:clamp(34px,5vw,64px) 0 72px; }
|
||||||
.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-page-header { max-width:680px; padding-bottom:30px; }
|
||||||
.personality-card h2,.personality-card p { margin:0; }
|
.personality-page-header .eyebrow { margin:0 0 10px; color:var(--brand-strong); }
|
||||||
.personality-card .subtitle { flex:1; }
|
.personality-page-header h1 { margin:0; font-size:clamp(2rem,4vw,2.75rem); letter-spacing:-.045em; }
|
||||||
.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-page-header .subtitle { margin:10px 0 0; color:var(--text-soft); line-height:1.65; }
|
||||||
.personality-specialization { color:var(--personality-accent,#168b87); font-size:.78rem; font-weight:800; letter-spacing:.04em; text-transform:uppercase; }
|
.personality-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; }
|
||||||
.personality-details { width:100%; color:var(--text-soft); font-size:.88rem; line-height:1.55; }
|
.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-details summary { color:var(--personality-accent,#168b87); cursor:pointer; font-weight:700; }
|
.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-details p { margin-top:9px; }
|
||||||
.personality-inspiration { font-size:.78rem; opacity:.8; }
|
.personality-inspiration { font-size:.78rem; opacity:.8; }
|
||||||
.personality-card .primary-action { margin-top:8px; text-decoration:none; }
|
.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:640px) { .personality-grid { grid-template-columns:1fr; } }
|
@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; } }
|
||||||
|
|||||||
@@ -1,18 +1,34 @@
|
|||||||
import {get} from "./api.js";
|
import {get} from "./api.js";
|
||||||
|
|
||||||
const grid = document.getElementById("personalityGrid");
|
const grid = document.getElementById("personalityGrid");
|
||||||
const icons = {spark:"✥", quill:"✒", code:"⌘", flask:"⚗", "book-open":"▤", logic:"∴"};
|
const iconPaths = {
|
||||||
|
spark: '<path d="M12 2.8 14.5 9.5 21.2 12l-6.7 2.5L12 21.2l-2.5-6.7L2.8 12l6.7-2.5L12 2.8Z"/><path d="m19 2 .8 2.2L22 5l-2.2.8L19 8l-.8-2.2L16 5l2.2-.8L19 2Z"/>',
|
||||||
|
quill: '<path d="M20.8 3.2c-6.3-.4-11 2.3-13.2 7.1-1 2.1-.9 4.1-.5 5.7 1.6.4 3.6.5 5.7-.5 4.8-2.2 7.5-6.9 7.1-13.2Z"/><path d="M3 21c3.5-5.1 7.8-8.8 13-11.4M7.2 16.4l-3.4-.3M10.2 13.1l-.1-3.4"/>',
|
||||||
|
code: '<path d="m8 7-5 5 5 5M16 7l5 5-5 5M14 4l-4 16"/>',
|
||||||
|
flask: '<path d="M9 3h6M10 3v6l-5.8 9.5A2.3 2.3 0 0 0 6.2 22h11.6a2.3 2.3 0 0 0 2-3.5L14 9V3M7.5 16h9"/>',
|
||||||
|
"book-open": '<path d="M12 7.2C9.8 5.4 6.5 5 3 5.8v13c3.5-.8 6.8-.4 9 1.4m0-13c2.2-1.8 5.5-2.2 9-1.4v13c-3.5-.8-6.8-.4-9 1.4m0-13v13"/>',
|
||||||
|
logic: '<circle cx="6" cy="6" r="2"/><circle cx="18" cy="6" r="2"/><circle cx="12" cy="18" r="2"/><path d="M8 7.2 10.8 16M16 7.2 13.2 16M8 6h8"/>'
|
||||||
|
};
|
||||||
const result = await get("/personalities");
|
const result = await get("/personalities");
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
grid.textContent = result.error;
|
grid.textContent = result.error;
|
||||||
} else {
|
} else {
|
||||||
for (const item of result.personalities || []) {
|
for (const item of result.personalities || []) {
|
||||||
const card = document.createElement("article");
|
const card = document.createElement("article");
|
||||||
card.className = "settings-panel personality-card";
|
card.className = "personality-card";
|
||||||
card.style.setProperty("--personality-accent", item.accentColor);
|
card.style.setProperty("--personality-accent", item.accentColor);
|
||||||
const icon = document.createElement("div");
|
const icon = document.createElement("span");
|
||||||
icon.className = "personality-icon";
|
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.title = item.name;
|
||||||
icon.setAttribute("aria-hidden", "true");
|
icon.setAttribute("aria-hidden", "true");
|
||||||
const specialization = document.createElement("p");
|
const specialization = document.createElement("p");
|
||||||
@@ -20,9 +36,8 @@ if (result.error) {
|
|||||||
specialization.textContent = `${item.specialization}${item.isDefault ? " · Default" : ""}`;
|
specialization.textContent = `${item.specialization}${item.isDefault ? " · Default" : ""}`;
|
||||||
const name = document.createElement("h2");
|
const name = document.createElement("h2");
|
||||||
name.textContent = item.name;
|
name.textContent = item.name;
|
||||||
name.title = `Inspired by ${item.historicalInspiration}`;
|
|
||||||
const description = document.createElement("p");
|
const description = document.createElement("p");
|
||||||
description.className = "subtitle";
|
description.className = "personality-description";
|
||||||
description.textContent = item.description;
|
description.textContent = item.description;
|
||||||
const details = document.createElement("details");
|
const details = document.createElement("details");
|
||||||
details.className = "personality-details";
|
details.className = "personality-details";
|
||||||
@@ -36,10 +51,13 @@ if (result.error) {
|
|||||||
details.append(summary, longDescription, inspiration);
|
details.append(summary, longDescription, inspiration);
|
||||||
const action = document.createElement("a");
|
const action = document.createElement("a");
|
||||||
action.className = "primary-action";
|
action.className = "primary-action";
|
||||||
action.textContent = "Start Chat";
|
action.innerHTML = '<span>Start a chat</span><span aria-hidden="true">→</span>';
|
||||||
action.setAttribute("aria-label", `Start a chat with ${item.name}, ${item.specialization}`);
|
action.setAttribute("aria-label", `Start a chat with ${item.name}, ${item.specialization}`);
|
||||||
action.href = `/app/chats/new?personality=${encodeURIComponent(item.id)}`;
|
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);
|
grid.append(card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" href="/img/favicon.svg"><title>Personalities - Elsewhere</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Manrope:wght@400;500;600;700;800&display=swap" rel="stylesheet"><script src="/js/theme-bootstrap.js"></script><link rel="stylesheet" href="/css/style.css"><link rel="stylesheet" href="/css/pages.css"><link rel="stylesheet" href="/css/shell.css"></head>
|
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" href="/img/favicon.svg"><title>Personalities - Elsewhere</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Manrope:wght@400;500;600;700;800&display=swap" rel="stylesheet"><script src="/js/theme-bootstrap.js"></script><link rel="stylesheet" href="/css/style.css"><link rel="stylesheet" href="/css/pages.css"><link rel="stylesheet" href="/css/shell.css"></head>
|
||||||
<body class="site-page" data-theme="fakegpt" data-theme-mode="light"><!-- site-header --><main id="main" class="page-shell"><section class="market-header"><p class="eyebrow">Choose your approach</p><h1>Personalities</h1><p class="subtitle">Specialized assistants for different kinds of work. Choose one to start a conversation.</p></section><section id="personalityGrid" class="personality-grid" aria-live="polite"></section></main><script type="module" src="/js/personalities.js"></script></body></html>
|
<body class="site-page personalities-page" data-theme="fakegpt" data-theme-mode="light"><!-- site-header --><main id="main" class="personality-shell"><header class="personality-page-header"><p class="eyebrow">Choose your approach</p><h1>Personalities</h1><p class="subtitle">Six specialized assistants, each designed for a different kind of work.</p></header><section id="personalityGrid" class="personality-grid" aria-live="polite"></section></main><script type="module" src="/js/personalities.js"></script></body></html>
|
||||||
|
|||||||
Reference in New Issue
Block a user