251210_01_ENH : 프로젝트 수정, 에디터 구현중
This commit is contained in:
@@ -6,7 +6,10 @@ import { Header } from "@/components/layout/Header";
|
||||
import { Sidebar } from "@/components/layout/Sidebar";
|
||||
import {useFontSize} from "@/hooks/useFontSize";
|
||||
import {projectSideMenus, manageSideMenus, topMenus} from "@/config/menu.data";
|
||||
import commonConst from "@/config/commonConst";
|
||||
import ProjectTitle from "@/components/layout/ProjectTitle";
|
||||
import {cn} from "@/lib/utils";
|
||||
import {FONT_SIZE} from "@/const/commonConst";
|
||||
import {useSelectedProject} from "@/hooks/useSelectedProject";
|
||||
|
||||
type MainLayoutProps = {
|
||||
children: ReactNode;
|
||||
@@ -17,13 +20,15 @@ const MainLayout = ({ children, initialFontSize }: MainLayoutProps) => {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
|
||||
const [isProjectMenu, setIsProjectMenu] = useState(false);
|
||||
const { selectedProject } = useSelectedProject();
|
||||
const [menuOpen, setMenuOpen] = useState(true);
|
||||
const [fontSize, setFontSize] = useFontSize(initialFontSize, { hydrateFromCookie: false });
|
||||
|
||||
const isMain = pathname === "/";
|
||||
const isProjectMenu = !pathname.startsWith("/manage");
|
||||
const isViewProjectTitle = !isMain && isProjectMenu && !pathname.startsWith("/project/info")
|
||||
const activeTop = topMenus.find((m) => m.match?.(pathname)) ?? topMenus[0];
|
||||
const sideMenus = pathname.startsWith("/manage") ? manageSideMenus : projectSideMenus;
|
||||
const sideMenus = isProjectMenu ? projectSideMenus : manageSideMenus;
|
||||
|
||||
// 2단 메뉴 open 상태
|
||||
const [openMenus, setOpenMenus] = useState<Record<string, boolean>>(() => {
|
||||
@@ -43,10 +48,6 @@ const MainLayout = ({ children, initialFontSize }: MainLayoutProps) => {
|
||||
return initial;
|
||||
});
|
||||
|
||||
const handleIsProjectMenu = (isProject: boolean) => {
|
||||
setIsProjectMenu(isProject);
|
||||
}
|
||||
|
||||
const movePage = (path: string) => {
|
||||
router.push(path);
|
||||
};
|
||||
@@ -56,11 +57,11 @@ const MainLayout = ({ children, initialFontSize }: MainLayoutProps) => {
|
||||
};
|
||||
|
||||
const decreaseFontSize = () =>{
|
||||
setFontSize(Math.max(commonConst.fontSizeMin, fontSize - 2));
|
||||
setFontSize(Math.max(FONT_SIZE.MIN, fontSize - 2));
|
||||
}
|
||||
|
||||
const increaseFontSize = () =>{
|
||||
setFontSize(Math.min(commonConst.fontSizeMax, fontSize + 2));
|
||||
setFontSize(Math.min(FONT_SIZE.MAX, fontSize + 2));
|
||||
}
|
||||
|
||||
// CSS 변수 동기화
|
||||
@@ -72,15 +73,25 @@ const MainLayout = ({ children, initialFontSize }: MainLayoutProps) => {
|
||||
);
|
||||
}, [fontSize]);
|
||||
|
||||
useEffect(() => {
|
||||
if(!isMain && isProjectMenu && !selectedProject){
|
||||
alert("옳지 않은 접근입니다.");
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50">
|
||||
<div
|
||||
className={cn(
|
||||
"bg-gray-50 flex flex-col",
|
||||
isMain ? "min-h-screen" : "h-screen overflow-hidden" // ✅ 메인 제외: 바깥 스크롤 잠금
|
||||
)}
|
||||
>
|
||||
{/* 헤더 - 고정 폰트 크기 */}
|
||||
<Header
|
||||
isMain={isMain}
|
||||
menuOpen={menuOpen}
|
||||
activeTopId={activeTop.id}
|
||||
fontSize={fontSize}
|
||||
handleIsProjectMenu={handleIsProjectMenu}
|
||||
onToggleMenu={() => setMenuOpen((prev) => !prev)}
|
||||
onNavigate={movePage}
|
||||
decreaseFontSize={decreaseFontSize}
|
||||
@@ -88,7 +99,7 @@ const MainLayout = ({ children, initialFontSize }: MainLayoutProps) => {
|
||||
/>
|
||||
|
||||
{/* 본문 */}
|
||||
<div className="flex">
|
||||
<div className={cn("flex flex-1", !isMain && "min-h-0")}>
|
||||
{/* 사이드바 - 고정 폰트 크기 */}
|
||||
{!isMain && (
|
||||
<Sidebar
|
||||
@@ -104,11 +115,17 @@ const MainLayout = ({ children, initialFontSize }: MainLayoutProps) => {
|
||||
|
||||
{/* 메인 콘텐츠만 가변 폰트 크기 적용 */}
|
||||
<main
|
||||
className="flex-1 p-4"
|
||||
className={cn(
|
||||
"flex-1 p-4",
|
||||
!isMain && "min-h-0 overflow-y-auto"
|
||||
)}
|
||||
// 전역 CSS 변수(--content-font-size)를 실제 렌더에 적용
|
||||
// SSR 단계에서의 초기 폰트 값을 FOUC 없이 유지하기 위해 fallback을 함께 지정
|
||||
style={{ fontSize: `var(--content-font-size, ${initialFontSize}px)` }}
|
||||
>
|
||||
{isViewProjectTitle &&
|
||||
<ProjectTitle/>
|
||||
}
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user