import styled from 'styles' import state, { useSelector } from 'state' import * as Panel from 'components/panel' import { useRef } from 'react' import { IconButton } from 'components/shared' import { ChevronDown, Trash2, X } from 'react-feather' import { deepCompare, deepCompareArrays, getPage, getSelectedIds, setToArray, } from 'utils' import AlignDistribute from './align-distribute' import { MoveType } from 'types' import SizePicker from './size-picker' import { ArrowDownIcon, ArrowUpIcon, AspectRatioIcon, BoxIcon, CopyIcon, EyeClosedIcon, EyeOpenIcon, LockClosedIcon, LockOpen1Icon, PinBottomIcon, PinTopIcon, RotateCounterClockwiseIcon, } from '@radix-ui/react-icons' import DashPicker from './dash-picker' import QuickColorSelect from './quick-color-select' import ColorPicker from './color-picker' import IsFilledPicker from './is-filled-picker' import QuickSizeSelect from './quick-size-select' import QuickdashSelect from './quick-dash-select' import Tooltip from 'components/tooltip' export default function StylePanel(): JSX.Element { const rContainer = useRef(null) const isOpen = useSelector((s) => s.data.settings.isStyleOpen) return ( {isOpen ? ( ) : ( <> state.send('TOGGLED_STYLE_PANEL_OPEN')} > )} ) } // This panel is going to be hard to keep cool, as we're selecting computed // information, based on the user's current selection. We might have to keep // track of this data manually within our state. function SelectedShapeStyles(): JSX.Element { const selectedIds = useSelector( (s) => setToArray(getSelectedIds(s.data)), deepCompareArrays ) const isAllLocked = useSelector((s) => { const page = getPage(s.data) return selectedIds.every((id) => page.shapes[id].isLocked) }) const isAllAspectLocked = useSelector((s) => { const page = getPage(s.data) return selectedIds.every((id) => page.shapes[id].isAspectRatioLocked) }) const isAllHidden = useSelector((s) => { const page = getPage(s.data) return selectedIds.every((id) => page.shapes[id].isHidden) }) const commonStyle = useSelector((s) => s.values.selectedStyle, deepCompare) const hasSelection = selectedIds.length > 0 return (

Style

state.send('TOGGLED_STYLE_PANEL_OPEN')} >
state.send('CHANGED_STYLE', { color })} /> state.send('CHANGED_STYLE', { isFilled })} /> state.send('DUPLICATED')} > state.send('ROTATED_CCW')} > state.send('TOGGLED_SHAPE_HIDE')} > {isAllHidden ? : } state.send('TOGGLED_SHAPE_LOCK')} > {isAllLocked ? : } state.send('TOGGLED_SHAPE_ASPECT_LOCK')} > {isAllAspectLocked ? : } state.send('MOVED', { type: MoveType.ToBack })} > state.send('MOVED', { type: MoveType.Backward })} > state.send('MOVED', { type: MoveType.Forward })} > state.send('MOVED', { type: MoveType.ToFront })} > state.send('DELETED')} > 1} hasThreeOrMore={selectedIds.length > 2} />
) } const StylePanelRoot = styled(Panel.Root, { minWidth: 1, width: 184, maxWidth: 184, overflow: 'hidden', position: 'relative', border: '1px solid $panel', boxShadow: '0px 2px 4px rgba(0,0,0,.2)', display: 'flex', alignItems: 'center', pointerEvents: 'all', variants: { isOpen: { true: {}, false: { padding: 2, width: 'fit-content', }, }, }, }) const Content = styled(Panel.Content, { padding: 8, }) const Row = styled('div', { position: 'relative', display: 'flex', width: '100%', background: 'none', border: 'none', outline: 'none', alignItems: 'center', justifyContent: 'space-between', padding: '4px 2px 4px 12px', '& label': { fontFamily: '$ui', fontSize: '$1', fontWeight: '$1', margin: 0, padding: 0, }, '& > svg': { position: 'relative', }, }) const ButtonsRow = styled('div', { position: 'relative', display: 'flex', width: '100%', background: 'none', border: 'none', cursor: 'pointer', outline: 'none', alignItems: 'center', justifyContent: 'flex-start', padding: 4, })