All files / packages/components/src icons.web.tsx

100% Statements 4/4
100% Branches 4/4
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127                                                                                                      332x                                                                                                                         332x 38770x 38770x                        
import type React from "react";
 
import {
	ArrowDown,
	ArrowDown01,
	ArrowDown10,
	ArrowLeft,
	ArrowLeftFromLine,
	ArrowLeftRight,
	ArrowRight,
	ArrowRightFromLine,
	ChartCandlestick,
	Check,
	ChevronDown,
	CircleOff,
	Coins,
	Ellipsis,
	Eye,
	EyeOff,
	HandCoins,
	Inbox,
	Info,
	KeyRound,
	Link,
	ListFilter,
	LogIn,
	Minus,
	Moon,
	Pencil,
	Plus,
	ReceiptText,
	RefreshCw,
	RefreshCwOff,
	Search,
	Send,
	Settings,
	ShieldUser,
	Sun,
	Trash,
	TriangleAlert,
	Unlink,
	UserPen,
	UserRound,
	UserRoundPlus,
	UserStar,
	UsersRound,
	X,
} from "lucide-react";
 
import { cn } from "~components/utils";
 
const mapping = {
	refresh: RefreshCw,
	sync: RefreshCw,
	unsync: RefreshCwOff,
	incoming: ArrowLeftFromLine,
	outcoming: ArrowRightFromLine,
	debts: HandCoins,
	add: Plus,
	link: Link,
	pencil: Pencil,
	unlink: Unlink,
	receipt: ReceiptText,
	send: Send,
	zero: CircleOff,
	info: Info,
	filter: ListFilter,
	admin: ShieldUser,
	key: KeyRound,
	money: Coins,
	transfer: ArrowLeftRight,
	search: Search,
	editor: UserPen,
	owner: UserStar,
	viewer: UserRound,
	warning: TriangleAlert,
	trash: Trash,
	check: Check,
	close: X,
	inbox: Inbox,
	minus: Minus,
	plus: Plus,
	moon: Moon,
	sun: Sun,
	users: UsersRound,
	user: UserRound,
	"arrow-left": ArrowLeft,
	"arrow-right": ArrowRight,
	"arrow-down": ArrowDown,
	"chevron-down": ChevronDown,
	settings: Settings,
	login: LogIn,
	register: UserRoundPlus,
	"sort-down": ArrowDown10,
	"sort-up": ArrowDown01,
	exchange: ChartCandlestick,
	eye: Eye,
	"eye-off": EyeOff,
	ellipsis: Ellipsis,
} satisfies Record<string, typeof ArrowLeft>;
 
export type IconName = keyof typeof mapping;
 
export type Props = Pick<
	React.ComponentProps<(typeof mapping)["eye"]>,
	"className"
> & {
	onClick?: () => void;
	name: IconName;
	testID?: string;
};
 
export const Icon = ({ name, className, testID, ...props }: Props) => {
	const Component = mapping[name];
	return (
		<Component
			data-testid={testID ?? `${name}-icon`}
			className={cn(
				"shrink-0",
				props.onClick ? "cursor-pointer" : undefined,
				className,
			)}
			{...props}
		/>
	);
};