From afcfeaf0ac59f41570b40dd6938c5ba82a802528 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 9 Aug 2019 14:25:25 -0700 Subject: [PATCH] Improve template Accessibility (#12891) Add aria-label to table to give title --- .../src/app/counter/counter.component.html | 2 +- .../app/fetch-data/fetch-data.component.html | 4 +- .../ClientApp/src/components/Counter.js | 8 +- .../ClientApp/src/components/FetchData.js | 4 +- .../ClientApp/src/components/Counter.tsx | 6 +- .../ClientApp/src/components/FetchData.tsx | 124 +++++++++--------- 6 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/ClientApp/src/app/counter/counter.component.html b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/ClientApp/src/app/counter/counter.component.html index d37b212c4c..89b9c80ff8 100644 --- a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/ClientApp/src/app/counter/counter.component.html +++ b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/ClientApp/src/app/counter/counter.component.html @@ -2,6 +2,6 @@

This is a simple example of an Angular component.

-

Current count: {{ currentCount }}

+

Current count: {{ currentCount }}

diff --git a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/ClientApp/src/app/fetch-data/fetch-data.component.html b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/ClientApp/src/app/fetch-data/fetch-data.component.html index cd33b58a5c..19b3835dbf 100644 --- a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/ClientApp/src/app/fetch-data/fetch-data.component.html +++ b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/ClientApp/src/app/fetch-data/fetch-data.component.html @@ -1,10 +1,10 @@ -

Weather forecast

+

Weather forecast

This component demonstrates fetching data from the server.

Loading...

- +
diff --git a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/ClientApp/src/components/Counter.js b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/ClientApp/src/components/Counter.js index 734887d18f..9a4ec746ba 100644 --- a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/ClientApp/src/components/Counter.js +++ b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/ClientApp/src/components/Counter.js @@ -3,26 +3,26 @@ import React, { Component } from 'react'; export class Counter extends Component { static displayName = Counter.name; - constructor (props) { + constructor(props) { super(props); this.state = { currentCount: 0 }; this.incrementCounter = this.incrementCounter.bind(this); } - incrementCounter () { + incrementCounter() { this.setState({ currentCount: this.state.currentCount + 1 }); } - render () { + render() { return (

Counter

This is a simple example of a React component.

-

Current count: {this.state.currentCount}

+

Current count: {this.state.currentCount}

diff --git a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/ClientApp/src/components/FetchData.js b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/ClientApp/src/components/FetchData.js index 4782540e3b..d1a9f910d0 100644 --- a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/ClientApp/src/components/FetchData.js +++ b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/ClientApp/src/components/FetchData.js @@ -17,7 +17,7 @@ export class FetchData extends Component { static renderForecastsTable(forecasts) { return ( -
Date
+
@@ -47,7 +47,7 @@ export class FetchData extends Component { return (
-

Weather forecast

+

Weather forecast

This component demonstrates fetching data from the server.

{contents}
diff --git a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/ClientApp/src/components/Counter.tsx b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/ClientApp/src/components/Counter.tsx index a31720c44b..82fde952e6 100644 --- a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/ClientApp/src/components/Counter.tsx +++ b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/ClientApp/src/components/Counter.tsx @@ -17,11 +17,11 @@ class Counter extends React.PureComponent {

This is a simple example of a React component.

-

Current count: {this.props.count}

+

Current count: {this.props.count}

diff --git a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/ClientApp/src/components/FetchData.tsx b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/ClientApp/src/components/FetchData.tsx index c177f0bc67..9fed830288 100644 --- a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/ClientApp/src/components/FetchData.tsx +++ b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/ClientApp/src/components/FetchData.tsx @@ -7,78 +7,78 @@ import * as WeatherForecastsStore from '../store/WeatherForecasts'; // At runtime, Redux will merge together... type WeatherForecastProps = - WeatherForecastsStore.WeatherForecastsState // ... state we've requested from the Redux store - & typeof WeatherForecastsStore.actionCreators // ... plus action creators we've requested - & RouteComponentProps<{ startDateIndex: string }>; // ... plus incoming routing parameters + WeatherForecastsStore.WeatherForecastsState // ... state we've requested from the Redux store + & typeof WeatherForecastsStore.actionCreators // ... plus action creators we've requested + & RouteComponentProps<{ startDateIndex: string }>; // ... plus incoming routing parameters class FetchData extends React.PureComponent { - // This method is called when the component is first added to the document - public componentDidMount() { - this.ensureDataFetched(); - } + // This method is called when the component is first added to the document + public componentDidMount() { + this.ensureDataFetched(); + } - // This method is called when the route parameters change - public componentDidUpdate() { - this.ensureDataFetched(); - } + // This method is called when the route parameters change + public componentDidUpdate() { + this.ensureDataFetched(); + } - public render() { - return ( - -

Weather forecast

-

This component demonstrates fetching data from the server and working with URL parameters.

- { this.renderForecastsTable() } - { this.renderPagination() } -
- ); - } + public render() { + return ( + +

Weather forecast

+

This component demonstrates fetching data from the server and working with URL parameters.

+ {this.renderForecastsTable()} + {this.renderPagination()} +
+ ); + } - private ensureDataFetched() { - const startDateIndex = parseInt(this.props.match.params.startDateIndex, 10) || 0; - this.props.requestWeatherForecasts(startDateIndex); - } + private ensureDataFetched() { + const startDateIndex = parseInt(this.props.match.params.startDateIndex, 10) || 0; + this.props.requestWeatherForecasts(startDateIndex); + } - private renderForecastsTable() { - return ( -
Date
- - - - - - - - - - {this.props.forecasts.map((forecast: WeatherForecastsStore.WeatherForecast) => - - - - - - - )} - -
DateTemp. (C)Temp. (F)Summary
{forecast.date}{forecast.temperatureC}{forecast.temperatureF}{forecast.summary}
- ); - } + private renderForecastsTable() { + return ( + + + + + + + + + + + {this.props.forecasts.map((forecast: WeatherForecastsStore.WeatherForecast) => + + + + + + + )} + +
DateTemp. (C)Temp. (F)Summary
{forecast.date}{forecast.temperatureC}{forecast.temperatureF}{forecast.summary}
+ ); + } - private renderPagination() { - const prevStartDateIndex = (this.props.startDateIndex || 0) - 5; - const nextStartDateIndex = (this.props.startDateIndex || 0) + 5; + private renderPagination() { + const prevStartDateIndex = (this.props.startDateIndex || 0) - 5; + const nextStartDateIndex = (this.props.startDateIndex || 0) + 5; - return ( -
- Previous - {this.props.isLoading && Loading...} - Next -
- ); - } + return ( +
+ Previous + {this.props.isLoading && Loading...} + Next +
+ ); + } } export default connect( - (state: ApplicationState) => state.weatherForecasts, // Selects which state properties are merged into the component's props - WeatherForecastsStore.actionCreators // Selects which action creators are merged into the component's props + (state: ApplicationState) => state.weatherForecasts, // Selects which state properties are merged into the component's props + WeatherForecastsStore.actionCreators // Selects which action creators are merged into the component's props )(FetchData as any);