From 6520a501e386c3a9ba684129cdd18dcca5ea2fec Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Fri, 30 Aug 2019 00:27:40 -0700 Subject: [PATCH] fix: accessiblity improvements, focus states, real buttons --- app/components/Button.js | 13 ++++++++++ app/components/Editor/Editor.js | 6 +++-- app/components/NudeButton.js | 26 +++++++++++++++++++ app/components/Tab.js | 8 ++++++ app/components/Tooltip.js | 4 --- app/menus/CollectionMenu.js | 10 ++++--- app/menus/DocumentMenu.js | 18 ++++++++++--- app/menus/RevisionMenu.js | 10 ++++--- app/menus/ShareMenu.js | 10 ++++--- app/menus/UserMenu.js | 9 ++++++- .../components/MemberListItem.js | 9 ++++++- app/scenes/Document/components/Header.js | 24 ++++++++++------- .../Document/components/KeyboardShortcuts.js | 23 ++-------------- app/scenes/Invite.js | 5 +++- 14 files changed, 123 insertions(+), 52 deletions(-) create mode 100644 app/components/NudeButton.js diff --git a/app/components/Button.js b/app/components/Button.js index 94a541a95..a7daa2ee5 100644 --- a/app/components/Button.js +++ b/app/components/Button.js @@ -65,6 +65,13 @@ const RealButton = styled.button` border: 1px solid ${darken(0.15, props.theme.buttonNeutralBackground)}; } + &:focus { + transition-duration: 0.05s; + border: 1px solid ${lighten(0.4, props.theme.buttonBackground)}; + box-shadow: ${lighten(0.4, props.theme.buttonBackground)} 0px 0px + 0px 2px; + } + &:disabled { color: ${props.theme.textTertiary}; } @@ -77,6 +84,12 @@ const RealButton = styled.button` &:hover { background: ${darken(0.05, props.theme.danger)}; } + + &:focus { + transition-duration: 0.05s; + box-shadow: ${lighten(0.4, props.theme.danger)} 0px 0px + 0px 3px; + } `}; `; diff --git a/app/components/Editor/Editor.js b/app/components/Editor/Editor.js index 48c474a9a..4fa087693 100644 --- a/app/components/Editor/Editor.js +++ b/app/components/Editor/Editor.js @@ -272,8 +272,10 @@ const PrismStyles = createGlobalStyle` } `; -const EditorTooltip = props => ( - +const EditorTooltip = ({ children, ...props }) => ( + + {children} + ); export default withTheme( diff --git a/app/components/NudeButton.js b/app/components/NudeButton.js new file mode 100644 index 000000000..7a847f9df --- /dev/null +++ b/app/components/NudeButton.js @@ -0,0 +1,26 @@ +// @flow +import * as React from 'react'; +import styled from 'styled-components'; +import { lighten } from 'polished'; + +const Button = styled.button` + width: 24px; + height: 24px; + background: none; + border-radius: 4px; + line-height: 0; + border: 0; + padding: 0; + + &:focus { + transition-duration: 0.05s; + box-shadow: ${props => lighten(0.4, props.theme.buttonBackground)} 0px 0px + 0px 3px; + outline: none; + } +`; + +// $FlowFixMe - need to upgrade to get forwardRef +export default React.forwardRef((props, ref) => ( + + + )} diff --git a/app/scenes/Document/components/KeyboardShortcuts.js b/app/scenes/Document/components/KeyboardShortcuts.js index 5d82873b2..a8dceea3e 100644 --- a/app/scenes/Document/components/KeyboardShortcuts.js +++ b/app/scenes/Document/components/KeyboardShortcuts.js @@ -2,12 +2,12 @@ import * as React from 'react'; import styled from 'styled-components'; import breakpoint from 'styled-components-breakpoint'; -import { lighten } from 'polished'; import { observable } from 'mobx'; import { observer } from 'mobx-react'; import { KeyboardIcon } from 'outline-icons'; import Modal from 'components/Modal'; import Tooltip from 'components/Tooltip'; +import NudeButton from 'components/NudeButton'; import KeyboardShortcuts from 'scenes/KeyboardShortcuts'; type Props = {}; @@ -49,31 +49,12 @@ class KeyboardShortcutsButton extends React.Component { } } -const Button = styled.button` +const Button = styled(NudeButton)` display: none; position: fixed; bottom: 0; right: 0; margin: 24px; - width: 24px; - height: 24px; - opacity: 0.8; - background: none; - border-radius: 4px; - line-height: 0; - border: 0; - padding: 0; - - &:hover { - opacity: 1; - } - - &:focus { - transition-duration: 0.05s; - box-shadow: ${props => lighten(0.4, props.theme.buttonBackground)} 0px 0px - 0px 3px; - outline: none; - } ${breakpoint('tablet')` display: block; diff --git a/app/scenes/Invite.js b/app/scenes/Invite.js index b04a578f2..22a13d077 100644 --- a/app/scenes/Invite.js +++ b/app/scenes/Invite.js @@ -11,6 +11,7 @@ import Button from 'components/Button'; import Input from 'components/Input'; import HelpText from 'components/HelpText'; import Tooltip from 'components/Tooltip'; +import NudeButton from 'components/NudeButton'; import UiStore from 'stores/UiStore'; import AuthStore from 'stores/AuthStore'; @@ -124,7 +125,9 @@ class Invite extends React.Component { {index !== 0 && ( - this.handleRemove(index)} /> + this.handleRemove(index)}> + + )}