From ca5110e4f75251facbf17d43a86adaffce843804 Mon Sep 17 00:00:00 2001 From: swve Date: Sat, 8 Apr 2023 15:11:24 +0200 Subject: [PATCH 01/11] feat: init new modal --- .../course/[courseid]/edit/page.tsx | 48 ++-- front/components/Drags/Chapter.tsx | 3 + .../Modals/CourseEdit/NewActivity.tsx | 14 +- .../Modals/CourseEdit/NewChapter.tsx | 6 +- front/components/UI/Modal/Modal.tsx | 226 ++++++++++++++++++ front/package-lock.json | 11 + front/package.json | 1 + 7 files changed, 283 insertions(+), 26 deletions(-) create mode 100644 front/components/UI/Modal/Modal.tsx diff --git a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx index d4be427d..1b2a686a 100644 --- a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx +++ b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx @@ -14,6 +14,7 @@ import NewChapterModal from "@components/Modals/CourseEdit/NewChapter"; import NewActivityModal from "@components/Modals/CourseEdit/NewActivity"; import { createActivity, createFileActivity } from "@services/courses/activities"; import { getOrganizationContextInfo } from "@services/organizations/orgs"; +import Modal from "@components/UI/Modal/Modal"; function CourseEdit(params: any) { const router = useRouter(); @@ -32,7 +33,7 @@ function CourseEdit(params: any) { const courseid = params.params.courseid; const orgslug = params.params.orgslug; - + async function getCourseChapters() { const courseChapters = await getCourseChaptersMetadata(courseid); @@ -123,6 +124,8 @@ function CourseEdit(params: any) { }; const closeNewActivityModal = () => { + console.log("closeNewActivityModal"); + setNewActivityModal(false); }; @@ -233,13 +236,22 @@ function CourseEdit(params: any) { Edit Course {" "} - <button - onClick={() => { - setNewChapterModal(true); - }} - > - Add chapter + - </button> + <Modal + isDialogOpen={newChapterModal} + onOpenChange={setNewChapterModal} + minHeight="sm" + dialogContent={<NewChapterModal + closeModal={closeNewChapterModal} + submitChapter={submitChapter} + ></NewChapterModal>} + dialogTitle="Create chapter" + dialogDescription="Add a new chapter to the course" + dialogTrigger={ + <button> Add chapter + + </button> + } + /> + <button onClick={() => { updateChapters(); @@ -247,16 +259,22 @@ function CourseEdit(params: any) { > Save </button> - - {newChapterModal && } - {newActivityModal && ( - - + + - )} + >} + dialogTitle="Create Activity" + dialogDescription="Choose between types of activities to add to the course" + + />
{winReady && ( @@ -287,7 +305,7 @@ function CourseEdit(params: any) { )} -
+ ); } diff --git a/front/components/Drags/Chapter.tsx b/front/components/Drags/Chapter.tsx index f4253593..850e189a 100644 --- a/front/components/Drags/Chapter.tsx +++ b/front/components/Drags/Chapter.tsx @@ -21,8 +21,11 @@ function Chapter(props: any) { props.openNewActivityModal(props.info.list.chapter.id); }} > + Create Activity + + -

Add New Activity

-
{selectedView === "home" && ( - {setSelectedView("dynamic")}}>✨📄 - {setSelectedView("video")}}>📹 + { setSelectedView("dynamic") }}>✨📄 + { setSelectedView("video") }}>📹 )} @@ -33,8 +31,8 @@ function NewActivityModal({ closeModal, submitActivity, submitFileActivity, chap {selectedView === "video" && ( )} - - + + ); } diff --git a/front/components/Modals/CourseEdit/NewChapter.tsx b/front/components/Modals/CourseEdit/NewChapter.tsx index 1910ebde..aa7549ca 100644 --- a/front/components/Modals/CourseEdit/NewChapter.tsx +++ b/front/components/Modals/CourseEdit/NewChapter.tsx @@ -20,13 +20,13 @@ function NewChapterModal({ submitChapter , closeModal }: any) { }; return ( - -

Add New Chapter

+
+

- +
); } diff --git a/front/components/UI/Modal/Modal.tsx b/front/components/UI/Modal/Modal.tsx new file mode 100644 index 00000000..ff49fadd --- /dev/null +++ b/front/components/UI/Modal/Modal.tsx @@ -0,0 +1,226 @@ +import React from 'react'; +import * as Dialog from '@radix-ui/react-dialog'; +import { styled, keyframes } from '@stitches/react'; +import { violet, blackA, mauve, green } from '@radix-ui/colors'; +import { Cross2Icon } from '@radix-ui/react-icons'; + +type ModalParams = { + dialogTitle: string; + dialogDescription: string; + dialogContent: React.ReactNode; + dialogClose?: React.ReactNode | null; + dialogTrigger?: React.ReactNode; + onOpenChange: any; + isDialogOpen?: boolean; + minHeight?: "sm" | "md" | "lg" | "xl" +}; + +const Modal = (params: ModalParams) => ( + + {params.dialogTrigger ? ( + + {params.dialogTrigger} + + ) : null} + + + + + + {params.dialogTitle} + + {params.dialogDescription} + + + {params.dialogContent} + + {params.dialogClose} + + + + +); + +const overlayShow = keyframes({ + '0%': { opacity: 0 }, + '100%': { opacity: 1 }, +}); + +const overlayClose = keyframes({ + '0%': { opacity: 1 }, + '100%': { opacity: 0 }, +}); + +const contentShow = keyframes({ + '0%': { opacity: 0, transform: 'translate(-50%, -50%) scale(.96)' }, + '100%': { opacity: 1, transform: 'translate(-50%, -50%) scale(1)' }, +}); + +const contentClose = keyframes({ + '0%': { opacity: 1, transform: 'translate(-50%, -50%) scale(1)' }, + '100%': { opacity: 0, transform: 'translate(-50%, -52%) scale(.96)' }, +}); + +const DialogOverlay = styled(Dialog.Overlay, { + backgroundColor: blackA.blackA9, + position: 'fixed', + + inset: 0, + animation: `${overlayShow} 150ms cubic-bezier(0.16, 1, 0.3, 1)`, + '&[data-state="closed"]': { + animation: `${overlayClose} 150ms cubic-bezier(0.16, 1, 0.3, 1)`, + }, +}); + +const DialogContent = styled(Dialog.Content, { + + variants: { + minHeight: { + 'sm': { + minHeight: '300px', + }, + 'md': { + minHeight: '500px', + }, + 'lg': { + minHeight: '700px', + }, + 'xl': { + minHeight: '900px', + }, + }, + }, + + backgroundColor: 'white', + borderRadius: 18, + boxShadow: 'hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px', + position: 'fixed', + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: '90vw', + overflow: 'hidden', + maxHeight: '85vh', + minHeight: '300px', + maxWidth: '600px', + padding: 11, + animation: `${contentShow} 150ms cubic-bezier(0.16, 1, 0.3, 1)`, + '&:focus': { outline: 'none' }, + + '&[data-state="closed"]': { + animation: `${contentClose} 150ms cubic-bezier(0.16, 1, 0.3, 1)`, + }, + transition: "max-height 0.3s ease-out", +}); + +const DialogTopBar = styled('div', { + background: "#F7F7F7", + padding: "8px 14px ", + borderRadius: 14, +}); +const DialogTitle = styled(Dialog.Title, { + margin: 0, + fontWeight: 700, + letterSpacing: "-0.05em", + padding: 0, + color: mauve.mauve12, + fontSize: 21, +}); + +const DialogDescription = styled(Dialog.Description, { + color: mauve.mauve11, + letterSpacing: "-0.03em", + fontSize: 15, + padding: 0, + margin: 0, +}); + +const Flex = styled('div', { display: 'flex' }); + +const Button = styled('button', { + all: 'unset', + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + borderRadius: 4, + padding: '0 15px', + fontSize: 15, + lineHeight: 1, + fontWeight: 500, + height: 35, + + variants: { + variant: { + violet: { + backgroundColor: 'white', + color: violet.violet11, + boxShadow: `0 2px 10px ${blackA.blackA7}`, + '&:hover': { backgroundColor: mauve.mauve3 }, + '&:focus': { boxShadow: `0 0 0 2px black` }, + }, + green: { + backgroundColor: green.green4, + color: green.green11, + '&:hover': { backgroundColor: green.green5 }, + '&:focus': { boxShadow: `0 0 0 2px ${green.green7}` }, + }, + }, + }, + + defaultVariants: { + variant: 'violet', + }, +}); + +const IconButton = styled('button', { + all: 'unset', + fontFamily: 'inherit', + borderRadius: '100%', + height: 25, + width: 25, + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + color: violet.violet11, + position: 'absolute', + top: 10, + right: 10, + + '&:hover': { backgroundColor: violet.violet4 }, + '&:focus': { boxShadow: `0 0 0 2px ${violet.violet7}` }, +}); + +const Fieldset = styled('fieldset', { + all: 'unset', + display: 'flex', + gap: 20, + alignItems: 'center', + marginBottom: 15, +}); + +const Label = styled('label', { + fontSize: 15, + color: violet.violet11, + width: 90, + textAlign: 'right', +}); + +const Input = styled('input', { + all: 'unset', + width: '100%', + flex: '1', + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + borderRadius: 4, + padding: '0 10px', + fontSize: 15, + lineHeight: 1, + color: violet.violet11, + boxShadow: `0 0 0 1px ${violet.violet7}`, + height: 35, + + '&:focus': { boxShadow: `0 0 0 2px ${violet.violet8}` }, +}); + +export default Modal; \ No newline at end of file diff --git a/front/package-lock.json b/front/package-lock.json index 749c6bb9..b562f2b7 100644 --- a/front/package-lock.json +++ b/front/package-lock.json @@ -8,6 +8,7 @@ "name": "learnhouse", "version": "0.1.0", "dependencies": { + "@radix-ui/colors": "^0.1.8", "@radix-ui/react-dialog": "^1.0.2", "@radix-ui/react-icons": "^1.1.1", "@stitches/react": "^1.2.8", @@ -2352,6 +2353,11 @@ "url": "https://opencollective.com/popperjs" } }, + "node_modules/@radix-ui/colors": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/@radix-ui/colors/-/colors-0.1.8.tgz", + "integrity": "sha512-jwRMXYwC0hUo0mv6wGpuw254Pd9p/R6Td5xsRpOmaWkUHlooNWqVcadgyzlRumMq3xfOTXwJReU0Jv+EIy4Jbw==" + }, "node_modules/@radix-ui/primitive": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.0.0.tgz", @@ -8906,6 +8912,11 @@ "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz", "integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==" }, + "@radix-ui/colors": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/@radix-ui/colors/-/colors-0.1.8.tgz", + "integrity": "sha512-jwRMXYwC0hUo0mv6wGpuw254Pd9p/R6Td5xsRpOmaWkUHlooNWqVcadgyzlRumMq3xfOTXwJReU0Jv+EIy4Jbw==" + }, "@radix-ui/primitive": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.0.0.tgz", diff --git a/front/package.json b/front/package.json index 50b1bf6c..f7ab0554 100644 --- a/front/package.json +++ b/front/package.json @@ -9,6 +9,7 @@ "lint": "next lint" }, "dependencies": { + "@radix-ui/colors": "^0.1.8", "@radix-ui/react-dialog": "^1.0.2", "@radix-ui/react-icons": "^1.1.1", "@stitches/react": "^1.2.8", From d6289edb29a1ebe0c08666b20db9d60f2c10858b Mon Sep 17 00:00:00 2001 From: swve Date: Sat, 8 Apr 2023 15:54:02 +0200 Subject: [PATCH 02/11] chore: refactor components --- .../[courseid]/activity/[activityid]/page.tsx | 4 +- .../course/[courseid]/edit/page.tsx | 16 ++--- front/app/layout.tsx | 2 +- front/app/organizations/new/page.tsx | 5 +- front/app/signup/page.tsx | 7 +- front/components/Modals/Modal.tsx | 54 --------------- .../Activities}/DynamicCanva/DynamicCanva.tsx | 0 .../Activities}/Video/Video.tsx | 0 .../CourseEdit/Draggables}/Activity.tsx | 0 .../CourseEdit/Draggables}/Chapter.tsx | 0 .../CourseEdit/Draggables}/data.ts | 0 .../CourseEdit/NewActivity.tsx | 1 - .../NewActivityModal/DynamicCanva.tsx | 0 .../CourseEdit/NewActivityModal/Video.tsx | 0 .../CourseEdit/NewChapter.tsx | 1 - front/components/UI/Elements/Menu.tsx | 6 +- front/components/UI/Header.tsx | 13 ---- front/components/UI/Layout.tsx | 66 ------------------- front/components/UI/Modal/Modal.tsx | 1 - .../{lib => UI/libs}/styled-registry.tsx | 0 front/services/courses/chapters.ts | 2 +- 21 files changed, 13 insertions(+), 165 deletions(-) delete mode 100644 front/components/Modals/Modal.tsx rename front/components/{ActivityViews => Pages/Activities}/DynamicCanva/DynamicCanva.tsx (100%) rename front/components/{ActivityViews => Pages/Activities}/Video/Video.tsx (100%) rename front/components/{Drags => Pages/CourseEdit/Draggables}/Activity.tsx (100%) rename front/components/{Drags => Pages/CourseEdit/Draggables}/Chapter.tsx (100%) rename front/components/{Drags => Pages/CourseEdit/Draggables}/data.ts (100%) rename front/components/{Modals => Pages}/CourseEdit/NewActivity.tsx (98%) rename front/components/{Modals => Pages}/CourseEdit/NewActivityModal/DynamicCanva.tsx (100%) rename front/components/{Modals => Pages}/CourseEdit/NewActivityModal/Video.tsx (100%) rename front/components/{Modals => Pages}/CourseEdit/NewChapter.tsx (97%) delete mode 100644 front/components/UI/Header.tsx delete mode 100644 front/components/UI/Layout.tsx rename front/components/{lib => UI/libs}/styled-registry.tsx (100%) diff --git a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx index 1ba17cb3..7156f041 100644 --- a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx +++ b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx @@ -5,10 +5,10 @@ import React, { useMemo } from "react"; import Layout from "@components/UI/Layout"; import { getActivity } from "@services/courses/activities"; import { getAPIUrl, getBackendUrl, getUriWithOrg } from "@services/config/config"; -import Canva from "@components/ActivityViews/DynamicCanva/DynamicCanva"; +import Canva from "@components/Pages/Activities/DynamicCanva/DynamicCanva"; import styled from "styled-components"; import { getCourse } from "@services/courses/courses"; -import VideoActivity from "@components/ActivityViews/Video/Video"; +import VideoActivity from "@components/Pages/Activities/Video/Video"; import useSWR, { mutate } from "swr"; import { Check } from "lucide-react"; import { swrFetcher } from "@services/utils/requests"; diff --git a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx index 1b2a686a..cafe8d37 100644 --- a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx +++ b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx @@ -2,23 +2,19 @@ import React from "react"; import { useState, useEffect } from "react"; import styled from "styled-components"; -import { Header } from "@components/UI/Header"; -import Layout from "@components/UI/Layout"; import { Title } from "@components/UI/Elements/Styles/Title"; import { DragDropContext, Droppable } from "react-beautiful-dnd"; -import { initialData, initialData2 } from "@components/Drags/data"; -import Chapter from "@components/Drags/Chapter"; +import { initialData, initialData2 } from "@components/Pages/CourseEdit/Draggables/data"; +import Chapter from "@components/Pages/CourseEdit/Draggables/Chapter"; import { createChapter, deleteChapter, getCourseChaptersMetadata, updateChaptersMetadata } from "@services/courses/chapters"; import { useRouter } from "next/navigation"; -import NewChapterModal from "@components/Modals/CourseEdit/NewChapter"; -import NewActivityModal from "@components/Modals/CourseEdit/NewActivity"; +import NewChapterModal from "@components/Pages/CourseEdit/NewChapter"; +import NewActivityModal from "@components/Pages/CourseEdit/NewActivity"; import { createActivity, createFileActivity } from "@services/courses/activities"; import { getOrganizationContextInfo } from "@services/organizations/orgs"; import Modal from "@components/UI/Modal/Modal"; function CourseEdit(params: any) { - const router = useRouter(); - // Initial Course State const [data, setData] = useState(initialData2) as any; @@ -33,8 +29,6 @@ function CourseEdit(params: any) { const courseid = params.params.courseid; const orgslug = params.params.orgslug; - - async function getCourseChapters() { const courseChapters = await getCourseChaptersMetadata(courseid); setData(courseChapters); @@ -107,9 +101,7 @@ function CourseEdit(params: any) { }; /* - Modals - */ const openNewActivityModal = async (chapterId: any) => { diff --git a/front/app/layout.tsx b/front/app/layout.tsx index fc7645c4..dfad1471 100644 --- a/front/app/layout.tsx +++ b/front/app/layout.tsx @@ -1,6 +1,6 @@ "use client"; import "../styles/globals.css"; -import StyledComponentsRegistry from "../components/lib/styled-registry"; +import StyledComponentsRegistry from "../components/UI/libs/styled-registry"; import { motion } from "framer-motion"; export default function RootLayout({ children }: { children: React.ReactNode }) { diff --git a/front/app/organizations/new/page.tsx b/front/app/organizations/new/page.tsx index a645e3d8..6fa3dcb3 100644 --- a/front/app/organizations/new/page.tsx +++ b/front/app/organizations/new/page.tsx @@ -1,6 +1,5 @@ "use client"; import React from "react"; -import Layout from "../../../components/UI/Layout"; import { Title } from "../../../components/UI/Elements/Styles/Title"; import { createNewOrganization } from "../../../services/organizations/orgs"; @@ -34,7 +33,7 @@ const Organizations = () => { }; return ( - +
New Organization Name:
@@ -45,7 +44,7 @@ const Organizations = () => { Email Address:
- +
); }; diff --git a/front/app/signup/page.tsx b/front/app/signup/page.tsx index 6c30f89d..2860c4d8 100644 --- a/front/app/signup/page.tsx +++ b/front/app/signup/page.tsx @@ -1,7 +1,5 @@ "use client"; import React from "react"; -import { Header } from "../../components/UI/Header"; -import Layout from "../../components/UI/Layout"; import { Title } from "../../components/UI/Elements/Styles/Title"; import { signup } from "../../services/auth/auth"; @@ -31,8 +29,7 @@ const SignUp = () => { return (
- -
+
Sign up
@@ -43,7 +40,7 @@ const SignUp = () => { Sign up
- +
); }; diff --git a/front/components/Modals/Modal.tsx b/front/components/Modals/Modal.tsx deleted file mode 100644 index 7923df5b..00000000 --- a/front/components/Modals/Modal.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import React from "react"; -import styled from "styled-components"; -import { motion, AnimatePresence } from "framer-motion"; - -function Modal(props: any) { - return ( -
- - - - {props.children} - - - -
- ); -} - -const Overlay = styled.div` - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 100; - background-color: #00000029; - backdrop-filter: blur(1px); - -`; - -const Content = styled.div` - background-color: white; - border-radius: 5px; - padding: 20px; - width: 500px; - height: 500px; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - box-shadow: 0px 64px 84px 15px rgb(0 0 0 / 10%); -`; -export default Modal; diff --git a/front/components/ActivityViews/DynamicCanva/DynamicCanva.tsx b/front/components/Pages/Activities/DynamicCanva/DynamicCanva.tsx similarity index 100% rename from front/components/ActivityViews/DynamicCanva/DynamicCanva.tsx rename to front/components/Pages/Activities/DynamicCanva/DynamicCanva.tsx diff --git a/front/components/ActivityViews/Video/Video.tsx b/front/components/Pages/Activities/Video/Video.tsx similarity index 100% rename from front/components/ActivityViews/Video/Video.tsx rename to front/components/Pages/Activities/Video/Video.tsx diff --git a/front/components/Drags/Activity.tsx b/front/components/Pages/CourseEdit/Draggables/Activity.tsx similarity index 100% rename from front/components/Drags/Activity.tsx rename to front/components/Pages/CourseEdit/Draggables/Activity.tsx diff --git a/front/components/Drags/Chapter.tsx b/front/components/Pages/CourseEdit/Draggables/Chapter.tsx similarity index 100% rename from front/components/Drags/Chapter.tsx rename to front/components/Pages/CourseEdit/Draggables/Chapter.tsx diff --git a/front/components/Drags/data.ts b/front/components/Pages/CourseEdit/Draggables/data.ts similarity index 100% rename from front/components/Drags/data.ts rename to front/components/Pages/CourseEdit/Draggables/data.ts diff --git a/front/components/Modals/CourseEdit/NewActivity.tsx b/front/components/Pages/CourseEdit/NewActivity.tsx similarity index 98% rename from front/components/Modals/CourseEdit/NewActivity.tsx rename to front/components/Pages/CourseEdit/NewActivity.tsx index 063424a0..fa67bc86 100644 --- a/front/components/Modals/CourseEdit/NewActivity.tsx +++ b/front/components/Pages/CourseEdit/NewActivity.tsx @@ -1,6 +1,5 @@ import React, { useState } from "react"; import { ArrowLeftIcon, Cross1Icon } from "@radix-ui/react-icons"; -import Modal from "../Modal"; import styled from "styled-components"; import DynamicCanvaModal from "./NewActivityModal/DynamicCanva"; import VideoModal from "./NewActivityModal/Video"; diff --git a/front/components/Modals/CourseEdit/NewActivityModal/DynamicCanva.tsx b/front/components/Pages/CourseEdit/NewActivityModal/DynamicCanva.tsx similarity index 100% rename from front/components/Modals/CourseEdit/NewActivityModal/DynamicCanva.tsx rename to front/components/Pages/CourseEdit/NewActivityModal/DynamicCanva.tsx diff --git a/front/components/Modals/CourseEdit/NewActivityModal/Video.tsx b/front/components/Pages/CourseEdit/NewActivityModal/Video.tsx similarity index 100% rename from front/components/Modals/CourseEdit/NewActivityModal/Video.tsx rename to front/components/Pages/CourseEdit/NewActivityModal/Video.tsx diff --git a/front/components/Modals/CourseEdit/NewChapter.tsx b/front/components/Pages/CourseEdit/NewChapter.tsx similarity index 97% rename from front/components/Modals/CourseEdit/NewChapter.tsx rename to front/components/Pages/CourseEdit/NewChapter.tsx index aa7549ca..11cb2927 100644 --- a/front/components/Modals/CourseEdit/NewChapter.tsx +++ b/front/components/Pages/CourseEdit/NewChapter.tsx @@ -1,5 +1,4 @@ import React, { useState } from "react"; -import Modal from "../Modal"; function NewChapterModal({ submitChapter , closeModal }: any) { const [chapterName, setChapterName] = useState(""); diff --git a/front/components/UI/Elements/Menu.tsx b/front/components/UI/Elements/Menu.tsx index 7b9d7629..c0907232 100644 --- a/front/components/UI/Elements/Menu.tsx +++ b/front/components/UI/Elements/Menu.tsx @@ -6,13 +6,9 @@ import learnhouseIcon from "public/learnhouse_icon.png"; import learnhouseLogo from "public/learnhouse_logo.png"; import Link from "next/link"; import Image from "next/image"; -import { useRouter, useSearchParams, usePathname } from "next/navigation"; -import { headers } from "next/headers"; -import { getOrgFromUri, getUriWithOrg } from "@services/config/config"; +import { getUriWithOrg } from "@services/config/config"; export const Menu = (props : any ) => { - const router = useRouter(); - const pathname = usePathname(); const orgslug = props.orgslug; diff --git a/front/components/UI/Header.tsx b/front/components/UI/Header.tsx deleted file mode 100644 index 012a2dfb..00000000 --- a/front/components/UI/Header.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from "react"; -import Link from 'next/link' -import styled from "styled-components"; - - -export const Header = () => { - return ( -
-
- ); -}; - - diff --git a/front/components/UI/Layout.tsx b/front/components/UI/Layout.tsx deleted file mode 100644 index 070eea57..00000000 --- a/front/components/UI/Layout.tsx +++ /dev/null @@ -1,66 +0,0 @@ -"use client"; -import React from "react"; -import Head from "next/head"; -import styled from "styled-components"; -import AuthProvider from "../Security/AuthProvider"; -import { motion } from "framer-motion"; -import { Menu } from "./Elements/Menu"; - -const Layout = (props: any) => { - const variants = { - hidden: { opacity: 0, x: 0, y: 0 }, - enter: { opacity: 1, x: 0, y: 0 }, - exit: { opacity: 0, x: 0, y: 0 }, - }; - - return ( - - 🚧 Dev Phase - - -
{props.children}
-
-
-

LearnHouse © 2021 - {new Date().getFullYear()} - All rights reserved

-
-
- ); -}; - -const Main = styled.main` - min-height: 100vh; -`; - -const Footer = styled.footer` - display: flex; - justify-content: center; - margin: 20px; - font-size: 16px; - - img { - width: 20px; - opacity: 0.4; - display: inline; - } -`; - -export const ProjectPhaseLabel = styled.div` - position: fixed; - bottom: 0; - right: 0; - padding: 9px; - background-color: #080501; - color: white; - font-size: 19px; - font-weight: bold; - border-radius: 5px 0 0 0px; -`; - -export default Layout; diff --git a/front/components/UI/Modal/Modal.tsx b/front/components/UI/Modal/Modal.tsx index ff49fadd..6eae03de 100644 --- a/front/components/UI/Modal/Modal.tsx +++ b/front/components/UI/Modal/Modal.tsx @@ -2,7 +2,6 @@ import React from 'react'; import * as Dialog from '@radix-ui/react-dialog'; import { styled, keyframes } from '@stitches/react'; import { violet, blackA, mauve, green } from '@radix-ui/colors'; -import { Cross2Icon } from '@radix-ui/react-icons'; type ModalParams = { dialogTitle: string; diff --git a/front/components/lib/styled-registry.tsx b/front/components/UI/libs/styled-registry.tsx similarity index 100% rename from front/components/lib/styled-registry.tsx rename to front/components/UI/libs/styled-registry.tsx diff --git a/front/services/courses/chapters.ts b/front/services/courses/chapters.ts index 5cf8077c..86ad056f 100644 --- a/front/services/courses/chapters.ts +++ b/front/services/courses/chapters.ts @@ -1,4 +1,4 @@ -import { initialData } from "../../components/Drags/data"; +import { initialData } from "../../components/Pages/CourseEdit/Draggables/data"; import { getAPIUrl } from "@services/config/config"; import { RequestBody } from "@services/utils/requests"; From a10fcbd9a077b803120e56cf5022b1568b25c38a Mon Sep 17 00:00:00 2001 From: swve Date: Sat, 8 Apr 2023 16:24:06 +0200 Subject: [PATCH 03/11] chore : remove deprecated imports --- front/app/login/page.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/front/app/login/page.tsx b/front/app/login/page.tsx index 19bf4ba7..50698b2a 100644 --- a/front/app/login/page.tsx +++ b/front/app/login/page.tsx @@ -1,8 +1,6 @@ "use client"; import { useRouter } from 'next/navigation'; import React from "react"; -import { Header } from "../../components/UI/Header"; -import Layout from "../../components/UI/Layout"; import { Title } from "../../components/UI/Elements/Styles/Title"; import { loginAndGetToken } from "../../services/auth/auth"; @@ -35,7 +33,6 @@ const Login = () => { return (
< > -
Login
From 5eabb0b16a587383602b89bd411bb9e93788f01c Mon Sep 17 00:00:00 2001 From: swve Date: Sat, 8 Apr 2023 18:11:09 +0200 Subject: [PATCH 04/11] feat: add Forms component --- .../Pages/CourseEdit/NewChapter.tsx | 41 +++++-- front/components/UI/Form/Form.tsx | 86 +++++++++++++++ front/components/UI/Modal/Modal.tsx | 13 ++- front/package-lock.json | 103 ++++++++++++++++++ front/package.json | 1 + 5 files changed, 231 insertions(+), 13 deletions(-) create mode 100644 front/components/UI/Form/Form.tsx diff --git a/front/components/Pages/CourseEdit/NewChapter.tsx b/front/components/Pages/CourseEdit/NewChapter.tsx index 11cb2927..8e03201c 100644 --- a/front/components/Pages/CourseEdit/NewChapter.tsx +++ b/front/components/Pages/CourseEdit/NewChapter.tsx @@ -1,6 +1,9 @@ +import FormLayout, { Flex, FormField, Input, Textarea, FormLabel, ButtonBlack } from "@components/UI/Form/Form"; +import { FormMessage } from "@radix-ui/react-form"; +import * as Form from '@radix-ui/react-form'; import React, { useState } from "react"; -function NewChapterModal({ submitChapter , closeModal }: any) { +function NewChapterModal({ submitChapter, closeModal }: any) { const [chapterName, setChapterName] = useState(""); const [chapterDescription, setChapterDescription] = useState(""); @@ -15,17 +18,37 @@ function NewChapterModal({ submitChapter , closeModal }: any) { const handleSubmit = async (e: any) => { e.preventDefault(); console.log({ chapterName, chapterDescription }); - submitChapter({ name : chapterName, description : chapterDescription , activities : [] }); + submitChapter({ name: chapterName, description: chapterDescription, activities: [] }); }; return ( -
- -
- -
- -
+ + + + + Chapter name + Please provide a chapter name + + + + + + + + Chapter description + Please provide a chapter description + + +