Implement creator studio and upload updates

This commit is contained in:
2026-04-04 10:12:02 +02:00
parent 1da7d3bf88
commit 0b216b7ecd
15107 changed files with 31206 additions and 626514 deletions

View File

@@ -108,13 +108,40 @@ function positionToObjectPosition(position) {
return map[position] || '50% 50%'
}
function SectionCard({ title, description, children, actionSlot }) {
function SuccessMessage({ text, className = '' }) {
if (!text) return null
return (
<section className="rounded-xl border border-white/5 bg-white/[0.03] p-6">
<header className="flex flex-col gap-3 border-b border-white/5 pb-4 md:flex-row md:items-start md:justify-between">
<div>
<h2 className="text-base font-semibold text-white">{title}</h2>
{description ? <p className="mt-1 text-sm text-slate-400">{description}</p> : null}
<div className={`flex items-center gap-2.5 rounded-xl border border-emerald-400/25 bg-emerald-500/10 px-4 py-2.5 text-sm text-emerald-300 animate-in fade-in ${className}`}>
<i className="fa-solid fa-circle-check shrink-0 text-emerald-400" />
<span>{text}</span>
</div>
)
}
function ErrorMessage({ text, className = '' }) {
if (!text) return null
return (
<div className={`flex items-center gap-2.5 rounded-xl border border-red-400/25 bg-red-500/10 px-4 py-2.5 text-sm text-red-300 ${className}`}>
<i className="fa-solid fa-circle-exclamation shrink-0 text-red-400" />
<span>{text}</span>
</div>
)
}
function SectionCard({ title, description, icon, children, actionSlot }) {
return (
<section className="rounded-2xl border border-white/[0.06] bg-gradient-to-b from-white/[0.04] to-white/[0.02] p-6 shadow-lg shadow-black/10">
<header className="flex flex-col gap-3 border-b border-white/[0.06] pb-4 md:flex-row md:items-start md:justify-between">
<div className="flex items-start gap-3">
{icon ? (
<span className="mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-accent/10 text-accent">
<i className={`${icon} text-sm`} />
</span>
) : null}
<div>
<h2 className="text-base font-semibold text-white">{title}</h2>
{description ? <p className="mt-1 text-sm text-slate-400">{description}</p> : null}
</div>
</div>
{actionSlot ? <div>{actionSlot}</div> : null}
</header>
@@ -820,6 +847,15 @@ export default function ProfileEdit() {
}
}
// Auto-dismiss success messages after 4 seconds
useEffect(() => {
if (!savedMessage.text) return
const timer = window.setTimeout(() => {
setSavedMessage({ section: '', text: '' })
}, 4000)
return () => window.clearTimeout(timer)
}, [savedMessage])
const sectionSaved = savedMessage.section === activeSection ? savedMessage.text : ''
return (
@@ -828,23 +864,15 @@ export default function ProfileEdit() {
sections={SETTINGS_SECTIONS}
activeSection={activeSection}
onSectionChange={switchSection}
dirtyMap={dirtyMap}
>
<div className="space-y-4">
<div className="flex flex-col gap-2 rounded-xl border border-white/5 bg-white/[0.02] p-4 md:flex-row md:items-center md:justify-between">
<p className="text-sm text-slate-300">
Configure your account by section. Each card saves independently.
</p>
{dirtyMap[activeSection] ? (
<span className="inline-flex items-center rounded-full border border-amber-400/30 bg-amber-400/10 px-3 py-1 text-xs font-medium text-amber-300">
Unsaved changes
</span>
) : null}
</div>
<div className="space-y-5">
{activeSection === 'profile' ? (
<form className="space-y-4" onSubmit={saveProfileSection}>
<SectionCard
title="Profile"
icon="fa-solid fa-user-astronaut"
description="Manage your public identity and profile presentation."
actionSlot={
<Button type="submit" variant="accent" size="sm" loading={savingSection === 'profile'}>
@@ -854,23 +882,88 @@ export default function ProfileEdit() {
>
<div className="grid gap-6 lg:grid-cols-[260px,1fr]">
<div className="space-y-3">
<div className="rounded-xl border border-white/10 bg-black/20 p-4">
<div
className="mx-auto overflow-hidden rounded-full border border-white/15 bg-white/5"
style={{ width: 144, height: 144, minWidth: 144, minHeight: 144 }}
>
{avatarUrl ? (
<img
src={avatarUrl}
alt="Avatar preview"
className="block h-full w-full object-cover object-center"
style={{ aspectRatio: '1 / 1', objectPosition: positionToObjectPosition(avatarPosition) }}
/>
) : (
<div className="flex h-full w-full items-center justify-center text-slate-500">No avatar</div>
)}
<div
className={`group relative rounded-2xl border border-white/10 bg-black/20 p-5 transition-colors duration-200 ${
dragActive ? 'border-accent/50 bg-accent/5' : ''
}`}
onDragEnter={(e) => {
dragHandler(e)
setDragActive(true)
}}
onDragLeave={(e) => {
dragHandler(e)
setDragActive(false)
}}
onDragOver={dragHandler}
onDrop={handleDrop}
>
<div className="relative mx-auto" style={{ width: 144, height: 144 }}>
<div
className="overflow-hidden rounded-full border-2 border-white/10 bg-white/5 shadow-lg shadow-black/20"
style={{ width: 144, height: 144, minWidth: 144, minHeight: 144 }}
>
{avatarUrl ? (
<img
src={avatarUrl}
alt="Avatar preview"
className="block h-full w-full object-cover object-center"
style={{ aspectRatio: '1 / 1', objectPosition: positionToObjectPosition(avatarPosition) }}
/>
) : (
<div className="flex h-full w-full flex-col items-center justify-center gap-1 text-slate-500">
<i className="fa-solid fa-camera text-xl" />
<span className="text-[11px]">No avatar</span>
</div>
)}
</div>
{/* Hover overlay */}
<button
type="button"
onClick={() => avatarInputRef.current?.click()}
className="absolute inset-0 flex cursor-pointer flex-col items-center justify-center rounded-full bg-black/60 text-white opacity-0 transition-opacity duration-200 hover:opacity-100 focus-visible:opacity-100"
aria-label="Upload avatar"
>
<i className="fa-solid fa-camera-retro text-lg" />
<span className="mt-1 text-xs font-medium">Change</span>
</button>
</div>
<p className="mt-3 text-center text-xs text-slate-500">256 × 256 recommended · JPG, PNG, WEBP</p>
<input
ref={avatarInputRef}
type="file"
className="hidden"
accept="image/jpeg,image/png,image/webp"
onChange={(e) => handleAvatarSelect(e.target.files?.[0])}
/>
<div className="mt-3 flex items-center justify-center gap-2">
<Button
type="button"
size="xs"
variant="secondary"
onClick={() => avatarInputRef.current?.click()}
leftIcon={<i className="fa-solid fa-arrow-up-from-bracket text-[10px]" />}
>
Upload
</Button>
{avatarUrl ? (
<Button
type="button"
size="xs"
variant="ghost"
onClick={() => {
setAvatarFile(null)
setRemoveAvatar(true)
setAvatarUrl('')
}}
leftIcon={<i className="fa-solid fa-trash-can text-[10px]" />}
>
Remove
</Button>
) : null}
</div>
<p className="mt-3 text-center text-xs text-slate-400">Recommended size: 256 x 256</p>
</div>
<div className="rounded-xl border border-white/10 bg-black/20 p-3">
@@ -885,68 +978,11 @@ export default function ProfileEdit() {
hint="Applies when saving a newly selected avatar"
/>
</div>
<div
className={`rounded-xl border-2 border-dashed p-4 text-center transition ${
dragActive ? 'border-accent/60 bg-accent/10' : 'border-white/15 bg-white/[0.02]'
}`}
onDragEnter={(e) => {
dragHandler(e)
setDragActive(true)
}}
onDragLeave={(e) => {
dragHandler(e)
setDragActive(false)
}}
onDragOver={dragHandler}
onDrop={handleDrop}
>
<p className="text-sm text-white">Drag and drop avatar here</p>
<p className="mt-1 text-xs text-slate-400">JPG, PNG, WEBP up to 2 MB</p>
<input
ref={avatarInputRef}
type="file"
className="hidden"
accept="image/jpeg,image/png,image/webp"
onChange={(e) => handleAvatarSelect(e.target.files?.[0])}
/>
<div className="mt-3 flex items-center justify-center gap-2">
<Button
type="button"
size="xs"
variant="secondary"
onClick={() => avatarInputRef.current?.click()}
>
Upload avatar
</Button>
<Button
type="button"
size="xs"
variant="ghost"
onClick={() => {
setAvatarFile(null)
setRemoveAvatar(true)
setAvatarUrl('')
}}
>
Remove avatar
</Button>
</div>
</div>
</div>
<div className="space-y-4">
{errorsBySection.profile._general ? (
<div className="rounded-lg border border-red-400/30 bg-red-500/10 px-3 py-2 text-sm text-red-300">
{errorsBySection.profile._general[0]}
</div>
) : null}
{sectionSaved ? (
<div className="rounded-lg border border-emerald-400/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-300">
{sectionSaved}
</div>
) : null}
<ErrorMessage text={errorsBySection.profile._general?.[0]} />
<SuccessMessage text={sectionSaved} />
<TextInput
label="Display Name"
@@ -1017,6 +1053,7 @@ export default function ProfileEdit() {
<form className="space-y-4" onSubmit={saveAccountSection}>
<SectionCard
title="Account"
icon="fa-solid fa-id-badge"
description="Update your core account identity details."
actionSlot={
<Button
@@ -1030,17 +1067,8 @@ export default function ProfileEdit() {
</Button>
}
>
{errorsBySection.account._general ? (
<div className="mb-4 rounded-lg border border-red-400/30 bg-red-500/10 px-3 py-2 text-sm text-red-300">
{errorsBySection.account._general[0]}
</div>
) : null}
{sectionSaved ? (
<div className="mb-4 rounded-lg border border-emerald-400/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-300">
{sectionSaved}
</div>
) : null}
<ErrorMessage text={errorsBySection.account._general?.[0]} className="mb-4" />
<SuccessMessage text={sectionSaved} className="mb-4" />
<div className="grid gap-4 md:grid-cols-2">
<TextInput
@@ -1068,7 +1096,7 @@ export default function ProfileEdit() {
{usernameAvailability.status !== 'idle' ? (
<p
className={`mt-4 rounded-lg border px-3 py-2 text-xs ${
className={`mt-4 flex items-center gap-2 rounded-xl border px-3 py-2 text-xs ${
usernameAvailability.status === 'available'
? 'border-emerald-400/30 bg-emerald-500/10 text-emerald-300'
: usernameAvailability.status === 'checking'
@@ -1076,11 +1104,17 @@ export default function ProfileEdit() {
: 'border-red-400/30 bg-red-500/10 text-red-300'
}`}
>
<i className={`fa-solid ${
usernameAvailability.status === 'available' ? 'fa-circle-check' :
usernameAvailability.status === 'checking' ? 'fa-spinner fa-spin' :
'fa-circle-xmark'
} shrink-0`} />
{usernameAvailability.message}
</p>
) : null}
<p className="mt-4 rounded-lg border border-white/10 bg-white/[0.02] px-3 py-2 text-xs text-slate-300">
<p className="mt-4 flex items-center gap-2 rounded-xl border border-white/[0.06] bg-white/[0.02] px-3 py-2 text-xs text-slate-400">
<i className="fa-solid fa-clock shrink-0 text-slate-500" />
You can change your username once every {usernameCooldownDays} days.
</p>
@@ -1093,6 +1127,7 @@ export default function ProfileEdit() {
<form className="space-y-4" onSubmit={savePersonalSection}>
<SectionCard
title="Personal Details"
icon="fa-solid fa-address-card"
description="Optional information shown only when you decide to provide it."
actionSlot={
<Button type="submit" variant="accent" size="sm" loading={savingSection === 'personal'}>
@@ -1100,17 +1135,8 @@ export default function ProfileEdit() {
</Button>
}
>
{errorsBySection.personal._general ? (
<div className="mb-4 rounded-lg border border-red-400/30 bg-red-500/10 px-3 py-2 text-sm text-red-300">
{errorsBySection.personal._general[0]}
</div>
) : null}
{sectionSaved ? (
<div className="mb-4 rounded-lg border border-emerald-400/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-300">
{sectionSaved}
</div>
) : null}
<ErrorMessage text={errorsBySection.personal._general?.[0]} className="mb-4" />
<SuccessMessage text={sectionSaved} className="mb-4" />
<div className="space-y-4">
<div>
@@ -1210,6 +1236,7 @@ export default function ProfileEdit() {
<form className="space-y-4" onSubmit={saveNotificationsSection}>
<SectionCard
title="Notifications"
icon="fa-solid fa-bell"
description="Choose how and when Skinbase should notify you."
actionSlot={
<Button type="submit" variant="accent" size="sm" loading={savingSection === 'notifications'}>
@@ -1217,30 +1244,24 @@ export default function ProfileEdit() {
</Button>
}
>
{errorsBySection.notifications._general ? (
<div className="mb-4 rounded-lg border border-red-400/30 bg-red-500/10 px-3 py-2 text-sm text-red-300">
{errorsBySection.notifications._general[0]}
</div>
) : null}
<ErrorMessage text={errorsBySection.notifications._general?.[0]} className="mb-4" />
<SuccessMessage text={sectionSaved} className="mb-4" />
{sectionSaved ? (
<div className="mb-4 rounded-lg border border-emerald-400/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-300">
{sectionSaved}
</div>
) : null}
<div className="space-y-3">
<div className="space-y-2">
{[
['email_notifications', 'Email notifications', 'General email alerts for account activity.'],
['upload_notifications', 'Upload notifications', 'Notify me when followed creators upload.'],
['follower_notifications', 'Follower notifications', 'Notify me when someone follows me.'],
['comment_notifications', 'Comment notifications', 'Notify me about comments on my content.'],
['newsletter', 'Newsletter', 'Receive occasional community and product updates.'],
].map(([field, label, hint]) => (
<div key={field} className="flex items-center justify-between rounded-lg border border-white/5 bg-white/[0.02] px-3 py-2">
<div>
['email_notifications', 'Email notifications', 'General email alerts for account activity.', 'fa-solid fa-envelope'],
['upload_notifications', 'Upload notifications', 'Notify me when followed creators upload.', 'fa-solid fa-cloud-arrow-up'],
['follower_notifications', 'Follower notifications', 'Notify me when someone follows me.', 'fa-solid fa-user-plus'],
['comment_notifications', 'Comment notifications', 'Notify me about comments on my content.', 'fa-solid fa-comment-dots'],
['newsletter', 'Newsletter', 'Receive occasional community and product updates.', 'fa-solid fa-newspaper'],
].map(([field, label, hint, icon]) => (
<div key={field} className="flex items-center gap-3 rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3 transition-colors hover:bg-white/[0.04]">
<span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-white/[0.06] text-slate-400">
<i className={`${icon} text-xs`} />
</span>
<div className="flex-1 min-w-0">
<p className="text-sm font-medium text-white/90">{label}</p>
<p className="text-xs text-slate-400">{hint}</p>
<p className="text-xs text-slate-500">{hint}</p>
</div>
<Toggle
checked={!!notificationForm[field]}
@@ -1263,6 +1284,7 @@ export default function ProfileEdit() {
<form className="space-y-4" onSubmit={saveSecuritySection}>
<SectionCard
title="Security"
icon="fa-solid fa-shield-halved"
description="Update password. Additional security controls can be added here later."
actionSlot={
<Button type="submit" variant="accent" size="sm" loading={savingSection === 'security'}>
@@ -1270,17 +1292,8 @@ export default function ProfileEdit() {
</Button>
}
>
{errorsBySection.security._general ? (
<div className="mb-4 rounded-lg border border-red-400/30 bg-red-500/10 px-3 py-2 text-sm text-red-300">
{errorsBySection.security._general[0]}
</div>
) : null}
{sectionSaved ? (
<div className="mb-4 rounded-lg border border-emerald-400/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-300">
{sectionSaved}
</div>
) : null}
<ErrorMessage text={errorsBySection.security._general?.[0]} className="mb-4" />
<SuccessMessage text={sectionSaved} className="mb-4" />
<div className="grid max-w-2xl gap-4">
<TextInput
@@ -1318,8 +1331,11 @@ export default function ProfileEdit() {
autoComplete="new-password"
/>
<div className="rounded-lg border border-white/5 bg-white/[0.02] p-3 text-xs text-slate-400">
Future security controls: Two-factor authentication, active sessions, and login history.
<div className="rounded-xl border border-white/[0.06] bg-white/[0.02] p-4">
<p className="flex items-center gap-2 text-xs text-slate-400">
<i className="fa-solid fa-lock text-slate-500" />
Coming soon: Two-factor authentication, active sessions, and login history.
</p>
</div>
{renderCaptchaChallenge('security')}
@@ -1329,19 +1345,35 @@ export default function ProfileEdit() {
) : null}
{activeSection === 'danger' ? (
<SectionCard
title="Danger Zone"
description="This action cannot be undone."
actionSlot={
<Button variant="danger" size="sm" onClick={() => setShowDeleteModal(true)}>
Delete Account
</Button>
}
>
<p className="text-sm text-slate-300">
Deleting your account permanently removes your artworks, comments, and profile data.
</p>
</SectionCard>
<section className="rounded-2xl border border-red-500/20 bg-gradient-to-b from-red-500/[0.06] to-red-500/[0.02] p-6 shadow-lg shadow-red-900/10">
<header className="flex flex-col gap-3 border-b border-red-500/10 pb-4 md:flex-row md:items-start md:justify-between">
<div className="flex items-start gap-3">
<span className="mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-red-500/15 text-red-400">
<i className="fa-solid fa-triangle-exclamation text-sm" />
</span>
<div>
<h2 className="text-base font-semibold text-red-300">Danger Zone</h2>
<p className="mt-1 text-sm text-red-400/70">These actions are permanent and cannot be undone.</p>
</div>
</div>
</header>
<div className="pt-5">
<div className="rounded-xl border border-red-500/15 bg-red-500/[0.04] p-4">
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<div>
<p className="text-sm font-medium text-white">Delete account</p>
<p className="mt-0.5 text-xs text-slate-400">
Permanently removes your artworks, comments, followers, and all profile data.
</p>
</div>
<Button variant="danger" size="sm" onClick={() => setShowDeleteModal(true)}>
<i className="fa-solid fa-trash-can mr-1.5 text-xs" />
Delete Account
</Button>
</div>
</div>
</div>
</section>
) : null}
</div>