From dbf50353e53f8c218a19b1dff6bca7d551b1b52a Mon Sep 17 00:00:00 2001 From: Pedro Pupo Sa da Costa Date: Wed, 7 Feb 2024 23:09:15 +0000 Subject: [PATCH] feat: new design --- .../questions/editor/[questionId].page.tsx | 108 +++++------ libs/react/containers/src/index.ts | 1 + .../layouts/layout-module/layout-module.tsx | 3 +- .../questions/hooks/use-question-editor.tsx | 1 - .../question-editor-annexes.tsx | 108 +++++------ .../question-editor-explanation.tsx | 57 ++---- .../question-editor-learning-objectives.tsx | 35 ++-- .../question-editor-variant.tsx | 167 ++---------------- .../routers/containers/questions-router.ts | 1 + 9 files changed, 160 insertions(+), 321 deletions(-) diff --git a/apps/next-app/pages/modules/[questionBank]/questions/editor/[questionId].page.tsx b/apps/next-app/pages/modules/[questionBank]/questions/editor/[questionId].page.tsx index d96a80657..8d54a5676 100644 --- a/apps/next-app/pages/modules/[questionBank]/questions/editor/[questionId].page.tsx +++ b/apps/next-app/pages/modules/[questionBank]/questions/editor/[questionId].page.tsx @@ -1,11 +1,20 @@ -import { useRouter } from "next/router"; -import { Box, Tab, TabList, TabPanel, Tabs, tabClasses } from "@mui/joy"; +import { default as RightArrow } from "@mui/icons-material/ChevronRightOutlined"; +import { + Divider, + Tab, + TabList, + TabPanel, + Tabs, + tabClasses, + tabPanelClasses, +} from "@mui/joy"; import { AppHead } from "@chair-flight/react/components"; import { LayoutModule, QuestionEditorAnnexes, QuestionEditorExplanation, QuestionEditorLearningObjectives, + QuestionEditorPreview, QuestionEditorRelatedQuestions, QuestionEditorVariant, } from "@chair-flight/react/containers"; @@ -14,11 +23,7 @@ import type { QuestionBankName } from "@chair-flight/core/question-bank"; import type { Breadcrumbs } from "@chair-flight/react/containers"; import type { NextPage } from "next"; -type QueryParams = { - tab?: string; -}; - -type PageParams = QueryParams & { +type PageParams = { questionBank: QuestionBankName; questionId: string; }; @@ -26,26 +31,9 @@ type PageParams = QueryParams & { type PageProps = { questionBank: QuestionBankName; questionId: string; - tab: string; }; -const Page: NextPage = ({ - questionBank, - questionId, - tab: initialTab, -}) => { - const router = useRouter(); - const query = router.query as PageParams; - const tab = query.tab ?? initialTab; - - const updateQuery = (query: QueryParams) => { - router.push( - { ...router, query: { ...router.query, ...query } }, - undefined, - { shallow: true }, - ); - }; - +const Page: NextPage = ({ questionBank, questionId }) => { const crumbs = [ [questionBank.toUpperCase(), `/modules/${questionBank}`], ["Questions", `/modules/${questionBank}/questions`], @@ -59,70 +47,64 @@ const Page: NextPage = ({ breadcrumbs={crumbs} fixedHeight noPadding + sx={{ flexDirection: "row" }} > + updateQuery({ tab: v as string })} + defaultValue={"question"} sx={{ - backgroundColor: "transparent", - display: "flex", - flexDirection: "column", - height: "100%", + pl: 1, + flex: 1, + background: "transparent", + + [`& .${tabPanelClasses.root}`]: { + flex: 1, + overflow: "hidden", + my: 1, + py: 0, + }, + + [`& .${tabClasses.selected}`]: { + color: "primary.plainColor", + background: "transparent", + }, }} > - `calc(${theme.spacing(5)} + 2px)`, - - [`& .${tabClasses.selected}`]: { - color: "primary.plainColor", - }, - }} - > + Question Explanation - Learning Objectives - Related Questions + LOs Annexes + Related - `calc(${theme.spacing(5)} + 2px)` }} /> - + - + - - - - - + - - + = ({ /> + + + + ); }; diff --git a/libs/react/containers/src/index.ts b/libs/react/containers/src/index.ts index 4fb4f5fe6..8e3c86477 100644 --- a/libs/react/containers/src/index.ts +++ b/libs/react/containers/src/index.ts @@ -31,3 +31,4 @@ export * from "./tests/test-review"; export * from "./tests/test-search"; export * from "./tests/test-study"; export * from "./user/user-settings"; +export * from "./questions/question-editor-preview"; diff --git a/libs/react/containers/src/layouts/layout-module/layout-module.tsx b/libs/react/containers/src/layouts/layout-module/layout-module.tsx index dac3ae882..bfb65d68b 100644 --- a/libs/react/containers/src/layouts/layout-module/layout-module.tsx +++ b/libs/react/containers/src/layouts/layout-module/layout-module.tsx @@ -61,7 +61,7 @@ type Params = { type Data = AppRouterOutput["containers"]["layouts"]["getLayoutModule"]; export const LayoutModule = container( - ({ children, fixedHeight, noPadding, questionBank, breadcrumbs }) => { + ({ children, fixedHeight, noPadding, questionBank, breadcrumbs, sx }) => { const { isTransitioning } = usePageTransition(); const router = useRouter(); const data = LayoutModule.useData({ questionBank }); @@ -231,6 +231,7 @@ export const LayoutModule = container( ...(fixedHeight ? { height: `calc(100vh - ${HEADER_HEIGHT}px)` } : {}), + ...sx, }} /> diff --git a/libs/react/containers/src/questions/hooks/use-question-editor.tsx b/libs/react/containers/src/questions/hooks/use-question-editor.tsx index aa3250d8f..89eb59488 100644 --- a/libs/react/containers/src/questions/hooks/use-question-editor.tsx +++ b/libs/react/containers/src/questions/hooks/use-question-editor.tsx @@ -247,7 +247,6 @@ export const useQuestionEditor = create()( questionA: questionAid, questionB: questionBid, }) => { - const router = trpc.common.questions; const questionA = get()[questionBank].afterState[questionAid]; const questionB = get()[questionBank].afterState[questionBid]; diff --git a/libs/react/containers/src/questions/question-editor-annexes/question-editor-annexes.tsx b/libs/react/containers/src/questions/question-editor-annexes/question-editor-annexes.tsx index 07ed39b98..31aeaa3e7 100644 --- a/libs/react/containers/src/questions/question-editor-annexes/question-editor-annexes.tsx +++ b/libs/react/containers/src/questions/question-editor-annexes/question-editor-annexes.tsx @@ -3,14 +3,7 @@ import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { default as AddIcon } from "@mui/icons-material/Add"; import { default as DeleteIcon } from "@mui/icons-material/DeleteOutlineOutlined"; -import { - Box, - Button, - ListItemContent, - Stack, - Tooltip, - Typography, -} from "@mui/joy"; +import { Button, ListItemContent, Stack, Tooltip, Typography } from "@mui/joy"; import { annexSearchFilters } from "@chair-flight/core/search"; import { ImageWithModal, @@ -81,20 +74,21 @@ export const QuestionEditorAnnexes = container( }; return ( - - - - filterForm.setValue(k as FilterKeys, v) - } - /> + + + filterForm.setValue(k as FilterKeys, v) + } + /> + ( renderThead={() => null} renderTableRow={() => null} renderListItemContent={(result) => ( - - - + + {result.id} - - {result.description} - - -