refactor: Consolidate icon imports across components and streamline import statements for improved readability
This commit is contained in:
@@ -2,6 +2,7 @@ import React, { useSyncExternalStore } from 'react';
|
||||
import { IconButton } from 'folds';
|
||||
import * as lucide from 'lucide-react';
|
||||
import { UILocation } from '@paarrot/plugin-manager';
|
||||
import { Icon, Icons, type IconName } from '../../../components/icons';
|
||||
import { pluginRegistry } from './PluginAPI';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -39,11 +40,6 @@ interface PluginButtonSlotProps {
|
||||
location: UILocation;
|
||||
}
|
||||
|
||||
type LucideIconComponent = React.ComponentType<{
|
||||
size?: number | string;
|
||||
strokeWidth?: number | string;
|
||||
}>;
|
||||
|
||||
function renderPluginButtonIcon(button: {
|
||||
icon?: string;
|
||||
lucideIcon?: string;
|
||||
@@ -54,8 +50,14 @@ function renderPluginButtonIcon(button: {
|
||||
? button.icon.slice('lucide:'.length)
|
||||
: undefined);
|
||||
|
||||
if (lucideName && lucideName in Icons) {
|
||||
return <Icon src={Icons[lucideName as IconName]} size="300" />;
|
||||
}
|
||||
|
||||
if (lucideName) {
|
||||
const IconComponent = (lucide as Record<string, LucideIconComponent | undefined>)[lucideName];
|
||||
const IconComponent = (lucide as Record<string, React.ComponentType<{ size?: number; strokeWidth?: number }> | undefined>)[
|
||||
lucideName
|
||||
];
|
||||
if (IconComponent) {
|
||||
return <IconComponent size={18} strokeWidth={2} aria-hidden />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user