Skip to content

🎥 Make videos programmatically with React

Add compact toolbar tooltips

Jonny Burger5185f9c420fa
diff --git a/packages/studio/src/components/ActionTooltip.tsx b/packages/studio/src/components/ActionTooltip.tsx
index 4cff9b03da..ac7d0814a6 100644
--- a/packages/studio/src/components/ActionTooltip.tsx
+++ b/packages/studio/src/components/ActionTooltip.tsx
@@ -15,7 +15,7 @@ import {useZIndex} from '../state/z-index';
import {getPortal} from './Menu/portals';
import {SHADOW_TOWARDS_TOP} from './Menu/styles';
-const triggerStyle: React.CSSProperties = {display: 'inline-flex'};
+const defaultTriggerStyle: React.CSSProperties = {display: 'inline-flex'};
const tooltipStyle: React.CSSProperties = {
position: 'fixed',
@@ -63,8 +63,17 @@ export const ActionTooltip: React.FC<{
readonly delay: number | null;
readonly dismissOnClick: boolean;
readonly side?: 'top' | 'right';
+ readonly triggerStyle?: React.CSSProperties;
readonly children: React.ReactNode;
-}> = ({label, shortcut, delay, dismissOnClick, side = 'top', children}) => {
+}> = ({
+ label,
+ shortcut,
+ delay,
+ dismissOnClick,
+ side = 'top',
+ triggerStyle,
+ children,
+}) => {
const triggerRef = useRef<HTMLSpanElement>(null);
const tooltipRef = useRef<HTMLDivElement>(null);
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -202,7 +211,7 @@ export const ActionTooltip: React.FC<{
<>
<span
ref={triggerRef}
- style={triggerStyle}
+ style={{...defaultTriggerStyle, ...triggerStyle}}
onPointerEnter={onPointerEnter}
onPointerLeave={hide}
onPointerDownCapture={dismissOnClick ? hide : undefined}
diff --git a/packages/studio/src/components/AppLaunchButton.tsx b/packages/studio/src/components/AppLaunchButton.tsx
index d7e5f5a5e4..3c33107cbd 100644
--- a/packages/studio/src/components/AppLaunchButton.tsx
+++ b/packages/studio/src/components/AppLaunchButton.tsx
@@ -80,6 +80,7 @@ export const AppLaunchButton: React.FC<{
? defaultMainSegmentStyle
: compactMainSegmentStyle,
title,
+ tooltipLabel: null,
type: 'action',
},
...(items.length > 0
diff --git a/packages/studio/src/components/InspectorOpenInEditor.tsx b/packages/studio/src/components/InspectorOpenInEditor.tsx
index ca9b4fbdfa..6f15ee4b51 100644
--- a/packages/studio/src/components/InspectorOpenInEditor.tsx
+++ b/packages/studio/src/components/InspectorOpenInEditor.tsx
@@ -219,6 +219,7 @@ export const InspectorOpenInEditor: React.FC<{
segmentId: 'default-editor',
style: mainSegmentStyle,
title: `Open in ${defaultAppName}`,
+ tooltipLabel: null,
type: 'action',
},
];
diff --git a/packages/studio/src/components/PreviewToolbarOverflowButton.tsx b/packages/studio/src/components/PreviewToolbarOverflowButton.tsx
index 639911cdbf..2256a7f4e3 100644
--- a/packages/studio/src/components/PreviewToolbarOverflowButton.tsx
+++ b/packages/studio/src/components/PreviewToolbarOverflowButton.tsx
@@ -9,6 +9,7 @@ import {CheckerboardContext} from '../state/checkerboard';
import {EditorShowGuidesContext} from '../state/editor-guides';
import {EditorShowOutlinesContext} from '../state/editor-outlines';
import {EditorShowRulersContext} from '../state/editor-rulers';
+import {ActionTooltip} from './ActionTooltip';
import type {RenderInlineAction} from './InlineAction';
import {InlineDropdown} from './InlineDropdown';
import {toggleLoop} from './LoopToggle';
@@ -249,12 +250,19 @@ export const PreviewToolbarOverflowButton: React.FC<{
}
return (
- <InlineDropdown
- variant={null}
- renderAction={renderAction}
- values={values}
- title="More actions"
- unhoveredColor={WHITE_ALPHA_80}
- />
+ <ActionTooltip
+ label="View options"
+ shortcut={null}
+ delay={800}
+ dismissOnClick
+ >
+ <InlineDropdown
+ variant={null}
+ renderAction={renderAction}
+ values={values}
+ aria-label="View options"
+ unhoveredColor={WHITE_ALPHA_80}
+ />
+ </ActionTooltip>
);
};
diff --git a/packages/studio/src/components/RenderButton.tsx b/packages/studio/src/components/RenderButton.tsx
index 0abe3f23dd..cdb76ee158 100644
--- a/packages/studio/src/components/RenderButton.tsx
+++ b/packages/studio/src/components/RenderButton.tsx
@@ -401,7 +401,8 @@ const RenderButtonInner: React.FC<{
controlSize === 'compact'
? compactMainSegmentStyle
: defaultMainSegmentStyle,
- title: tooltip,
+ title: showRenderLabel ? tooltip : null,
+ tooltipLabel: showRenderLabel ? null : renderLabel,
type: 'action',
},
{
@@ -462,7 +463,7 @@ const RenderButtonInner: React.FC<{
<SegmentedButton
segments={segments}
style={segmentedButtonStyle}
- title={tooltip}
+ title={showRenderLabel ? tooltip : null}
/>
</>
);
diff --git a/packages/studio/src/components/SegmentedButton.tsx b/packages/studio/src/components/SegmentedButton.tsx
index 05ca6ce737..cce35859b1 100644
--- a/packages/studio/src/components/SegmentedButton.tsx
+++ b/packages/studio/src/components/SegmentedButton.tsx
@@ -15,6 +15,7 @@ import {
import {useMobileLayout} from '../helpers/mobile-layout';
import {noop} from '../helpers/noop';
import {HigherZIndex, useZIndex} from '../state/z-index';
+import {ActionTooltip} from './ActionTooltip';
import {MENU_INITIATOR_CLASSNAME} from './Menu/is-menu-item';
import {getPortal} from './Menu/portals';
import {
@@ -44,6 +45,7 @@ export type SegmentedButtonSegment = SegmentedButtonSegmentCommon &
| {
readonly onClick: React.MouseEventHandler<HTMLButtonElement>;
readonly onPointerDown: React.PointerEventHandler<HTMLButtonElement> | null;
+ readonly tooltipLabel: string | null;
readonly type: 'action';
}
| {
@@ -87,6 +89,8 @@ const segmentStyle: React.CSSProperties = {
whiteSpace: 'nowrap',
};
+const tooltipTriggerStyle: React.CSSProperties = {height: '100%'};
+
const getSegmentBorderRadius = ({
index,
segmentCount,
@@ -174,7 +178,7 @@ const SegmentedButtonAction: React.FC<{
[segment],
);
- return (
+ const button = (
<button
aria-label={segment.ariaLabel}
className={`${HOVERABLE_CLASS_NAME} ${FOCUS_VISIBLE_ONLY_CLASS_NAME}`}
@@ -191,6 +195,22 @@ const SegmentedButtonAction: React.FC<{
{segment.renderContent(CURRENT_COLOR)}
</button>
);
+
+ if (segment.tooltipLabel === null) {
+ return button;
+ }
+
+ return (
+ <ActionTooltip
+ label={segment.tooltipLabel}
+ shortcut={null}
+ delay={800}
+ dismissOnClick
+ triggerStyle={tooltipTriggerStyle}
+ >
+ {button}
+ </ActionTooltip>
+ );
};
const SegmentedButtonMenu: React.FC<{