feat: update branding and enhance AppHeader functionality

- Changed the document title from "orcid-system" to "ORCID2SWORD".
- Updated AppHeader to reflect the new brand name and improved user profile link for authenticated users.
- Added user name extraction from JWT for personalized greetings in the header.
- Refactored layout and styling for better responsiveness and user experience on the LandingPage.
This commit is contained in:
Alexis
2026-05-07 13:51:03 +02:00
parent bdb36ee13c
commit ecdfadbf20
4 changed files with 174 additions and 195 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>orcid-system</title> <title>ORCID2SWORD</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
+23 -65
View File
@@ -1,18 +1,16 @@
import { Link, useNavigate } from "react-router-dom"; import { Link, useNavigate } from "react-router-dom";
import { toast } from "sonner"; import { toast } from "sonner";
import { ArrowLeftIcon, LayersIcon, LogoutIcon, UserCheckIcon } from "../ui/Icons"; import { LogoutIcon, UserCheckIcon } from "../ui/Icons";
import { useAuth } from "../../contexts/AuthContext"; import { useAuth } from "../../contexts/AuthContext";
/** /**
* Institutional navy header used across all views. * Institutional navy header used across all views.
* *
* Variants: * Brand: ORCID2SWORD — "2" in orcid-green, rest in white.
* - `landing` → logo + full product name. * Authenticated users see their name (or "Mi Perfil") + logout button.
* - `dashboard` → back button to `/` + auth indicator + logout (if logged in).
* - `group` → back button to `/` + group label + auth indicator.
*/ */
export function AppHeader({ variant = "landing" }) { export function AppHeader({ variant = "landing" }) {
const { isAuthenticated, userOrcidId, logout } = useAuth(); const { isAuthenticated, userOrcidId, userName, logout } = useAuth();
const navigate = useNavigate(); const navigate = useNavigate();
function handleLogout() { function handleLogout() {
@@ -23,82 +21,42 @@ export function AppHeader({ variant = "landing" }) {
navigate("/"); navigate("/");
} }
if (variant === "dashboard" || variant === "group") { const profileLabel = userName ?? "Mi Perfil";
return ( const profileHref = userOrcidId ? `/dashboard/${userOrcidId}` : "/";
<header className="flex h-14 items-center gap-4 bg-brand-primary px-7 text-white">
return (
<header className="bg-brand-primary">
<div className="mx-auto flex h-14 max-w-7xl items-center px-4">
{/* Brand — always navigates home */}
<Link <Link
to="/" to="/"
className="inline-flex items-center gap-1.5 rounded-md bg-white/10 px-2.5 py-1.5 text-[13px] transition-colors hover:bg-white/20" className="text-[15px] font-bold tracking-tight text-white transition-opacity hover:opacity-90"
> >
<ArrowLeftIcon /> ORCID<span className="text-orcid-green">2</span>SWORD
Inicio
</Link> </Link>
<div className="flex-1" /> <div className="flex-1" />
{isAuthenticated && ( {isAuthenticated && (
<div className="flex items-center gap-3"> <div className="flex items-center gap-2">
{userOrcidId && ( <Link
<Link to={profileHref}
to={`/dashboard/${userOrcidId}`} className="inline-flex items-center gap-1.5 rounded-md bg-white/10 px-3 py-1.5 text-[13px] text-white transition-colors hover:bg-white/20"
className="inline-flex items-center gap-1.5 rounded-md bg-white/10 px-2.5 py-1.5 text-[13px] transition-colors hover:bg-white/20" >
>
<UserCheckIcon size={13} />
Mi perfil
</Link>
)}
<span className="inline-flex items-center gap-1.5 rounded-full bg-white/10 px-2.5 py-1 text-[12px] text-white/80">
<UserCheckIcon size={13} /> <UserCheckIcon size={13} />
Sesión activa {profileLabel}
</span> </Link>
<button <button
type="button" type="button"
onClick={handleLogout} onClick={handleLogout}
className="inline-flex items-center gap-1.5 rounded-md bg-white/10 px-2.5 py-1.5 text-[13px] transition-colors hover:bg-white/20" className="inline-flex items-center gap-1.5 rounded-md bg-white/10 px-3 py-1.5 text-[13px] text-white transition-colors hover:bg-white/20"
> >
<LogoutIcon /> <LogoutIcon />
Cerrar sesión Cerrar sesión
</button> </button>
</div> </div>
)} )}
<span className="text-[13px] text-white/60">
{variant === "group" ? "Búsqueda grupal · ORCID" : "Sistema ORCID · SWORD"}
</span>
</header>
);
}
return (
<header className="flex items-center gap-3 bg-brand-primary px-8 py-3.5">
<div className="flex h-8 w-8 items-center justify-center rounded-md bg-white/15 text-white">
<LayersIcon />
</div> </div>
<span className="text-sm font-medium tracking-wide text-white">
Sistema de Integración ORCID · SWORD
</span>
{isAuthenticated && (
<div className="ml-auto flex items-center gap-2">
{userOrcidId && (
<Link
to={`/dashboard/${userOrcidId}`}
className="inline-flex items-center gap-1.5 rounded-md bg-white/10 px-2.5 py-1.5 text-[13px] transition-colors hover:bg-white/20"
>
<UserCheckIcon size={13} />
Mi perfil
</Link>
)}
<span className="inline-flex items-center gap-1.5 rounded-full bg-white/10 px-2.5 py-1 text-[12px] text-white/80">
<UserCheckIcon size={13} />
Sesión activa
</span>
<button
type="button"
onClick={handleLogout}
className="inline-flex items-center gap-1.5 rounded-md bg-white/10 px-2.5 py-1.5 text-[13px] transition-colors hover:bg-white/20"
>
<LogoutIcon />
Cerrar sesión
</button>
</div>
)}
</header> </header>
); );
} }
+16
View File
@@ -29,6 +29,21 @@ function extractOrcidFromToken(token) {
} }
} }
function extractNameFromToken(token) {
if (!token) return null;
try {
const payloadBase64 = token.split(".")[1];
if (!payloadBase64) return null;
const payloadJson = atob(payloadBase64.replace(/-/g, "+").replace(/_/g, "/"));
const payload = JSON.parse(payloadJson);
if (payload?.name) return payload.name;
const parts = [payload?.given_name, payload?.family_name].filter(Boolean);
return parts.length > 0 ? parts.join(" ") : null;
} catch {
return null;
}
}
/** /**
* Provides JWT-based authentication state throughout the app. * Provides JWT-based authentication state throughout the app.
* *
@@ -82,6 +97,7 @@ export function AuthProvider({ children }) {
token, token,
isAuthenticated: Boolean(token), isAuthenticated: Boolean(token),
userOrcidId: extractOrcidFromToken(token), userOrcidId: extractOrcidFromToken(token),
userName: extractNameFromToken(token),
storeToken, storeToken,
logout, logout,
}), }),
+134 -129
View File
@@ -168,163 +168,168 @@ export function LandingPage() {
<div className="flex min-h-screen flex-col bg-surface-tertiary"> <div className="flex min-h-screen flex-col bg-surface-tertiary">
<AppHeader variant="landing" /> <AppHeader variant="landing" />
<main className="flex flex-1 items-center justify-center p-12 sm:p-6"> <main className="flex flex-1 flex-col items-center px-4 py-12">
<div className="w-full max-w-[520px]"> <div className="w-full max-w-7xl">
<div className="mb-10 text-center">
<div className="mx-auto mb-5 flex h-[72px] w-[72px] items-center justify-center rounded-2xl bg-brand-primary shadow-[0_4px_24px_rgba(11,61,107,0.18)]"> {/* ── Hero ── */}
<DocumentIcon size={36} className="text-white" /> <div className="mb-12 text-center">
<div className="mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-2xl bg-brand-primary shadow-[0_4px_24px_rgba(11,61,107,0.18)]">
<DocumentIcon size={32} className="text-white" />
</div> </div>
<h1 className="mb-2 text-[28px] font-semibold tracking-tight text-ink-primary"> <h1 className="mb-3 text-[32px] font-bold tracking-tight text-ink-primary md:text-[40px]">
Repositorio Institucional Tu producción científica,{" "}
<span className="text-brand-primary">siempre al día.</span>
</h1> </h1>
<p className="text-[15px] leading-relaxed text-ink-secondary"> <p className="mx-auto max-w-xl text-[16px] leading-relaxed text-ink-secondary">
Conecta tu perfil ORCID y deposita tus publicaciones Sincroniza tu perfil ORCID y deposita tus publicaciones
automáticamente en el repositorio institucional vía protocolo automáticamente vía SWORD.
SWORD.
</p> </p>
</div> </div>
{/* Main card */} {/* ── Two-column grid ── */}
<div className="rounded-2xl border border-surface-border/60 bg-surface-primary p-8"> <div className="grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-8">
{isAuthenticated ? (
<div className="flex items-center justify-between rounded-xl border border-green-200 bg-green-50 px-4 py-2.5 text-sm text-green-800"> {/* ── Left: individual search + login ── */}
<span className="font-medium">Sesión activa</span> <div className="flex flex-col rounded-2xl border border-surface-border/60 bg-surface-primary p-8">
<span className="text-xs text-green-600"> {isAuthenticated ? (
Verás publicaciones nuevas marcadas en el dashboard <div className="flex items-center justify-between rounded-xl border border-green-200 bg-green-50 px-4 py-3 text-sm text-green-800">
</span> <span className="font-medium">Sesión activa</span>
</div> <span className="text-xs text-green-600">
) : ( Verás publicaciones nuevas marcadas en el dashboard
<> </span>
</div>
) : (
<button <button
type="button" type="button"
onClick={handleOrcidLogin} onClick={handleOrcidLogin}
disabled={loginLoading} disabled={loginLoading}
className="flex w-full items-center justify-center gap-2.5 rounded-xl bg-orcid-green px-5 py-3 text-[15px] font-semibold tracking-wide text-orcid-green-dark transition-opacity enabled:hover:opacity-95 disabled:cursor-not-allowed disabled:opacity-75" className="flex w-full items-center justify-center gap-2.5 rounded-xl bg-orcid-green px-5 py-3.5 text-[15px] font-semibold tracking-wide text-orcid-green-dark transition-opacity enabled:hover:opacity-95 disabled:cursor-not-allowed disabled:opacity-75"
> >
{loginLoading ? <Spinner size={17} /> : <OrcidLogo />} {loginLoading ? <Spinner size={17} /> : <OrcidLogo />}
{loginLoading {loginLoading
? "Abriendo ventana de ORCID..." ? "Abriendo ventana de ORCID..."
: "Iniciar sesión con ORCID"} : "Iniciar sesión con ORCID"}
</button> </button>
</>
)}
<div className="my-6 flex items-center gap-3">
<div className="h-px flex-1 bg-surface-border" />
<span className="text-xs tracking-widest text-ink-tertiary">
{isAuthenticated ? "TU ORCID iD" : "O INTRODUCE TU ORCID iD"}
</span>
<div className="h-px flex-1 bg-surface-border" />
</div>
<div>
<label className="mb-2 block text-[13px] font-medium text-ink-secondary">
ORCID iD
</label>
<div className="flex gap-2.5">
<div className="relative flex-1">
<input
type="text"
inputMode="numeric"
placeholder="0000-0002-1234-5678"
value={orcidInput}
onChange={handleOrcidChange}
onKeyDown={handleKeyDown}
maxLength={19}
className={`w-full rounded-lg py-2.5 pl-10 pr-3.5 font-mono text-[15px] tracking-wider text-ink-primary outline-none transition-colors ${
error
? "border border-border-danger"
: "border border-surface-border-strong focus:border-brand-accent"
}`}
/>
<span className="pointer-events-none absolute left-3 top-1/2 -translate-y-1/2">
<OrcidLogo />
</span>
</div>
<button
type="button"
onClick={handleValidate}
disabled={validating || loginLoading || !orcidInput}
className={`inline-flex items-center gap-2 whitespace-nowrap rounded-lg px-5 py-2.5 text-sm font-medium transition-colors ${
orcidInput
? "bg-brand-primary text-white enabled:hover:bg-brand-primary-hover"
: "bg-surface-secondary text-ink-tertiary"
} disabled:cursor-not-allowed`}
>
{validating && <Spinner size={14} />}
{validating ? "Buscando..." : "Buscar"}
</button>
</div>
{error && (
<p className="mt-2 text-xs leading-relaxed text-ink-danger">
{error}
</p>
)} )}
<p className="mt-2 text-xs text-ink-tertiary">
{isAuthenticated <div className="my-6 flex items-center gap-3">
? "Busca un investigador o usa «Cerrar sesión» arriba." <div className="h-px flex-1 bg-surface-border" />
: "Pulsa «Iniciar sesión» para autenticarte, o «Buscar» de forma anónima."} <span className="text-xs tracking-widest text-ink-tertiary">
{isAuthenticated ? "TU ORCID iD" : "O INTRODUCE TU ORCID iD"}
</span>
<div className="h-px flex-1 bg-surface-border" />
</div>
<div className="flex flex-col gap-2">
<label className="text-[13px] font-medium text-ink-secondary">
ORCID iD
</label>
<div className="flex gap-2.5">
<div className="relative flex-1">
<input
type="text"
inputMode="numeric"
placeholder="0000-0002-1234-5678"
value={orcidInput}
onChange={handleOrcidChange}
onKeyDown={handleKeyDown}
maxLength={19}
className={`w-full rounded-lg py-3 pl-10 pr-3.5 font-mono text-[15px] tracking-wider text-ink-primary outline-none transition-colors ${
error
? "border border-border-danger"
: "border border-surface-border-strong focus:border-brand-accent"
}`}
/>
<span className="pointer-events-none absolute left-3 top-1/2 -translate-y-1/2">
<OrcidLogo />
</span>
</div>
<button
type="button"
onClick={handleValidate}
disabled={validating || loginLoading || !orcidInput}
className={`inline-flex items-center gap-2 whitespace-nowrap rounded-lg px-5 py-3 text-sm font-medium transition-colors ${
orcidInput
? "bg-brand-primary text-white enabled:hover:bg-brand-primary-hover"
: "bg-surface-secondary text-ink-tertiary"
} disabled:cursor-not-allowed`}
>
{validating && <Spinner size={14} />}
{validating ? "Buscando..." : "Buscar"}
</button>
</div>
{error && (
<p className="text-xs leading-relaxed text-ink-danger">
{error}
</p>
)}
<p className="text-xs text-ink-tertiary">
{isAuthenticated
? "Busca un investigador o usa «Cerrar sesión» arriba."
: "Pulsa «Iniciar sesión» para autenticarte, o «Buscar» de forma anónima."}
</p>
</div>
</div>
{/* ── Right: group search ── */}
<div className="flex flex-col rounded-2xl border border-surface-border/60 bg-surface-primary p-8">
<div className="mb-3 flex items-center gap-2">
<UsersIcon size={18} className="text-brand-accent" />
<h2 className="text-[15px] font-semibold text-ink-primary">
Búsqueda grupal de investigadores
</h2>
</div>
<p className="mb-4 text-[13px] leading-relaxed text-ink-secondary">
Pega varios ORCID iDs separados por comas, espacios o saltos de
línea para buscar y comparar varios investigadores a la vez.
</p> </p>
<textarea
rows={5}
placeholder={"0000-0002-1825-0097\n0000-0001-5000-0007\n0000-0003-4321-9876"}
value={groupInput}
onChange={(e) => {
setGroupInput(e.target.value);
if (groupError) setGroupError("");
}}
onKeyDown={handleGroupKeyDown}
className={`w-full flex-1 resize-none rounded-lg border px-3.5 py-3 font-mono text-[13px] text-ink-primary outline-none transition-colors ${
groupError
? "border-border-danger"
: "border-surface-border-strong focus:border-brand-accent"
}`}
/>
{groupError && (
<p className="mt-1 text-xs text-ink-danger">{groupError}</p>
)}
<button
type="button"
onClick={handleGroupSearch}
disabled={groupLoading || !groupInput.trim()}
className={`mt-4 inline-flex w-full items-center justify-center gap-2 rounded-lg px-5 py-3 text-sm font-medium transition-colors ${
groupInput.trim()
? "bg-brand-primary text-white enabled:hover:bg-brand-primary-hover"
: "bg-surface-secondary text-ink-tertiary"
} disabled:cursor-not-allowed`}
>
{groupLoading && <Spinner size={14} />}
<UsersIcon size={14} />
{groupLoading ? "Preparando..." : "Buscar investigadores"}
</button>
</div> </div>
</div> </div>
{/* Group search card */} {/* ── Info chips ── */}
<div className="mt-4 rounded-2xl border border-surface-border/60 bg-surface-primary p-6"> <div className="mt-8 flex flex-wrap justify-center gap-4">
<div className="mb-3 flex items-center gap-2">
<UsersIcon size={17} className="text-brand-accent" />
<h2 className="text-[14px] font-semibold text-ink-primary">
Búsqueda grupal de investigadores
</h2>
</div>
<p className="mb-3 text-xs leading-relaxed text-ink-secondary">
Pega varios ORCID iDs separados por comas, espacios o saltos de
línea para buscar y comparar varios investigadores a la vez.
</p>
<textarea
rows={3}
placeholder={"0000-0002-1825-0097\n0000-0001-5000-0007, 0000-0003-4321-9876"}
value={groupInput}
onChange={(e) => {
setGroupInput(e.target.value);
if (groupError) setGroupError("");
}}
onKeyDown={handleGroupKeyDown}
className={`w-full resize-none rounded-lg border px-3.5 py-2.5 font-mono text-[13px] text-ink-primary outline-none transition-colors ${
groupError
? "border-border-danger"
: "border-surface-border-strong focus:border-brand-accent"
}`}
/>
{groupError && (
<p className="mt-1 text-xs text-ink-danger">{groupError}</p>
)}
<button
type="button"
onClick={handleGroupSearch}
disabled={groupLoading || !groupInput.trim()}
className={`mt-3 inline-flex w-full items-center justify-center gap-2 rounded-lg px-5 py-2.5 text-sm font-medium transition-colors ${
groupInput.trim()
? "bg-brand-primary text-white enabled:hover:bg-brand-primary-hover"
: "bg-surface-secondary text-ink-tertiary"
} disabled:cursor-not-allowed`}
>
{groupLoading && <Spinner size={14} />}
<UsersIcon size={14} />
{groupLoading ? "Preparando..." : "Buscar investigadores"}
</button>
</div>
{/* Info chips */}
<div className="mt-6 flex flex-wrap justify-center gap-4">
{["ORCID OAuth 2.0", "SWORD v2", "DSpace · EPrints"].map((label) => ( {["ORCID OAuth 2.0", "SWORD v2", "DSpace · EPrints"].map((label) => (
<span <span
key={label} key={label}
className="rounded-full border border-surface-border/60 bg-surface-secondary px-3 py-1 text-xs text-ink-tertiary" className="rounded-full border border-surface-border/60 bg-surface-secondary px-3.5 py-1.5 text-xs text-ink-tertiary"
> >
{label} {label}
</span> </span>
))} ))}
</div> </div>
</div> </div>
</main> </main>
</div> </div>