From 26e077eed4a248ef1e0046e3b67aa556bcb64f74 Mon Sep 17 00:00:00 2001 From: swve Date: Fri, 13 Jan 2023 18:45:56 +0100 Subject: [PATCH] feat: init element ui design --- .../[courseid]/element/[elementid]/page.tsx | 130 ++++++++++++++++-- front/app/_orgs/[orgslug]/page.tsx | 2 +- front/app/layout.tsx | 4 +- front/components/UI/Layout.tsx | 6 +- 4 files changed, 124 insertions(+), 18 deletions(-) diff --git a/front/app/_orgs/[orgslug]/course/[courseid]/element/[elementid]/page.tsx b/front/app/_orgs/[orgslug]/course/[courseid]/element/[elementid]/page.tsx index 0ddb9693..5c1a41f7 100644 --- a/front/app/_orgs/[orgslug]/course/[courseid]/element/[elementid]/page.tsx +++ b/front/app/_orgs/[orgslug]/course/[courseid]/element/[elementid]/page.tsx @@ -1,26 +1,41 @@ "use client"; import { useRouter } from "next/navigation"; +import Link from "next/link"; import React, { useMemo } from "react"; import Layout from "../../../../../../../components/UI/Layout"; import { getElement } from "../../../../../../../services/courses/elements"; import { getBackendUrl } from "../../../../../../../services/config"; import Canva from "../../../../../../../components/Canva/Canva"; +import styled from "styled-components"; +import { getCourse, getCourseMetadata } from "../../../../../../../services/courses/courses"; + function ElementPage(params: any) { const router = useRouter(); const elementid = params.params.elementid; + const courseid = params.params.courseid; + const orgslug = params.params.orgslug; const [element, setElement] = React.useState({}); + const [course, setCourse] = React.useState({}); const [isLoading, setIsLoading] = React.useState(true); async function fetchElementData() { + setIsLoading(true); const element = await getElement("element_" + elementid); setElement(element); + } + + async function fetchCourseData() { + const course = await getCourseMetadata("course_" + courseid); + setCourse(course); + console.log(course); setIsLoading(false); } React.useEffect(() => { if (elementid) { fetchElementData(); + fetchCourseData(); } return () => {}; // eslint-disable-next-line react-hooks/exhaustive-deps @@ -31,20 +46,115 @@ function ElementPage(params: any) { {isLoading ? (
Loading...
) : ( -
-

element

-

{element.name}

-
+ + + + + + + + +

Lecture

+

{element.name}

+
+
+ + {course.chapters.map((chapter: any) => { + return ( + <> +
+ {chapter.elements.map((element: any) => { + return ( + <> + + + {" "} + + ); + })} +
+      + + ); + })} +
- {element.type == "dynamic" && } - {/* todo : use apis & streams instead of this */} - {element.type == "video" && ( - - )} -
+ + {element.type == "dynamic" && } + {/* todo : use apis & streams instead of this */} + {element.type == "video" && ( + + )} + + )} ); } +const LectureLayout = styled.div``; + +const LectureThumbnail = styled.div` + padding-right: 30px; + justify-self: center; + img { + box-shadow: 0px 13px 33px -13px rgba(0, 0, 0, 0.42); + border-radius: 7px; + width: 100px; + height: 57px; + } +`; +const LectureInfo = styled.div` + h1 { + margin-top: 0px; + } + + p { + margin-top: 0; + margin-bottom: 0; + font-weight: 700; + } +`; + +const ChaptersWrapper = styled.div` + display: flex; + // row + flex-direction: row; + justify-content: space-around; + width: 100%; + width: 1300px; + margin: 0 auto; +`; + +const ChapterIndicator = styled.div` + border-radius: 20px; + height: 5px; + background: #151515; + border-radius: 3px; + + width: 35px; + background-color: black; + margin: 10px; + margin-bottom: 0px; + margin-left: 0px; + transition: all 0.2s ease; + + &:hover { + width: 50px; + cursor: pointer; + } +`; + +const LectureTopWrapper = styled.div` + width: 1300px; + padding-top: 50px; + margin: 0 auto; + display: flex; +`; + +const CourseContent = styled.div` + display: flex; + background-color: white; + min-height: 600px; +`; export default ElementPage; diff --git a/front/app/_orgs/[orgslug]/page.tsx b/front/app/_orgs/[orgslug]/page.tsx index 21c5c527..e2b7e478 100644 --- a/front/app/_orgs/[orgslug]/page.tsx +++ b/front/app/_orgs/[orgslug]/page.tsx @@ -13,7 +13,7 @@ const OrgHomePage = (params: any) => { return (
-
+ Welcome {orgslug} 👋🏻 diff --git a/front/app/layout.tsx b/front/app/layout.tsx index 71fb5ed3..9f0b19de 100644 --- a/front/app/layout.tsx +++ b/front/app/layout.tsx @@ -1,12 +1,12 @@ + import "../styles/globals.css"; import StyledComponentsRegistry from "../services/lib/styled-registry"; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( - + - {" "} {children} diff --git a/front/components/UI/Layout.tsx b/front/components/UI/Layout.tsx index 6606e03c..070eea57 100644 --- a/front/components/UI/Layout.tsx +++ b/front/components/UI/Layout.tsx @@ -1,4 +1,4 @@ - +"use client"; import React from "react"; import Head from "next/head"; import styled from "styled-components"; @@ -14,8 +14,6 @@ const Layout = (props: any) => { }; return ( - - 🚧 Dev Phase @@ -33,8 +31,6 @@ const Layout = (props: any) => {

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

- - ); };