Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

9.4 KB
Raw Blame
import type { Icon as PhosphorIcon } from "@phosphor-icons/react";
import type * as React from "react";
import {
	ArrowClockwiseIcon,
	ArrowCounterClockwiseIcon,
	ArrowDownIcon,
	ArrowLeftIcon,
	ArrowRightIcon,
	ArrowsClockwiseIcon,
	ArrowsDownUpIcon,
	ArrowsInLineVerticalIcon,
	ArrowsInSimpleIcon,
	ArrowsLeftRightIcon,
	ArrowsOutSimpleIcon,
	ArrowSquareOutIcon,
	ArrowUpIcon,
	ArrowUpRightIcon,
	ArrowUUpLeftIcon,
	ArrowUUpRightIcon,
	BellIcon,
	BookmarkSimpleIcon,
	BookOpenIcon,
	BookOpenTextIcon,
	BooksIcon,
	BracketsCurlyIcon,
	BrainIcon,
	BriefcaseIcon,
	BugIcon,
	CalendarBlankIcon,
	CalendarDotIcon,
	CalendarDotsIcon,
	CalendarPlusIcon,
	CameraPlusIcon,
	CaretDownIcon,
	CaretLeftIcon,
	CaretRightIcon,
	ChartLineUpIcon,
	ChatCenteredTextIcon,
	ChatTextIcon,
	CheckCircleIcon,
	CheckIcon,
	CheckSquareIcon,
	CircleHalfIcon,
	CircleIcon,
	CircleNotchIcon,
	ClipboardTextIcon,
	ClockCounterClockwiseIcon,
	ClockIcon,
	CloudCheckIcon,
	CloudSlashIcon,
	CloudWarningIcon,
	CodeIcon,
	CompassIcon,
	CopyIcon,
	DesktopIcon,
	DeviceMobileIcon,
	DotsSixVerticalIcon,
	DotsThreeIcon,
	DotsThreeVerticalIcon,
	DownloadSimpleIcon,
	EnvelopeIcon,
	EnvelopeSimpleIcon,
	ExportIcon,
	EyeIcon,
	EyeSlashIcon,
	FileArrowUpIcon,
	FileDocIcon,
	FileIcon,
	FilePdfIcon,
	FilePlusIcon,
	FileTextIcon,
	FingerprintIcon,
	GearSixIcon,
	GlobeHemisphereWestIcon,
	GlobeIcon,
	GlobeSimpleIcon,
	GraduationCapIcon,
	GraphIcon,
	HandHeartIcon,
	HighlighterIcon,
	HourglassIcon,
	HouseIcon,
	InfoIcon,
	KanbanIcon,
	KeyboardIcon,
	KeyIcon,
	LightningIcon,
	LinkSimpleHorizontalBreakIcon,
	LinkSimpleHorizontalIcon,
	ListBulletsIcon,
	ListChecksIcon,
	ListDashesIcon,
	ListMagnifyingGlassIcon,
	ListNumbersIcon,
	LockIcon,
	LockOpenIcon,
	MagicWandIcon,
	MagnifyingGlassIcon,
	MagnifyingGlassMinusIcon,
	MagnifyingGlassPlusIcon,
	MapPinIcon,
	MicrophoneIcon,
	MinusIcon,
	MoonIcon,
	NoteIcon,
	NotePencilIcon,
	PaletteIcon,
	PaperclipIcon,
	ParagraphIcon,
	PasswordIcon,
	PauseIcon,
	PencilLineIcon,
	PencilSimpleIcon,
	PhoneIcon,
	PlayIcon,
	PlusCircleIcon,
	PlusIcon,
	PrinterIcon,
	QrCodeIcon,
	QuestionIcon,
	RowsIcon,
	ScalesIcon,
	ScissorsIcon,
	SealCheckIcon,
	ShareNetworkIcon,
	SidebarSimpleIcon,
	SignOutIcon,
	SlidersHorizontalIcon,
	SparkleIcon,
	SpeakerHighIcon,
	SquareIcon,
	SquaresFourIcon,
	SquareSplitHorizontalIcon,
	StarIcon,
	StopCircleIcon,
	StopIcon,
	SunIcon,
	TagIcon,
	TextAaIcon,
	TextAlignCenterIcon,
	TextAlignJustifyIcon,
	TextAlignLeftIcon,
	TextAlignRightIcon,
	TextBIcon,
	TextHOneIcon,
	TextHThreeIcon,
	TextHTwoIcon,
	TextIndentIcon,
	TextItalicIcon,
	TextOutdentIcon,
	TextStrikethroughIcon,
	TextTIcon,
	TextTSlashIcon,
	TextUnderlineIcon,
	ThumbsUpIcon,
	TimerIcon,
	TranslateIcon,
	TrashIcon,
	TrayIcon,
	TrendUpIcon,
	UploadSimpleIcon,
	UserCircleIcon,
	UserPlusIcon,
	UserSoundIcon,
	WarningCircleIcon,
	WarningIcon,
	WaveformIcon,
	WifiSlashIcon,
	WrenchIcon,
	XCircleIcon,
	XIcon,
} from "@phosphor-icons/react";
import { cn } from "@reactive-resume/utils/style";

/** Every app icon, by its Phosphor name. Add an entry here to use another Phosphor glyph. */
const icons = {
	"arrow-clockwise": ArrowClockwiseIcon,
	"arrow-counter-clockwise": ArrowCounterClockwiseIcon,
	"arrow-down": ArrowDownIcon,
	"arrow-left": ArrowLeftIcon,
	"arrow-right": ArrowRightIcon,
	"arrow-square-out": ArrowSquareOutIcon,
	"arrow-u-up-left": ArrowUUpLeftIcon,
	"arrow-u-up-right": ArrowUUpRightIcon,
	"arrow-up": ArrowUpIcon,
	"arrow-up-right": ArrowUpRightIcon,
	"arrows-clockwise": ArrowsClockwiseIcon,
	"arrows-down-up": ArrowsDownUpIcon,
	"arrows-in-line-vertical": ArrowsInLineVerticalIcon,
	"arrows-in-simple": ArrowsInSimpleIcon,
	"arrows-left-right": ArrowsLeftRightIcon,
	"arrows-out-simple": ArrowsOutSimpleIcon,
	bell: BellIcon,
	"book-open": BookOpenIcon,
	"book-open-text": BookOpenTextIcon,
	"bookmark-simple": BookmarkSimpleIcon,
	books: BooksIcon,
	"brackets-curly": BracketsCurlyIcon,
	brain: BrainIcon,
	briefcase: BriefcaseIcon,
	bug: BugIcon,
	"calendar-blank": CalendarBlankIcon,
	"calendar-dot": CalendarDotIcon,
	"calendar-dots": CalendarDotsIcon,
	"calendar-plus": CalendarPlusIcon,
	"camera-plus": CameraPlusIcon,
	"caret-down": CaretDownIcon,
	"caret-left": CaretLeftIcon,
	"caret-right": CaretRightIcon,
	"chart-line-up": ChartLineUpIcon,
	"chat-centered-text": ChatCenteredTextIcon,
	"chat-text": ChatTextIcon,
	check: CheckIcon,
	"check-circle": CheckCircleIcon,
	"check-square": CheckSquareIcon,
	circle: CircleIcon,
	"circle-half": CircleHalfIcon,
	"circle-notch": CircleNotchIcon,
	"clipboard-text": ClipboardTextIcon,
	clock: ClockIcon,
	"clock-counter-clockwise": ClockCounterClockwiseIcon,
	"cloud-check": CloudCheckIcon,
	"cloud-slash": CloudSlashIcon,
	"cloud-warning": CloudWarningIcon,
	code: CodeIcon,
	compass: CompassIcon,
	copy: CopyIcon,
	desktop: DesktopIcon,
	"device-mobile": DeviceMobileIcon,
	"dots-six-vertical": DotsSixVerticalIcon,
	"dots-three": DotsThreeIcon,
	"dots-three-vertical": DotsThreeVerticalIcon,
	"download-simple": DownloadSimpleIcon,
	envelope: EnvelopeIcon,
	"envelope-simple": EnvelopeSimpleIcon,
	export: ExportIcon,
	eye: EyeIcon,
	"eye-slash": EyeSlashIcon,
	file: FileIcon,
	"file-arrow-up": FileArrowUpIcon,
	"file-doc": FileDocIcon,
	"file-pdf": FilePdfIcon,
	"file-plus": FilePlusIcon,
	"file-text": FileTextIcon,
	fingerprint: FingerprintIcon,
	"gear-six": GearSixIcon,
	globe: GlobeIcon,
	"globe-hemisphere-west": GlobeHemisphereWestIcon,
	"globe-simple": GlobeSimpleIcon,
	"graduation-cap": GraduationCapIcon,
	graph: GraphIcon,
	"hand-heart": HandHeartIcon,
	highlighter: HighlighterIcon,
	hourglass: HourglassIcon,
	house: HouseIcon,
	info: InfoIcon,
	kanban: KanbanIcon,
	key: KeyIcon,
	keyboard: KeyboardIcon,
	lightning: LightningIcon,
	"link-simple-horizontal": LinkSimpleHorizontalIcon,
	"link-simple-horizontal-break": LinkSimpleHorizontalBreakIcon,
	"list-bullets": ListBulletsIcon,
	"list-checks": ListChecksIcon,
	"list-dashes": ListDashesIcon,
	"list-magnifying-glass": ListMagnifyingGlassIcon,
	"list-numbers": ListNumbersIcon,
	lock: LockIcon,
	"lock-open": LockOpenIcon,
	"magic-wand": MagicWandIcon,
	"magnifying-glass": MagnifyingGlassIcon,
	"magnifying-glass-minus": MagnifyingGlassMinusIcon,
	"magnifying-glass-plus": MagnifyingGlassPlusIcon,
	"map-pin": MapPinIcon,
	microphone: MicrophoneIcon,
	minus: MinusIcon,
	moon: MoonIcon,
	note: NoteIcon,
	"note-pencil": NotePencilIcon,
	palette: PaletteIcon,
	paragraph: ParagraphIcon,
	paperclip: PaperclipIcon,
	password: PasswordIcon,
	pause: PauseIcon,
	"pencil-line": PencilLineIcon,
	"pencil-simple": PencilSimpleIcon,
	phone: PhoneIcon,
	play: PlayIcon,
	plus: PlusIcon,
	"plus-circle": PlusCircleIcon,
	printer: PrinterIcon,
	"qr-code": QrCodeIcon,
	question: QuestionIcon,
	rows: RowsIcon,
	scales: ScalesIcon,
	scissors: ScissorsIcon,
	"seal-check": SealCheckIcon,
	"share-network": ShareNetworkIcon,
	"sidebar-simple": SidebarSimpleIcon,
	"sign-out": SignOutIcon,
	"sliders-horizontal": SlidersHorizontalIcon,
	sparkle: SparkleIcon,
	"speaker-high": SpeakerHighIcon,
	square: SquareIcon,
	"square-split-horizontal": SquareSplitHorizontalIcon,
	"squares-four": SquaresFourIcon,
	star: StarIcon,
	stop: StopIcon,
	"stop-circle": StopCircleIcon,
	sun: SunIcon,
	tag: TagIcon,
	"text-aa": TextAaIcon,
	"text-align-center": TextAlignCenterIcon,
	"text-align-justify": TextAlignJustifyIcon,
	"text-align-left": TextAlignLeftIcon,
	"text-align-right": TextAlignRightIcon,
	"text-h-one": TextHOneIcon,
	"text-h-three": TextHThreeIcon,
	"text-h-two": TextHTwoIcon,
	"text-indent": TextIndentIcon,
	"text-outdent": TextOutdentIcon,
	"text-strikethrough": TextStrikethroughIcon,
	"text-underline": TextUnderlineIcon,
	"text-b": TextBIcon,
	"text-italic": TextItalicIcon,
	"text-t": TextTIcon,
	"text-t-slash": TextTSlashIcon,
	"thumbs-up": ThumbsUpIcon,
	timer: TimerIcon,
	translate: TranslateIcon,
	trash: TrashIcon,
	tray: TrayIcon,
	"trend-up": TrendUpIcon,
	"upload-simple": UploadSimpleIcon,
	"user-circle": UserCircleIcon,
	"user-plus": UserPlusIcon,
	"user-sound": UserSoundIcon,
	warning: WarningIcon,
	"warning-circle": WarningCircleIcon,
	waveform: WaveformIcon,
	"wifi-slash": WifiSlashIcon,
	wrench: WrenchIcon,
	x: XIcon,
	"x-circle": XCircleIcon,
} satisfies Record<string, PhosphorIcon>;

type IconName = keyof typeof icons;

// Icons that point somewhere are mirrored in right-to-left layouts.
const DIRECTIONAL_ICONS = new Set<IconName>([
	"arrow-left",
	"arrow-right",
	"arrow-u-up-left",
	"arrow-u-up-right",
	"caret-left",
	"caret-right",
]);

type IconProps = Omit<React.ComponentProps<"span">, "children"> & {
	name: IconName;
	/** The filled glyph. The design system reserves it for the selected navigation item. */
	filled?: boolean | undefined;
	/** Glyph size in CSS pixels: 20 on desktop, 24 on touch. */
	size?: number | undefined;
};

/**
 * A Phosphor glyph sized by the span's font size, so containers can resize it with `text-*` like text.
 * Icons are decorative: the control they sit in carries the accessible name.
 */
function Icon({ name, filled = false, size = 20, className, style, ...props }: IconProps) {
	const Glyph = icons[name];

	return (
		<span
			aria-hidden="true"
			data-slot="icon"
			{...props}
			className={cn("inline-block size-[1em] shrink-0", DIRECTIONAL_ICONS.has(name) && "rtl:-scale-x-100", className)}
			style={{ fontSize: size, ...style }}
		>
			{/* Inline sizing, so the `size-4` rules buttons and menus give bare SVGs can't shrink the glyph. */}
			<Glyph weight={filled ? "fill" : "regular"} style={{ display: "block", width: "100%", height: "100%" }} />
		</span>
	);
}

export { Icon, type IconName, type IconProps };