Skip to content

Commit 16f2de4

Browse files
committed
♻️(frontend) logo theme customization optional
To not create a breaking change, the logo in the theme customization is now optional, meaning that if no logo is provided, the default logo will be used. We add some documentation about this feature.
1 parent f19fa93 commit 16f2de4

File tree

7 files changed

+42
-24
lines changed

7 files changed

+42
-24
lines changed

docs/theming.md

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

3333
----
3434

35+
# **Your logo** 📝
36+
37+
You can add your own logo in the header from the theme customization file.
38+
39+
### Settings 🔧
40+
41+
```shellscript
42+
THEME_CUSTOMIZATION_FILE_PATH=<path>
43+
```
44+
45+
### Example of JSON
46+
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
48+
49+
This configuration is optional. If not set, the default logo will be used.
50+
51+
----
52+
3553
# **Footer Configuration** 📝
3654

3755
The footer is configurable from the theme customization file.

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ 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';
7+
import { HeaderType } from '@/features/header';
88
import { PostHogConf } from '@/services';
99

1010
interface ThemeCustomization {

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ export const Header = () => {
2323

2424
const logo = config?.theme_customization?.header?.logo;
2525

26-
const styleWidth = logo?.width || '32px';
27-
2826
return (
2927
<Box
3028
as="header"
@@ -66,18 +64,19 @@ export const Header = () => {
6664
$height="fit-content"
6765
$margin={{ top: 'auto' }}
6866
>
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-
)}
67+
<Image
68+
className="c__image-system-filter"
69+
data-testid="header-icon-docs"
70+
src={logo?.src || '/assets/icon-docs.svg'}
71+
alt={logo?.alt || t('Docs')}
72+
width={0}
73+
height={0}
74+
style={{
75+
width: logo?.width || 32,
76+
height: logo?.height || 'auto',
77+
}}
78+
priority
79+
/>
8180
<Title headingLevel="h1" aria-hidden="true" />
8281
</Box>
8382
</StyledLink>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './components/';
22
export * from './conf';
3+
export * from './types';
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export interface HeaderType {
22
logo?: {
3-
src: string;
3+
src?: string;
44
width?: string;
5+
height?: string;
56
alt?: string;
6-
withTitle?: boolean;
77
};
88
}

src/helm/env.d/dev/configuration/theme/demo.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,12 @@
133133
}
134134
}
135135
}
136+
},
137+
"header": {
138+
"logo": {
139+
"src": "/assets/icon-docs.svg",
140+
"width": "32px",
141+
"alt": "Notes"
142+
}
136143
}
137144
}

0 commit comments

Comments
 (0)