Files
zitadel/apps/login/src/components/app-avatar.tsx
T
Max PeintnerandGitHub 0a31f4ba2b fix(login): remove image optimization entirely (#10702)
This PR completely removes Next.js image optimization from the login app
by replacing all next/image components with standard HTML <img> tags and
removing the image optimization configuration.

Closes https://github.com/zitadel/zitadel-charts/issues/381

# Which Problems Are Solved

Users were encountering issue when loading images in dedicated
environments. These happened due to nextjs imaging optimizations
creating different paths for images.

# How the Problems Are Solved

- Removed Next.js Image Optimization Config
- Removed images: { unoptimized: true } configuration from
[next.config.mjs](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
This config was redundant since we no longer use next/image components
- Replaced next/image with standard <img> tags
2025-09-22 11:49:21 +00:00

48 lines
1.6 KiB
TypeScript

import { ColorShade, getColorHash } from "@/helpers/colors";
import { useTheme } from "next-themes";
import { getInitials } from "./avatar";
interface AvatarProps {
appName: string;
imageUrl?: string;
shadow?: boolean;
}
export function AppAvatar({ appName, imageUrl, shadow }: AvatarProps) {
const { resolvedTheme } = useTheme();
const credentials = getInitials(appName, appName);
const color: ColorShade = getColorHash(appName);
const avatarStyleDark = {
backgroundColor: color[900],
color: color[200],
};
const avatarStyleLight = {
backgroundColor: color[200],
color: color[900],
};
return (
<div
className={`dark:group-focus:ring-offset-blue dark:text-blue pointer-events-none flex h-[100px] w-[100px] cursor-default items-center justify-center rounded-full bg-primary-light-500 text-primary-light-contrast-500 transition-colors duration-200 hover:bg-primary-light-400 group-focus:outline-none group-focus:ring-2 group-focus:ring-primary-light-200 dark:bg-primary-dark-300 dark:text-primary-dark-contrast-300 hover:dark:bg-primary-dark-500 dark:group-focus:ring-primary-dark-400 ${
shadow ? "shadow" : ""
}`}
style={resolvedTheme === "light" ? avatarStyleLight : avatarStyleDark}
>
{imageUrl ? (
<img
height={48}
width={48}
alt="avatar"
className="h-full w-full rounded-full border border-divider-light dark:border-divider-dark"
src={imageUrl}
/>
) : (
<span className={`text-3xl uppercase`}>{credentials}</span>
)}
</div>
);
}