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,16 +1,18 @@
|
||||
'use client';
|
||||
import React from 'react';
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
||||
import {faArrowLeft, faEdit, faPlus, faSave, faShare, faTrash, faTimes} from '@fortawesome/free-solid-svg-icons';
|
||||
import {IconDefinition} from '@fortawesome/fontawesome-svg-core';
|
||||
import {useTranslations} from 'next-intl';
|
||||
import {ViewMode} from '@/shared/interface';
|
||||
import {ArrowLeft, LucideIcon, Pencil, Plus, Save, Share2, Trash2, X} from 'lucide-react';
|
||||
import {useTranslations} from '@/lib/i18n';
|
||||
import {ViewMode} from '@/lib/types/settings';
|
||||
import Button from '@/components/ui/Button';
|
||||
import IconButton from '@/components/ui/IconButton';
|
||||
|
||||
type ActionVariant = 'primary' | 'danger' | 'ghost';
|
||||
|
||||
interface ActionButton {
|
||||
icon: IconDefinition;
|
||||
icon: LucideIcon;
|
||||
onClick: () => void;
|
||||
title?: string;
|
||||
variant?: 'primary' | 'danger' | 'secondary' | 'blue';
|
||||
variant?: ActionVariant;
|
||||
}
|
||||
|
||||
interface SidebarHeaderProps {
|
||||
@@ -36,82 +38,53 @@ interface SidebarHeaderProps {
|
||||
* - edit: Boutons Cancel, Save/Create
|
||||
*/
|
||||
export default function ToolDetailHeader({
|
||||
title,
|
||||
defaultTitle,
|
||||
viewMode,
|
||||
isNew,
|
||||
onBack,
|
||||
onEdit,
|
||||
onSave,
|
||||
onCancel,
|
||||
onDelete,
|
||||
onExport,
|
||||
showExport = false,
|
||||
showDelete = true,
|
||||
}: SidebarHeaderProps): React.JSX.Element | null {
|
||||
title,
|
||||
defaultTitle,
|
||||
viewMode,
|
||||
isNew,
|
||||
onBack,
|
||||
onEdit,
|
||||
onSave,
|
||||
onCancel,
|
||||
onDelete,
|
||||
onExport,
|
||||
showExport = false,
|
||||
showDelete = true,
|
||||
}: SidebarHeaderProps): React.JSX.Element | null {
|
||||
const t = useTranslations();
|
||||
|
||||
if (viewMode === 'list') {
|
||||
return null;
|
||||
}
|
||||
|
||||
function getVariantClasses(variant: 'primary' | 'danger' | 'secondary' | 'blue'): string {
|
||||
switch (variant) {
|
||||
case 'primary':
|
||||
return 'bg-primary/10 hover:bg-primary/20 border-primary/30';
|
||||
case 'danger':
|
||||
return 'bg-error/10 hover:bg-error/20 border-error/30';
|
||||
case 'blue':
|
||||
return 'bg-blue-500/10 hover:bg-blue-500/20 border-blue-500/30';
|
||||
case 'secondary':
|
||||
default:
|
||||
return 'bg-secondary/50 hover:bg-secondary border-secondary/50 hover:border-secondary';
|
||||
}
|
||||
}
|
||||
|
||||
function getIconColorClass(variant: 'primary' | 'danger' | 'secondary' | 'blue'): string {
|
||||
switch (variant) {
|
||||
case 'primary':
|
||||
return 'text-primary';
|
||||
case 'danger':
|
||||
return 'text-error';
|
||||
case 'blue':
|
||||
return 'text-blue-500';
|
||||
case 'secondary':
|
||||
default:
|
||||
return 'text-text-primary';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function renderActionButton(button: ActionButton, index: number): React.JSX.Element {
|
||||
const variant = button.variant || 'secondary';
|
||||
return (
|
||||
<button
|
||||
<IconButton
|
||||
key={`action-${index}`}
|
||||
icon={button.icon}
|
||||
variant={button.variant || 'ghost'}
|
||||
shape="square"
|
||||
onClick={button.onClick}
|
||||
title={button.title}
|
||||
className={`group flex items-center justify-center w-10 h-10 rounded-lg border hover:shadow-md hover:scale-110 transition-all duration-200 ${getVariantClasses(variant)}`}
|
||||
>
|
||||
<FontAwesomeIcon icon={button.icon} className={`w-4 h-4 transition-transform group-hover:scale-110 ${getIconColorClass(variant)}`}/>
|
||||
</button>
|
||||
tooltip={button.title}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function getActionButtons(): ActionButton[] {
|
||||
const buttons: ActionButton[] = [];
|
||||
|
||||
|
||||
if (viewMode === 'detail') {
|
||||
if (showExport && onExport) {
|
||||
buttons.push({
|
||||
icon: faShare,
|
||||
icon: Share2,
|
||||
onClick: onExport,
|
||||
title: t('common.exportToSeries'),
|
||||
variant: 'blue',
|
||||
variant: 'primary',
|
||||
});
|
||||
}
|
||||
if (showDelete && onDelete) {
|
||||
buttons.push({
|
||||
icon: faTrash,
|
||||
icon: Trash2,
|
||||
onClick: onDelete,
|
||||
title: t('common.delete'),
|
||||
variant: 'danger',
|
||||
@@ -119,7 +92,7 @@ export default function ToolDetailHeader({
|
||||
}
|
||||
if (onEdit) {
|
||||
buttons.push({
|
||||
icon: faEdit,
|
||||
icon: Pencil,
|
||||
onClick: onEdit,
|
||||
title: t('common.edit'),
|
||||
variant: 'primary',
|
||||
@@ -128,7 +101,7 @@ export default function ToolDetailHeader({
|
||||
} else if (viewMode === 'edit') {
|
||||
if (onCancel) {
|
||||
buttons.push({
|
||||
icon: faTimes,
|
||||
icon: X,
|
||||
onClick: onCancel,
|
||||
title: t('common.cancel'),
|
||||
variant: 'danger',
|
||||
@@ -136,31 +109,28 @@ export default function ToolDetailHeader({
|
||||
}
|
||||
if (onSave) {
|
||||
buttons.push({
|
||||
icon: isNew ? faPlus : faSave,
|
||||
icon: isNew ? Plus : Save,
|
||||
onClick: onSave,
|
||||
title: isNew ? t('common.create') : t('common.save'),
|
||||
variant: 'primary',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<div className="flex justify-between items-center p-4 border-b border-secondary/50 bg-tertiary/50 backdrop-blur-sm">
|
||||
<button
|
||||
onClick={onBack}
|
||||
className="flex items-center gap-2 bg-secondary/50 py-2 px-4 rounded-xl border border-secondary/50 hover:bg-secondary hover:border-secondary hover:shadow-md hover:scale-105 transition-all duration-200"
|
||||
>
|
||||
<FontAwesomeIcon icon={faArrowLeft} className="text-primary w-4 h-4"/>
|
||||
<span className="text-text-primary font-medium">{t('common.back')}</span>
|
||||
</button>
|
||||
|
||||
<div
|
||||
className="flex justify-between items-center p-4 border-b border-secondary bg-darkest-background">
|
||||
<Button variant="secondary" size="sm" icon={ArrowLeft} onClick={onBack}>
|
||||
{t('common.back')}
|
||||
</Button>
|
||||
|
||||
<span className="text-text-primary font-semibold text-lg">
|
||||
{title || defaultTitle}
|
||||
</span>
|
||||
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{getActionButtons().map(renderActionButton)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user