hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import chevronDown from "pixelarticons/svg/chevron-down.svg?raw"; |
| 2 | import chevronUp from "pixelarticons/svg/chevron-up.svg?raw"; |
| 3 | import checkDouble from "pixelarticons/svg/check-double.svg?raw"; |
| 4 | import checkboxOn from "pixelarticons/svg/checkbox-on.svg?raw"; |
| 5 | import bookOpen from "pixelarticons/svg/book-open.svg?raw"; |
| 6 | import calendarWeeks from "pixelarticons/svg/calendar-weeks.svg?raw"; |
| 7 | import crown from "pixelarticons/svg/crown.svg?raw"; |
| 8 | import fire from "pixelarticons/svg/fire.svg?raw"; |
| 9 | import hourglass from "pixelarticons/svg/hourglass.svg?raw"; |
| 10 | import lock from "pixelarticons/svg/lock.svg?raw"; |
| 11 | import messageText from "pixelarticons/svg/message-text.svg?raw"; |
| 12 | import notes from "pixelarticons/svg/notes.svg?raw"; |
| 13 | import penSquare from "pixelarticons/svg/pen-square.svg?raw"; |
| 14 | import pencil from "pixelarticons/svg/pencil.svg?raw"; |
| 15 | import sparkles from "pixelarticons/svg/sparkles.svg?raw"; |
| 16 | import star from "pixelarticons/svg/star.svg?raw"; |
| 17 | import trophy from "pixelarticons/svg/trophy.svg?raw"; |
| 18 | import users from "pixelarticons/svg/users.svg?raw"; |
| 19 | import zap from "pixelarticons/svg/zap.svg?raw"; |
| 20 | import { cn } from "@/lib/cn"; |
| 21 | |
| 22 | // Pixel-art glyphs from pixelarticons (MIT, https://pixelarticons.com). Only |
| 23 | // the handful the profile uses are imported, so the rest never reach a bundle. |
| 24 | const ICONS = { |
| 25 | "book-open": bookOpen, |
| 26 | "calendar-weeks": calendarWeeks, |
| 27 | "check-double": checkDouble, |
| 28 | "chevron-down": chevronDown, |
| 29 | "chevron-up": chevronUp, |
| 30 | "checkbox-on": checkboxOn, |
| 31 | crown, |
| 32 | fire, |
| 33 | hourglass, |
| 34 | lock, |
| 35 | "message-text": messageText, |
| 36 | notes, |
| 37 | "pen-square": penSquare, |
| 38 | pencil, |
| 39 | sparkles, |
| 40 | star, |
| 41 | trophy, |
| 42 | users, |
| 43 | zap, |
| 44 | } as const; |
| 45 | |
| 46 | export type PixelIconName = keyof typeof ICONS; |
| 47 | |
| 48 | const sized = (svg: string) => |
| 49 | svg |
| 50 | .replace(/\s(?:width|height)="[^"]*"/g, "") |
| 51 | .replace("<svg", '<svg aria-hidden="true" focusable="false" shape-rendering="crispEdges"'); |
| 52 | |
| 53 | export function PixelIcon(props: { name: PixelIconName; class?: string }) { |
| 54 | return <span class={cn("inline-block shrink-0 [&>svg]:h-full [&>svg]:w-full", props.class ?? "h-4 w-4")} innerHTML={sized(ICONS[props.name])} />; |
| 55 | } |