Skip to content

Commit

Permalink
Fixing accessibility issues according to lighthouse (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
devinmatte authored Jul 7, 2023
1 parent 812b1ce commit c604513
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const DownloadButton: React.FC<DownloadButtonProps> = ({
<CSVLink
className={'csv-link'}
data={data}
title={'Download data as CSV'}
filename={filename(datasetName, location, bothStops, startDate, endDate)}
>
<FontAwesomeIcon icon={faFileArrowDown} className="text-stone-600" />
Expand Down
2 changes: 1 addition & 1 deletion common/components/charts/AggregateLineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ChartjsPluginWatermark from 'chartjs-plugin-watermark';
import type { AggregateDataPoint, AggregateLineProps } from '../../types/charts';
import { prettyDate } from '../../utils/date';
import { CHART_COLORS } from '../../../common/constants/colors';
import { DownloadButton } from '../general/DownloadButton';
import { DownloadButton } from '../buttons/DownloadButton';
import { useBreakpoint } from '../../hooks/useBreakpoint';
import { watermarkLayout } from '../../constants/charts';
import { writeError } from '../../utils/chartError';
Expand Down
2 changes: 1 addition & 1 deletion common/components/charts/SingleDayLineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CHART_COLORS, COLORS, LINE_COLORS } from '../../../common/constants/col
import type { SingleDayLineProps } from '../../../common/types/charts';
import { prettyDate } from '../../utils/date';
import { useDelimitatedRoute } from '../../utils/router';
import { DownloadButton } from '../general/DownloadButton';
import { DownloadButton } from '../buttons/DownloadButton';
import { useBreakpoint } from '../../hooks/useBreakpoint';
import { watermarkLayout } from '../../constants/charts';
import { writeError } from '../../utils/chartError';
Expand Down
2 changes: 1 addition & 1 deletion common/components/general/WidgetCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const WidgetCarousel: FC<WidgetCarouselProps> = ({ children, isSingleWidg
className={classNames(
'group/button flex cursor-pointer items-center justify-center rounded-md focus:outline-none lg:p-1'
)}
aria-label={'Next Statistic'}
title={'Next Statistic'}
onClick={navigateTo(activeItem + 1)}
type="button"
>
Expand Down
2 changes: 1 addition & 1 deletion common/components/graphics/LoadingSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const LoadingSpinner: React.FC<LoadingSpinnerProps> = ({ isWidget }) => {
const { line } = useDelimitatedRoute();
return (
<div
role="status"
role={'status'}
className={`absolute bottom-0 left-0 right-0 top-0 flex h-auto w-auto items-center justify-center rounded-md ${
isWidget && 'bg-white bg-opacity-90'
}`}
Expand Down
8 changes: 6 additions & 2 deletions common/components/widgets/StationSelectorWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ export const StationSelectorWidget: React.FC<StationSelectorWidgetProps> = ({ li
toStation={toStation}
setStation={(stationId) => updateStations('to', stationId)}
/>
<Button onClick={() => updateStations('swap')} additionalClasses="shrink-0 w-fit">
<FontAwesomeIcon icon={faRightLeft} className="h-4 w-4" />
<Button
onClick={() => updateStations('swap')}
title={'Swap Stations'}
additionalClasses={'shrink-0 w-fit'}
>
<FontAwesomeIcon icon={faRightLeft} className={'h-4 w-4'} />
</Button>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion modules/navigation/BusNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const BusNavMenu: React.FC<BusNavMenuProps> = ({ setSidebarOpen }) => {
return (
<>
<BusSelection setSidebarOpen={setSidebarOpen} />
<div className="flex flex-col gap-y-3 px-1">
<div className="flex flex-col gap-y-3 px-1" role={'navigation'}>
<SidebarTabs tabs={BUS_OVERVIEW} setSidebarOpen={setSidebarOpen} />
<SidebarTabs tabs={TRIP_PAGES} setSidebarOpen={setSidebarOpen} />
</div>
Expand Down
4 changes: 3 additions & 1 deletion modules/navigation/BusSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ export const BusSelection: React.FC<BusSelectionProps> = ({ setSidebarOpen }) =>
return (
<Tab.Group
manual
aria-label={'Bus Routes'}
selectedIndex={busRoutes.findIndex((key) => key === route.query.busRoute)}
onChange={handleChange}
>
<Tab.List className="relative grid grid-cols-3 gap-2">
{busRoutes.map((key) => {
const selected = route.query.busRoute === key;
return (
<Tab key={key}>
<Tab key={key} aria-label={key}>
<Link
href={getBusRouteSelectionItemHref(key, route)}
onClick={handleChange}
key={key}
aria-label={key}
className={classNames(
'flex w-full cursor-pointer items-center justify-center rounded-md border border-mbta-bus bg-mbta-bus px-2 py-1 text-sm font-medium',
selected
Expand Down
2 changes: 1 addition & 1 deletion modules/navigation/SideNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const SideNavigation: React.FC<SideNavigationProps> = ({ setSidebarOpen }
const { tab } = useDelimitatedRoute();
return (
<nav className="flex flex-1 flex-col pb-3 md:px-4 md:pb-0 md:pt-5">
<ul role="list" className="flex flex-1 flex-col gap-y-4">
<ul role={'navigation'} className="flex flex-1 flex-col gap-y-4">
<DashboardSelection />
{getNavMenu(tab)}
</ul>
Expand Down
4 changes: 2 additions & 2 deletions modules/navigation/SidebarTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const SidebarTabs: React.FC<SidebarTabs> = ({ tabs, setSidebarOpen }) =>
};

return (
<div className="rounded-md bg-white bg-opacity-5 p-1">
<ul role="list" className="space-y-1">
<div className="rounded-md bg-white bg-opacity-5 p-1" role={'navigation'}>
<ul className="space-y-1">
{tabs.map((tab: PageMetadata) => {
const enabled = line ? tab.lines.includes(line) : true;
const selected = page === tab.key;
Expand Down
2 changes: 1 addition & 1 deletion modules/navigation/SubwayNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const LINE_ITEMS = [
export const SubwayNavMenu: React.FC<SubwayNavMenuProps> = ({ setSidebarOpen }) => (
<>
<LineSelection lineItems={LINE_ITEMS} setSidebarOpen={setSidebarOpen} />
<div className="flex flex-col gap-y-3 px-1">
<div className="flex flex-col gap-y-3 px-1" role={'navigation'}>
<SidebarTabs tabs={LINE_PAGES} setSidebarOpen={setSidebarOpen} />
<SidebarTabs tabs={TRIP_PAGES} setSidebarOpen={setSidebarOpen} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion modules/navigation/SystemNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface SystemNavMenuProps {
}
export const SystemNavMenu = ({ setSidebarOpen }: SystemNavMenuProps) => {
return (
<div className="flex flex-col gap-y-2 px-1">
<div className="flex flex-col gap-y-2 px-1" role={'navigation'}>
<SidebarTabs tabs={LANDING_PAGE} setSidebarOpen={setSidebarOpen} />
<SidebarTabs tabs={SYSTEM_SLOWZONES_PAGE} setSidebarOpen={setSidebarOpen} />
</div>
Expand Down

0 comments on commit c604513

Please sign in to comment.