-
Notifications
You must be signed in to change notification settings - Fork 28
refactor: split introduction and FAQ into separate components #3233
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
Open
rohitpaulk
wants to merge
12
commits into
main
Choose a base branch
from
refactor-split-introduction-faq
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d6abfa5
refactor: split introduction and FAQ into separate components
rohitpaulk 09e771b
refactor: rename Stages component to StageCardList for clarity
rohitpaulk 1720e3b
feat(course-overview-page): refactor stage list into stage card list
rohitpaulk a1be7f2
refactor(ui): replace StageCardList component with inline markup
rohitpaulk bc681d0
feat(course-overview): extract StageListCard component
rohitpaulk b4761d7
refactor(component-names): rename StageList components for clarity
rohitpaulk 04baa4d
refactor: extract stage list cards into a dedicated component
rohitpaulk 4c07699
fix(ui): remove extra blank line in course overview template
rohitpaulk 306a84c
refactor(course-overview-page): remove isCurrent and isComplete props
rohitpaulk ee97959
refactor: simplify StageListCard ListItem component usage
rohitpaulk ec213c0
style: remove leading-7 class from prose containers
rohitpaulk 061809c
feat(course-overview): add collapsible stage list cards
rohitpaulk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 2 additions & 9 deletions
11
...overview-page/introduction-and-stages.hbs → ...se-overview-page/introduction-and-faq.hbs
This file contains hidden or 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,21 +1,14 @@ | ||
| <div class="bg-white dark:bg-gray-850 rounded-md shadow-xs border border-gray-200 dark:border-white/5 relative" ...attributes> | ||
| <div class="p-4 md:p-6"> | ||
| <div class="leading-7 prose dark:prose-invert mb-4"> | ||
| <div class="prose dark:prose-invert"> | ||
| {{markdown-to-html @course.descriptionMarkdown}} | ||
| </div> | ||
|
|
||
| {{#if (gt @course.frequentlyAskedQuestions.length 0)}} | ||
| {{! Extra if convinces typescript that frequentlyAskedQuestions is not null }} | ||
| {{#if @course.frequentlyAskedQuestions}} | ||
| <CollapsibleFaqList @faqs={{@course.frequentlyAskedQuestions}} class="mb-6" /> | ||
| <CollapsibleFaqList @faqs={{@course.frequentlyAskedQuestions}} class="mt-4" /> | ||
| {{/if}} | ||
| {{/if}} | ||
|
|
||
| <h3 class="font-semibold text-gray-600 dark:text-gray-400 text-center text-sm relative mb-3"> | ||
| <span class="block h-px w-full bg-gray-200 dark:bg-white/5 absolute top-50-percent -mt-px"></span> | ||
| <span class="relative px-6 bg-white dark:bg-gray-850">Stages</span> | ||
| </h3> | ||
|
|
||
| <CourseOverviewPage::StageList @course={{@course}} @completedStages={{@completedStages}} /> | ||
| </div> | ||
| </div> |
18 changes: 18 additions & 0 deletions
18
app/components/course-overview-page/introduction-and-faq.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import Component from '@glimmer/component'; | ||
| import type CourseModel from 'codecrafters-frontend/models/course'; | ||
|
|
||
| interface Signature { | ||
| Element: HTMLDivElement; | ||
|
|
||
| Args: { | ||
| course: CourseModel; | ||
| }; | ||
| } | ||
|
|
||
| export default class CourseOverviewPageIntroductionAndFaq extends Component<Signature> {} | ||
|
|
||
| declare module '@glint/environment-ember-loose/registry' { | ||
| export default interface Registry { | ||
| 'CourseOverviewPage::IntroductionAndFaq': typeof CourseOverviewPageIntroductionAndFaq; | ||
| } | ||
| } |
48 changes: 0 additions & 48 deletions
48
app/components/course-overview-page/introduction-and-stages.ts
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
app/components/course-overview-page/stage-list-card-list.hbs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <div class="space-y-4 w-full" ...attributes> | ||
| <CourseOverviewPage::StageListCard | ||
| @title={{if (gt @course.extensions.length 0) "Base Stages" "Stages"}} | ||
| @descriptionMarkdown={{@course.descriptionMarkdown}} | ||
| @stages={{@course.sortedBaseStages}} | ||
| /> | ||
|
|
||
| {{#each @course.sortedExtensions as |extension|}} | ||
| <CourseOverviewPage::StageListCard | ||
| @title={{extension.name}} | ||
| @descriptionMarkdown={{extension.descriptionMarkdown}} | ||
| @stages={{extension.sortedStages}} | ||
| @isCollapsedByDefault={{true}} | ||
| /> | ||
| {{/each}} | ||
| </div> |
18 changes: 18 additions & 0 deletions
18
app/components/course-overview-page/stage-list-card-list.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import Component from '@glimmer/component'; | ||
| import type CourseModel from 'codecrafters-frontend/models/course'; | ||
|
|
||
| interface Signature { | ||
| Element: HTMLDivElement; | ||
|
|
||
| Args: { | ||
| course: CourseModel; | ||
| }; | ||
| } | ||
|
|
||
| export default class CourseOverviewPageStageListCardList extends Component<Signature> {} | ||
|
|
||
| declare module '@glint/environment-ember-loose/registry' { | ||
| export default interface Registry { | ||
| 'CourseOverviewPage::StageListCardList': typeof CourseOverviewPageStageListCardList; | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <div | ||
| class="grid grid-cols-1 md:grid-cols-[2fr_3fr] p-4 md:p-6 gap-4 md:gap-6 bg-white dark:bg-gray-850 rounded-md shadow-xs border border-gray-200 dark:border-white/5 group relative | ||
| {{unless this.isExpanded 'h-48 overflow-hidden'}}" | ||
| ...attributes | ||
| > | ||
| <div> | ||
| <h3 class="font-semibold text-gray-900 dark:text-gray-100 text-lg mb-3"> | ||
| {{@title}} | ||
| </h3> | ||
|
|
||
| <div class="prose dark:prose-invert prose-sm mb-4"> | ||
| {{markdown-to-html @descriptionMarkdown}} | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="min-w-0"> | ||
| <CourseOverviewPage::StageListCard::List @stages={{@stages}} /> | ||
| </div> | ||
|
|
||
| {{#unless this.isExpanded}} | ||
| <div | ||
| class="absolute z-20 bottom-0 left-0 right-0 h-32 vertical-mask dark:vertical-mask-gray-850 p-4 flex items-end justify-center pointer-events-none group-hover:pointer-events-auto" | ||
| > | ||
| <TertiaryButton class="opacity-0 group-hover:opacity-100 transition-opacity duration-200" {{on "click" this.handleExpandClick}}> | ||
| Click to expand | ||
| </TertiaryButton> | ||
| </div> | ||
| {{/unless}} | ||
| </div> |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import Component from '@glimmer/component'; | ||
| import type CourseStageModel from 'codecrafters-frontend/models/course-stage'; | ||
| import { tracked } from '@glimmer/tracking'; | ||
| import { action } from '@ember/object'; | ||
|
|
||
| interface Signature { | ||
| Element: HTMLDivElement; | ||
|
|
||
| Args: { | ||
| title: string; | ||
| descriptionMarkdown: string; | ||
| stages: CourseStageModel[]; | ||
| isCollapsedByDefault?: boolean; | ||
| }; | ||
| } | ||
|
|
||
| export default class CourseOverviewPageStageListCard extends Component<Signature> { | ||
| @tracked isExpanded = !this.args.isCollapsedByDefault; | ||
|
|
||
| @action | ||
| handleExpandClick() { | ||
| this.isExpanded = true; | ||
| } | ||
| } | ||
|
|
||
| declare module '@glint/environment-ember-loose/registry' { | ||
| export default interface Registry { | ||
| 'CourseOverviewPage::StageListCard': typeof CourseOverviewPageStageListCard; | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
app/components/course-overview-page/stage-list-card/list-item.hbs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <div class="relative flex items-center" data-test-stage-list-item ...attributes> | ||
| {{! Bullet point }} | ||
| <div class="relative z-10 mr-1 flex-shrink-0"> | ||
| <div class="w-3.5 h-3.5 rounded-full border-3 bg-gray-200 dark:bg-gray-800 border-white dark:border-gray-600"></div> | ||
| </div> | ||
|
|
||
| {{! Stage name and difficulty }} | ||
| <div class="flex-1 flex items-center justify-between min-w-0 gap-4"> | ||
| <div class="text-gray-600 dark:text-gray-300 text-sm truncate"> | ||
| {{@stage.name}} | ||
| </div> | ||
|
|
||
| <div class="flex-shrink-0"> | ||
| <CourseStageDifficultyLabel @stage={{@stage}} /> | ||
| </div> | ||
| </div> | ||
| </div> |
18 changes: 18 additions & 0 deletions
18
app/components/course-overview-page/stage-list-card/list-item.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import Component from '@glimmer/component'; | ||
| import type CourseStageModel from 'codecrafters-frontend/models/course-stage'; | ||
|
|
||
| interface Signature { | ||
| Element: HTMLDivElement; | ||
|
|
||
| Args: { | ||
| stage: CourseStageModel; | ||
| }; | ||
| } | ||
|
|
||
| export default class StageListCardListItem extends Component<Signature> {} | ||
|
|
||
| declare module '@glint/environment-ember-loose/registry' { | ||
| export default interface Registry { | ||
| 'CourseOverviewPage::StageListCard::ListItem': typeof StageListCardListItem; | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
app/components/course-overview-page/stage-list-card/list.hbs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <div class="relative"> | ||
| {{! Connecting line }} | ||
| {{#if (gt @stages.length 1)}} | ||
| {{! template-lint-disable no-inline-styles }} | ||
| <div class="absolute left-[calc(0.4375rem-0.5px)] top-3 bottom-3 w-px bg-gray-200 dark:bg-white/5" style="height: calc(100% - 1rem);"></div> | ||
| {{/if}} | ||
|
|
||
| <div class="relative"> | ||
| {{#each @stages as |stage index|}} | ||
| <CourseOverviewPage::StageListCard::ListItem @stage={{stage}} class="{{if (eq index (sub @stages.length 1)) 'pt-1' 'py-1'}}" /> | ||
| {{/each}} | ||
| </div> | ||
| </div> |
10 changes: 6 additions & 4 deletions
10
...onents/course-overview-page/stage-list.ts → ...rse-overview-page/stage-list-card/list.ts
This file contains hidden or 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,18 +1,20 @@ | ||
| import Component from '@glimmer/component'; | ||
| import CourseModel from 'codecrafters-frontend/models/course'; | ||
| import type CourseStageModel from 'codecrafters-frontend/models/course-stage'; | ||
|
|
||
| interface Signature { | ||
| Element: HTMLDivElement; | ||
|
|
||
| Args: { | ||
| course: CourseModel; | ||
| stages: CourseStageModel[]; | ||
| completedStages?: CourseStageModel[]; | ||
| currentStage?: CourseStageModel; | ||
| }; | ||
| } | ||
|
|
||
| export default class StageList extends Component<Signature> {} | ||
| export default class StageListCardList extends Component<Signature> {} | ||
|
|
||
| declare module '@glint/environment-ember-loose/registry' { | ||
| export default interface Registry { | ||
| 'CourseOverviewPage::StageList': typeof StageList; | ||
| 'CourseOverviewPage::StageListCard::List': typeof StageListCardList; | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -20,7 +20,8 @@ | |
| <div class="flex items-start flex-row mb-4"> | ||
| <div class="grow"> | ||
| <CourseOverviewPage::Notices @course={{this.model.course}} class="mb-4" /> | ||
| <CourseOverviewPage::IntroductionAndStages @course={{this.model.course}} class="w-full" /> | ||
| <CourseOverviewPage::IntroductionAndFaq @course={{this.model.course}} class="w-full mb-4" /> | ||
| <CourseOverviewPage::StageListCardList @course={{this.model.course}} /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| </div> | ||
|
|
||
| <div class="hidden lg:block sticky top-4 w-80 shrink-0 ml-2"> | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing Stage Completion Status Display
The StageListCard::List component signature declares
completedStagesandcurrentStageas optional parameters, but these parameters are never referenced in the template (stage-list-card/list.hbs) or passed to child components. This means stage completion status is not being displayed, even though the data is available. The old IntroductionAndStages component passed this information through to display which stages were completed, but the refactored version lost this functionality. Either these parameters should be removed from the signature if intentionally unused, or they should be implemented to restore the completion status display functionality.