Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 80 additions & 15 deletions src/PlayerHub.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,80 @@
.spido-hub{min-height:100vh;background:radial-gradient(ellipse at 75% 3%,#183150,transparent 42%),#070e1c;color:#f1f8f9;font-family:Inter,sans-serif}.spido-hub-container{width:min(1100px,calc(100% - 42px));margin:auto}.spido-hub :is(a,button,input):focus-visible{outline:2px solid #b1f878;outline-offset:4px}.spido-hub-skip{position:absolute;top:-90px;left:12px;background:#b1f878;color:#07111f;padding:12px}.spido-hub-skip:focus{top:10px;z-index:99}.spido-hub-header{border-bottom:1px solid #2e3b4f;background:#081224}.spido-hub-nav{min-height:76px;display:flex;align-items:center;justify-content:space-between;gap:22px}.spido-hub-nav nav{display:flex;gap:20px}.spido-hub-nav nav a{color:#c7d7df;font-size:13px;text-decoration:none}.spido-hub-logo{font:700 27px 'Spido Pixel',monospace;color:#ecffe2;text-shadow:2px 2px #59418b;text-decoration:none}.spido-hub-logo span{color:#b1f878}.spido-hub-main{padding:70px 0 100px}.spido-hub-kicker,.spido-hub-panel small{font:11px 'JetBrains Mono',monospace;color:#b1f878;letter-spacing:.12em}.spido-hub h1{font:700 clamp(2.3rem,5vw,4rem) 'Space Grotesk',sans-serif;line-height:1.15;margin:16px 0}.spido-hub h1 span{color:#b1f878}.spido-hub-lead{max-width:690px;color:#b9c8d8;line-height:1.8;margin-bottom:38px}.spido-hub-panel{background:#0d1c30;border:1px solid #2d4d58;border-radius:11px;padding:27px;margin:22px 0}.spido-hub-panel h2{font:650 24px 'Space Grotesk',sans-serif;margin-top:0}.spido-hub-panel p{color:#bdcad8;line-height:1.7}.spido-hub-auth{max-width:500px}.spido-hub-auth form{display:grid;gap:16px}.spido-hub-auth label{display:grid;gap:8px;font-size:13px;color:#cbd6e4}.spido-hub-auth input{background:#071322;color:#fff;border:1px solid #4b6170;border-radius:5px;padding:13px}.spido-hub button{cursor:pointer;border:1px solid #9ed76d;border-radius:5px;padding:11px 17px;background:#b1f878;color:#07111f;font-weight:700}.spido-hub button:disabled{opacity:.65;cursor:wait}.spido-hub-account{display:flex;align-items:center;justify-content:space-between;gap:18px;flex-wrap:wrap;background:#102337;border:1px solid #2e4b51;padding:19px;border-radius:10px}.spido-hub-account div{display:grid;gap:6px}.spido-hub-account small,.spido-hub-stats small{font:11px 'JetBrains Mono',monospace;color:#84dece}.spido-hub-account strong{overflow-wrap:anywhere}.spido-hub-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin-top:20px}.spido-hub-stats article{background:#102034;border:1px solid #344d56;border-radius:9px;padding:21px;display:grid;gap:12px}.spido-hub-stats strong{font-size:23px;color:#b1f878;overflow-wrap:anywhere;text-transform:capitalize}.spido-hub-knowledge{display:flex;flex-wrap:wrap;gap:10px}.spido-hub-knowledge a{display:inline-block;padding:10px 14px;background:#143134;border:1px solid #42786f;border-radius:5px;color:#c9fff2;font-size:13px;text-decoration:none}.spido-hub-note{font-size:12px;color:#aabccb;line-height:1.7}.spido-hub-notice{padding:14px;color:#ffcfa2}.spido-hub-footer{border-top:1px solid #2d3a52;padding:28px 0;font:11px 'JetBrains Mono',monospace;color:#b8c7d6}.spido-hub-footer>div{display:flex;justify-content:space-between;gap:14px}.spido-hub-footer a{color:#b1f878}@media(max-width:760px){.spido-hub-stats{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:460px){.spido-hub-nav{flex-wrap:wrap;padding:12px 0}.spido-hub-nav nav{gap:12px}.spido-hub-main{padding:45px 0 60px}.spido-hub-stats{grid-template-columns:1fr}}
/* Códice conectado; lo bloqueado no revela contenido de progreso no alcanzado. */
.spido-hub-codex-heading{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:14px}
.spido-hub-codex-heading h2{margin:8px 0 10px}
.spido-hub-codex-total{font:12px 'JetBrains Mono',monospace;color:#b1f878}
.spido-hub-codex-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:13px;margin-top:23px}
.spido-hub-codex-card{display:flex;flex-direction:column;align-items:flex-start;gap:11px;padding:20px;border:1px solid #38665c;border-radius:8px;background:#0b2430}
.spido-hub-codex-card>span{color:#91e4d5;font:11px 'JetBrains Mono',monospace}
.spido-hub-codex-card h3{font:650 20px 'Space Grotesk',sans-serif;margin:0}
.spido-hub-codex-card p{font-size:13px;color:#c4d1de;line-height:1.6;margin:0 0 9px}
.spido-hub-codex-card a{margin-top:auto;color:#b1f878;font-weight:600;font-size:13px}
.spido-hub-codex-card.is-locked{border-color:#344154;background:#0b1728}
.spido-hub-codex-card.is-locked>span{color:#abb7c8}
.spido-hub-codex-card.is-locked h3{color:#c5d0dc}
@media(max-width:620px){.spido-hub-codex-grid{grid-template-columns:1fr}}
.spido-hub {
--ink: #2b3040;
--muted: #4c515f;
--green: #2b7a48;
--edge: #cbd2dc;
--shadow: 0 12px 30px #2b30400d;
min-height: 100vh;
background: radial-gradient(ellipse at 82% 9%, #dcece2, transparent 36%), linear-gradient(#eef1f6, #e1e6ee);
color: var(--ink);
font-family: Poppins, sans-serif;
}
.spido-hub-container { width: min(1140px, calc(100% - 32px)); margin-inline: auto; }
.spido-hub :is(a, button, input):focus-visible { outline: 3px solid #285837; outline-offset: 3px; }
.spido-hub-skip { position: absolute; top: 12px; left: 12px; transform: translateY(-150%); padding: 12px; background: white; z-index: 2; }
.spido-hub-skip:focus { transform: none; }
.spido-hub-header { background: #eef1f6; border-bottom: 1px solid var(--edge); }
.spido-hub-nav, .spido-hub-footer > div { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; }
.spido-hub-nav { min-height: 70px; padding-block: 10px; }
.spido-hub-nav nav { display: flex; flex-wrap: wrap; gap: 12px; }
.spido-hub-nav nav a { color: var(--muted); font-size: .85rem; font-weight: 600; text-decoration: none; }
.spido-hub-nav nav a:hover { text-decoration: underline; }
.spido-hub-logo, .spido-hub :is(h1, h2, h3) { font-family: 'Spido Pixel', 'Pixelify Sans', monospace; font-weight: 700; line-height: 1.15; }
.spido-hub-logo { color: var(--ink); font-size: clamp(1.5rem, 4vw, 2rem); text-decoration: none; }
.spido-hub-logo span { color: #7cbb89; }
.spido-hub-main { padding-block: clamp(32px, 5vw, 72px); }
.spido-hub-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(140px, 22%); align-items: center; gap: 24px; margin-bottom: 28px; }
.spido-hub-hero img { width: 100%; height: auto; display: block; filter: drop-shadow(0 12px 14px #2b304026); }
.spido-hub h1 { font-size: clamp(2.25rem, 6vw, 4rem); margin: 10px 0 14px; }
.spido-hub h1 span { color: #386c46; }
.spido-hub h2 { font-size: clamp(1.45rem, 3vw, 2rem); margin: 0 0 8px; }
.spido-hub h3 { font-size: 1.2rem; margin: 0; }
.spido-hub-kicker, .spido-hub small { color: #285837; font-size: .72rem; font-weight: 700; letter-spacing: .07em; }
.spido-hub-lead, .spido-hub-panel p, .spido-hub-note { color: var(--muted); line-height: 1.65; }
.spido-hub-lead { max-width: 62ch; }
.spido-hub :is(.spido-hub-panel, .spido-hub-account, .spido-hub-stats article) { background: white; border: 1px solid var(--edge); border-radius: 22px; box-shadow: var(--shadow); min-width: 0; }
.spido-hub-panel { margin-block: 20px; padding: clamp(18px, 4vw, 32px); }
.spido-hub-panel[role="alert"] { border-color: #c68688; }
.spido-hub-auth { max-width: 500px; }
.spido-hub-auth form { display: grid; gap: 12px; margin-block: 16px; }
.spido-hub-auth label { display: grid; gap: 6px; font-size: .88rem; font-weight: 600; }
.spido-hub-auth input { width: 100%; min-height: 46px; padding: 10px 12px; background: white; color: var(--ink); border: 1px solid #808999; border-radius: 10px; font: inherit; font-size: 16px; }
.spido-hub button { min-height: 44px; border: 0; border-radius: 10px; padding: 10px 16px; background: var(--green); color: white; font: inherit; font-weight: 700; cursor: pointer; }
.spido-hub button:hover:not(:disabled) { background: #216139; }
.spido-hub button:disabled { background: #d6eedc; color: #285837; cursor: wait; }
.spido-hub-account { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: clamp(16px, 3vw, 24px); }
.spido-hub-account > div { flex: 1 1 180px; min-width: 0; display: grid; gap: 4px; overflow-wrap: anywhere; }
.spido-hub-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px; background: #e0f0e4; color: #285837; }
.spido-hub-icon svg { width: 20px; height: 20px; }
.spido-hub-stats, .spido-hub-codex-grid { display: grid; gap: 14px; margin-top: 18px; }
.spido-hub-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.spido-hub-stats article { display: grid; align-content: start; gap: 8px; padding: clamp(14px, 3vw, 22px); }
.spido-hub-stats strong { font-size: clamp(1.1rem, 3vw, 1.6rem); color: #285837; overflow-wrap: anywhere; text-transform: capitalize; line-height: 1.25; }
.spido-hub-codex-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.spido-hub-codex-total { padding: 6px 10px; border-radius: 20px; background: #e0f0e4; color: #285837; font-size: .8rem; font-weight: 600; }
.spido-hub-codex-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.spido-hub-codex-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; border: 1px solid var(--edge); border-radius: 15px; background: #f3f5f8; }
.spido-hub-codex-card.is-unlocked { background: #f0f8f2; border-color: #91b99a; }
.spido-hub-codex-card > span { display: flex; align-items: center; gap: 8px; font-size: .76rem; font-weight: 600; color: var(--muted); }
.spido-hub-codex-card.is-unlocked > span { color: #285837; }
.spido-hub-codex-card p { font-size: .875rem; }
.spido-hub-codex-card a { margin-top: auto; font-weight: 600; }
.spido-hub :is(.spido-hub-codex-card, .spido-hub-footer) a { color: #285837; text-decoration: underline; text-underline-offset: 3px; }
.spido-hub-note { margin-top: 14px; font-size: .8rem; }
.spido-hub-notice { margin-top: 16px; padding: 12px; border-radius: 10px; background: #e0f0e4; color: #285837; }
.spido-hub-footer { border-top: 1px solid var(--edge); padding: 24px 0; color: var(--muted); font-size: .8rem; }
@media (max-width: 760px) { .spido-hub-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) {
.spido-hub-hero, .spido-hub-codex-grid { grid-template-columns: minmax(0, 1fr); }
.spido-hub-hero img { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
.spido-hub-hero > div { animation: spido-hub-enter 400ms ease-out; }
.spido-hub-hero img { animation: spido-hub-float 3.6s ease-in-out 450ms; }
.spido-hub button { transition: background-color 170ms ease; }
@supports (animation-timeline: view()) {
.spido-hub-codex-grid > article { animation: spido-hub-enter linear both; animation-timeline: view(); animation-range: entry 0% entry 45%; }
}
}
@keyframes spido-hub-enter { from { opacity: .86; transform: translateY(7px); } }
@keyframes spido-hub-float { 50% { transform: translateY(-5px); } }
51 changes: 38 additions & 13 deletions src/PlayerHub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ type Progress = {
const safeList = (value: unknown): string[] => Array.isArray(value) ? value.filter((item): item is string => typeof item === 'string') : []
const readable = (id: string) => id.replace(/_/g, ' ')

const iconPaths = {
account: 'M4 21v-2a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v2 M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z',
mission: 'M12 2v4m0 12v4M2 12h4m12 0h4M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0Z',
completed: 'm5 12 4 4L19 6M4 21h16',
ship: 'm12 3 7 4v8l-7 6-7-6V7Z m-7 4 7 5 7-5m-7 5v9',
spid: 'm12 3 8 9-8 9-8-9Z M4 12h16m-8-9v18',
map: 'm3 6 6-3 6 3 6-3v15l-6 3-6-3-6 3Z M9 3v15m6-12v15',
guides: 'M4 4h6a2 2 0 0 1 2 2v15a3 3 0 0 0-3-3H4Zm16 0h-6a2 2 0 0 0-2 2v15a3 3 0 0 1 3-3h5Z',
unlocked: 'M8 11V7a4 4 0 0 1 8 0 M6 11h12v10H6Zm6 4v2',
locked: 'M8 11V7a4 4 0 0 1 8 0v4 M6 11h12v10H6Zm6 4v2',
}

function HubIcon({ name }: { name: keyof typeof iconPaths }) {
return <span className="spido-hub-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" focusable="false">
<path d={iconPaths[name]} />
</svg>
</span>
}

export default function PlayerHub() {
const [user, setUser] = useState<User | null>(null)
const [checking, setChecking] = useState(true)
Expand Down Expand Up @@ -91,11 +111,16 @@ export default function PlayerHub() {
<nav aria-label="Navegación"><a href="/">Inicio</a><a href="/docs">Archivo A.D.A.</a></nav>
</div></header>
<main id="hub-content" className="spido-hub-container spido-hub-main">
<p className="spido-hub-kicker">CENTRO DE CONTROL // PERFIL DEL JUGADOR</p>
<h1>Tu aventura, <span>tu progreso.</span></h1>
<p className="spido-hub-lead">Consulta los datos guardados de tu partida de SpidoCode. Este panel no modifica misiones, minerales ni inventario.</p>
<section className="spido-hub-hero" aria-labelledby="hub-title">
<div>
<p className="spido-hub-kicker">PERFIL DEL JUGADOR</p>
<h1 id="hub-title">Tu aventura, <span>tu progreso.</span></h1>
<p className="spido-hub-lead">Consulta los datos guardados de tu partida de SpidoCode. Este panel no modifica misiones, minerales ni inventario.</p>
</div>
<img src="/images/spidocode/spid-smile.png" alt="" width="1024" height="788" />
</section>
{!supabase ? <section className="spido-hub-panel" role="status"><h2>Configuración pendiente</h2><p>El portal aún no tiene configuradas sus variables públicas de Supabase. No se puede acceder al perfil.</p></section>
: checking ? <p role="status">Comprobando sesión…</p>
: checking ? <p className="spido-hub-panel" role="status">Comprobando sesión…</p>
: !user ? <section className="spido-hub-panel spido-hub-auth">
<h2>Inicia sesión</h2><p>Usa la misma cuenta que utilizas en el videojuego.</p>
<form onSubmit={signIn}>
Expand All @@ -106,18 +131,18 @@ export default function PlayerHub() {
<p className="spido-hub-note">Las credenciales se procesan mediante Supabase Auth. Nunca aparecen en la URL ni se registran en esta página.</p>
</section>
: <section aria-label="Progreso del jugador">
<div className="spido-hub-account"><div><small>CUENTA CONECTADA</small><strong>{user.email ?? 'Cuenta de jugador'}</strong></div><button type="button" disabled={authBusy} onClick={signOut}>Cerrar sesión</button></div>
{loadingProgress ? <p role="status">Cargando progreso…</p>
<div className="spido-hub-account"><HubIcon name="account" /><div><small>CUENTA CONECTADA</small><strong>{user.email ?? 'Cuenta de jugador'}</strong></div><button type="button" disabled={authBusy} onClick={signOut}>Cerrar sesión</button></div>
{loadingProgress ? <p className="spido-hub-panel" role="status">Cargando progreso…</p>
: progressError ? <div className="spido-hub-panel" role="alert"><h2>Progreso no disponible</h2><p>{progressError}</p></div>
: !progress ? <div className="spido-hub-panel" role="status"><h2>Sin partida sincronizada</h2><p>Esta cuenta todavía no tiene una partida remota registrada. Abre SpidoCode con esa cuenta para generar progreso.</p></div>
: <>
<div className="spido-hub-stats">
<article><small>MISIÓN ACTUAL</small><strong>{progress.current_mission_id ? readable(progress.current_mission_id) : 'Sin datos'}</strong></article>
<article><small>MISIONES COMPLETADAS</small><strong>{safeList(progress.completed_missions).length}</strong></article>
<article><small>MINERALES EN NAVE</small><strong>{progress.minerals_ship ?? 'Sin datos'}</strong></article>
<article><small>MINERALES DE SPID</small><strong>{progress.minerals_spid ?? 'Sin datos'}</strong></article>
<article><small>NIVEL DEL MAPA</small><strong>{progress.map_tier ?? 'Sin datos'}</strong></article>
<article><small>CONOCIMIENTOS</small><strong>{safeList(progress.unlocked_knowledge).length}</strong></article>
<article><HubIcon name="mission" /><small>MISIÓN ACTUAL</small><strong>{progress.current_mission_id ? readable(progress.current_mission_id) : 'Sin datos'}</strong></article>
<article><HubIcon name="completed" /><small>MISIONES COMPLETADAS</small><strong>{safeList(progress.completed_missions).length}</strong></article>
<article><HubIcon name="ship" /><small>MINERALES EN NAVE</small><strong>{progress.minerals_ship ?? 'Sin datos'}</strong></article>
<article><HubIcon name="spid" /><small>MINERALES DE SPID</small><strong>{progress.minerals_spid ?? 'Sin datos'}</strong></article>
<article><HubIcon name="map" /><small>NIVEL DEL MAPA</small><strong>{progress.map_tier ?? 'Sin datos'}</strong></article>
<article><HubIcon name="guides" /><small>CONOCIMIENTOS</small><strong>{safeList(progress.unlocked_knowledge).length}</strong></article>
</div>
<section className="spido-hub-panel" aria-labelledby="hub-codex-heading">
<div className="spido-hub-codex-heading">
Expand All @@ -129,7 +154,7 @@ export default function PlayerHub() {
{learningGuides.map((guide) => {
const unlocked = safeList(progress.unlocked_knowledge).includes(guide.id)
return <article key={guide.id} className={`spido-hub-codex-card ${unlocked ? 'is-unlocked' : 'is-locked'}`}>
<span>{guide.group} · {unlocked ? 'Desbloqueado' : 'Pendiente en el juego'}</span>
<span><HubIcon name={unlocked ? 'unlocked' : 'locked'} />{guide.group} · {unlocked ? 'Desbloqueado' : 'Pendiente en el juego'}</span>
<h3>{guide.title}</h3>
<p>{unlocked ? guide.summary : 'Continúa avanzando en SpidoCode para desbloquear este conocimiento.'}</p>
{unlocked && <a href={`/docs?tema=${encodeURIComponent(guide.id)}#guias`}>Estudiar con A.D.A. ↗</a>}
Expand Down
Loading
Loading