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(components): Create LessonTabs #2394

Conversation

flacial
Copy link
Member

@flacial flacial commented Oct 3, 2022

Related to #2029

Description

For each lesson sub-page such as exercises, mentor exercises, challenges, and lesson, we create a the NavTab in all of them. To keep it DRY, this PR create a component that'll be used in all of the lesson pages.

Before:

const tabs = [
  ...(currentLesson.docUrl
    ? [{ text: 'lessons', url: currentLesson.docUrl }]
    : []),
  { text: 'challenges', url: `/curriculum/${currentLesson.slug}` },
  { text: 'exercises', url: `/exercises/${currentLesson.slug}` },
  {
    text: 'mentor exercises',
    url: `/curriculum/${currentLesson.slug}/mentor/`
  }
]

  <NavCard
    tabSelected={tabs.findIndex(tab => tab.text === 'exercises')}
    tabs={tabs}
  />

After:

<LessonTabs lesson={lesson} activeTab={'exercises'} />

Testing

  1. Go to /exercise/js0
  2. Confirm switching between the tabs work

@vercel
Copy link

vercel bot commented Oct 3, 2022

@flacial is attempting to deploy a commit to the c0d3-prod Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Oct 3, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
c0d3-app ✅ Ready (Inspect) Visit Preview Oct 6, 2022 at 2:50AM (UTC)

@codecov
Copy link

codecov bot commented Oct 3, 2022

Codecov Report

Merging #2394 (ba48999) into master (f3dd09d) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #2394   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          184       185    +1     
  Lines         3286      3285    -1     
  Branches       874       872    -2     
=========================================
- Hits          3286      3285    -1     
Impacted Files Coverage Δ
pages/exercises/[lessonSlug].tsx 100.00% <ø> (ø)
components/LessonTabs/LessonTabs.tsx 100.00% <100.00%> (ø)
pages/curriculum/[lessonSlug]/mentor/index.tsx 100.00% <100.00%> (ø)

const tabs = [
...(lesson.docUrl ? [{ text: 'lesson', url: lesson.docUrl }] : []),
{ text: 'challenges', url: `/curriculum/${lesson.slug}` },
{ text: 'exercises', url: `/exercises/${lesson.slug}` },
Copy link
Member

Choose a reason for hiding this comment

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

Might as well add this path to the constants.

Copy link
Member Author

@flacial flacial Oct 4, 2022

Choose a reason for hiding this comment

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

The exercises shouldn't be under /exercises but something like /curriculum/js0/exercises.

Copy link
Member

@SlyBouhafs SlyBouhafs Oct 5, 2022

Choose a reason for hiding this comment

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

Yes, i also think the mentor path needs a bit more thought!

Copy link
Collaborator

@anthonykhoa anthonykhoa Oct 6, 2022

Choose a reason for hiding this comment

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

The exercises shouldn't be under /exercises but something like /curriculum/js0/exercises.

@flacial Can you explain your reasoning on why the above should mean that we shouldn't make a /exercises constant?

Copy link
Member Author

@flacial flacial Oct 6, 2022

Choose a reason for hiding this comment

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

I thought /exercises/js0 would make things inconsistent with the way we manage things that are related to a lesson (e.g, challenges) and thus it should be changed to something like /curriculum/js0/exercises. But it appears the lesson submissions are under /review/js0.

I'l create one for /exercises in a different PR as this is merged.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought /exercises/js0 would make things inconsistent with the way we manage things that are related to a lesson (e.g, challenges) and thus it should be changed to something like /curriculum/js0/exercises.

I'm not understanding the reasoning -- even if the path is /curriculum/js0/exercises, why do you think a /exercises constant should still not be made for that?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought /exercises/js0 would make things inconsistent with the way we manage things that are related to a lesson (e.g, challenges) and thus it should be changed to something like /curriculum/js0/exercises.

I'm not understanding the reasoning -- even if the path is /curriculum/js0/exercises, why do you think a /exercises constant should still not be made for that?

I decided not to add that constant because, based on the possibility of introducing inconsistency in how we manage things that are related to a lesson, we could change the exercises' paths before launching DOJO. I was wrong as we already have the /review/[lessonSlug] path.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking that since we are going to need /exercises in the path it would be a good idea to make the constant anyway(which I see you note you'll do in another PR). Whether the path is /curriculum/js0/exercises or /exercises/js0 it needs /exercises. The reason I think /exercises should be a constant is because of its high potential for reusability -- if you search the path /curriculum for example, you can find a lot of results of its usage,
https://github.com/garageScript/c0d3-app/search?p=4&q=%2Fcurriculum

Copy link
Member Author

@flacial flacial Oct 6, 2022

Choose a reason for hiding this comment

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

I like this idea. By creating the exercises constant, we can join constants to create paths like the following CURRICULUM_PATH/[lessonSlug]/EXERCISES_PATH.

components/LessonTabs/LessonTabs.tsx Outdated Show resolved Hide resolved
…of github.com:flacial/c0d3-app into 2029-dojomentorpage-list-mentor-submitted-exercises/5
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.

4 participants