Skip to content

Commit

Permalink
fix: Redesign sidebar description (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
nesadrian authored Dec 10, 2024
1 parent 9a39225 commit c499138
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 44 deletions.
4 changes: 2 additions & 2 deletions components/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Icon.add({ link });
export default function MarkdownEditor(props: {
canEdit?: boolean;
defaultText: string;
label: string;
label?: string;
onChange?: (value?: string) => void;
helperText?: string;
requireText?: boolean;
Expand Down Expand Up @@ -137,7 +137,7 @@ export default function MarkdownEditor(props: {
previewOptions={{
rehypePlugins: [[rehypeSanitize]],
style: {
backgroundColor: canEdit ? "rgba(247,247,247,1" : "white",
backgroundColor: "rgba(247,247,247,1",
color: "rgba(61,61,61,1)",
cursor: canEdit ? "text" : "not-allowed",
fontSize: "1rem",
Expand Down
2 changes: 1 addition & 1 deletion components/canvas/Flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Flow = ({ apiNodes, apiEdges, userCanEdit }: CanvasProps) => {
const ref = useRef<HTMLDivElement>(null);
const { menuData, onNodeContextMenu, onPaneContextMenu, closeContextMenu } =
useContextMenu(ref);
const anyNodeIsSelected = selectedNode !== undefined;
const anyNodeIsSelected = selectedNode !== undefined || !!selectedNodeForPQIR;

const { copyToClipboard, paste } = useCopyPaste(
hoveredNode,
Expand Down
17 changes: 10 additions & 7 deletions components/canvas/Sidebar/NewPQIR.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { NodeDataCommon } from "@/types/NodeData";
import { uid } from "@/utils/uuid";
import { Button, Checkbox, Icon } from "@equinor/eds-core-react";
import { add } from "@equinor/eds-icons";
import dynamic from "next/dynamic";
import styles from "./PQIRListElement.module.scss";
import { PQIRListElementTextField } from "./PQIRListElementTextField";
import { PQIRTypeSelection } from "./PQIRTypeSelection";
import { usePQIR } from "./usePQIR";
import { usePQIRMutations } from "./usePQIRMutations";

const MarkdownEditor = dynamic(() => import("components/MarkdownEditor"), {
ssr: false,
});

type NewPQIRProps = {
selectedNode: NodeDataCommon;
};
Expand Down Expand Up @@ -87,11 +90,11 @@ export const NewPQIR = ({ selectedNode }: NewPQIRProps) => {
<div className={styles.panel}>
<div className={styles.panelContent}>
{panelSectionTop()}
<PQIRListElementTextField
id={uid()}
value={description}
onEdit={(e) => setDescription(e)}
userCanEdit
<MarkdownEditor
defaultText={description}
onChange={(value) => value && setDescription(value)}
canEdit
requireText
/>
{panelSectionBottom(selectedNode.id)}
</div>
Expand Down
16 changes: 10 additions & 6 deletions components/canvas/Sidebar/PQIRListElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ import {
Typography,
} from "@equinor/eds-core-react";
import { add, delete_to_trash, minimize } from "@equinor/eds-icons";
import dynamic from "next/dynamic";
import { TextCircle } from "../entities/TextCircle";
import styles from "./PQIRListElement.module.scss";
import { PQIRListElementTextField } from "./PQIRListElementTextField";
import { PQIRTypeSelection } from "./PQIRTypeSelection";
import { usePQIR } from "./usePQIR";
import { usePQIRMutations } from "./usePQIRMutations";

const MarkdownEditor = dynamic(() => import("components/MarkdownEditor"), {
ssr: false,
});

type PQIRListElement = {
pqir: Task;
isSelectedSection?: boolean;
Expand Down Expand Up @@ -122,11 +126,11 @@ export const PQIRListELement = ({
<Accordion.Panel className={styles.panel}>
<div className={styles.panelContent}>
{userCanEdit && panelSectionTop}
<PQIRListElementTextField
id={pqir.id}
value={description}
userCanEdit={userCanEdit}
onEdit={(e) => setDescription(e)}
<MarkdownEditor
defaultText={description}
onChange={(value) => value && setDescription(value)}
canEdit={userCanEdit}
requireText
/>
{userCanEdit && panelSectionBottom}
</div>
Expand Down
28 changes: 0 additions & 28 deletions components/canvas/Sidebar/PQIRListElementTextField.tsx

This file was deleted.

0 comments on commit c499138

Please sign in to comment.