Skip to content

Commit b467d75

Browse files
committed
feat(settings): add video tooltip previews for canvas settings
1 parent 77eafab commit b467d75

File tree

4 files changed

+88
-2
lines changed

4 files changed

+88
-2
lines changed

apps/sim/app/workspace/[workspaceId]/settings/components/general/general.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
ModalFooter,
1717
ModalHeader,
1818
Switch,
19+
Tooltip,
1920
} from '@/components/emcn'
2021
import { signOut, useSession } from '@/lib/auth/auth-client'
2122
import { ANONYMOUS_USER_ID } from '@/lib/auth/constants'
@@ -375,7 +376,20 @@ export function General() {
375376
</div>
376377

377378
<div className='flex items-center justify-between'>
378-
<Label htmlFor='auto-connect'>Auto-connect on drop</Label>
379+
<Tooltip.Root>
380+
<Tooltip.Trigger asChild>
381+
<Label htmlFor='auto-connect' className='cursor-help'>
382+
Auto-connect on drop
383+
</Label>
384+
</Tooltip.Trigger>
385+
<Tooltip.Content side='bottom' align='start'>
386+
<p>Automatically connect blocks when dropped near each other</p>
387+
<Tooltip.Preview
388+
src='/tooltips/auto-connect-on-drop.mp4'
389+
alt='Auto-connect on drop example'
390+
/>
391+
</Tooltip.Content>
392+
</Tooltip.Root>
379393
<Switch
380394
id='auto-connect'
381395
checked={settings?.autoConnect ?? true}
@@ -384,7 +398,20 @@ export function General() {
384398
</div>
385399

386400
<div className='flex items-center justify-between'>
387-
<Label htmlFor='error-notifications'>Workflow error notifications</Label>
401+
<Tooltip.Root>
402+
<Tooltip.Trigger asChild>
403+
<Label htmlFor='error-notifications' className='cursor-help'>
404+
Canvas error notifications
405+
</Label>
406+
</Tooltip.Trigger>
407+
<Tooltip.Content side='bottom' align='start'>
408+
<p>Show error popups on blocks when a workflow run fails</p>
409+
<Tooltip.Preview
410+
src='/tooltips/canvas-error-notification.mp4'
411+
alt='Canvas error notification example'
412+
/>
413+
</Tooltip.Content>
414+
</Tooltip.Root>
388415
<Switch
389416
id='error-notifications'
390417
checked={settings?.errorNotificationsEnabled ?? true}

apps/sim/components/emcn/components/tooltip/tooltip.tsx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,69 @@ const Shortcut = ({ keys, className, children }: ShortcutProps) => (
8989
)
9090
Shortcut.displayName = 'Tooltip.Shortcut'
9191

92+
interface PreviewProps {
93+
/** The URL of the image, GIF, or video to display */
94+
src: string
95+
/** Alt text for the media */
96+
alt?: string
97+
/** Width of the preview in pixels */
98+
width?: number
99+
/** Height of the preview in pixels */
100+
height?: number
101+
/** Optional additional class names */
102+
className?: string
103+
}
104+
105+
const VIDEO_EXTENSIONS = ['.mp4', '.webm', '.ogg', '.mov'] as const
106+
107+
/**
108+
* Displays a preview image, GIF, or video within tooltip content.
109+
*
110+
* @example
111+
* ```tsx
112+
* <Tooltip.Content>
113+
* <p>Canvas error notifications</p>
114+
* <Tooltip.Preview src="/tooltips/canvas-error-notification.mp4" alt="Error notification example" />
115+
* </Tooltip.Content>
116+
* ```
117+
*/
118+
const Preview = ({ src, alt = '', width = 240, height, className }: PreviewProps) => {
119+
const isVideo = VIDEO_EXTENSIONS.some((ext) => src.toLowerCase().endsWith(ext))
120+
121+
return (
122+
<div className={cn('mt-[4px] overflow-hidden rounded-[3px]', className)}>
123+
{isVideo ? (
124+
<video
125+
src={src}
126+
width={width}
127+
height={height}
128+
className='block max-w-full'
129+
autoPlay
130+
loop
131+
muted
132+
playsInline
133+
aria-label={alt}
134+
/>
135+
) : (
136+
<img
137+
src={src}
138+
alt={alt}
139+
width={width}
140+
height={height}
141+
className='block max-w-full'
142+
loading='lazy'
143+
/>
144+
)}
145+
</div>
146+
)
147+
}
148+
Preview.displayName = 'Tooltip.Preview'
149+
92150
export const Tooltip = {
93151
Root,
94152
Trigger,
95153
Content,
96154
Provider,
97155
Shortcut,
156+
Preview,
98157
}
16.6 KB
Binary file not shown.
58.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)