-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Move chapter page to index in coursename
- add a type prop to change according to the type of page - chapters / courses Feat: show only few chapters initially, clicking on view more should show more chapters - scroll to the section for chapters and courses
- Loading branch information
1 parent
384c650
commit 9b53409
Showing
5 changed files
with
178 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,59 @@ | ||
import styles from './ChapterList.module.scss'; | ||
import Link from "next/link"; | ||
import { useEffect, useState } from "react"; | ||
import styles from "./ChapterList.module.scss"; | ||
|
||
export default function ChapterList(){ | ||
export default function ChapterList({ chapters, courseUrl }) { | ||
// console.log({ chapters }); | ||
const [chaptersToShow, setChaptersToShow] = useState([]); | ||
const [next, setNext] = useState(3); | ||
const chaptersPerPage = 3; | ||
let tempChapterList = []; | ||
|
||
return( | ||
<section className={styles.section}> | ||
<div className="container container--small"> | ||
<ul className={styles.list}> | ||
<li> | ||
<div className={styles.text}> | ||
<h3>Syntax and Selectors</h3> | ||
<p>Learn how to add styles websites with CSS and how to use selectors to apply styles to specific elements.</p> | ||
<a href="" className="btn btn--purple"> | ||
<span className="btn__text">Start</span> | ||
</a> | ||
</div> | ||
</li> | ||
<li> | ||
<div className={styles.text}> | ||
<h3>Syntax and Selectors</h3> | ||
<p>Learn how to add styles websites with CSS and how to use selectors to apply styles to specific elements.</p> | ||
<a href="" className="btn btn--purple"> | ||
<span className="btn__text">Start</span> | ||
</a> | ||
</div> | ||
</li> | ||
</ul> | ||
<div className="cta text-center"> | ||
<a href="" className="btn"> | ||
<span className="btn__text">VIEW MORE</span> | ||
</a> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
const getSlicedChapters = (start, end) => { | ||
const slicedChapters = chapters.slice(start, end); | ||
console.log({ slicedChapters }); | ||
tempChapterList = [...chaptersToShow, ...slicedChapters]; | ||
console.log({ tempChapterList }); | ||
setChaptersToShow(tempChapterList); | ||
}; | ||
|
||
} | ||
useEffect(() => { | ||
getSlicedChapters(0, chaptersPerPage); | ||
}, []); | ||
|
||
const handleViewMore = () => { | ||
getSlicedChapters(next, next + chaptersPerPage); | ||
setNext(next + chaptersPerPage); | ||
}; | ||
return ( | ||
<section id="chapters" className={styles.section}> | ||
<div className="container container--small"> | ||
<ul className={styles.list}> | ||
{chaptersToShow.map((chapter) => ( | ||
<li key={chapter.chapterUrl} className=""> | ||
<div className={styles.text}> | ||
<h3>{chapter.chapterName}</h3> | ||
<p> | ||
Learn how to add styles websites with CSS and how to use | ||
selectors to apply styles to specific elements. | ||
</p> | ||
<Link href={`/curriculum/${courseUrl}/${chapter.chapterUrl}`}> | ||
<a className="btn btn--purple"> | ||
<span className="btn__text">Start</span> | ||
</a> | ||
</Link> | ||
</div> | ||
</li> | ||
))} | ||
</ul> | ||
<div className="cta text-center"> | ||
{chaptersToShow.length !== chapters.length && ( | ||
<button className="btn" onClick={handleViewMore}> | ||
<span className="btn__text">VIEW MORE</span> | ||
</button> | ||
)} | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,47 @@ | ||
import styles from './ChapterOverview.module.scss'; | ||
import styles from "./ChapterOverview.module.scss"; | ||
|
||
export default function ChapterOverview(){ | ||
|
||
return( | ||
<section className="pb-10 lg:pb-20" style={{ color: "#202020" }}> | ||
<div className="container"> | ||
<h2 className="text-gray-01 font-darker font-extrabold text-64 mb-10 xl:mb-14">Overview</h2> | ||
<div className="row md:flex"> | ||
<div className="md:w-8/12 pt-5 text-18 font-semibold leading-loose mb-10 md:mb-0"> | ||
<p className="mb-10">Without CSS, every web page would be drab plain text and images that flowed straight down the page. With CSS, you can add color and background images and change the layout of your page — your web pages can feel like works of art!</p> | ||
<h3 className="text-25 font-extrabold mb-5">Take-Away Skills:</h3> | ||
<p>You will learn many aspects of styling web pages! You’ll be able to set up the correct file structure, edit text and colors, and create attractive layouts. With these skills, you’ll be able to customize the appearance of your web pages to suit your every need!</p> | ||
</div> | ||
<div className="md:w-4/12"> | ||
<div className={styles.overview}> | ||
<div className={styles.item}> | ||
<h3>Certificate</h3> | ||
<p>of completion for free</p> | ||
</div> | ||
<div className={styles.item}> | ||
<h3>490,362</h3> | ||
<p>People who have taken this course</p> | ||
</div> | ||
<div className={styles.item}> | ||
<p>Time to Complete</p> | ||
<h3>10 Hours</h3> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
export default function ChapterOverview() { | ||
return ( | ||
<section className="pb-10 lg:pb-20" style={{ color: "#202020" }}> | ||
<div className="container"> | ||
<h2 className="text-gray-01 font-darker font-extrabold text-64 mb-10 xl:mb-14"> | ||
Overview | ||
</h2> | ||
<div className="row md:flex"> | ||
<div className="md:w-8/12 pt-5 text-18 font-semibold leading-loose mb-10 md:mb-0"> | ||
<p className="mb-10"> | ||
Without CSS, every web page would be drab plain text and images | ||
that flowed straight down the page. With CSS, you can add color | ||
and background images and change the layout of your page — your | ||
web pages can feel like works of art! | ||
</p> | ||
<h3 className="text-25 font-extrabold mb-5">Take-Away Skills:</h3> | ||
<p> | ||
You will learn many aspects of styling web pages! You’ll be able | ||
to set up the correct file structure, edit text and colors, and | ||
create attractive layouts. With these skills, you’ll be able to | ||
customize the appearance of your web pages to suit your every | ||
need! | ||
</p> | ||
</div> | ||
<div className="md:w-4/12"> | ||
<div className={styles.overview}> | ||
<div className={styles.item}> | ||
<h3>Certificate</h3> | ||
<p>of completion for free</p> | ||
</div> | ||
<div className={styles.item}> | ||
<h3>490,362</h3> | ||
<p>People who have taken this course</p> | ||
</div> | ||
<div className={styles.item}> | ||
<p>Time to Complete</p> | ||
<h3>10 Hours</h3> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
|
||
} | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,86 @@ | ||
import { getAllCourseIds, getCourseData } from "../../../lib/jslist"; | ||
import { getCourse } from "../../../lib/getCourse"; | ||
import Navbar from "../../../component/layout/NavBar/NavBar"; | ||
// import Navbar from "../../../component/layout/NavBar/NavBar"; | ||
import Head from "next/head"; | ||
import Link from "next/link"; | ||
import SiteHeader from "../../../component/layout/SiteHeader/SiteHeader"; | ||
import CourseSpotlight from "../../../component/layout/CourseSpotlight/CourseSpotlight"; | ||
import ChapterOverview from "../../../component/layout/ChapterOverview/ChapterOverview"; | ||
import ChapterList from "../../../component/layout/ChapterList/ChapterList"; | ||
import SiteFooter from "../../../component/layout/SiteFooter/SiteFooter"; | ||
import SectionSwag from "../../../component/layout/SectionSwag/SectionSwag"; | ||
|
||
export async function getStaticPaths() { | ||
const paths = await getAllCourseIds(); | ||
return { | ||
paths, | ||
fallback: false | ||
}; | ||
const paths = await getAllCourseIds(); | ||
return { | ||
paths, | ||
fallback: false | ||
}; | ||
} | ||
|
||
export async function getStaticProps({ params }) { | ||
const courseData = await getCourseData(params.courseName); | ||
// console.log(courseData); | ||
return { | ||
props: { | ||
params, | ||
courseData | ||
} | ||
}; | ||
const courseData = await getCourseData(params.courseName); | ||
// console.log(courseData); | ||
return { | ||
props: { | ||
params, | ||
courseData | ||
} | ||
}; | ||
} | ||
|
||
export default function CourseName({ courseData, params }) { | ||
// console.log(courseData, params); | ||
const currentCourseName = params.courseName; | ||
// console.log(courseData, params); | ||
const currentCourseName = params.courseName; | ||
|
||
let currentCourse = getCourse(currentCourseName); | ||
// console.log(currentCourse); | ||
let currentCourse = getCourse(currentCourseName); | ||
// console.log(currentCourse); | ||
|
||
let { courseName, courseUrl } = currentCourse; | ||
let currentChapters = currentCourse.chapters; | ||
// console.log(courseName, currentChapters); | ||
let { courseName, courseUrl } = currentCourse; | ||
let currentChapters = currentCourse.chapters; | ||
// console.log(courseName, currentChapters); | ||
|
||
return ( | ||
<div> | ||
<Head> | ||
<title> {courseName} | Curriculum</title> | ||
</Head> | ||
<Navbar showMenuIcon={false} showTitle={false} /> | ||
<div className="bg-gray-50 h-screen"> | ||
<h1 className="uppercase text-2xl tracking-widest text-center p-8"> | ||
{courseName} | ||
</h1> | ||
<div className="flex flex-col items-center justify-center"> | ||
{currentChapters.map((chapter) => ( | ||
<div | ||
key={chapter.chapterUrl + courseUrl} | ||
className="bg-white m-2 px-12 h-14 w-2/4 flex flex-row items-center shadow-md text-xl tracking-wider hover:shadow-lg" | ||
> | ||
<Link href={`/curriculum/${courseUrl}/${chapter.chapterUrl}`}> | ||
<a className="text-gray-700 font-medium hover:text-purple-800"> | ||
{chapter.chapterName} | ||
</a> | ||
</Link> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
const contents = { | ||
type: "chapters", | ||
title: `Learn ${courseName}`, | ||
buttonText: "Start", | ||
image: "/images/illustration-1.svg", | ||
alt: `Learn ${courseName}`, | ||
imageWidth: 482, | ||
imageHeight: 377, | ||
bgcolor: "#083644", | ||
bgimage: "bg2" | ||
}; | ||
return ( | ||
<div> | ||
<Head> | ||
<title> {courseName} | Curriculum</title> | ||
</Head> | ||
<SiteHeader /> | ||
<CourseSpotlight contents={contents} /> | ||
<ChapterOverview /> | ||
<ChapterList chapters={currentChapters} courseUrl={courseUrl} /> | ||
<SectionSwag /> | ||
<SiteFooter /> | ||
{/* <Navbar showMenuIcon={false} showTitle={false} /> | ||
<div className="bg-gray-50 h-screen"> | ||
<h1 className="uppercase text-2xl tracking-widest text-center p-8"> | ||
{courseName} | ||
</h1> | ||
<div className="flex flex-col items-center justify-center"> | ||
{currentChapters.map((chapter) => ( | ||
<div | ||
key={chapter.chapterUrl + courseUrl} | ||
className="bg-white m-2 px-12 h-14 w-2/4 flex flex-row items-center shadow-md text-xl tracking-wider hover:shadow-lg" | ||
> | ||
<Link href={`/curriculum/${courseUrl}/${chapter.chapterUrl}`}> | ||
<a className="text-gray-700 font-medium hover:text-purple-800"> | ||
{chapter.chapterName} | ||
</a> | ||
</Link> | ||
</div> | ||
))} | ||
</div> | ||
</div> */} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters