Skip to content

Commit

Permalink
feat: added accessible labels to different toolbar container #2510
Browse files Browse the repository at this point in the history
  • Loading branch information
Kausar-HM authored and chejimmy committed Feb 28, 2024
1 parent 06b5ee5 commit ce5af6f
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 75 deletions.
46 changes: 26 additions & 20 deletions packages/dashboard/src/components/actions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,33 @@ const Actions: React.FC<ActionsProps> = ({

return (
<Box padding={{ top: 'xxs' }} data-testid='dashboard-actions'>
<SpaceBetween size='s' direction='horizontal'>
{onSave && <Button onClick={handleOnSave}>Save</Button>}
{editable && (
<CustomOrangeButton
title={readOnly ? 'Edit' : 'Preview'}
handleClick={handleOnReadOnly}
<div
aria-label='dashboard actions'
//eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
>
<SpaceBetween size='s' direction='horizontal'>
{onSave && <Button onClick={handleOnSave}>Save</Button>}
{editable && (
<CustomOrangeButton
title={readOnly ? 'Edit' : 'Preview'}
handleClick={handleOnReadOnly}
/>
)}
{editable && !readOnly && (
<Button
onClick={() => setSettingVisibility(true)}
iconName='settings'
variant='icon'
ariaLabel='Dashboard settings'
/>
)}
<DashboardSettings
isVisible={dashboardSettingsVisible}
onClose={() => setSettingVisibility(false)}
/>
)}
{editable && !readOnly && (
<Button
onClick={() => setSettingVisibility(true)}
iconName='settings'
variant='icon'
ariaLabel='Dashboard settings'
/>
)}
<DashboardSettings
isVisible={dashboardSettingsVisible}
onClose={() => setSettingVisibility(false)}
/>
</SpaceBetween>
</SpaceBetween>
</div>
</Box>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export const AssetModelSelection = ({ client }: AssetModelSelectionOptions) => {
if (!hasModelBasedQuery || !assetModelId) return null;

return (
<div className='asset-model-selection'>
<div
className='asset-model-selection'
//eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
>
<h4 style={{ color: colorTextBodyDefault }}>
<label htmlFor={assetModelSelectionControlId}>Assets</label>
</h4>
Expand Down
11 changes: 10 additions & 1 deletion packages/dashboard/src/components/internalDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@ const InternalDashboard: React.FC<InternalDashboardProperties> = ({
setUserSelect(isDragging ? disabledUserSelect : defaultUserSelect)
}
/>
<div style={dashboardToolbarBottomBorder} className='dashboard-toolbar'>
<div
style={dashboardToolbarBottomBorder}
className='dashboard-toolbar'
aria-label='edit mode dashboard toolbar'
//eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
>
<Box float='left' padding='s'>
<ComponentPalette />
</Box>
Expand Down Expand Up @@ -334,6 +340,9 @@ const InternalDashboard: React.FC<InternalDashboardProperties> = ({
<div
style={dashboardToolbarBottomBorder}
className='dashboard-toolbar-read-only'
aria-label='preview mode dashboard toolbar'
//eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
>
<Box float='left' padding='s'>
<AssetModelSelection client={iotSiteWiseClient} />
Expand Down
6 changes: 5 additions & 1 deletion packages/dashboard/src/components/palette/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ const PaletteComponent: React.FC<PaletteComponentProps> = ({
);

return (
<li ref={node}>
<li
ref={node}
//eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
>
<div aria-label={`add ${name} widget`} role='button' ref={dragRef}>
<PaletteComponentIcon widgetName={name} Icon={IconComponent} />
</div>
Expand Down
8 changes: 6 additions & 2 deletions packages/dashboard/src/components/palette/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ const Divider = () => <div style={divider} />;

const Palette = () => {
return (
<div className='widget-panel'>
<div
className='widget-panel'
//eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
>
<h4 style={widgetFont}>Widgets</h4>
<Divider />
<ul className='component-palette-widgets'>
<ul className='component-palette-widgets' aria-label='widget panel'>
{ComponentLibraryComponentOrdering.map((widgetType) => {
const [name, iconComponent] =
ComponentLibraryComponentMap[widgetType];
Expand Down
106 changes: 56 additions & 50 deletions packages/react-components/src/components/time-sync/timeSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,57 +150,63 @@ export const TimeSelection = ({
} = messages;

return (
<FormField label={!hideTitle ? title : ''} data-testid='time-selection'>
<SpaceBetween direction='horizontal' size='xxs'>
{isPaginationEnabled && (
<Tooltip
content={`Move back ${
viewport && 'duration' in viewport
? viewport.duration
: 'selected range'
}`}
position='bottom'
children={
<Button
iconName='caret-left-filled'
onClick={handlePaginateBackward}
ariaLabel='Move backward'
/>
}
/>
)}
<div
aria-label='viewport picker'
//eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
>
<FormField label={!hideTitle ? title : ''} data-testid='time-selection'>
<SpaceBetween direction='horizontal' size='xxs'>
{isPaginationEnabled && (
<Tooltip
content={`Move back ${
viewport && 'duration' in viewport
? viewport.duration
: 'selected range'
}`}
position='bottom'
children={
<Button
iconName='caret-left-filled'
onClick={handlePaginateBackward}
ariaLabel='Move backward'
/>
}
/>
)}

<DateRangePicker
expandToViewport={true}
onChange={handleChangeDateRange}
value={viewportToDateRange(viewport)}
showClearButton={false}
relativeOptions={relativeOptions}
isValidRange={rangeValidator({
dateRangeIncompleteError,
dateRangeInvalidError,
})}
i18nStrings={i18nStrings}
placeholder={placeholder}
/>
{isPaginationEnabled && (
<Tooltip
content={`Move forward ${
viewport && 'duration' in viewport
? viewport.duration
: 'selected range'
}`}
position='bottom'
children={
<Button
iconName='caret-right-filled'
onClick={handlePaginateForward}
ariaLabel='Move forward'
/>
}
<DateRangePicker
expandToViewport={true}
onChange={handleChangeDateRange}
value={viewportToDateRange(viewport)}
showClearButton={false}
relativeOptions={relativeOptions}
isValidRange={rangeValidator({
dateRangeIncompleteError,
dateRangeInvalidError,
})}
i18nStrings={i18nStrings}
placeholder={placeholder}
/>
)}
</SpaceBetween>
</FormField>
{isPaginationEnabled && (
<Tooltip
content={`Move forward ${
viewport && 'duration' in viewport
? viewport.duration
: 'selected range'
}`}
position='bottom'
children={
<Button
iconName='caret-right-filled'
onClick={handlePaginateForward}
ariaLabel='Move forward'
/>
}
/>
)}
</SpaceBetween>
</FormField>
</div>
);
};

0 comments on commit ce5af6f

Please sign in to comment.