Skip to content

Commit 5f04bd4

Browse files
committed
cleanup, best practices
1 parent 8ff0417 commit 5f04bd4

10 files changed

Lines changed: 198 additions & 174 deletions

File tree

apps/sim/app/chat/components/message/components/markdown-renderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const COMPONENTS = {
115115
),
116116

117117
blockquote: ({ children }: React.HTMLAttributes<HTMLQuoteElement>) => (
118-
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 font-sans text-[var(--text-primary)] italic [&>p]:my-2 [&>p:first-child]:mt-0 [&>p:last-child]:mb-0'>
118+
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 font-sans text-[var(--text-primary)] italic [&>p:first-child]:mt-0 [&>p:last-child]:mb-0 [&>p]:my-2'>
119119
{children}
120120
</blockquote>
121121
),

apps/sim/app/workspace/[workspaceId]/files/components/action-bar/action-bar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import { domAnimation, LazyMotion, m } from 'framer-motion'
44
import { Button, Download, Tooltip, Trash2 } from '@/components/emcn'
55
import { Folder } from '@/components/emcn/icons'
6+
import { cn } from '@/lib/core/utils/cn'
67

78
interface FilesActionBarProps {
89
selectedCount: number
910
onDownload?: () => void
1011
onMove?: () => void
1112
onDelete?: () => void
1213
isLoading?: boolean
14+
className?: string
1315
}
1416

1517
export function FilesActionBar({
@@ -18,6 +20,7 @@ export function FilesActionBar({
1820
onMove,
1921
onDelete,
2022
isLoading = false,
23+
className,
2124
}: FilesActionBarProps) {
2225
if (selectedCount === 0) return null
2326

@@ -28,7 +31,7 @@ export function FilesActionBar({
2831
animate={{ opacity: 1, y: 0 }}
2932
exit={{ opacity: 0, y: 10 }}
3033
transition={{ duration: 0.2 }}
31-
className='-translate-x-1/2 fixed bottom-6 left-1/2 z-50 transform'
34+
className={cn('-translate-x-1/2 fixed bottom-6 left-1/2 z-50 transform', className)}
3235
>
3336
<div className='flex items-center gap-2 rounded-[10px] border border-[var(--border)] bg-[var(--surface-2)] px-2 py-1.5'>
3437
<span className='px-1 text-[var(--text-secondary)] text-small'>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'use client'
2+
3+
import { memo } from 'react'
4+
import { Button, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader } from '@/components/emcn'
5+
6+
interface DeleteConfirmModalProps {
7+
open: boolean
8+
onOpenChange: (open: boolean) => void
9+
fileName?: string
10+
fileCount: number
11+
folderCount: number
12+
onDelete: () => void
13+
isPending: boolean
14+
}
15+
16+
export const DeleteConfirmModal = memo(function DeleteConfirmModal({
17+
open,
18+
onOpenChange,
19+
fileName,
20+
fileCount,
21+
folderCount,
22+
onDelete,
23+
isPending,
24+
}: DeleteConfirmModalProps) {
25+
const totalCount = fileCount + folderCount
26+
const hasFolders = folderCount > 0
27+
const title = totalCount > 1 ? 'Delete Items' : hasFolders ? 'Delete Folder' : 'Delete File'
28+
const consequence = hasFolders
29+
? totalCount > 1
30+
? 'This will also delete files and folders inside any selected folders.'
31+
: 'This will also delete files and folders inside it.'
32+
: 'You can restore it from Recently Deleted in Settings.'
33+
34+
return (
35+
<Modal open={open} onOpenChange={onOpenChange}>
36+
<ModalContent size='sm'>
37+
<ModalHeader>{title}</ModalHeader>
38+
<ModalBody>
39+
<p className='text-[var(--text-secondary)]'>
40+
Are you sure you want to delete{' '}
41+
<span className='font-medium text-[var(--text-primary)]'>{fileName}</span>?{' '}
42+
{consequence}
43+
</p>
44+
</ModalBody>
45+
<ModalFooter>
46+
<Button variant='default' onClick={() => onOpenChange(false)} disabled={isPending}>
47+
Cancel
48+
</Button>
49+
<Button variant='destructive' onClick={onDelete} disabled={isPending}>
50+
{isPending ? 'Deleting...' : 'Delete'}
51+
</Button>
52+
</ModalFooter>
53+
</ModalContent>
54+
</Modal>
55+
)
56+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { DeleteConfirmModal } from './delete-confirm-modal'
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
'use client'
2+
3+
import { memo } from 'react'
4+
import {
5+
Download,
6+
DropdownMenu,
7+
DropdownMenuContent,
8+
DropdownMenuItem,
9+
DropdownMenuSeparator,
10+
DropdownMenuTrigger,
11+
Eye,
12+
Pencil,
13+
Trash2,
14+
} from '@/components/emcn'
15+
16+
interface FileRowContextMenuProps {
17+
isOpen: boolean
18+
position: { x: number; y: number }
19+
onClose: () => void
20+
onOpen: () => void
21+
onDownload?: () => void
22+
onRename: () => void
23+
onDelete: () => void
24+
canEdit: boolean
25+
}
26+
27+
export const FileRowContextMenu = memo(function FileRowContextMenu({
28+
isOpen,
29+
position,
30+
onClose,
31+
onOpen,
32+
onDownload,
33+
onRename,
34+
onDelete,
35+
canEdit,
36+
}: FileRowContextMenuProps) {
37+
return (
38+
<DropdownMenu open={isOpen} onOpenChange={(open) => !open && onClose()} modal={false}>
39+
<DropdownMenuTrigger asChild>
40+
<div
41+
style={{
42+
position: 'fixed',
43+
left: `${position.x}px`,
44+
top: `${position.y}px`,
45+
width: '1px',
46+
height: '1px',
47+
pointerEvents: 'none',
48+
}}
49+
tabIndex={-1}
50+
aria-hidden
51+
/>
52+
</DropdownMenuTrigger>
53+
<DropdownMenuContent
54+
align='start'
55+
side='bottom'
56+
sideOffset={4}
57+
onCloseAutoFocus={(e) => e.preventDefault()}
58+
>
59+
<DropdownMenuItem onSelect={onOpen}>
60+
<Eye />
61+
Open
62+
</DropdownMenuItem>
63+
{onDownload && (
64+
<DropdownMenuItem onSelect={onDownload}>
65+
<Download />
66+
Download
67+
</DropdownMenuItem>
68+
)}
69+
{canEdit && (
70+
<>
71+
<DropdownMenuSeparator />
72+
<DropdownMenuItem onSelect={onRename}>
73+
<Pencil />
74+
Rename
75+
</DropdownMenuItem>
76+
<DropdownMenuItem onSelect={onDelete}>
77+
<Trash2 />
78+
Delete
79+
</DropdownMenuItem>
80+
</>
81+
)}
82+
</DropdownMenuContent>
83+
</DropdownMenu>
84+
)
85+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { FileRowContextMenu } from './file-row-context-menu'

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function CalloutBlock({ type, children }: { type: string; children?: React.React
263263
const config = CALLOUT_CONFIG[type]
264264
if (!config) {
265265
return (
266-
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p]:my-2 [&>p:first-child]:mt-0 [&>p:last-child]:mb-0'>
266+
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p:first-child]:mt-0 [&>p:last-child]:mb-0 [&>p]:my-2'>
267267
{children}
268268
</blockquote>
269269
)
@@ -605,7 +605,7 @@ const STATIC_MARKDOWN_COMPONENTS = {
605605
return <CalloutBlock type={calloutType}>{children}</CalloutBlock>
606606
}
607607
return (
608-
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p]:my-2 [&>p:first-child]:mt-0 [&>p:last-child]:mb-0'>
608+
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p:first-child]:mt-0 [&>p:last-child]:mb-0 [&>p]:my-2'>
609609
{children}
610610
</blockquote>
611611
)

0 commit comments

Comments
 (0)