Skip to content

Commit 7dae3a3

Browse files
committed
🍱(frontend) Docs icon overridable from theme
Depend the theme, you can have different Docs icons in the header. A customization was already possible from the theme customization file, but now it is as well possible to override the icon from the theme itself, making it easier to manage different themes with different icons. We change the theme customization variable name to "icon" instead of "logo", "logo" was already used for the main logo of the application inside the theme configuration.
1 parent bdf62e2 commit 7dae3a3

File tree

12 files changed

+69
-34
lines changed

12 files changed

+69
-34
lines changed

docs/theming.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Then, set the `FRONTEND_CSS_URL` environment variable to the URL of your custom
3232

3333
----
3434

35-
# **Your logo** 📝
35+
# **Your Docs icon** 📝
3636

37-
You can add your own logo in the header from the theme customization file.
37+
You can add your own Docs icon in the header from the theme customization file.
3838

3939
### Settings 🔧
4040

@@ -44,9 +44,9 @@ THEME_CUSTOMIZATION_FILE_PATH=<path>
4444

4545
### Example of JSON
4646

47-
You can activate it with the `header.logo` configuration: https://github.com/suitenumerique/docs/blob/main/src/helm/env.d/dev/configuration/theme/demo.json
47+
You can activate it with the `header.icon` configuration: https://github.com/suitenumerique/docs/blob/main/src/helm/env.d/dev/configuration/theme/demo.json
4848

49-
This configuration is optional. If not set, the default logo will be used.
49+
This configuration is optional. If not set, the default icon will be used.
5050

5151
----
5252

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ test.describe('Header: Override configuration', () => {
156156
FRONTEND_THEME: 'dsfr',
157157
theme_customization: {
158158
header: {
159-
logo: {
159+
icon: {
160160
src: '/assets/logo-gouv.svg',
161161
width: '220px',
162+
height: 'auto',
162163
alt: '',
163164
},
164165
},

src/frontend/apps/impress/cunningham.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ tokens.themes.default.components = {
3939
},
4040
'la-gaufre': false,
4141
'home-proconnect': false,
42+
icon: {
43+
src: '/assets/icon-docs.svg',
44+
width: '32px',
45+
height: 'auto',
46+
},
4247
favicon: {
4348
'png-light': '/assets/favicon-light.png',
4449
'png-dark': '/assets/favicon-dark.png',
@@ -65,6 +70,11 @@ const dsfrTheme = {
6570
},
6671
'la-gaufre': true,
6772
'home-proconnect': true,
73+
icon: {
74+
src: '/assets/icon-docs-dsfr.svg',
75+
width: '32px',
76+
height: 'auto',
77+
},
6878
favicon: {
6979
ico: '/assets/favicon-dsfr.ico',
7080
'png-light': '/assets/favicon-dsfr.png',
Lines changed: 12 additions & 0 deletions
Loading
Lines changed: 3 additions & 11 deletions
Loading

src/frontend/apps/impress/src/assets/icons/icon-docs.svg

Lines changed: 1 addition & 1 deletion
Loading

src/frontend/apps/impress/src/cunningham/cunningham-tokens.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,9 @@
10801080
--c--components--logo--widthfooter: ;
10811081
--c--components--la-gaufre: false;
10821082
--c--components--home-proconnect: false;
1083+
--c--components--icon--src: /assets/icon-docs.svg;
1084+
--c--components--icon--width: 32px;
1085+
--c--components--icon--height: auto;
10831086
--c--components--favicon--png-light: /assets/favicon-light.png;
10841087
--c--components--favicon--png-dark: /assets/favicon-dark.png;
10851088
}
@@ -2061,6 +2064,9 @@
20612064
--c--components--logo--alt: gouvernement logo;
20622065
--c--components--la-gaufre: true;
20632066
--c--components--home-proconnect: true;
2067+
--c--components--icon--src: /assets/icon-docs-dsfr.svg;
2068+
--c--components--icon--width: 32px;
2069+
--c--components--icon--height: auto;
20642070
--c--components--favicon--ico: /assets/favicon-dsfr.ico;
20652071
--c--components--favicon--png-light: /assets/favicon-dsfr.png;
20662072
--c--components--favicon--png-dark: /assets/favicon-dark-dsfr.png;

src/frontend/apps/impress/src/cunningham/cunningham-tokens.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ export const tokens = {
801801
logo: { src: '', alt: '', widthHeader: '', widthFooter: '' },
802802
'la-gaufre': false,
803803
'home-proconnect': false,
804+
icon: { src: '/assets/icon-docs.svg', width: '32px', height: 'auto' },
804805
favicon: {
805806
'png-light': '/assets/favicon-light.png',
806807
'png-dark': '/assets/favicon-dark.png',
@@ -1549,6 +1550,11 @@ export const tokens = {
15491550
},
15501551
'la-gaufre': true,
15511552
'home-proconnect': true,
1553+
icon: {
1554+
src: '/assets/icon-docs-dsfr.svg',
1555+
width: '32px',
1556+
height: 'auto',
1557+
},
15521558
favicon: {
15531559
ico: '/assets/favicon-dsfr.ico',
15541560
'png-light': '/assets/favicon-dsfr.png',

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ import { Title } from './Title';
1818
export const Header = () => {
1919
const { t } = useTranslation();
2020
const { data: config } = useConfig();
21-
const { spacingsTokens } = useCunninghamTheme();
21+
const { spacingsTokens, componentTokens } = useCunninghamTheme();
2222
const { isDesktop } = useResponsiveStore();
2323

24-
const logo = config?.theme_customization?.header?.logo;
24+
const icon =
25+
config?.theme_customization?.header?.icon || componentTokens.icon;
2526

2627
return (
2728
<Box
@@ -65,15 +66,14 @@ export const Header = () => {
6566
$margin={{ top: 'auto' }}
6667
>
6768
<Image
68-
className="c__image-system-filter"
6969
data-testid="header-icon-docs"
70-
src={logo?.src || '/assets/icon-docs.svg'}
70+
src={icon.src || ''}
7171
alt=""
7272
width={0}
7373
height={0}
7474
style={{
75-
width: logo?.width || 32,
76-
height: logo?.height || 'auto',
75+
width: icon.width,
76+
height: icon.height,
7777
}}
7878
priority
7979
/>

src/frontend/apps/impress/src/features/header/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface HeaderType {
2-
logo?: {
2+
icon?: {
33
src?: string;
44
width?: string;
55
height?: string;

0 commit comments

Comments
 (0)