feat: massive front-end overhaul and initial github release
This commit is contained in:
parent
a2b40e38bf
commit
d5a0e70580
303 changed files with 19840 additions and 676 deletions
32
src/mainview/components/SvgIcon.tsx
Normal file
32
src/mainview/components/SvgIcon.tsx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import "virtual:svg-icons/register";
|
||||
import { StaticAssetPath } from "../gen/static-icon-assets.gen";
|
||||
|
||||
type OnlySvgIcon<T extends string> = T extends `${infer Rest}.svg`
|
||||
? Rest
|
||||
: never;
|
||||
type StripSvg<T extends string> = T extends `${infer Rest}.svg` ? Rest : T;
|
||||
type ReplaceSlash<T extends string> = T extends `${infer Left}/${infer Right}`
|
||||
? `${Left}-${ReplaceSlash<Right>}`
|
||||
: T;
|
||||
type IconName<T extends string> = ReplaceSlash<StripSvg<OnlySvgIcon<T>>>;
|
||||
export type IconType = IconName<StaticAssetPath>;
|
||||
|
||||
export default function SvgIcon ({
|
||||
icon,
|
||||
prefix = "icon",
|
||||
className,
|
||||
...props
|
||||
}: {
|
||||
icon: IconType;
|
||||
prefix?: string;
|
||||
className?: string;
|
||||
})
|
||||
{
|
||||
const symbolId = `#${prefix}-${icon}`;
|
||||
|
||||
return (
|
||||
<svg className={className} {...props} aria-hidden="true">
|
||||
<use href={symbolId} />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue