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: question creation module #125

Merged
merged 23 commits into from Feb 24, 2023
Merged

feat: question creation module #125

merged 23 commits into from Feb 24, 2023

Conversation

joyce-shi
Copy link
Contributor

@joyce-shi joyce-shi commented Feb 13, 2023

Notion ticket link

Add text component to Question Editor

Implementation description

  • Installed react-dnd library
  • Added drag and drop for text element in question creation module

Steps to test

  1. Run locally
Screen.Recording.2023-02-20.at.6.23.18.PM.mov

What should reviewers focus on?

  • Test feature compared to Figma design

Some Notes:

  • While dragging, the image preview is the sidebar item, not the text input component. According to design this is the desired behaviour!
  • Currently, the error message behaviour has not been implemented, since I am awaiting design on some related decisions

import {
ArrowBackOutlineIcon,
ColumnIcon,
Copy link
Contributor Author

@joyce-shi joyce-shi Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per design, since we are no longer supporting the Column feature!

...prevQuestionElements,
newQuestionElement,
]);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the next PR, I'm going to refactor this to use useContext to avoid prop drilling + for a cleaner implementation. Just wanted to get this PR merged since the ticket has been open for waaaaaay too long!

@joyce-shi joyce-shi marked this pull request as ready for review February 20, 2023 23:14
@joyce-shi joyce-shi requested review from carissa-tang and a team February 20, 2023 23:14
@@ -194,7 +194,6 @@ const UsersPage = (): React.ReactElement => {
}
};

type Role = "teacher" | "admin";
return (
<>
<Box>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linting

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should disappear once you pull from staging


const HoverMessage = (): React.ReactElement => <Text>You are hovering.</Text>;

export default HoverMessage;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is temporary, I'm waiting for a design decision on what the Hover state should look like here!

return <Text key={index}>this is a multi select element.</Text>;
default:
return null;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update this to use the appropriate components as they are created!

const opacity = isDragging ? 0.4 : 1;
return (
<Box ref={drag} style={{ opacity }}>
<WrapItem cursor="grab">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the cursor changes appropriately when hovering over the QuestionSidebarItem. However, I can't get the cursor to change while dragging. According to the linked thread, this is how the HTML API for drag and drop works and the fix is to implement a custom API. Given this, leaving the cursor as is.

VStack,
HStack,
} from "@chakra-ui/react";
import { Text, VStack, HStack } from "@chakra-ui/react";

import { AdminUser, TeacherUser } from "../../types/UserTypes";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter

@@ -1,5 +1,4 @@
import React from "react";
import { AdminUser } from "../../types/UserTypes";
import { TableRow, Table } from "../common/Table";
import RemoveUserPopover from "./RemoveUserPopover";
import { AdminTableProps } from "./AdminTab";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter

);
};

export default TextElement;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the TextElement is not draggable or deletable... I'll address that in a future PR since this ones getting pretty big.

Copy link
Collaborator

@carissa-tang carissa-tang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two small comments, but looks good otherwise!

we probably will need to restructure how errors are handled (probably in QuestionPage and passed into QuestionEditor for setting/unsetting and QuestionSidebar for onSubmit) but can be in a follow up PR

@joyce-shi
Copy link
Contributor Author

two small comments, but looks good otherwise!

we probably will need to restructure how errors are handled (probably in QuestionPage and passed into QuestionEditor for setting/unsetting and QuestionSidebar for onSubmit) but can be in a follow up PR

yup makes sense! I created a ticket to handle passing the data from the entire QuestionEditor to the Create Assessment page, so I think all the error stuff can be finalized then? Lmk if I'm understanding correctly!

@carissa-tang
Copy link
Collaborator

assing the data from the entire QuestionEditor to the Create Assessment page, so I think all the error stuff can be finalized then? Lmk if I'm understanding correctly!

i guess in QuestionPage, we would

  1. initialize error variables and pass to QuestionEditor
  2. have handleSave function that validates errors and is passed to QuestionSidebar for callback

and then on success, we would need to pass the data back to Create Assessment

@github-actions
Copy link

Visit the preview URL for this PR (updated for commit 14b7350):

https://jump-math-staging--pr125-joyce-dnd-setup-ipyui92f.web.app

(expires Fri, 03 Mar 2023 03:56:24 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c42d8d0d853b05885664a2dd73f8245f4333ae51

@joyce-shi joyce-shi merged commit 04b65a1 into staging Feb 24, 2023
@joyce-shi joyce-shi deleted the joyce/dnd-setup branch March 31, 2023 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants