Skip to content

Commit 0b78ffd

Browse files
feat: add all 800 linguist language icons (#129)
* 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 <[email protected]>
1 parent 1ba4e82 commit 0b78ffd

File tree

7 files changed

+881
-86
lines changed

7 files changed

+881
-86
lines changed

packages/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@codemirror/state": "^6.4.1",
3535
"@codemirror/view": "^6.33.0",
3636
"@hookform/resolvers": "^3.9.0",
37+
"@iconify/react": "^5.1.0",
3738
"@radix-ui/react-dropdown-menu": "^2.1.1",
3839
"@radix-ui/react-icons": "^1.3.0",
3940
"@radix-ui/react-label": "^2.1.0",

packages/web/src/app/search/components/filterPanel/index.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { cn, getRepoCodeHostInfo } from "@/lib/utils";
55
import { SetStateAction, useCallback, useEffect, useState } from "react";
66
import { Entry } from "./entry";
77
import { Filter } from "./filter";
8-
import { getLanguageIcon } from "./languageIcons";
98
import Image from "next/image";
10-
import { LaptopIcon, QuestionMarkCircledIcon } from "@radix-ui/react-icons";
9+
import { LaptopIcon } from "@radix-ui/react-icons";
10+
import { FileIcon } from "@/components/ui/fileIcon";
1111

1212
interface FilePanelProps {
1313
matches: SearchResultFile[];
@@ -58,16 +58,9 @@ export const FilterPanel = ({
5858
"Language",
5959
matches,
6060
(key) => {
61-
const iconSrc = getLanguageIcon(key);
62-
const Icon = iconSrc ? (
63-
<Image
64-
src={iconSrc}
65-
alt={key}
66-
className="w-4 h-4 flex-shrink-0"
67-
/>
68-
) : (
69-
<QuestionMarkCircledIcon className="w-4 h-4 flex-shrink-0" />
70-
);
61+
const Icon = (
62+
<FileIcon language={key} />
63+
)
7164

7265
return {
7366
key,
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use client';
2+
3+
import { getFileIconSvg } from "./fileIconSvg";
4+
import { getFileIconIconify } from "./fileIconIconify"
5+
import Image from "next/image";
6+
import { QuestionMarkCircledIcon } from "@radix-ui/react-icons";
7+
import { Icon } from '@iconify/react';
8+
9+
interface FileIconProps {
10+
language: string;
11+
}
12+
13+
export const FileIcon = ({ language }: FileIconProps) => {
14+
const iconSvg = getFileIconSvg(language);
15+
let iconifyName = null;
16+
if (!iconSvg) {
17+
iconifyName = getFileIconIconify(language);
18+
}
19+
20+
if (iconSvg) {
21+
return (
22+
<Image
23+
src={iconSvg}
24+
alt={language}
25+
className="w-4 h-4 flex-shrink-0"
26+
/>
27+
)
28+
} else if (iconifyName) {
29+
return (
30+
<Icon icon={iconifyName} className="w-4 h-4 flex-shrink-0" />
31+
)
32+
} else {
33+
return (
34+
<QuestionMarkCircledIcon className="w-4 h-4 flex-shrink-0" />
35+
)
36+
}
37+
};

0 commit comments

Comments
 (0)