Skip to content

Commit 225f68e

Browse files
chore(js-ts): Improve accessibility and update to useIntl hook
Co-Authored-By: Joseph Gross <joseph@cognition.ai>
1 parent ce24b09 commit 225f68e

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/elements/common/header/Header.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import * as React from 'react';
7-
import { injectIntl, IntlShape } from 'react-intl';
7+
import { useIntl } from 'react-intl';
88
import Logo from './Logo';
99
import messages from '../messages';
1010
import { VIEW_FOLDER, VIEW_SEARCH } from '../../../constants';
@@ -13,7 +13,6 @@ import { View } from '../../../common/types/core';
1313
import './Header.scss';
1414

1515
interface HeaderProps {
16-
intl: IntlShape;
1716
isHeaderLogoVisible?: boolean;
1817
isSmall: boolean;
1918
logoUrl?: string;
@@ -22,17 +21,15 @@ interface HeaderProps {
2221
view: View;
2322
}
2423

25-
// eslint-disable-next-line react/prop-types
2624
const Header = ({
2725
isHeaderLogoVisible = true,
2826
view,
2927
isSmall,
3028
searchQuery,
3129
onSearch,
3230
logoUrl,
33-
intl,
3431
}: HeaderProps): JSX.Element => {
35-
const { formatMessage } = intl;
32+
const { formatMessage } = useIntl();
3633
const search = ({ currentTarget }: { currentTarget: HTMLInputElement }): void => onSearch(currentTarget.value);
3734
const searchMessage = formatMessage(messages.searchPlaceholder);
3835
const isFolder = view === VIEW_FOLDER;
@@ -57,4 +54,4 @@ const Header = ({
5754
};
5855

5956
export { Header as HeaderBase };
60-
export default injectIntl(Header);
57+
export default Header;

src/elements/common/header/Logo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ interface LogoProps {
1616

1717
function getLogo(url?: string): React.ReactNode {
1818
if (url === 'box') {
19-
return <IconLogo />;
19+
return <IconLogo aria-label="Box logo" role="img" />;
2020
}
2121
if (typeof url === 'string') {
22-
return <img alt="" className="be-logo-custom" src={url} />;
22+
return <img alt="Logo" aria-label="Custom logo" className="be-logo-custom" src={url} />;
2323
}
2424

2525
return (
26-
<div className="be-logo-placeholder">
26+
<div className="be-logo-placeholder" role="img" aria-label="Logo placeholder">
2727
<FormattedMessage {...messages.logo} />
2828
</div>
2929
);

0 commit comments

Comments
 (0)