refactor[genericIconComponent]: Remove unnecesary switch case

This commit is contained in:
Igor Carvalho 2023-07-17 19:43:46 -03:00
commit 5af49e5a36
40 changed files with 40 additions and 217 deletions

View file

@ -167,7 +167,6 @@ export default function ParameterComponent({
<IconComponent
name="Info"
style="relative bottom-0.5 ml-2 h-3 w-3"
method="LUCIDE"
/>
</ShadTooltip>
)}

View file

@ -39,12 +39,6 @@ export default function GenericNode({
const { sseData, isBuilding } = useSSE();
const refHtml = useRef(null);
// useEffect(() => {
// if (reactFlowInstance) {
// setParams(Object.values(reactFlowInstance.toObject()));
// }
// }, [save]);
// New useEffect to watch for changes in sseData and update validation status
useEffect(() => {
const relevantData = sseData[data.id];
@ -90,7 +84,6 @@ export default function GenericNode({
<IconComponent
name={name}
style="generic-node-icon"
method="LUCIDE"
iconColor={`${nodeColors[types[data.type]]}`}
/>
<div className="generic-node-tooltip-div">
@ -122,7 +115,6 @@ export default function GenericNode({
<IconComponent
name="Zap"
style="mx-0.5 h-5 fill-build-trigger stroke-build-trigger stroke-1"
method="LUCIDE"
/>{" "}
flow to validate status.
</span>

View file

@ -30,7 +30,6 @@ export default function SingleAlert({
>
<div className="flex-shrink-0">
<IconComponent
method="LUCIDE"
name="XCircle"
style="h-5 w-5 text-status-red"
aria-hidden="true"
@ -69,7 +68,6 @@ export default function SingleAlert({
<span className="sr-only">Dismiss</span>
<IconComponent
name="X"
method="LUCIDE"
style="h-4 w-4 text-error-foreground"
aria-hidden="true"
/>
@ -85,7 +83,6 @@ export default function SingleAlert({
<div className="flex-shrink-0">
<IconComponent
name="Info"
method="LUCIDE"
style="h-5 w-5 text-status-blue "
aria-hidden="true"
/>
@ -121,7 +118,6 @@ export default function SingleAlert({
>
<span className="sr-only">Dismiss</span>
<IconComponent
method="LUCIDE"
name="X"
style="h-4 w-4 text-info-foreground"
aria-hidden="true"
@ -139,7 +135,6 @@ export default function SingleAlert({
<IconComponent
name="CheckCircle2"
style="h-5 w-5 text-status-green"
method="LUCIDE"
aria-hidden="true"
/>
</div>
@ -163,7 +158,6 @@ export default function SingleAlert({
<span className="sr-only">Dismiss</span>
<IconComponent
name="X"
method="LUCIDE"
style="h-4 w-4 text-success-foreground"
aria-hidden="true"
/>

View file

@ -36,17 +36,13 @@ export default function AlertDropdown({}: AlertDropdownType) {
setTimeout(clearNotificationList, 100);
}}
>
<IconComponent
name="Trash2"
method="LUCIDE"
style="h-[1.1rem] w-[1.1rem]"
/>
<IconComponent name="Trash2" style="h-[1.1rem] w-[1.1rem]" />
</button>
<button
className="text-foreground hover:text-status-red"
onClick={closePopUp}
>
<IconComponent method="LUCIDE" name="X" style="h-5 w-5" />
<IconComponent name="X" style="h-5 w-5" />
</button>
</div>
</div>

View file

@ -46,7 +46,6 @@ export default function ErrorAlert({
<div className="flex-shrink-0">
<IconComponent
name="XCircle"
method="LUCIDE"
style="error-build-message-circle"
aria-hidden="true"
/>

View file

@ -44,7 +44,6 @@ export default function NoticeAlert({
name="Info"
style="h-5 w-5 text-status-blue "
aria-hidden="true"
method="LUCIDE"
/>
</div>
<div className="ml-3 flex-1 md:flex md:justify-between">

View file

@ -41,7 +41,6 @@ export default function SuccessAlert({
<IconComponent
name="CheckCircle2"
style="success-alert-icon"
method="LUCIDE"
aria-hidden="true"
/>
</div>

View file

@ -37,11 +37,7 @@ export const CardComponent = ({
<span className="card-component-title-size">{flow.name}</span>
{onDelete && (
<button className="card-component-delete-button" onClick={onDelete}>
<IconComponent
name="Trash2"
style="card-component-delete-icon"
method="LUCIDE"
/>
<IconComponent name="Trash2" style="card-component-delete-icon" />
</button>
)}
</CardTitle>

View file

@ -193,7 +193,6 @@ export default function BuildTrigger({
<IconComponent
name="Zap"
style="sh-6 w-6 fill-build-trigger stroke-build-trigger stroke-1"
method="LUCIDE"
/>
)}
</div>

View file

@ -58,7 +58,6 @@ export default function ChatTrigger({ open, setOpen, isBuilt, canOpen }) {
? "message-button-icon"
: "disabled-message-button-icon")
}
method="LUCIDE"
/>
</div>
</button>

View file

@ -72,7 +72,6 @@ export default function CodeAreaComponent({
{!editNode && (
<IconComponent
name="ExternalLink"
method="LUCIDE"
style={
"icons-parameters-comp" +
(disabled ? " text-ring" : " hover:text-accent-foreground")

View file

@ -47,7 +47,6 @@ export default function Dropdown({
</span>
<span className={"dropdown-component-arrow"}>
<IconComponent
method="LUCIDE"
name="ChevronsUpDown"
style="dropdown-component-arrow-color"
aria-hidden="true"
@ -102,7 +101,6 @@ export default function Dropdown({
)}
>
<IconComponent
method="LUCIDE"
name="Check"
style={
active

View file

@ -11,16 +11,10 @@ export function IconFromLucide({
}
export default function IconComponent({
method,
name,
style,
iconColor,
}: IconComponentProps): JSX.Element {
switch (method) {
case "LUCIDE":
return <IconFromLucide name={name} style={style} iconColor={iconColor} />;
default:
console.error("IconComponent: invalid method");
return <IconFromLucide name={"unknown"} style={"unknown"} />;
}
const TargetIcon = nodeIconsLucide[name] ?? nodeIconsLucide["unknown"];
return <TargetIcon className={style} style={{ color: iconColor }} />;
}

View file

@ -39,7 +39,7 @@ export const MenuBar = ({ flows, tabId }) => {
return (
<div className="round-button-div">
<Link to="/">
<IconComponent name="ChevronLeft" style="w-4" method="LUCIDE" />
<IconComponent name="ChevronLeft" style="w-4" />
</Link>
<div className="header-menu-bar">
<DropdownMenu>
@ -47,11 +47,7 @@ export const MenuBar = ({ flows, tabId }) => {
<Button asChild variant="primary" size="sm">
<div className="header-menu-bar-display">
<div className="header-menu-flow-name">{current_flow.name}</div>
<IconComponent
name="ChevronDown"
style="h-4 w-4"
method="LUCIDE"
/>
<IconComponent name="ChevronDown" style="h-4 w-4" />
</div>
</Button>
</DropdownMenuTrigger>
@ -63,11 +59,7 @@ export const MenuBar = ({ flows, tabId }) => {
}}
className="cursor-pointer"
>
<IconComponent
name="Plus"
style="header-menu-options"
method="LUCIDE"
/>
<IconComponent name="Plus" style="header-menu-options" />
New
</DropdownMenuItem>
<DropdownMenuItem
@ -76,11 +68,7 @@ export const MenuBar = ({ flows, tabId }) => {
}}
className="cursor-pointer"
>
<IconComponent
name="Settings2"
style="header-menu-options "
method="LUCIDE"
/>
<IconComponent name="Settings2" style="header-menu-options " />
Settings
</DropdownMenuItem>
<DropdownMenuItem
@ -89,11 +77,7 @@ export const MenuBar = ({ flows, tabId }) => {
}}
className="cursor-pointer"
>
<IconComponent
name="Undo"
style="header-menu-options "
method="LUCIDE"
/>
<IconComponent name="Undo" style="header-menu-options " />
Undo
</DropdownMenuItem>
<DropdownMenuItem
@ -102,37 +86,9 @@ export const MenuBar = ({ flows, tabId }) => {
}}
className="cursor-pointer"
>
<IconComponent
name="Redo"
style="header-menu-options "
method="LUCIDE"
/>
<IconComponent name="Redo" style="header-menu-options " />
Redo
</DropdownMenuItem>
{/* <DropdownMenuSeparator /> */}
{/* <DropdownMenuLabel>Projects</DropdownMenuLabel> */}
{/* <DropdownMenuRadioGroup className="max-h-full overflow-scroll"
value={tabId}
onValueChange={(value) => {
setTabId(value);
}}
>
{flows.map((flow, idx) => {
return (
<Link
to={"/flow/" + flow.id}
className="flex w-full items-center"
>
<DropdownMenuRadioItem
value={flow.id}
className="flex-1 w-full inline-block truncate break-words mr-2"
>
{flow.name}
</DropdownMenuRadioItem>
</Link>
);
})}
</DropdownMenuRadioGroup> */}
</DropdownMenuContent>
</DropdownMenu>
</div>

View file

@ -51,7 +51,7 @@ export default function Header() {
variant={location.pathname === "/" ? "primary" : "secondary"}
size="sm"
>
<IconComponent name="Home" method="LUCIDE" style="h-4 w-4" />
<IconComponent name="Home" style="h-4 w-4" />
<div className="flex-1">{USER_PROJECTS_HEADER}</div>
</Button>
</Link>
@ -63,7 +63,7 @@ export default function Header() {
}
size="sm"
>
<IconComponent method="LUCIDE" name="Users2" style="h-4 w-4" />
<IconComponent name="Users2" style="h-4 w-4" />
<div className="flex-1">Community Examples</div>
</Button>
</Link>
@ -105,17 +105,9 @@ export default function Header() {
}}
>
{dark ? (
<IconComponent
name="SunIcon"
style="side-bar-button-size"
method="LUCIDE"
/>
<IconComponent name="SunIcon" style="side-bar-button-size" />
) : (
<IconComponent
name="MoonIcon"
style="side-bar-button-size"
method="LUCIDE"
/>
<IconComponent name="MoonIcon" style="side-bar-button-size" />
)}
</button>
<button
@ -141,7 +133,6 @@ export default function Header() {
{notificationCenter && <div className="header-notifications"></div>}
<IconComponent
name="Bell"
method="LUCIDE"
style="side-bar-button-size"
aria-hidden="true"
/>

View file

@ -110,7 +110,6 @@ export default function InputFileComponent({
{!editNode && !loading && (
<IconComponent
name="FileSearch2"
method="LUCIDE"
style={
"icons-parameters-comp" +
(disabled ? " text-ring " : " hover:text-accent-foreground")

View file

@ -68,7 +68,6 @@ export default function InputListComponent({
<IconComponent
name="Plus"
style={"h-4 w-4 hover:text-accent-foreground"}
method="LUCIDE"
/>
</button>
) : (
@ -82,11 +81,7 @@ export default function InputListComponent({
onChange(inputList);
}}
>
<IconComponent
name="X"
style="h-4 w-4 hover:text-status-red"
method="LUCIDE"
/>
<IconComponent name="X" style="h-4 w-4 hover:text-status-red" />
</button>
)}
</div>

View file

@ -90,7 +90,6 @@ export default function PromptAreaComponent({
{!editNode && (
<IconComponent
name="ExternalLink"
method="LUCIDE"
style={
"icons-parameters-comp" +
(disabled ? " text-ring" : " hover:text-accent-foreground")

View file

@ -70,7 +70,6 @@ export default function TextAreaComponent({
{!editNode && (
<IconComponent
name="ExternalLink"
method="LUCIDE"
style={
"icons-parameters-comp" +
(disabled ? " text-ring" : " hover:text-accent-foreground")

View file

@ -20,7 +20,7 @@ const Checkbox = React.forwardRef<
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
>
<IconComponent name="Check" method="LUCIDE" style="h-4 w-4" />
<IconComponent name="Check" style="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
));

Some files were not shown because too many files have changed in this diff Show more