mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-11 20:05:25 +00:00
* feat: add all 800 linguist language icons This uses existing svg icons for common languages, then falls back on the iconify library for the remaining 600 languages. * move icon component to ui components --------- Co-authored-by: Brendan Kellam <bshizzle1234@gmail.com>
37 lines
916 B
TypeScript
37 lines
916 B
TypeScript
'use client';
|
|
|
|
import { getFileIconSvg } from "./fileIconSvg";
|
|
import { getFileIconIconify } from "./fileIconIconify"
|
|
import Image from "next/image";
|
|
import { QuestionMarkCircledIcon } from "@radix-ui/react-icons";
|
|
import { Icon } from '@iconify/react';
|
|
|
|
interface FileIconProps {
|
|
language: string;
|
|
}
|
|
|
|
export const FileIcon = ({ language }: FileIconProps) => {
|
|
const iconSvg = getFileIconSvg(language);
|
|
let iconifyName = null;
|
|
if (!iconSvg) {
|
|
iconifyName = getFileIconIconify(language);
|
|
}
|
|
|
|
if (iconSvg) {
|
|
return (
|
|
<Image
|
|
src={iconSvg}
|
|
alt={language}
|
|
className="w-4 h-4 flex-shrink-0"
|
|
/>
|
|
)
|
|
} else if (iconifyName) {
|
|
return (
|
|
<Icon icon={iconifyName} className="w-4 h-4 flex-shrink-0" />
|
|
)
|
|
} else {
|
|
return (
|
|
<QuestionMarkCircledIcon className="w-4 h-4 flex-shrink-0" />
|
|
)
|
|
}
|
|
};
|