diff --git a/src/components/Apple.js b/src/components/Apple.js index fcc90ec..e2158ee 100644 --- a/src/components/Apple.js +++ b/src/components/Apple.js @@ -1,4 +1,4 @@ -import styled, { keyframes } from "styled-components"; +import styled, { keyframes, css } from "styled-components"; const fade = keyframes` from { transform: scale(.7) } @@ -20,7 +20,12 @@ const Apple = styled.div.attrs(({ theme, zoom }) => ({ &:after { content: "${props => (!props.died ? "🍎" : "🐛")}"; display: inline-block; - animation: ${fade} 1s ease-out alternate infinite; + animation: ${props => + props.died + ? "none" + : css` + ${fade} 1s ease-out alternate infinite + `}; } `; diff --git a/src/components/Button.js b/src/components/Button.js index 5915bd7..46adaac 100644 --- a/src/components/Button.js +++ b/src/components/Button.js @@ -31,9 +31,14 @@ const SharedStyle = () => ` } `; -const ButtonWrapper = styled.div` +const ButtonWrapper = styled.div.attrs(({ disabled }) => ({ tabIndex: disabled ? null : 0 }))` position: relative; display: inline-block; + + &:focus, + &:hover { + outline: ${({ disabled }) => (!disabled ? "1px solid silver" : "none")}; + } `; const StyledButton = styled.button` @@ -49,13 +54,16 @@ const StyledNavLink = styled(NavLink)` ${SharedStyle} `; -export const Button = (props, refs) => { +export const Button = props => { const [hover, setHover] = React.useState(false); const updatedProps = { ...props }; + const disabled = props.disabled || props.toggle; let tooltip = null; if (props.onClick) { - updatedProps.onClick = e => e.preventDefault() || props.onClick(); + updatedProps.onKeyUp = e => + !disabled && (e.which === 13 || e.which === 32) && (e.preventDefault() || props.onClick()); + updatedProps.onClick = e => (!disabled && e.preventDefault()) || props.onClick(); } if (props.href) { @@ -72,13 +80,19 @@ export const Button = (props, refs) => { if (props.icon) { return ( - setHover(true)} onMouseLeave={() => setHover(false)}> + setHover(true)} + onMouseLeave={() => setHover(false)} + onKeyUp={updatedProps.onKeyUp} + onClick={updatedProps.onClick} + disabled={disabled}> - {tooltip} + {!disabled && tooltip} ); } @@ -98,6 +112,7 @@ export const IconButton = styled(Button)` &:before { text-shadow: 0 0 1px black, 1px 1px 3px #d0bfa3; + text-shadow: 0 0 1px gray, 0 0 1px #d0bfa3; } `; diff --git a/src/components/ControlPanel.js b/src/components/ControlPanel.js index 954e1df..39e6ca8 100644 --- a/src/components/ControlPanel.js +++ b/src/components/ControlPanel.js @@ -41,9 +41,12 @@ const ThemeSelector = styled.select` '); background-repeat: no-repeat; - background-position: right 0.625rem center; + background-position: right 0 center; background-size: 1rem 1rem; outline-offset: 3px; + + &:active, + &:focus, &:hover { outline: 1px solid silver; } diff --git a/src/components/HeaderMenu.js b/src/components/HeaderMenu.js index 879e97b..12449e1 100644 --- a/src/components/HeaderMenu.js +++ b/src/components/HeaderMenu.js @@ -25,15 +25,20 @@ const MenuButton = styled(NavLink)` background: ${props => props.theme.header.menuButton.active.background}; color: ${props => props.theme.header.menuButton.active.color}; } + &:active, + &:focus, + &:hover { + outline: 1px solid silver; + } `; const HeaderMenu = () => ( - Snake + Snake - + About diff --git a/src/containers/App.js b/src/containers/App.js index 3009b49..106f683 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -1,8 +1,14 @@ import React from "react"; -import { Route, Switch } from "react-router"; // react-router v4/v5 +import { Route, Switch } from "react-router"; import { connect } from "react-redux"; import { hot } from "react-hot-loader/root"; +import { MODULE_NAME as UI_MODULE_NAME } from "../redux/ui.js"; + +import { ThemeProvider } from "styled-components"; +import { themes } from "../theming/theme.js"; +import GlobalStyle from "../theming/GlobalStyle.js"; + /* Containers */ import Header from "./Header"; import Footer from "./Footer"; @@ -10,20 +16,26 @@ import Page from "../components/Page"; import Home from "./Home"; import Snake from "./Snake"; -const App = ({ title, onNewTitle, getKeyboards, keyboards }) => ( - -
- - - - - - -