Remove sidebar
This commit is contained in:
parent
005c3fd2a6
commit
6f2b7a42b4
@ -2,7 +2,6 @@ import { useContext, useState } from "react";
|
|||||||
import {
|
import {
|
||||||
IconCaretdown,
|
IconCaretdown,
|
||||||
IconChevronRight,
|
IconChevronRight,
|
||||||
IconShareStroked,
|
|
||||||
IconChevronUp,
|
IconChevronUp,
|
||||||
IconChevronDown,
|
IconChevronDown,
|
||||||
IconCheckboxTick,
|
IconCheckboxTick,
|
||||||
@ -16,8 +15,6 @@ import {
|
|||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import icon from "../assets/icon_dark_64.png";
|
import icon from "../assets/icon_dark_64.png";
|
||||||
import {
|
import {
|
||||||
Avatar,
|
|
||||||
AvatarGroup,
|
|
||||||
Button,
|
Button,
|
||||||
Divider,
|
Divider,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
@ -30,8 +27,12 @@ import {
|
|||||||
Upload,
|
Upload,
|
||||||
Banner,
|
Banner,
|
||||||
Toast,
|
Toast,
|
||||||
TagInput,
|
SideSheet,
|
||||||
|
List,
|
||||||
} from "@douyinfe/semi-ui";
|
} from "@douyinfe/semi-ui";
|
||||||
|
import timeLine from "../assets/process.png";
|
||||||
|
import timeLineDark from "../assets/process_dark.png";
|
||||||
|
import todo from "../assets/calendar.png";
|
||||||
import { toPng, toJpeg, toSvg } from "html-to-image";
|
import { toPng, toJpeg, toSvg } from "html-to-image";
|
||||||
import { saveAs } from "file-saver";
|
import { saveAs } from "file-saver";
|
||||||
import {
|
import {
|
||||||
@ -64,6 +65,7 @@ import { Editor } from "@monaco-editor/react";
|
|||||||
import { db } from "../data/db";
|
import { db } from "../data/db";
|
||||||
import { useLiveQuery } from "dexie-react-hooks";
|
import { useLiveQuery } from "dexie-react-hooks";
|
||||||
import { socket } from "../data/socket";
|
import { socket } from "../data/socket";
|
||||||
|
import Todo from "./Todo";
|
||||||
|
|
||||||
export default function ControlPanel({
|
export default function ControlPanel({
|
||||||
diagramId,
|
diagramId,
|
||||||
@ -90,8 +92,14 @@ export default function ControlPanel({
|
|||||||
ERROR: 2,
|
ERROR: 2,
|
||||||
OK: 3,
|
OK: 3,
|
||||||
};
|
};
|
||||||
|
const SIDESHEET = {
|
||||||
|
NONE: 0,
|
||||||
|
TODO: 1,
|
||||||
|
TIMELINE: 2,
|
||||||
|
};
|
||||||
const diagrams = useLiveQuery(() => db.diagrams.toArray());
|
const diagrams = useLiveQuery(() => db.diagrams.toArray());
|
||||||
const [visible, setVisible] = useState(MODAL.NONE);
|
const [visible, setVisible] = useState(MODAL.NONE);
|
||||||
|
const [sidesheet, setSidesheet] = useState(SIDESHEET.NONE);
|
||||||
const [prevTitle, setPrevTitle] = useState(title);
|
const [prevTitle, setPrevTitle] = useState(title);
|
||||||
const [saveAsTitle, setSaveAsTitle] = useState(title);
|
const [saveAsTitle, setSaveAsTitle] = useState(title);
|
||||||
const [selectedDiagramId, setSelectedDiagramId] = useState(0);
|
const [selectedDiagramId, setSelectedDiagramId] = useState(0);
|
||||||
@ -1066,10 +1074,6 @@ export default function ControlPanel({
|
|||||||
function: () =>
|
function: () =>
|
||||||
setLayout((prev) => ({ ...prev, issues: !prev.issues })),
|
setLayout((prev) => ({ ...prev, issues: !prev.issues })),
|
||||||
},
|
},
|
||||||
Services: {
|
|
||||||
function: () =>
|
|
||||||
setLayout((prev) => ({ ...prev, services: !prev.services })),
|
|
||||||
},
|
|
||||||
"Strict mode": {
|
"Strict mode": {
|
||||||
function: viewStrictMode,
|
function: viewStrictMode,
|
||||||
shortcut: "Ctrl+Shift+M",
|
shortcut: "Ctrl+Shift+M",
|
||||||
@ -1584,9 +1588,85 @@ export default function ControlPanel({
|
|||||||
>
|
>
|
||||||
{getModalBody()}
|
{getModalBody()}
|
||||||
</Modal>
|
</Modal>
|
||||||
|
<SideSheet
|
||||||
|
visible={sidesheet !== SIDESHEET.NONE}
|
||||||
|
onCancel={() => {
|
||||||
|
setSidesheet(SIDESHEET.NONE);
|
||||||
|
}}
|
||||||
|
width={340}
|
||||||
|
title={getTitle(sidesheet)}
|
||||||
|
style={{ paddingBottom: "16px" }}
|
||||||
|
bodyStyle={{ padding: "0px" }}
|
||||||
|
>
|
||||||
|
{getContent(sidesheet)}
|
||||||
|
</SideSheet>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function getTitle(type) {
|
||||||
|
switch (type) {
|
||||||
|
case SIDESHEET.TIMELINE:
|
||||||
|
return (
|
||||||
|
<div className="flex items-center">
|
||||||
|
<img
|
||||||
|
src={settings.mode === "light" ? timeLine : timeLineDark}
|
||||||
|
className="w-7"
|
||||||
|
alt="chat icon"
|
||||||
|
/>
|
||||||
|
<div className="ms-3 text-lg">Timeline</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
case SIDESHEET.TODO:
|
||||||
|
return (
|
||||||
|
<div className="flex items-center">
|
||||||
|
<img src={todo} className="w-7" alt="todo icon" />
|
||||||
|
<div className="ms-3 text-lg">To-do list</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContent(type) {
|
||||||
|
switch (type) {
|
||||||
|
case SIDESHEET.TIMELINE:
|
||||||
|
return renderTimeline();
|
||||||
|
case SIDESHEET.TODO:
|
||||||
|
return <Todo />;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTimeline() {
|
||||||
|
if (undoStack.length > 0) {
|
||||||
|
return (
|
||||||
|
<List className="sidesheet-theme">
|
||||||
|
{[...undoStack].reverse().map((e, i) => (
|
||||||
|
<List.Item
|
||||||
|
key={i}
|
||||||
|
style={{ padding: "4px 18px 4px 18px" }}
|
||||||
|
className="hover-1"
|
||||||
|
>
|
||||||
|
<div className="flex items-center py-1 w-full">
|
||||||
|
<i className="block fa-regular fa-circle fa-xs"></i>
|
||||||
|
<div className="ms-2">{e.message}</div>
|
||||||
|
</div>
|
||||||
|
</List.Item>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div className="m-5 sidesheet-theme">
|
||||||
|
No activity was recorded. You have not added anything to your diagram
|
||||||
|
yet.
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toolbar() {
|
function toolbar() {
|
||||||
return (
|
return (
|
||||||
<div className="py-1 px-5 flex justify-between items-center rounded-xl my-1 sm:mx-1 xl:mx-6 select-none overflow-x-hidden toolbar-theme">
|
<div className="py-1 px-5 flex justify-between items-center rounded-xl my-1 sm:mx-1 xl:mx-6 select-none overflow-x-hidden toolbar-theme">
|
||||||
@ -1719,9 +1799,14 @@ export default function ControlPanel({
|
|||||||
<IconSaveStroked size="extra-large" />
|
<IconSaveStroked size="extra-large" />
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content="Commit" position="bottom">
|
<Tooltip content="Timeline" position="bottom">
|
||||||
<button className="py-1 px-2 hover-2 rounded text-xl">
|
<button className="py-1 px-2 hover-2 rounded text-xl" onClick={() => setSidesheet(SIDESHEET.TIMELINE)}>
|
||||||
<i className="fa-solid fa-code-branch"></i>
|
<i className="fa-solid fa-timeline"></i>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip content="To-do" position="bottom">
|
||||||
|
<button className="py-1 px-2 hover-2 rounded text-xl" onClick={() => setSidesheet(SIDESHEET.TODO)}>
|
||||||
|
<i className="fa-regular fa-calendar-check"></i>
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
@ -1915,19 +2000,6 @@ export default function ControlPanel({
|
|||||||
>
|
>
|
||||||
Issues
|
Issues
|
||||||
</Dropdown.Item>
|
</Dropdown.Item>
|
||||||
|
|
||||||
<Dropdown.Item
|
|
||||||
icon={
|
|
||||||
layout.services ? (
|
|
||||||
<IconCheckboxTick />
|
|
||||||
) : (
|
|
||||||
<div className="px-2"></div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
onClick={() => invertLayout("services")}
|
|
||||||
>
|
|
||||||
Services
|
|
||||||
</Dropdown.Item>
|
|
||||||
<Dropdown.Divider />
|
<Dropdown.Divider />
|
||||||
<Dropdown.Item
|
<Dropdown.Item
|
||||||
icon={
|
icon={
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { useState, createContext, useEffect } from "react";
|
import { useState, createContext, useEffect } from "react";
|
||||||
import Sidebar from "../components/Sidebar";
|
|
||||||
import ControlPanel from "../components/ControlPanel";
|
import ControlPanel from "../components/ControlPanel";
|
||||||
import Canvas from "../components/Canvas";
|
import Canvas from "../components/Canvas";
|
||||||
import SidePanel from "../components/SidePanel";
|
import SidePanel from "../components/SidePanel";
|
||||||
@ -67,10 +67,6 @@ export default function Editor() {
|
|||||||
showCardinality: true,
|
showCardinality: true,
|
||||||
});
|
});
|
||||||
const [tasks, setTasks] = useState([]);
|
const [tasks, setTasks] = useState([]);
|
||||||
const [messages, setMessages] = useState([]);
|
|
||||||
const [botMessages, setBotMessages] = useState([
|
|
||||||
{ sender: "bot", message: "Hey there! How can I help you?" },
|
|
||||||
]);
|
|
||||||
const [undoStack, setUndoStack] = useState([]);
|
const [undoStack, setUndoStack] = useState([]);
|
||||||
const [redoStack, setRedoStack] = useState([]);
|
const [redoStack, setRedoStack] = useState([]);
|
||||||
const [historyCount, setHistoryCount] = useState(0);
|
const [historyCount, setHistoryCount] = useState(0);
|
||||||
@ -1218,17 +1214,6 @@ export default function Editor() {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Canvas state={state} setState={setState} />
|
<Canvas state={state} setState={setState} />
|
||||||
{layout.services && (
|
|
||||||
<MessageContext.Provider
|
|
||||||
value={{ messages, setMessages }}
|
|
||||||
>
|
|
||||||
<BotMessageContext.Provider
|
|
||||||
value={{ botMessages, setBotMessages }}
|
|
||||||
>
|
|
||||||
<Sidebar />
|
|
||||||
</BotMessageContext.Provider>
|
|
||||||
</MessageContext.Provider>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TypeContext.Provider>
|
</TypeContext.Provider>
|
||||||
|
Loading…
Reference in New Issue
Block a user