- Deleted `CharacterComponent` and `CharacterDetail` files from the project. - Refactored related logic to improve code maintainability and reduce redundancy.
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
'use client'
|
|
import {ReactNode, useEffect, useState} from "react";
|
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
|
import {faX} from "@fortawesome/free-solid-svg-icons";
|
|
import {createPortal} from "react-dom";
|
|
|
|
interface SettingsPanelProps {
|
|
title: string;
|
|
sidebar: ReactNode;
|
|
children: ReactNode;
|
|
onClose: () => void;
|
|
}
|
|
|
|
export default function SettingsPanel({title, sidebar, children, onClose}: SettingsPanelProps) {
|
|
const [mounted, setMounted] = useState<boolean>(false);
|
|
|
|
useEffect((): void => {
|
|
setMounted(true);
|
|
}, []);
|
|
|
|
if (!mounted) return null;
|
|
|
|
return createPortal(
|
|
<div className="fixed inset-0 z-40 bg-black/60 backdrop-blur-md flex items-center justify-center">
|
|
<div className="w-3/4 h-[85vh] bg-tertiary rounded-2xl border border-secondary/50 shadow-2xl flex flex-col">
|
|
|
|
<div className="bg-primary px-6 py-4 rounded-t-2xl flex justify-between items-center">
|
|
<h2 className="font-['ADLaM_Display'] text-xl text-text-primary">{title}</h2>
|
|
<button
|
|
onClick={onClose}
|
|
className="text-white/80 hover:text-white p-2 rounded-lg hover:bg-white/10 transition-all"
|
|
>
|
|
<FontAwesomeIcon icon={faX} className="w-5 h-5"/>
|
|
</button>
|
|
</div>
|
|
|
|
<div className="flex flex-1 overflow-hidden">
|
|
<div className="w-64 bg-secondary/30 border-r border-secondary/50">
|
|
{sidebar}
|
|
</div>
|
|
<div className="flex-1 overflow-y-auto">
|
|
{children}
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>,
|
|
document.body
|
|
);
|
|
}
|