From aec79bd8c47fa62de73be52ae058bffe092e7c72 Mon Sep 17 00:00:00 2001 From: Andrew Prifer <2991360+AndrewPrifer@users.noreply.github.com> Date: Sun, 22 Jan 2023 20:44:22 +0100 Subject: [PATCH] Add chevron for collapsing detail rows (#383) * Add chevron for collapsing detail rows * Move collapse icon to the right of the label * Fix ugliness * Fix ugly --- .../DetailCompoundPropEditor.tsx | 66 +++++++++++++------ 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/theatre/studio/src/panels/DetailPanel/DeterminePropEditorForDetail/DetailCompoundPropEditor.tsx b/theatre/studio/src/panels/DetailPanel/DeterminePropEditorForDetail/DetailCompoundPropEditor.tsx index 325ddd1..c3c7d25 100644 --- a/theatre/studio/src/panels/DetailPanel/DeterminePropEditorForDetail/DetailCompoundPropEditor.tsx +++ b/theatre/studio/src/panels/DetailPanel/DeterminePropEditorForDetail/DetailCompoundPropEditor.tsx @@ -22,13 +22,12 @@ import {useEditingToolsForCompoundProp} from '@theatre/studio/propEditors/useEdi import type {PropHighlighted} from '@theatre/studio/panels/SequenceEditorPanel/whatPropIsHighlighted' import {whatPropIsHighlighted} from '@theatre/studio/panels/SequenceEditorPanel/whatPropIsHighlighted' import {deriver} from '@theatre/studio/utils/derive-utils' -import {getDetailRowHighlightBackground} from './getDetailRowHighlightBackground' import NumberPropEditor from '@theatre/studio/propEditors/simpleEditors/NumberPropEditor' import type {IDetailSimplePropEditorProps} from './DetailSimplePropEditor' import {useEditingToolsForSimplePropInDetailsPanel} from '@theatre/studio/propEditors/useEditingToolsForSimpleProp' -import {EllipsisFill} from '@theatre/studio/uiComponents/icons' import {usePrism} from '@theatre/react' import {val} from '@theatre/dataverse' +import {HiOutlineChevronRight} from 'react-icons/all' const Container = styled.div` --step: 15px; @@ -37,19 +36,24 @@ const Container = styled.div` --right-width: 60%; ` -const Header = deriver(styled.div<{isHighlighted: PropHighlighted}>` +const Header = styled.div<{isHighlighted: PropHighlighted}>` height: 30px; display: flex; align-items: stretch; position: relative; +` - /* background-color: ${getDetailRowHighlightBackground}; */ -`) - -const Padding = styled.div` +const Padding = styled.div<{isVectorProp: boolean}>` padding-left: ${rowIndentationFormulaCSS}; display: flex; align-items: center; + overflow: hidden; + ${({isVectorProp}) => + isVectorProp ? 'width: calc(100% - var(--right-width))' : ''}; +` + +const ControlIndicators = styled.div` + flexshrink: 0; ` const PropName = deriver(styled.div<{isHighlighted: PropHighlighted}>` @@ -63,10 +67,34 @@ const PropName = deriver(styled.div<{isHighlighted: PropHighlighted}>` &:hover { color: white; } + overflow: hidden; ${() => propNameTextCSS}; `) +const CollapseIcon = styled.span<{isCollapsed: boolean}>` + width: 28px; + height: 28px; + font-size: 9px; + display: flex; + align-items: center; + justify-content: center; + + transition: transform 0.05s ease-out, color 0.1s ease-out; + transform: rotateZ(${(props) => (props.isCollapsed ? 0 : 90)}deg); + color: #66686a; + + visibility: hidden; + ${Header}:hover & { + visibility: visible; + } + + &:hover { + transform: rotateZ(${(props) => (props.isCollapsed ? 15 : 75)}deg); + color: #c0c4c9; + } +` + const color = transparentize(0.05, `#282b2f`) const SubProps = styled.div<{depth: number; lastSubIsComposite: boolean}>` @@ -190,30 +218,26 @@ function DetailCompoundPropEditor< {contextMenu}
- - {tools.controlIndicators} + + {tools.controlIndicators} + + {propName || 'Props'} + + { box?.set(!box.get()) }} > - {propName || 'Props'} - {!isVectorProp(propConfig) && isCollapsed && ( - - )} - + + {isVectorProp(propConfig) && isCollapsed && (