You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dify-logo.tsx 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 'use client'
  2. import type { FC } from 'react'
  3. import classNames from '@/utils/classnames'
  4. import useTheme from '@/hooks/use-theme'
  5. import { basePath } from '@/utils/var'
  6. import { useGlobalPublicStore } from '@/context/global-public-context'
  7. export type LogoStyle = 'default' | 'monochromeWhite'
  8. export const logoPathMap: Record<LogoStyle, string> = {
  9. default: '/logo/logo.svg',
  10. monochromeWhite: '/logo/logo-monochrome-white.svg',
  11. }
  12. export type LogoSize = 'large' | 'medium' | 'small'
  13. export const logoSizeMap: Record<LogoSize, string> = {
  14. large: 'w-16 h-7',
  15. medium: 'w-12 h-[22px]',
  16. small: 'w-9 h-4',
  17. }
  18. type DifyLogoProps = {
  19. style?: LogoStyle
  20. size?: LogoSize
  21. className?: string
  22. }
  23. const DifyLogo: FC<DifyLogoProps> = ({
  24. style = 'default',
  25. size = 'medium',
  26. className,
  27. }) => {
  28. const { theme } = useTheme()
  29. const themedStyle = (theme === 'dark' && style === 'default') ? 'monochromeWhite' : style
  30. const { systemFeatures } = useGlobalPublicStore()
  31. const hasBrandingLogo = Boolean(systemFeatures.branding.enabled && systemFeatures.branding.workspace_logo)
  32. let src = `${basePath}${logoPathMap[themedStyle]}`
  33. if (hasBrandingLogo)
  34. src = systemFeatures.branding.workspace_logo
  35. return (
  36. <img
  37. src={src}
  38. className={classNames('block object-contain', logoSizeMap[size], hasBrandingLogo && 'w-auto', className)}
  39. alt={hasBrandingLogo ? 'Logo' : 'Dify logo'}
  40. />
  41. )
  42. }
  43. export default DifyLogo