Skip to content

Commit

Permalink
[PR feedback] Improve SR UX for versions
Browse files Browse the repository at this point in the history
+ improve variable names
  • Loading branch information
cee-chen committed Oct 19, 2023
1 parent 4cb0fba commit b9bb771
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src-docs/src/components/guide_page/guide_page_header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ import { CodeSandboxLink } from '../../components/codesandbox/link';
import logoEUI from '../../images/logo-eui.svg';
import { GuideThemeSelector, GuideFigmaLink } from '../guide_theme_selector';

const pkg = require('../../../../package.json');
const { euiVersions } = require('./versions.json');
const currentVersion = require('../../../../package.json').version;
const pronounceVersion = (version: string) => {
return `version ${version.replaceAll('.', ' point ')}`; // NVDA pronounciation issue
};

export type GuidePageHeaderProps = {
onToggleLocale: () => {};
Expand All @@ -49,10 +52,12 @@ export const GuidePageHeader: React.FunctionComponent<GuidePageHeaderProps> = ({
return (
<EuiBadge
onClick={() => setIsVersionPopoverOpen((isOpen) => !isOpen)}
onClickAriaLabel={`Version ${pkg.version}. Click to switch versions`}
onClickAriaLabel={`${
isLocalDev ? 'Local' : pronounceVersion(currentVersion)
}. Click to switch versions`}
color={isLocalDev ? 'accent' : 'default'}
>
{isLocalDev ? 'Local' : `v${pkg.version}`}
{isLocalDev ? 'Local' : `v${currentVersion}`}
</EuiBadge>
);
}, []);
Expand All @@ -75,23 +80,25 @@ export const GuidePageHeader: React.FunctionComponent<GuidePageHeaderProps> = ({
>
{({ index, style }) => {
const version = euiVersions[index];
const screenReaderVersion = pronounceVersion(version);
return (
<EuiListGroupItem
style={style}
size="xs"
label={`v${version}`}
aria-label={screenReaderVersion}
href={`https://eui.elastic.co/v${version}/`}
extraAction={{
'aria-label': `View release notes for ${version}`,
'aria-label': `View release notes for ${screenReaderVersion}`,
title: 'View release',
iconType: 'package',
iconSize: 's',
// @ts-ignore - this is valid
href: `https://github.com/elastic/eui/releases/tag/v${version}`,
target: '_blank',
}}
isActive={version === pkg.version}
color={version === pkg.version ? 'primary' : 'text'}
isActive={version === currentVersion}
color={version === currentVersion ? 'primary' : 'text'}
/>
);
}}
Expand Down

0 comments on commit b9bb771

Please sign in to comment.