Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.6 KB
Raw Blame
'use client'

import type { AvatarSize } from '@langgenius/dify-ui/avatar'
import { Avatar, AvatarFallback } from '@langgenius/dify-ui/avatar'
import { cn } from '@langgenius/dify-ui/cn'
import { getAvatarInitial } from '@/utils/avatar'

export type WorkspaceAvatarSize = Extract<AvatarSize, 'xs' | 'sm' | 'lg' | '2xl'>

const workspaceAvatarClasses: Record<WorkspaceAvatarSize, { root: string; text: string }> = {
  xs: { root: 'rounded-md', text: 'text-[10px] leading-3' },
  sm: { root: 'rounded-md', text: 'text-[13px] leading-4' },
  lg: { root: 'rounded-lg', text: 'text-base leading-5' },
  '2xl': { root: 'rounded-xl', text: 'text-xl leading-7' },
}

export function WorkspaceAvatar({
  name,
  size = 'sm',
  className,
}: {
  name?: string
  size?: WorkspaceAvatarSize
  className?: string
}) {
  return (
    <Avatar
      aria-hidden="true"
      size={size}
      className={cn('shadow-xs', workspaceAvatarClasses[size].root, className)}
    >
      <AvatarFallback
        className={cn(
          'border border-divider-regular bg-components-icon-bg-orange-dark-solid bg-linear-to-br from-components-avatar-bg-mask-stop-0 to-components-avatar-bg-mask-stop-100 p-1',
        )}
      >
        <span
          className={cn(
            'bg-linear-to-r from-components-avatar-shape-fill-stop-0 to-components-avatar-shape-fill-stop-100 bg-clip-text font-semibold text-shadow-shadow-1 text-transparent uppercase opacity-90',
            workspaceAvatarClasses[size].text,
          )}
        >
          {getAvatarInitial(name)}
        </span>
      </AvatarFallback>
    </Avatar>
  )
}