|
| 1 | +import { EmptyState } from '@/components/empty-state/empty-state' |
| 2 | +import { |
| 3 | + Bar, |
| 4 | + Vignette, |
| 5 | +} from '@/app/workspace/[workspaceId]/components/resource/components/resource-empty-state/vignette' |
| 6 | + |
| 7 | +/** |
| 8 | + * A document fanning into the chunks it is embedded as — the moment that makes a |
| 9 | + * knowledge base a knowledge base, drawn in the editor vignette's connector |
| 10 | + * language (6px-radius smooth steps in `--workflow-edge`). |
| 11 | + */ |
| 12 | +const CHUNK_EDGE_PATHS = [ |
| 13 | + 'M190,80 H207 Q213,80 213,74 V52 Q213,46 219,46 H236', |
| 14 | + 'M190,80 H236', |
| 15 | + 'M190,80 H207 Q213,80 213,86 V108 Q213,114 219,114 H236', |
| 16 | +] as const |
| 17 | + |
| 18 | +function KnowledgeGraphic() { |
| 19 | + return ( |
| 20 | + <Vignette> |
| 21 | + <svg className='absolute inset-0' fill='none' viewBox='0 0 320 148' width='320' height='148'> |
| 22 | + <defs> |
| 23 | + <linearGradient |
| 24 | + id='knowledge-empty-edge' |
| 25 | + x1='190' |
| 26 | + y1='0' |
| 27 | + x2='236' |
| 28 | + y2='0' |
| 29 | + gradientUnits='userSpaceOnUse' |
| 30 | + > |
| 31 | + <stop stopColor='var(--workflow-edge)' /> |
| 32 | + <stop offset='1' stopColor='var(--workflow-edge)' /> |
| 33 | + </linearGradient> |
| 34 | + </defs> |
| 35 | + {CHUNK_EDGE_PATHS.map((d) => ( |
| 36 | + <path |
| 37 | + key={d} |
| 38 | + d={d} |
| 39 | + stroke='url(#knowledge-empty-edge)' |
| 40 | + strokeWidth='1.5' |
| 41 | + strokeLinecap='round' |
| 42 | + strokeLinejoin='round' |
| 43 | + /> |
| 44 | + ))} |
| 45 | + </svg> |
| 46 | + |
| 47 | + <span className='absolute top-[22px] left-[78px] h-[92px] w-[124px] rounded-[8px] border border-[var(--border-1)] bg-[var(--surface-1)] opacity-40' /> |
| 48 | + <span className='absolute top-[28px] left-[72px] h-[92px] w-[124px] rounded-[8px] border border-[var(--border-1)] bg-[var(--surface-2)] opacity-70' /> |
| 49 | + |
| 50 | + <div className='absolute top-[34px] left-[66px] h-[92px] w-[124px] rounded-[8px] border border-[var(--border-1)] bg-[var(--surface-2)]'> |
| 51 | + <div className='flex items-center gap-2 px-3 pt-3 pb-2.5'> |
| 52 | + <span className='size-[14px] shrink-0 rounded-[4px] bg-[var(--surface-5)]' /> |
| 53 | + <Bar className='h-2 w-[62px]' /> |
| 54 | + </div> |
| 55 | + <div className='space-y-[7px] px-3'> |
| 56 | + <Bar className='h-2 w-[98px]' /> |
| 57 | + <Bar className='h-2 w-[84px]' /> |
| 58 | + <span className='block h-2 w-[92px] rounded-[3px] bg-[color-mix(in_srgb,var(--brand-knowledge)_26%,transparent)]' /> |
| 59 | + <Bar className='h-2 w-[70px]' /> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + |
| 63 | + {[35, 69, 103].map((top, index) => ( |
| 64 | + <span |
| 65 | + key={top} |
| 66 | + className='absolute left-[236px] size-[22px] rounded-[6px] border border-[var(--border-1)] bg-[var(--surface-3)]' |
| 67 | + style={{ top }} |
| 68 | + > |
| 69 | + <span |
| 70 | + className='absolute inset-[5px] rounded-[3px]' |
| 71 | + style={{ |
| 72 | + background: |
| 73 | + index === 1 |
| 74 | + ? 'color-mix(in srgb, var(--brand-knowledge) 34%, transparent)' |
| 75 | + : 'var(--surface-5)', |
| 76 | + }} |
| 77 | + /> |
| 78 | + </span> |
| 79 | + ))} |
| 80 | + </Vignette> |
| 81 | + ) |
| 82 | +} |
| 83 | + |
| 84 | +/** Empty state for the knowledge bases list when the workspace has none. */ |
| 85 | +export function KnowledgeEmptyState() { |
| 86 | + return ( |
| 87 | + <EmptyState |
| 88 | + graphic={<KnowledgeGraphic />} |
| 89 | + title='No knowledge bases yet' |
| 90 | + description='Upload documents to give your agents a memory they can search.' |
| 91 | + /> |
| 92 | + ) |
| 93 | +} |
0 commit comments