Use a different color when a keyframe is selected AND the inline editor popup is open

This commit is contained in:
Fülöp Kovács 2022-06-08 13:22:10 +02:00 committed by Fülöp
parent 5ce01e8350
commit 6c943e176d

View file

@ -35,15 +35,32 @@ const DOT_HOVER_SIZE_PX = DOT_SIZE_PX + 5
const dotTheme = { const dotTheme = {
normalColor: '#40AAA4', normalColor: '#40AAA4',
selectedColor: '#F2C95C', selectedColor: '#F2C95C',
selectedAndPopOverOpen: '#E08318',
} }
const selectBacgroundForDiamond = ({
isSelected,
isInlineEditorPopoverOpen,
}: IDiamond) => {
if (isSelected && isInlineEditorPopoverOpen) {
return dotTheme.selectedAndPopOverOpen
} else if (isSelected) {
return dotTheme.selectedColor
} else if (isInlineEditorPopoverOpen) {
return dotTheme.selectedColor
} else {
return dotTheme.normalColor
}
}
type IDiamond = {isSelected: boolean; isInlineEditorPopoverOpen: boolean}
/** The keyframe diamond ◆ */ /** The keyframe diamond ◆ */
const Diamond = styled.div<{isSelected: boolean}>` const Diamond = styled.div<IDiamond>`
position: absolute; position: absolute;
${absoluteDims(DOT_SIZE_PX)} ${absoluteDims(DOT_SIZE_PX)}
background: ${(props) => background: ${(props) => selectBacgroundForDiamond(props)};
props.isSelected ? dotTheme.selectedColor : dotTheme.normalColor};
transform: rotateZ(45deg); transform: rotateZ(45deg);
z-index: 1; z-index: 1;
@ -71,7 +88,7 @@ const SingleKeyframeDot: React.VFC<ISingleKeyframeDotProps> = (props) => {
const [ref, node] = useRefAndState<HTMLDivElement | null>(null) const [ref, node] = useRefAndState<HTMLDivElement | null>(null)
const [contextMenu] = useSingleKeyframeContextMenu(node, logger, props) const [contextMenu] = useSingleKeyframeContextMenu(node, logger, props)
const [inlineEditorPopover, openEditor, _, isOpen] = const [inlineEditorPopover, openEditor, _, isInlineEditorPopoverOpen] =
useSingleKeyframeInlineEditorPopover(props) useSingleKeyframeInlineEditorPopover(props)
const [isDragging] = useDragForSingleKeyframeDot(node, props, { const [isDragging] = useDragForSingleKeyframeDot(node, props, {
onClickFromDrag(dragStartEvent) { onClickFromDrag(dragStartEvent) {
@ -82,7 +99,10 @@ const SingleKeyframeDot: React.VFC<ISingleKeyframeDotProps> = (props) => {
return ( return (
<> <>
<HitZone ref={ref} /> <HitZone ref={ref} />
<Diamond isSelected={!!props.selection || isOpen} /> <Diamond
isSelected={!!props.selection}
isInlineEditorPopoverOpen={isInlineEditorPopoverOpen}
/>
{inlineEditorPopover} {inlineEditorPopover}
{contextMenu} {contextMenu}
</> </>