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.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. let src = `${basePath}${logoPathMap[themedStyle]}`
  32. if (systemFeatures.branding.enabled)
  33. src = systemFeatures.branding.workspace_logo
  34. return (
  35. <img
  36. src={src}
  37. className={classNames('block object-contain', logoSizeMap[size], className)}
  38. alt='Dify logo'
  39. />
  40. )
  41. }
  42. export default DifyLogo