Skip to content

Commit

Permalink
fix(a11y): sitename in logo alt
Browse files Browse the repository at this point in the history
  • Loading branch information
langemike authored and AntonLantukh committed Apr 11, 2024
1 parent 2a5e2fe commit 051e46f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/ui-react/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Props = {
currentLanguage: LanguageDefinition | undefined;
onLanguageClick: (code: string) => void;
favoritesEnabled?: boolean;
siteName?: string;

profilesData?: {
currentProfile: Profile | null;
Expand Down Expand Up @@ -87,6 +88,7 @@ const Header: React.FC<Props> = ({
currentLanguage,
onLanguageClick,
favoritesEnabled,
siteName,
profilesData: { currentProfile, profiles, profilesEnabled, selectProfile, isSelectingProfile } = {},
}) => {
const { t } = useTranslation('menu');
Expand Down Expand Up @@ -215,7 +217,7 @@ const Header: React.FC<Props> = ({
</div>
{logoSrc && (
<div className={styles.brand}>
<Logo src={logoSrc} onLoad={() => setLogoLoaded(true)} />
<Logo alt={t('logo_alt', { siteName })} src={logoSrc} onLoad={() => setLogoLoaded(true)} />
</div>
)}
<nav className={styles.nav}>{logoLoaded || !logoSrc ? children : null}</nav>
Expand Down
5 changes: 3 additions & 2 deletions packages/ui-react/src/components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import styles from './Logo.module.scss';

type Props = {
src: string;
alt?: string;
onLoad: () => void;
};

Expand All @@ -13,7 +14,7 @@ type ImgRef = {
width?: number;
};

const Logo: React.FC<Props> = ({ src, onLoad }: Props) => {
const Logo: React.FC<Props> = ({ src, alt = 'logo', onLoad }: Props) => {
const [imgDimensions, updateImgDimensions] = useState<ImgRef>({ height: undefined, width: undefined });

const onLoadHandler = (event: React.SyntheticEvent<HTMLImageElement, Event>) => {
Expand All @@ -24,7 +25,7 @@ const Logo: React.FC<Props> = ({ src, onLoad }: Props) => {

return (
<Link to="/">
<img className={styles.logo} alt="logo" src={src} height={imgDimensions.height} width={imgDimensions.width} onLoad={onLoadHandler} onError={onLoad} />
<img className={styles.logo} alt={alt} src={src} height={imgDimensions.height} width={imgDimensions.width} onLoad={onLoadHandler} onError={onLoad} />
</Link>
);
};
Expand Down
1 change: 1 addition & 0 deletions packages/ui-react/src/containers/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const Layout = () => {
canLogin={canLogin}
showPaymentsMenuItem={accessModel !== ACCESS_MODEL.AVOD}
favoritesEnabled={favoritesEnabled}
siteName={siteName}
profilesData={{
currentProfile: profile,
profiles,
Expand Down
1 change: 1 addition & 0 deletions platforms/web/public/locales/en/menu.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"close_menu": "Close menu",
"language_menu": "Open language menu",
"logo_alt": "Homepage of {{siteName}}",
"open_menu": "Open menu",
"open_user_menu": "Open user menu",
"profile_icon": "Profile icon",
Expand Down
1 change: 1 addition & 0 deletions platforms/web/public/locales/es/menu.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"close_menu": "Cerrar menú",
"language_menu": "Abrir el menú de idiomas",
"logo_alt": "Página de inicio de {{siteName}}",
"open_menu": "Abrir menú",
"open_user_menu": "Abrir menú de usuario",
"profile_icon": "Icono de perfil",
Expand Down

0 comments on commit 051e46f

Please sign in to comment.