Skip to content

Commit 0639594

Browse files
committed
✨(frontend) load docs logo from public folder via url instead of svg
allows logo override at deploy-time using k8s configmaps and static assets Signed-off-by: Cyril <c.gromoff@gmail.com>
1 parent 546f97c commit 0639594

File tree

6 files changed

+61
-7
lines changed

6 files changed

+61
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ and this project adheres to
4949
- 🐛(backend) filter invitation with case insensitive email
5050
- 🐛(frontend) reduce no access image size from 450 to 300 #1463
5151
- 🐛(frontend) preserve interlink style on drag-and-drop in editor #1460
52+
- ✨(frontend) load docs logo from public folder via url #1462
5253

5354
## [3.7.0] - 2025-09-12
5455

src/backend/impress/configuration/theme/default.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,12 @@
125125
}
126126
}
127127
}
128+
},
129+
"header": {
130+
"logo": {
131+
"src": "/assets/icon-docs.svg",
132+
"width": "32px",
133+
"alt": "Docs"
134+
}
128135
}
129136
}

src/frontend/apps/e2e/__tests__/app-impress/header.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,27 @@ test.describe('Header: Log out', () => {
131131
await expectLoginPage(page);
132132
});
133133
});
134+
135+
test.describe('Header: Override configuration', () => {
136+
test('checks the header is correctly overrided', async ({ page }) => {
137+
await overrideConfig(page, {
138+
FRONTEND_THEME: 'dsfr',
139+
theme_customization: {
140+
header: {
141+
logo: {
142+
src: '/assets/logo-gouv.svg',
143+
width: '220px',
144+
alt: 'Gouvernement Logo',
145+
},
146+
},
147+
},
148+
});
149+
150+
await page.goto('/');
151+
const header = page.locator('header').first();
152+
153+
await expect(header.getByAltText('Gouvernement Logo')).toBeVisible();
154+
155+
await expect(header.getByAltText('Docs')).toBeHidden();
156+
});
157+
});

src/frontend/apps/impress/src/core/config/api/useConfig.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { Resource } from 'i18next';
44
import { APIError, errorCauses, fetchAPI } from '@/api';
55
import { Theme } from '@/cunningham/';
66
import { FooterType } from '@/features/footer';
7+
import { HeaderType } from '@/features/header/types';
78
import { PostHogConf } from '@/services';
89

910
interface ThemeCustomization {
1011
footer?: FooterType;
1112
translations?: Resource;
13+
header?: HeaderType;
1214
}
1315

1416
export interface ConfigResponse {

src/frontend/apps/impress/src/features/header/components/Header.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import Image from 'next/image';
12
import { useTranslation } from 'react-i18next';
23
import { css } from 'styled-components';
34

4-
import IconDocs from '@/assets/icons/icon-docs.svg';
55
import { Box, StyledLink } from '@/components/';
6+
import { useConfig } from '@/core/config';
67
import { useCunninghamTheme } from '@/cunningham';
78
import { ButtonLogin } from '@/features/auth';
89
import { LanguagePicker } from '@/features/language';
@@ -16,9 +17,14 @@ import { Title } from './Title';
1617

1718
export const Header = () => {
1819
const { t } = useTranslation();
20+
const { data: config } = useConfig();
1921
const { spacingsTokens, colorsTokens } = useCunninghamTheme();
2022
const { isDesktop } = useResponsiveStore();
2123

24+
const logo = config?.theme_customization?.header?.logo;
25+
26+
const styleWidth = logo?.width || '32px';
27+
2228
return (
2329
<Box
2430
as="header"
@@ -60,12 +66,18 @@ export const Header = () => {
6066
$height="fit-content"
6167
$margin={{ top: 'auto' }}
6268
>
63-
<IconDocs
64-
data-testid="header-icon-docs"
65-
width={32}
66-
color={colorsTokens['primary-text']}
67-
aria-hidden="true"
68-
/>
69+
{logo?.src && (
70+
<Image
71+
className="c__image-system-filter"
72+
data-testid="header-icon-docs"
73+
src={logo.src}
74+
alt={logo?.alt || t('Logo')}
75+
width={32}
76+
height={32}
77+
style={{ width: styleWidth, height: 'auto' }}
78+
priority
79+
/>
80+
)}
6981
<Title headingLevel="h1" aria-hidden="true" />
7082
</Box>
7183
</StyledLink>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface HeaderType {
2+
logo?: {
3+
src: string;
4+
width?: string;
5+
alt?: string;
6+
withTitle?: boolean;
7+
};
8+
}

0 commit comments

Comments
 (0)