feat(profile)!: replace sidebar and add avatar navigation
Rename the global Sidebar route, UI, assets, analytics, and payment return context to Profile. Add accessible message-avatar navigation and preserve the source character across auth and logout flows. BREAKING CHANGE: /sidebar has been removed; use /profile instead.
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
import Image from "next/image";
|
||||
import type { CSSProperties } from "react";
|
||||
|
||||
export interface CharacterAvatarProps {
|
||||
import type { AvatarInteractionProps } from "./avatar-interaction";
|
||||
|
||||
interface CharacterAvatarVisualProps {
|
||||
src: string;
|
||||
alt: string;
|
||||
className?: string;
|
||||
@@ -12,6 +14,9 @@ export interface CharacterAvatarProps {
|
||||
priority?: boolean;
|
||||
}
|
||||
|
||||
export type CharacterAvatarProps = CharacterAvatarVisualProps &
|
||||
AvatarInteractionProps;
|
||||
|
||||
export function CharacterAvatar({
|
||||
src,
|
||||
alt,
|
||||
@@ -19,6 +24,9 @@ export function CharacterAvatar({
|
||||
size = 43,
|
||||
imageSize,
|
||||
priority = false,
|
||||
onClick,
|
||||
actionLabel,
|
||||
analyticsKey,
|
||||
}: CharacterAvatarProps) {
|
||||
const resolvedImageSize =
|
||||
imageSize ?? (typeof size === "number" ? size : 96);
|
||||
@@ -27,24 +35,45 @@ export function CharacterAvatar({
|
||||
height: size,
|
||||
};
|
||||
|
||||
const avatarClassName = [
|
||||
"inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full border-0 bg-(--color-avatar-border,#fbf3f5)",
|
||||
onClick
|
||||
? "cursor-pointer p-0 transition-transform duration-150 focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-accent active:scale-96"
|
||||
: undefined,
|
||||
className,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
const image = (
|
||||
<Image
|
||||
src={src}
|
||||
alt={alt}
|
||||
width={resolvedImageSize}
|
||||
height={resolvedImageSize}
|
||||
priority={priority}
|
||||
className="size-full object-cover"
|
||||
/>
|
||||
);
|
||||
|
||||
if (onClick) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={avatarClassName}
|
||||
style={style}
|
||||
aria-label={actionLabel}
|
||||
data-analytics-key={analyticsKey}
|
||||
data-analytics-label={actionLabel}
|
||||
onClick={onClick}
|
||||
>
|
||||
{image}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
className={[
|
||||
"inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-(--color-avatar-border,#fbf3f5)",
|
||||
className,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ")}
|
||||
style={style}
|
||||
>
|
||||
<Image
|
||||
src={src}
|
||||
alt={alt}
|
||||
width={resolvedImageSize}
|
||||
height={resolvedImageSize}
|
||||
priority={priority}
|
||||
className="size-full object-cover"
|
||||
/>
|
||||
<span className={avatarClassName} style={style}>
|
||||
{image}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user