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

DO NOT MERGE Match Component Prototype #61

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react-router-dom": "^5.2.0",
"react-scripts": "^5.0.1",
"react-table": "^7.7.0",
"reactflow": "^11.11.4",
"styled-components": "^6.1.11",
"tailwind-merge": "^2.3.0",
"typescript": "^4.1.2",
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/common/grid/GridElement.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useRef, useEffect } from "react";
import BaseModule from "../../course_authoring/BaseModule";
import BaseModule from "../../course_authoring/BaseComponent";

interface MouseEventLike {
clientX: number;
Expand All @@ -8,7 +8,7 @@ interface MouseEventLike {

interface GridElementProps {
temp?: boolean;
index: string;
elementLayoutManifest: { i: string; w: number; h: number };
componentType?: string;
mouseEvent?: MouseEventLike;
activeComponent: string;
Expand Down Expand Up @@ -59,7 +59,7 @@ const createDragStartEvent = (

const GridElement: React.FC<GridElementProps> = ({
temp,
index,
elementLayoutManifest,
activeComponent,
setActiveComponent,
data,
Expand Down Expand Up @@ -96,7 +96,7 @@ const GridElement: React.FC<GridElementProps> = ({
style={{ height: "100%", ...style }}
className={className}
onMouseDown={(e) => {
setActiveComponent(activeComponent === index ? "10000" : index);
setActiveComponent(elementLayoutManifest.i);
if (onMouseDown) onMouseDown(e);
}}
onMouseUp={onMouseUp}
Expand All @@ -106,7 +106,7 @@ const GridElement: React.FC<GridElementProps> = ({
<BaseModule
name={componentType || ""}
activeComponent={activeComponent}
index={index}
elementLayoutManifest={elementLayoutManifest}
data={data}
setData={setData}
/>
Expand Down
58 changes: 58 additions & 0 deletions frontend/src/components/course_authoring/BaseComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from "react";
import TextComponent from "./TextComponent";
import MatchComponent from "./MatchComponent";
import TextPanel from "./TextPanel";
import MatchPanel from "./MatchPanel";

interface BasePrototypeProps {
name: string;
activeComponent: string;
elementLayoutManifest?: { i: string; w: number; h: number };
data: Map<string, object>;
setData: (data: Map<string, object>) => void;
}

const BaseComponent: React.FC<BasePrototypeProps> = ({
name,
data,
setData,
activeComponent,
elementLayoutManifest = { i: "", w: 0, h: 0 },
}) => {
switch (name) {
case "TextComponent":
return (
<TextComponent componentData={data.get(elementLayoutManifest.i)} />
);
case "MatchComponent":
return (
<MatchComponent
componentData={data}
setComponentData={setData}
i={elementLayoutManifest.i}
w={elementLayoutManifest.w}
h={elementLayoutManifest.h}
/>
);
case "EditTextComponent":
return (
<TextPanel
componentData={data}
setComponentData={setData}
index={activeComponent}
/>
);
case "EditMatchComponent":
return (
<MatchPanel
componentData={data}
setComponentData={setData}
index={activeComponent}
/>
);
default:
return null;
}
};

export default BaseComponent;
40 changes: 0 additions & 40 deletions frontend/src/components/course_authoring/BaseModule.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions frontend/src/components/course_authoring/EditMatch.tsx

This file was deleted.

38 changes: 0 additions & 38 deletions frontend/src/components/course_authoring/Match.tsx

This file was deleted.

Loading