Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements in Accessibility #123

Merged
merged 6 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const Wrapper = styled.div`

const Search = ({ onChange, placeholder }) => (
<Wrapper>
<input type="text" name="dialect" onChange={onChange} placeholder={placeholder} autoComplete="off" />
<label className="sr-only" htmlFor="search"> {placeholder} </label>
<input type="text" name="dialect" onChange={onChange} placeholder={placeholder} autoComplete="off" id="search" />
<SearchIcon />
</Wrapper>
)
Expand Down
4 changes: 4 additions & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import Head from 'next/head'
import App, { Container } from 'next/app'
import { ThemeProvider } from 'styled-components'

Expand All @@ -20,6 +21,9 @@ class MyApp extends App {
const { Component, pageProps } = this.props
return (
<Container>
<Head>
<title> Dialetos Brasileiros </title>
</Head>
<GlobalStyle />
<ThemeProvider theme={theme}>
<Component {...pageProps} />
Expand Down
2 changes: 1 addition & 1 deletion pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MyDocument extends Document {

render () {
return (
<html>
<html lang="pt-br">
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charSet="utf-8" />
Expand Down
21 changes: 14 additions & 7 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react'
import { debounce } from 'throttle-debounce'
import PropTypes from 'prop-types'
import { If } from 'react-extras'
import Head from 'next/head'

import { Card, PageTitle, Navigation, Search, Loading } from '../components'
import Page from '../layouts/default'
Expand Down Expand Up @@ -64,15 +65,21 @@ class Home extends Component {
render () {
const { dialects, regionName, loading } = this.state
const { region } = this.props
const regionNameCap = regionName[0].toUpperCase() + regionName.slice(1)

return (
<Page>
<Navigation regions={region} onClick={this.handleRegionClick} />
<PageTitle title={regionName} />
<Search onChange={this.handleChange} />
<If condition={loading} render={() => <Loading />} />
<Card data={dialects} />
</Page>
<>
<Head>
<title> Dialetos Brasileiros - {regionNameCap} </title>
</Head>
<Page>
<Navigation regions={region} onClick={this.handleRegionClick} />
<PageTitle title={regionName} />
<Search onChange={this.handleChange} placeholder="Digite um dialeto" />
<If condition={loading} render={() => <Loading />} />
<Card data={dialects} />
</Page>
</>
)
}
}
Expand Down
12 changes: 12 additions & 0 deletions theme/global-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,17 @@ const GlobalStyle = createGlobalStyle`
a {
text-decoration: none;
}

/* https://cloudfour.com/thinks/see-no-evil-hidden-content-and-accessibility/ */
.sr-only {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
`
export default GlobalStyle