|
| 1 | +import { Chip, cn } from '@sim/emcn' |
| 2 | +import { Upload } from '@sim/emcn/icons' |
| 3 | +import { EmptyState } from '@/components/empty-state/empty-state' |
| 4 | +import { EmptyStateDocsLink } from '@/app/workspace/[workspaceId]/components/resource/components/resource-empty-state/docs-link' |
| 5 | + |
| 6 | +const FILES_DOCS_URL = 'https://docs.sim.ai/files' |
| 7 | + |
| 8 | +/** |
| 9 | + * Hairline contours, matching the tables grid's 1px `--border-1` rules and the |
| 10 | + * knowledge mark's thinned strokes — the graphics sit one nav item apart, so a |
| 11 | + * heavier outline here would read as a different illustration system. |
| 12 | + * |
| 13 | + * Fills stay near the top of the surface ramp for the same reason: the border |
| 14 | + * draws the folder and the fill only has to separate one layer from the next. A |
| 15 | + * solid mid-grey body made this the heaviest thing on the page. |
| 16 | + */ |
| 17 | +const HAIRLINE = { |
| 18 | + stroke: 'var(--border-1)', |
| 19 | + strokeWidth: 1.1, |
| 20 | + strokeLinejoin: 'round' as const, |
| 21 | +} as const |
| 22 | + |
| 23 | +const FOLDER_BACK = [ |
| 24 | + 'M 22 34', |
| 25 | + 'H 66', |
| 26 | + 'Q 72 34 75.5 38', |
| 27 | + 'L 82.5 46', |
| 28 | + 'Q 86 50 92 50', |
| 29 | + 'H 178', |
| 30 | + 'Q 188 50 188 60', |
| 31 | + 'V 140', |
| 32 | + 'Q 188 150 178 150', |
| 33 | + 'H 22', |
| 34 | + 'Q 12 150 12 140', |
| 35 | + 'V 44', |
| 36 | + 'Q 12 34 22 34', |
| 37 | + 'Z', |
| 38 | +].join(' ') |
| 39 | + |
| 40 | +/** |
| 41 | + * Dissolves upward, so the folder rises out of the page while its front panel |
| 42 | + * stays crisp where the copy begins. Running it the other way — the direction the |
| 43 | + * logs feed fades — ate the panel's base and left the tab hanging. |
| 44 | + */ |
| 45 | +const FOLDER_FADE = |
| 46 | + '[-webkit-mask-image:linear-gradient(to_top,#000_58%,transparent_100%)] [mask-image:linear-gradient(to_top,#000_58%,transparent_100%)]' |
| 47 | + |
| 48 | +/** |
| 49 | + * A folder held open with sheets standing proud of its front panel. |
| 50 | + * |
| 51 | + * Depth is carried by the surface ramp rather than by shadow: the back panel is the |
| 52 | + * darkest tier, the sheets the lightest, the front panel between them. Shadows |
| 53 | + * would need separate light and dark recipes; the ramp inverts on its own. |
| 54 | + * |
| 55 | + * Every outer corner shares the same 10-unit radius so the silhouette reads as a |
| 56 | + * single drawn shape — mixing radii makes the corners fight each other at this size. |
| 57 | + */ |
| 58 | +function FilesGraphic() { |
| 59 | + return ( |
| 60 | + <svg |
| 61 | + viewBox='0 0 200 160' |
| 62 | + width={185} |
| 63 | + height={148} |
| 64 | + fill='none' |
| 65 | + aria-hidden='true' |
| 66 | + focusable='false' |
| 67 | + className={cn('block max-w-none shrink-0', FOLDER_FADE)} |
| 68 | + > |
| 69 | + <path d={FOLDER_BACK} fill='var(--surface-4)' {...HAIRLINE} /> |
| 70 | + |
| 71 | + <rect x='34' y='56' width='132' height='84' rx='5' fill='var(--surface-2)' {...HAIRLINE} /> |
| 72 | + <rect x='26' y='64' width='148' height='76' rx='5' fill='var(--surface-2)' {...HAIRLINE} /> |
| 73 | + |
| 74 | + <rect x='12' y='74' width='176' height='76' rx='10' fill='var(--surface-2)' {...HAIRLINE} /> |
| 75 | + </svg> |
| 76 | + ) |
| 77 | +} |
| 78 | + |
| 79 | +interface FilesEmptyStateProps { |
| 80 | + /** Opens the file picker — the same action the header's upload chip runs. */ |
| 81 | + onUpload: () => void |
| 82 | + /** Mirrors the header chip's disabled state: no edit rights, or an upload in flight. */ |
| 83 | + uploadDisabled?: boolean |
| 84 | +} |
| 85 | + |
| 86 | +/** Empty state for the files list when the workspace has none. */ |
| 87 | +export function FilesEmptyState({ onUpload, uploadDisabled = false }: FilesEmptyStateProps) { |
| 88 | + return ( |
| 89 | + <EmptyState |
| 90 | + graphic={<FilesGraphic />} |
| 91 | + title='Files' |
| 92 | + description='Upload files to share them across your team and every agent.' |
| 93 | + action={ |
| 94 | + <> |
| 95 | + <Chip variant='primary' onClick={onUpload} disabled={uploadDisabled} leftIcon={Upload}> |
| 96 | + Upload |
| 97 | + </Chip> |
| 98 | + <EmptyStateDocsLink href={FILES_DOCS_URL} /> |
| 99 | + </> |
| 100 | + } |
| 101 | + /> |
| 102 | + ) |
| 103 | +} |
0 commit comments