improve menu bar tab-navigating

main
Mike Fix 6 years ago committed by Michael Fix
parent f5f53f17d6
commit 1a2bb3f6d7

@ -3,6 +3,7 @@ import colornames from 'colornames'
import ImagePicker from './ImagePicker' import ImagePicker from './ImagePicker'
import ColorPicker from './ColorPicker' import ColorPicker from './ColorPicker'
import Button from './Button'
import Popout, { managePopout } from './Popout' import Popout, { managePopout } from './Popout'
import { COLORS, DEFAULT_BG_COLOR } from '../lib/constants' import { COLORS, DEFAULT_BG_COLOR } from '../lib/constants'
import { capitalize, stringifyRGBA } from '../lib/util' import { capitalize, stringifyRGBA } from '../lib/util'
@ -31,12 +32,17 @@ class BackgroundSelect extends React.PureComponent {
return ( return (
<div className="bg-select-container"> <div className="bg-select-container">
<div className={`bg-select-display ${isVisible ? 'is-visible' : ''}`}> <Button
<div role="button" tabIndex={0} className="bg-color-container" onClick={toggleVisibility}> border
<div className="bg-color-alpha" /> center
<div className="bg-color" /> selected={isVisible}
</div> className={`bg-select-display ${isVisible ? 'is-visible' : ''}`}
</div> onClick={toggleVisibility}
>
<div className="bg-color-alpha" />
<div className="bg-color" />
</Button>
<Popout <Popout
id="bg-select-pickers" id="bg-select-pickers"
pointerLeft="15px" pointerLeft="15px"
@ -71,26 +77,19 @@ class BackgroundSelect extends React.PureComponent {
height: 100%; height: 100%;
} }
.bg-select-display { .bg-select-container :global(.bg-select-display) {
display: flex; position: relative;
overflow: hidden; overflow: hidden;
height: 100%; height: 100%;
width: 40px; width: 40px;
border: 1px solid ${COLORS.SECONDARY}; border: 1px solid ${COLORS.SECONDARY};
border-radius: 3px;
} }
.bg-select-display.is-visible { .bg-select-container :global(.bg-select-display.is-visible),
.bg-select-container :global(.bg-select-display:focus) {
border-width: 2px; border-width: 2px;
} }
.bg-color-container {
position: relative;
width: 100%;
background: #fff;
cursor: pointer;
}
.bg-color { .bg-color {
position: absolute; position: absolute;
top: 0px; top: 0px;

@ -5,6 +5,7 @@ import { COLORS } from '../lib/constants'
const Button = ({ const Button = ({
id, id,
onClick = () => {}, onClick = () => {},
onBlur,
className = '', className = '',
background = COLORS.BLACK, background = COLORS.BLACK,
color = COLORS.SECONDARY, color = COLORS.SECONDARY,
@ -21,7 +22,14 @@ const Button = ({
padding = 0, padding = 0,
margin = 0 margin = 0
}) => ( }) => (
<button id={id} onClick={onClick} className={className} disabled={disabled} style={style}> <button
id={id}
onClick={onClick}
onBlur={onBlur}
className={className}
disabled={disabled}
style={style}
>
{children} {children}
<style jsx> <style jsx>
{` {`
@ -48,6 +56,10 @@ const Button = ({
background-color: ${hoverBackground} !important; background-color: ${hoverBackground} !important;
color: ${hoverColor || color}; color: ${hoverColor || color};
} }
button:focus {
box-shadow: ${border ? `inset 0px 0px 0px 2px ${color}` : 'initial'};
}
`} `}
</style> </style>
</button> </button>

@ -212,7 +212,8 @@ const SelectedItem = ({
border-radius: ${hasIcon ? '0 3px 3px 0' : '3px'}; border-radius: ${hasIcon ? '0 3px 3px 0' : '3px'};
outline: none; outline: none;
} }
.dropdown-display:hover { .dropdown-display:hover,
.dropdown-display:focus {
background: ${COLORS.HOVER}; background: ${COLORS.HOVER};
} }

Loading…
Cancel
Save