All files / src/components/img/MakerLogo MakerLogo.tsx

100% Statements 6/6
91.66% Branches 11/12
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85                                                              14x                                                       14x         33x 33x 1x             32x                      
import anthropic from "@lobehub/icons-static-svg/icons/anthropic.svg";
import cohere from "@lobehub/icons-static-svg/icons/cohere-color.svg";
import deepseek from "@lobehub/icons-static-svg/icons/deepseek-color.svg";
import google from "@lobehub/icons-static-svg/icons/google-color.svg";
import groq from "@lobehub/icons-static-svg/icons/groq.svg";
import mistral from "@lobehub/icons-static-svg/icons/mistral-color.svg";
import moonshot from "@lobehub/icons-static-svg/icons/moonshot.svg";
import nova from "@lobehub/icons-static-svg/icons/nova-color.svg";
import nvidia from "@lobehub/icons-static-svg/icons/nvidia-color.svg";
import openai from "@lobehub/icons-static-svg/icons/openai.svg";
import qwen from "@lobehub/icons-static-svg/icons/qwen-color.svg";
import { BrainCog } from "lucide-react";
import React from "react";
 
import { MODEL_MAKERS } from "@/objects/modelOrigin";
 
/**
 * A model maker's mark, keyed as `makerKey` keys it: a model shows its
 * maker's, never that of whoever runs it.
 *
 * The marks are LobeHub's AI brand icons (`@lobehub/icons-static-svg`, MIT;
 * each mark remains its owner's trademark, shown only to say who made a
 * model). Bundled by Vite from the imports above, so only these few ship.
 * A mono mark draws in `currentColor`, which an `<img>` resolves to black,
 * so it is inverted in dark mode.
 */
interface MakerMark {
  src: string;
  mono: boolean;
}
 
export const MAKER_LOGOS: Record<string, MakerMark> = {
  // Amazon's own mark is its cloud's, which no page names (the cloud is a
  // sub-processor, `objects/modelOrigin.ts`); Nova is the family its chat
  // models belong to.
  amazon: { src: nova, mono: false },
  anthropic: { src: anthropic, mono: true },
  cohere: { src: cohere, mono: false },
  deepseek: { src: deepseek, mono: false },
  google: { src: google, mono: false },
  groq: { src: groq, mono: true },
  local: { src: "/chain.svg", mono: false },
  mistral: { src: mistral, mono: false },
  moonshotai: { src: moonshot, mono: true },
  nvidia: { src: nvidia, mono: false },
  openai: { src: openai, mono: true },
  qwen: { src: qwen, mono: false },
};
 
export interface MakerLogoProps {
  /** The maker's key (`makerKey`). */
  maker: string;
  /** Size, as Tailwind classes (`size-5`). */
  className?: string;
  /** Beside the maker's name already (a picker's option): the mark adds
   *  nothing for a screen reader, so it is hidden from one. */
  decorative?: boolean;
}
 
const MakerLogo: React.FC<MakerLogoProps> = ({
  maker,
  className = "size-5",
  decorative = false,
}) => {
  const mark = MAKER_LOGOS[maker];
  if (!mark) {
    return (
      <BrainCog
        className={`${className} text-gray-600 dark:text-gray-300`}
        aria-hidden="true"
      />
    );
  }
  return (
    <img
      src={mark.src}
      alt={decorative ? "" : (MODEL_MAKERS[maker] ?? maker)}
      aria-hidden={decorative || undefined}
      className={mark.mono ? `${className} dark:invert` : className}
    />
  );
};
 
export default MakerLogo;