Admin-teksten en merklogo: Weergavenaam, Wachtwoord wijzigen, Eerste account aanmaken, logo per thema

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 14:36:10 +01:00
co-authored by Claude Sonnet 5.5
parent cd81723bf5
commit 55dcab121b
20 changed files with 350 additions and 25 deletions
@@ -0,0 +1,29 @@
import { describe, expect, it } from 'vitest';
import { screen } from '@testing-library/react';
import { renderWithProviders } from '@/test/utils';
import { BrandLogo } from '@/components/layout/BrandLogo';
describe('BrandLogo', () => {
it('falls back to the application name with its dot when the site has no logo', () => {
renderWithProviders(<BrandLogo logo={null} />);
expect(screen.getByTestId('brand-fallback')).toHaveTextContent('SlpModularCms');
expect(screen.queryByTestId('brand-logo')).not.toBeInTheDocument();
});
it('shows the default (unthemed) admin the same way', () => {
renderWithProviders(<BrandLogo />);
expect(screen.getByTestId('brand-fallback')).toBeInTheDocument();
});
it('draws the logo for both colour modes, named for screen readers', () => {
renderWithProviders(<BrandLogo logo={{ onLight: '/admin/l.png', onDark: '/admin/d.png' }} />);
const images = screen.getAllByRole('img', { hidden: true });
expect(images).toHaveLength(2);
expect(images.map((i) => i.getAttribute('src'))).toEqual(['/admin/l.png', '/admin/d.png']);
images.forEach((i) => expect(i).toHaveAttribute('alt', 'SlpModularCms'));
expect(screen.queryByTestId('brand-fallback')).not.toBeInTheDocument();
});
});
@@ -0,0 +1,36 @@
import { useTranslation } from 'react-i18next';
import { cn } from '@/lib/utils';
import { getBrand } from '@/lib/brand';
import type { BrandLogo as BrandLogoFiles } from '@/lib/brand';
interface BrandLogoProps {
/** Overrides the site brand; mainly for tests and, later, a logo loaded from site settings. */
logo?: BrandLogoFiles | null;
className?: string;
}
/**
* The site's logo, or, when it has none, the application name with its dot (what the admin always
* showed). The single place the admin draws the brand: do not hardcode it elsewhere.
*/
export function BrandLogo({ logo, className }: BrandLogoProps) {
const { t } = useTranslation();
const resolved = logo === undefined ? getBrand().logo : logo;
const name = t('common.appName');
if (resolved === null) {
return (
<div className={cn('flex items-center gap-2', className)} data-testid="brand-fallback">
<span className="h-3 w-3 rounded-full bg-primary" aria-hidden="true" />
<span className="text-lg font-semibold">{name}</span>
</div>
);
}
return (
<div className={cn('flex items-center', className)} data-testid="brand-logo">
<img src={resolved.onLight} alt={name} className="h-10 w-auto dark:hidden" />
<img src={resolved.onDark} alt={name} className="hidden h-10 w-auto dark:block" />
</div>
);
}
+2 -1
View File
@@ -1,5 +1,6 @@
import { Menu } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { BrandLogo } from './BrandLogo';
interface MobileBarProps {
onMenuOpen: () => void;
@@ -22,7 +23,7 @@ export function MobileBar({ onMenuOpen }: MobileBarProps) {
>
<Menu className="size-5" />
</button>
<span className="font-semibold">{t('common.appName')}</span>
<BrandLogo className="[&_img]:h-8 [&_span]:text-base" />
</header>
);
}