feat: keyboard accessibility in navbar

This commit is contained in:
Kyle Gill
2019-03-29 11:35:05 -06:00
parent f3ac895199
commit 7eaa6b6046
5 changed files with 44 additions and 17 deletions

View File

@@ -17,19 +17,24 @@ const IconBase = styled.div`
display: flex;
justify-content: center;
align-items: center;
background-color: none;
background-color: transparent;
border-radius: 12px;
padding: 5px;
transition: 0.1s all ease-in-out;
color: ${props => props.theme.colors.secondary};
&:focus {
outline: none;
box-shadow: 0 0 0 3px ${props => props.theme.colors.bodyBackground},
0 0 0 5px ${props => props.theme.colors.hover};
}
&:hover {
background-color: ${props => !props.disabled && props.theme.colors.hover};
cursor: pointer;
}
`
const Icon = ({ name, ...rest }) => (
<IconBase {...rest}>
const Icon = ({ name, tabindex, ...rest }) => (
<IconBase tabIndex={tabindex} {...rest}>
{name === "Book" && <Book />}
{name === "Calendar" && <Calendar />}
{name === "ChevronLeft" && <ChevronLeft />}

View File

@@ -70,13 +70,15 @@ const Navbar = ({ authUser, theme, toggleTheme }) => (
<Link to={yearUrl()}>
<Icon name="Calendar" />
</Link>
<Icon
onClick={() => toggleTheme()}
name={theme.name === "Dark" ? "Sun" : "Moon"}
/>
<Link to={"/user"}>
<Icon name="User" />
</Link>
<Icon
tabindex={0}
onClick={() => toggleTheme()}
onKeyPress={() => toggleTheme()}
name={theme.name === "Dark" ? "Sun" : "Moon"}
/>
</React.Fragment>
) : (
<React.Fragment>

View File

@@ -1,5 +1,6 @@
import React, { Component } from "react"
import styled from "@emotion/styled"
import { css, keyframes } from "@emotion/core"
import { compose } from "recompose"
import { withRouter } from "react-router-dom"
import { withTheme } from "emotion-theming"
@@ -31,7 +32,7 @@ const JournalEntryArea = styled.textarea`
resize: none;
outline: none;
font-size: ${SIZES.small};
border-radius: 3px;
border-radius: 1px;
margin-top: ${SIZES.tiny};
padding-top: 0px;
padding-bottom: 0px;
@@ -43,6 +44,18 @@ const JournalEntryArea = styled.textarea`
0 0 0 10px ${props => props.theme.colors.hover};
}
`
const fadeKeyFrames = keyframes`
from {
opacity: 0;
}
to {
opacity: 1;
}
`
const LoadingSpinner = styled(BeatLoader)`
opacity: 0;
animation: fadein 2s;
`
const AUTOSAVE_DELAY = 2000
@@ -165,7 +178,14 @@ class Day extends Component {
{loading ? (
// <JournalEntryArea disabled placeholder="Loading..." />
<div style={{ marginTop: 10 }}>
<BeatLoader color={theme.colors.tertiary} size={10} margin="4px" />
<LoadingSpinner
color={theme.colors.tertiary}
size={10}
margin="4px"
css={css`
animation: ${fadeKeyFrames} 1s ease-in;
`}
/>
</div>
) : (
<JournalEntryArea

View File

@@ -31,7 +31,7 @@ class LoginFormBase extends Component {
.doSignInWithEmailAndPassword(email, password)
.then(() => {
this.setState({ email: "", password: "", error: null })
this.props.history.push(format(new Date(), "/YYYY/MM/DD"))
this.props.history.push(format(new Date(), "/"))
})
.catch(error => {
this.setState({ error })