Skip to content

Commit 1ab38d2

Browse files
committed
image best practice fix
1 parent 34dd941 commit 1ab38d2

File tree

2 files changed

+14
-32
lines changed

2 files changed

+14
-32
lines changed

src/app/components/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export default function DrawerAppBar(): React.ReactElement {
218218
: '/assets/MOBILTYDATA_logo_purple_M.png'
219219
}
220220
alt='MobilityData logo'
221-
width={45}
221+
width={45 * 1.05} // aspect ratio of the logo is slightly off, adjust width to prevent layout shift between themes
222222
height={45}
223223
priority
224224
fetchPriority='high'

src/app/components/HeaderMobileDrawer.tsx

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { mobileNavElementStyle } from './Header.style';
2626
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
2727
import { useRemoteConfig } from '../context/RemoteConfigProvider';
2828
import { useTranslations } from 'next-intl';
29+
import Image from 'next/image';
2930

3031
const websiteTile = 'MobilityDatabase';
3132

@@ -55,37 +56,18 @@ export default function DrawerContent({
5556
router.push('/');
5657
}}
5758
>
58-
{theme.palette.mode === 'light' ? (
59-
<picture style={{ display: 'flex' }}>
60-
<source
61-
src='/assets/MOBILTYDATA_logo_light_blue_M.png'
62-
type='image/png'
63-
height={40}
64-
width={40}
65-
/>
66-
<img
67-
alt='MobilityData logo'
68-
src='/assets/MOBILTYDATA_logo_light_blue_M.png'
69-
height={40}
70-
width={40}
71-
/>
72-
</picture>
73-
) : (
74-
<picture style={{ display: 'flex' }}>
75-
<source
76-
src='/assets/MOBILTYDATA_logo_purple_M.png'
77-
type='image/png'
78-
height={40}
79-
width={40}
80-
/>
81-
<img
82-
alt='MobilityData logo'
83-
src='/assets/MOBILTYDATA_logo_purple_M.png'
84-
height={40}
85-
width={40}
86-
/>
87-
</picture>
88-
)}
59+
<Image
60+
src={
61+
theme.palette.mode === 'light'
62+
? '/assets/MOBILTYDATA_logo_light_blue_M.png'
63+
: '/assets/MOBILTYDATA_logo_purple_M.png'
64+
}
65+
alt='MobilityData logo'
66+
width={40 * 1.05} // aspect ratio of the logo is slightly off, adjust width to prevent layout shift between themes
67+
height={40}
68+
priority
69+
fetchPriority='high'
70+
/>
8971

9072
<Typography
9173
component={'h2'}

0 commit comments

Comments
 (0)