Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fe2): collapsible editor tab #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 54 additions & 32 deletions cvdl-editor/fe2/src/components/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function App() {
const [currentTab, setCurrentTab] = useState<
"content-editor" | "layout-editor" | "schema-editor" | "raw-editor"
>("content-editor");
const [isEditorTabCollapsed, setIsEditorTabCollapsed] = useState<boolean>(false);

useEffect(() => {
require("../registerStaticFiles.js");
Expand Down Expand Up @@ -301,38 +302,59 @@ function App() {
<DocumentDispatchContext.Provider value={dispatch}>
<Layout>
<div style={{ display: "flex", flexDirection: "row", height: '100%' }}>
<div
style={{
display: "flex",
flexDirection: "column",
margin: "20px",
}}
>
<button
className={`bordered ${currentTab === "content-editor" ? "selected" : ""}`}
onClick={() => setCurrentTab("content-editor")}
>
Content Editor
</button>
<button
className={`bordered ${currentTab === "layout-editor" ? "selected" : ""}`}
onClick={() => setCurrentTab("layout-editor")}
>
Layout Editor
</button>
<button
className={`bordered ${currentTab === "schema-editor" ? "selected" : ""}`}
onClick={() => setCurrentTab("schema-editor")}
>
Schema Editor
</button>
<button
className={`bordered ${currentTab === "raw-editor" ? "selected" : ""}`}
onClick={() => setCurrentTab("raw-editor")}
>
Raw Editor
</button>
</div>
<div className="flex flex-col m-5 w-40">
{isEditorTabCollapsed ? (
<>
<button
className={`border border-[rgb(var(--foreground-rgb))] rounded px-2.5 py-1.5 mb-1.5 w-full `}
onClick={() => setIsEditorTabCollapsed((prev) => !prev)}
>
Editors +
</button>
</>
) : (
<>
<button
className={`border border-[rgb(var(--foreground-rgb))] rounded px-2.5 py-1.5 mb-1.5 w-full`}
onClick={() => setIsEditorTabCollapsed((prev) => !prev)}
>
Editors -
</button>
<button
className={`border border-[rgb(var(--foreground-rgb))] rounded px-2.5 py-1.5 mb-1.5 w-full ${
currentTab === "content-editor" ? "selected" : ""
}`}
onClick={() => setCurrentTab("content-editor")}
>
Content Editor
</button>
<button
className={`border border-[rgb(var(--foreground-rgb))] rounded px-2.5 py-1.5 mb-1.5 w-full ${
currentTab === "layout-editor" ? "selected" : ""
}`}
onClick={() => setCurrentTab("layout-editor")}
>
Layout Editor
</button>
<button
className={`border border-[rgb(var(--foreground-rgb))] rounded px-2.5 py-1.5 mb-1.5 w-full ${
currentTab === "schema-editor" ? "selected" : ""
}`}
onClick={() => setCurrentTab("schema-editor")}
>
Schema Editor
</button>
<button
className={`border border-[rgb(var(--foreground-rgb))] rounded px-2.5 py-1.5 mb-1.5 w-full ${
currentTab === "raw-editor" ? "selected" : ""
}`}
onClick={() => setCurrentTab("raw-editor")}
>
Raw Editor
</button>
</>
)}
</div>
<div
style={{
display: "flex",
Expand Down