Remove unused components and models for improved maintainability
- Deleted redundant components (`AddActionButton`, `AlertBox`, `AlertStack`, `BackButton`, `CancelButton`, and `CollapsableArea`) and related files. - Removed unused models (`Book`, `BookSerie`, `BookTables`, `Character`, and `Chapter`) to reduce codebase clutter. - Updated project structure and references to reflect these removals.
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import React from "react";
|
||||
import {IconDefinition} from "@fortawesome/fontawesome-svg-core";
|
||||
import {faPlus, faTrash} from "@fortawesome/free-solid-svg-icons";
|
||||
import {LucideIcon, Plus, Trash2} from "lucide-react";
|
||||
import IconButton from "@/components/ui/IconButton";
|
||||
import Button from "@/components/ui/Button";
|
||||
import Badge from "@/components/ui/Badge";
|
||||
|
||||
interface InputFieldProps {
|
||||
icon?: IconDefinition,
|
||||
fieldName?: string,
|
||||
input: React.ReactNode,
|
||||
addButtonCallBack?: () => Promise<void>
|
||||
removeButtonCallBack?: () => Promise<void>
|
||||
isAddButtonDisabled?: boolean
|
||||
action?: () => Promise<void>
|
||||
actionLabel?: string
|
||||
actionIcon?: IconDefinition
|
||||
hint?: string,
|
||||
centered?: boolean,
|
||||
icon?: LucideIcon;
|
||||
fieldName?: string;
|
||||
input: React.ReactNode;
|
||||
addButtonCallBack?: () => Promise<void>;
|
||||
removeButtonCallBack?: () => Promise<void>;
|
||||
isAddButtonDisabled?: boolean;
|
||||
action?: () => Promise<void>;
|
||||
actionLabel?: string;
|
||||
actionIcon?: LucideIcon;
|
||||
hint?: string;
|
||||
centered?: boolean;
|
||||
}
|
||||
|
||||
export default function InputField(
|
||||
@@ -31,63 +32,51 @@ export default function InputField(
|
||||
hint,
|
||||
centered = false
|
||||
}: InputFieldProps) {
|
||||
|
||||
function renderIcon(): React.JSX.Element | null {
|
||||
if (!icon) return null;
|
||||
const Icon: LucideIcon = icon;
|
||||
return <Icon className="text-primary w-5 h-5" strokeWidth={1.75}/>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`flex flex-col ${centered ? 'items-center' : ''}`}>
|
||||
<div className={`flex items-center mb-2 lg:mb-3 flex-wrap gap-2 ${centered ? 'justify-center' : 'justify-between'}`}>
|
||||
{
|
||||
fieldName && (
|
||||
<h3 className="text-text-primary text-xl font-[ADLaM Display] font-medium mb-2 flex items-center gap-2">
|
||||
{
|
||||
icon && <FontAwesomeIcon icon={icon} className="text-primary w-5 h-5"/>
|
||||
}
|
||||
{fieldName}
|
||||
</h3>
|
||||
)
|
||||
}
|
||||
{
|
||||
action && (
|
||||
<button
|
||||
onClick={action}
|
||||
className="flex items-center gap-1.5 px-3 py-1.5 text-xs bg-secondary/50 rounded-lg text-primary hover:bg-secondary hover:shadow-md hover:scale-105 transition-all duration-200 border border-secondary/50 font-medium"
|
||||
>
|
||||
{
|
||||
actionIcon && <FontAwesomeIcon icon={actionIcon} className={'w-3.5 h-3.5'}/>
|
||||
}
|
||||
{
|
||||
actionLabel && <span>{actionLabel}</span>
|
||||
}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
<div
|
||||
className={`flex items-center mb-2 lg:mb-3 flex-wrap gap-2 ${centered ? 'justify-center' : 'justify-between'}`}>
|
||||
{fieldName && (
|
||||
<h3 className="text-text-secondary text-sm font-medium flex items-center gap-2">
|
||||
{renderIcon()}
|
||||
{fieldName}
|
||||
</h3>
|
||||
)}
|
||||
{action && actionIcon && (
|
||||
<Button variant="secondary" size="sm" icon={actionIcon} onClick={action}>
|
||||
{actionLabel && <span>{actionLabel}</span>}
|
||||
</Button>
|
||||
)}
|
||||
{hint && (
|
||||
<span
|
||||
className="text-xs text-muted bg-secondary/30 px-3 py-1.5 rounded-lg border border-secondary/30">
|
||||
{hint}
|
||||
</span>
|
||||
<Badge variant="muted" size="sm">{hint}</Badge>
|
||||
)}
|
||||
</div>
|
||||
<div className={`flex items-center gap-2 ${centered ? 'justify-center' : 'justify-between'}`}>
|
||||
{input}
|
||||
{
|
||||
addButtonCallBack && (
|
||||
<button
|
||||
className="bg-primary text-text-primary w-9 h-9 rounded-full flex items-center justify-center disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 hover:bg-primary-dark hover:shadow-lg hover:scale-110 shadow-md"
|
||||
onClick={addButtonCallBack}
|
||||
disabled={isAddButtonDisabled}>
|
||||
<FontAwesomeIcon icon={faPlus} className="w-4 h-4"/>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
{
|
||||
removeButtonCallBack && (
|
||||
<button
|
||||
className="bg-error/90 hover:bg-error text-text-primary w-9 h-9 rounded-full flex items-center justify-center transition-all duration-200 hover:shadow-lg hover:scale-110 shadow-md"
|
||||
onClick={removeButtonCallBack}
|
||||
>
|
||||
<FontAwesomeIcon icon={faTrash} className={'w-4 h-4'}/>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
{addButtonCallBack && (
|
||||
<IconButton
|
||||
icon={Plus}
|
||||
variant="ghost"
|
||||
shape="square"
|
||||
onClick={addButtonCallBack}
|
||||
disabled={isAddButtonDisabled}
|
||||
/>
|
||||
)}
|
||||
{removeButtonCallBack && (
|
||||
<IconButton
|
||||
icon={Trash2}
|
||||
variant="danger"
|
||||
shape="square"
|
||||
onClick={removeButtonCallBack}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user