Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Add chevrons to collapsible Inspector sections

JonnyBurgerb7bc9938541f
diff --git a/packages/studio/src/components/InspectorPanel/CollapsibleInspectorSectionHeader.tsx b/packages/studio/src/components/InspectorPanel/CollapsibleInspectorSectionHeader.tsx
index 61720779a3..3fc1ae235c 100644
--- a/packages/studio/src/components/InspectorPanel/CollapsibleInspectorSectionHeader.tsx
+++ b/packages/studio/src/components/InspectorPanel/CollapsibleInspectorSectionHeader.tsx
@@ -3,6 +3,8 @@ import {LIGHT_TEXT, TRANSPARENT, WHITE} from '../../helpers/colors';
import {
FOCUS_VISIBLE_ONLY_CLASS_NAME,
HOVERABLE_CLASS_NAME,
+ HOVER_GROUP_CLASS_NAME,
+ HOVER_GROUP_REVEAL_CLASS_NAME,
hoverableStyle,
} from '../../helpers/hoverable';
import {sectionHeaderRow} from './styles';
@@ -32,11 +34,14 @@ const staticSectionTitle: React.CSSProperties = {
const collapsibleSectionHeaderButton: React.CSSProperties = {
...sectionTitle,
+ alignItems: 'center',
appearance: 'none',
backgroundColor: TRANSPARENT,
border: 'none',
borderRadius: 3,
cursor: 'default',
+ display: 'flex',
+ gap: 6,
...hoverableStyle({
idleBackground: TRANSPARENT,
hoverBackground: TRANSPARENT,
@@ -45,6 +50,30 @@ const collapsibleSectionHeaderButton: React.CSSProperties = {
}),
};
+const sectionTitleLabel: React.CSSProperties = {
+ fontFamily: 'Arial, Helvetica, sans-serif',
+ fontSize: 12,
+ fontWeight: 'bold',
+ lineHeight: '16px',
+ minWidth: 0,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+};
+
+const sectionChevronContainer: React.CSSProperties = {
+ alignItems: 'center',
+ display: 'flex',
+ justifyContent: 'center',
+};
+
+const sectionChevron: React.CSSProperties = {
+ display: 'block',
+ height: 10,
+ transition: 'transform 150ms ease',
+ width: 6,
+};
+
const stopActivationKeyPropagation = (
event: React.KeyboardEvent<HTMLButtonElement>,
) => {
@@ -68,13 +97,35 @@ export const CollapsibleInspectorSectionHeader: React.FC<{
type="button"
aria-expanded={expanded}
aria-label={`${expanded ? 'Collapse' : 'Expand'} ${label}`}
- className={`__remotion-inspector-section-title ${HOVERABLE_CLASS_NAME} ${FOCUS_VISIBLE_ONLY_CLASS_NAME}`}
+ className={`__remotion-inspector-section-title ${HOVERABLE_CLASS_NAME} ${HOVER_GROUP_CLASS_NAME} ${FOCUS_VISIBLE_ONLY_CLASS_NAME}`}
onClick={onToggle}
onKeyDown={stopActivationKeyPropagation}
onKeyUp={stopActivationKeyPropagation}
style={collapsibleSectionHeaderButton}
>
- {label}
+ <span style={sectionTitleLabel}>{label}</span>
+ <span
+ aria-hidden="true"
+ className={expanded ? HOVER_GROUP_REVEAL_CLASS_NAME : undefined}
+ style={sectionChevronContainer}
+ >
+ <svg
+ viewBox="0 0 6 10"
+ style={{
+ ...sectionChevron,
+ transform: expanded ? 'rotate(90deg)' : 'rotate(0deg)',
+ }}
+ >
+ <path
+ d="M1.5 1.5L4.5 5L1.5 8.5"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1"
+ />
+ </svg>
+ </span>
</button>
)}
{action}