|
1 | | -import type { ComponentType, SVGProps } from "react" |
| 1 | +import type { SVGProps } from "react" |
2 | 2 |
|
3 | | -import Ballerina from "./ballerina.svg?svgr" |
4 | | -import CNet from "./c-net.svg?svgr" |
5 | | -import Clojure from "./clojure.svg?svgr" |
6 | | -import Elixir from "./elixir.svg?svgr" |
7 | | -import Elm from "./elm.svg?svgr" |
8 | | -import Flutter from "./flutter.svg?svgr" |
9 | | -import GoIcon from "./go.svg?svgr" |
10 | | -import Haskell from "./haskell.svg?svgr" |
11 | | -import JavaKotlinAndroid from "./java-kotlin-android.svg?svgr" |
12 | | -import Javascript from "./javascript.svg?svgr" |
13 | | -import Julia from "./julia.svg?svgr" |
14 | | -import LanguageSupport from "./language-support.svg?svgr" |
15 | | -import Php from "./php.svg?svgr" |
16 | | -import Python from "./python.svg?svgr" |
17 | | -import Ruby from "./ruby.svg?svgr" |
18 | | -import Rust from "./rust.svg?svgr" |
19 | | -import Scala from "./scala.svg?svgr" |
20 | | -import SwiftObjectiveCIos from "./swift-objective-c-ios.svg?svgr" |
| 3 | +const sprite = new URL("./sprite.svg", import.meta.url).href |
21 | 4 |
|
22 | | -export const icons = { |
23 | | - ballerina: Ballerina, |
24 | | - "c-net": CNet, |
25 | | - clojure: Clojure, |
26 | | - elixir: Elixir, |
27 | | - elm: Elm, |
28 | | - flutter: Flutter, |
29 | | - go: GoIcon, |
30 | | - haskell: Haskell, |
31 | | - "java-kotlin-android": JavaKotlinAndroid, |
32 | | - javascript: Javascript, |
33 | | - julia: Julia, |
34 | | - "language-support": LanguageSupport, |
35 | | - php: Php, |
36 | | - python: Python, |
37 | | - ruby: Ruby, |
38 | | - rust: Rust, |
39 | | - scala: Scala, |
40 | | - "swift-objective-c-ios": SwiftObjectiveCIos, |
41 | | -} satisfies Record<string, ComponentType<SVGProps<SVGElement>>> |
| 5 | +export type IconName = |
| 6 | + | "ballerina" |
| 7 | + | "c-net" |
| 8 | + | "clojure" |
| 9 | + | "elixir" |
| 10 | + | "elm" |
| 11 | + | "flutter" |
| 12 | + | "go" |
| 13 | + | "haskell" |
| 14 | + | "java" |
| 15 | + | "javascript" |
| 16 | + | "julia" |
| 17 | + | "multiplatform" |
| 18 | + | "php" |
| 19 | + | "python" |
| 20 | + | "ruby" |
| 21 | + | "rust" |
| 22 | + | "scala" |
| 23 | + | "swift" |
| 24 | + |
| 25 | +interface IconProps extends SVGProps<SVGSVGElement> { |
| 26 | + icon: IconName |
| 27 | +} |
| 28 | + |
| 29 | +export function Icon({ icon, ...props }: IconProps) { |
| 30 | + return ( |
| 31 | + <svg {...props}> |
| 32 | + <use href={`${sprite}#${icon}`} /> |
| 33 | + </svg> |
| 34 | + ) |
| 35 | +} |
0 commit comments