Skip to content

Commit 6fe5225

Browse files
Merge pull request #213 from boostcampwm-2024/feature-fe-#212
에디터 전체화면 기능
2 parents 2ddd6ac + 2574d9d commit 6fe5225

File tree

7 files changed

+84
-30
lines changed

7 files changed

+84
-30
lines changed

apps/frontend/src/components/EditorView.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { SocketIOProvider } from "y-socket.io";
77
import Editor from "./editor";
88
import EditorLayout from "./layout/EditorLayout";
99
import EditorTitle from "./editor/EditorTitle";
10-
import SaveStatus from "./editor/ui/SaveStatus";
1110
import ActiveUser from "./commons/activeUser";
1211

1312
import usePageStore from "@/store/usePageStore";
@@ -85,15 +84,13 @@ export default function EditorView() {
8584
if (!ydoc || !provider) return null;
8685

8786
return (
88-
<EditorLayout>
89-
<SaveStatus saveStatus={saveStatus} />
87+
<EditorLayout saveStatus={saveStatus}>
9088
<EditorTitle
9189
key={currentPage}
9290
currentPage={currentPage}
9391
pageContent={pageContent}
9492
/>
9593
<ActiveUser
96-
className="px-12 py-4"
9794
users={users.filter(
9895
(user) => user.currentPageId === currentPage.toString(),
9996
)}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import {
2+
Maximize2,
3+
Minimize2,
4+
PanelLeftClose,
5+
PanelRightClose,
6+
} from "lucide-react";
7+
8+
import SaveStatus from "./ui/SaveStatus";
9+
import usePageStore from "@/store/usePageStore";
10+
import { cn } from "@/lib/utils";
11+
12+
interface EditorActionPanelProps {
13+
saveStatus: "saved" | "unsaved";
14+
}
15+
16+
export default function EditorActionPanel({
17+
saveStatus,
18+
}: EditorActionPanelProps) {
19+
const { isPanelOpen, togglePanel, isMaximized, toggleMaximized } =
20+
usePageStore();
21+
22+
return (
23+
<div
24+
className={cn(
25+
"mx-auto mb-2 flex items-center justify-between gap-2 p-4",
26+
isMaximized && "max-w-[900px] px-0",
27+
)}
28+
>
29+
<div className="flex items-center gap-1">
30+
<button
31+
onClick={togglePanel}
32+
className={cn(
33+
"z-50 flex h-6 w-6 !cursor-pointer items-center justify-center rounded-md hover:bg-neutral-200",
34+
!isPanelOpen &&
35+
"absolute -left-8 top-0 h-8 w-8 rounded-l border-b border-l border-t border-[#e0e6ee] bg-[#f5f5f5]",
36+
)}
37+
>
38+
{isPanelOpen ? (
39+
<PanelRightClose className="h-4 w-4" />
40+
) : (
41+
<PanelLeftClose className="h-4 w-4" />
42+
)}
43+
</button>
44+
<button
45+
onClick={toggleMaximized}
46+
className="flex h-6 w-6 !cursor-pointer items-center justify-center rounded-md rounded-l border-b border-l border-t border-none hover:bg-neutral-200"
47+
>
48+
{isMaximized ? (
49+
<Minimize2 className="h-4 w-4 rotate-90" />
50+
) : (
51+
<Maximize2 className="h-4 w-4 rotate-90" />
52+
)}
53+
</button>
54+
</div>
55+
<SaveStatus saveStatus={saveStatus} />
56+
</div>
57+
);
58+
}

apps/frontend/src/components/editor/EditorTitle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function EditorTitle({
2828
};
2929

3030
return (
31-
<div className="p-12 pb-0">
31+
<div className="pb-0">
3232
<input
3333
type="text"
3434
value={input as string}

apps/frontend/src/components/editor/prosemirror.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
font-weight: 600;
3434
}
3535

36-
.ProseMirror {
37-
@apply p-8 sm:px-12;
38-
}
39-
4036
.ProseMirror .p {
4137
@apply my-0;
4238
}

apps/frontend/src/components/editor/ui/SaveStatus.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ export interface SaveStatusProps {
44

55
export default function SaveStatus({ saveStatus }: SaveStatusProps) {
66
return (
7-
<div className="absolute right-5 top-5 z-10">
8-
<div className="rounded-lg bg-accent px-2 py-1 text-sm text-muted-foreground">
9-
{saveStatus}
10-
</div>
7+
<div className="rounded-lg bg-accent px-2 py-1 text-sm text-muted-foreground">
8+
{saveStatus}
119
</div>
1210
);
1311
}

apps/frontend/src/components/layout/EditorLayout.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
import { PanelRightClose, PanelLeftClose } from "lucide-react";
1+
import { cn } from "@/lib/utils";
22
import usePageStore from "@/store/usePageStore";
3+
import EditorActionPanel from "../editor/EditorActionPanel";
34

45
interface EditorLayoutProps {
6+
saveStatus: "saved" | "unsaved";
57
children: React.ReactNode;
68
}
79

8-
const EditorLayout = ({ children }: EditorLayoutProps) => {
9-
const { isPanelOpen, togglePanel } = usePageStore();
10+
const EditorLayout = ({ children, saveStatus }: EditorLayoutProps) => {
11+
const { isPanelOpen, isMaximized } = usePageStore();
1012

1113
return (
1214
<div
13-
className={`absolute right-0 h-[720px] w-[520px] rounded-bl-lg rounded-br-lg rounded-tr-lg border bg-white shadow-lg transition-transform duration-100 ease-in-out ${
14-
isPanelOpen ? "transform-none" : "translate-x-full"
15-
}`}
15+
className={cn(
16+
"absolute right-0 h-[720px] w-[520px] rounded-bl-lg rounded-br-lg rounded-tr-lg border bg-white shadow-lg transition-transform duration-100 ease-in-out",
17+
isPanelOpen ? "transform-none" : "translate-x-full",
18+
isMaximized ? "h-screen w-screen" : "w-[520px]",
19+
)}
1620
>
17-
<div className="h-full overflow-auto">{children}</div>
18-
19-
<button
20-
onClick={togglePanel}
21-
className="absolute -left-8 top-0 z-50 flex h-8 w-8 !cursor-pointer items-center justify-center rounded-l border-b border-l border-t border-[#e0e6ee] bg-[#f5f5f5]"
22-
>
23-
{isPanelOpen ? (
24-
<PanelRightClose className="h-4 w-4" />
25-
) : (
26-
<PanelLeftClose className="h-4 w-4" />
21+
<EditorActionPanel saveStatus={saveStatus} />
22+
<div
23+
className={cn(
24+
"flex h-full flex-col gap-4 overflow-auto px-12 py-4",
25+
isMaximized && "mx-auto mt-8 box-content w-[800px] px-0",
2726
)}
28-
</button>
27+
>
28+
{children}
29+
</div>
2930
</div>
3031
);
3132
};

apps/frontend/src/store/usePageStore.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ import { create } from "zustand";
33
interface PageStore {
44
currentPage: number | null;
55
isPanelOpen: boolean;
6+
isMaximized: boolean;
67
setCurrentPage: (currentPage: number | null) => void;
78
togglePanel: () => void;
9+
toggleMaximized: () => void;
810
setIsPanelOpen: (isOpen: boolean) => void;
911
}
1012

1113
const usePageStore = create<PageStore>((set) => ({
1214
currentPage: null,
1315
isPanelOpen: true,
16+
isMaximized: false,
1417
setCurrentPage: (currentPage: number | null) =>
1518
set((state) => ({
1619
currentPage,
@@ -20,6 +23,7 @@ const usePageStore = create<PageStore>((set) => ({
2023
: currentPage !== null,
2124
})),
2225
togglePanel: () => set((state) => ({ isPanelOpen: !state.isPanelOpen })),
26+
toggleMaximized: () => set((state) => ({ isMaximized: !state.isMaximized })),
2327
setIsPanelOpen: (isPanelOpen: boolean) => set({ isPanelOpen }),
2428
}));
2529

0 commit comments

Comments
 (0)