improve usability of selection styling

main
Mike Fix 5 years ago
parent 36930c8cf2
commit f43eda1214
No known key found for this signature in database
GPG Key ID: 1D85E862314CA79F

@ -454,6 +454,11 @@ class Editor extends React.Component {
.toolbar-second-row > :global(div:not(:last-of-type)) { .toolbar-second-row > :global(div:not(:last-of-type)) {
margin-right: 0.5rem; margin-right: 0.5rem;
} }
#style-editor-button {
display: flex;
align-items: center;
}
`} `}
</style> </style>
</div> </div>

@ -3,11 +3,8 @@ import { useKeyboardListener } from 'actionsack'
import Popout from './Popout' import Popout from './Popout'
import Button from './Button' import Button from './Button'
import ColorPicker from './ColorPicker' import ColorPicker from './ColorPicker'
import ThemeIcon from './svg/Theme'
import { COLORS } from '../lib/constants' import { COLORS } from '../lib/constants'
const styleEditorButtonStyle = { width: 28, maxWidth: 28, height: 28, borderRadius: '50%' }
function ModifierButton(props) { function ModifierButton(props) {
return ( return (
<Button <Button
@ -54,10 +51,9 @@ function reducer(state, action) {
} }
function SelectionEditor({ onChange }) { function SelectionEditor({ onChange }) {
const [visible, setVisible] = React.useState(false) const [open, setOpen] = React.useState(false)
const [open, setOpen] = React.useState(true)
useKeyboardListener('Escape', () => setVisible(false)) useKeyboardListener('Escape', () => setOpen(false))
const [state, dispatch] = React.useReducer(reducer, { const [state, dispatch] = React.useReducer(reducer, {
bold: false, bold: false,
@ -72,18 +68,6 @@ function SelectionEditor({ onChange }) {
return ( return (
<div style={{ position: 'relative' }}> <div style={{ position: 'relative' }}>
<Button
title="Style Menu"
border
center
selected={visible}
style={styleEditorButtonStyle}
margin="6px 0 0"
onClick={() => setVisible(v => !v)}
>
<ThemeIcon />
</Button>
<Popout hidden={!visible} pointerLeft="9px">
<div className="colorizer"> <div className="colorizer">
<div className="modifier"> <div className="modifier">
<ModifierButton selected={state.bold} onClick={() => dispatch({ type: 'BOLD' })}> <ModifierButton selected={state.bold} onClick={() => dispatch({ type: 'BOLD' })}>
@ -100,7 +84,7 @@ function SelectionEditor({ onChange }) {
</ModifierButton> </ModifierButton>
<button className="color-square" onClick={() => setOpen(o => !o)} /> <button className="color-square" onClick={() => setOpen(o => !o)} />
</div> </div>
{open && ( <Popout hidden={!open} pointerLeft="16px" style={{ left: 82 }}>
<div className="color-picker-container"> <div className="color-picker-container">
<ColorPicker <ColorPicker
color={state.color || COLORS.PRIMARY} color={state.color || COLORS.PRIMARY}
@ -108,7 +92,7 @@ function SelectionEditor({ onChange }) {
onChange={d => dispatch({ type: 'COLOR', color: d.hex })} onChange={d => dispatch({ type: 'COLOR', color: d.hex })}
/> />
</div> </div>
)} </Popout>
</div> </div>
<style jsx> <style jsx>
{` {`
@ -123,7 +107,7 @@ function SelectionEditor({ onChange }) {
font-style: italic; font-style: italic;
} }
.colorizer :global(button) { .colorizer :global(button) {
min-width: 24px; min-width: 20px;
} }
.color-square { .color-square {
cursor: pointer; cursor: pointer;
@ -142,7 +126,6 @@ function SelectionEditor({ onChange }) {
} }
`} `}
</style> </style>
</Popout>
</div> </div>
) )
} }

Loading…
Cancel
Save