-
Notifications
You must be signed in to change notification settings - Fork 17
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
Only show previous steps incomplete modal for instructions & setup #2331
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1850397
Add PreviousStepsIncompleteOverlay component and update step-content …
rohitpaulk 05f1e7b
Refactor PreviousStepsIncompleteOverlay to use currentStep and handle…
rohitpaulk f3de3da
Refactor layout and remove unused overlay in course stage templates.
rohitpaulk d1fa679
Update padding and margin classes in course templates for better resp…
rohitpaulk b3d8bf9
Remove unnecessary click on 'Just Exploring' button in code examples …
rohitpaulk 56dffdf
Add currentStep getter and wrap setup card in PreviousStepsIncomplete…
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
17 changes: 17 additions & 0 deletions
17
app/components/course-page/previous-steps-incomplete-overlay.hbs
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<BlurredOverlay | ||
@isBlurred={{this.shouldShowModal}} | ||
{{did-update this.handleStepIdUpdated @currentStep.id}} | ||
@overlayClass="bg-gray-200 bg-opacity-20 dark:bg-gray-800 dark:bg-opacity-20" | ||
...attributes | ||
> | ||
<:content> | ||
{{yield}} | ||
</:content> | ||
<:overlay> | ||
<CoursePage::PreviousStepsIncompleteModal | ||
class="mt-8 mx-3 md:mx-6" | ||
@onClose={{this.handleModalDismissed}} | ||
@activeStep={{this.coursePageState.activeStep}} | ||
/> | ||
</:overlay> | ||
</BlurredOverlay> |
55 changes: 55 additions & 0 deletions
55
app/components/course-page/previous-steps-incomplete-overlay.ts
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { action } from '@ember/object'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import type CoursePageStateService from 'codecrafters-frontend/services/course-page-state'; | ||
import { Step } from 'codecrafters-frontend/utils/course-page-step-list'; | ||
|
||
interface Signature { | ||
Element: HTMLDivElement; | ||
|
||
Args: { | ||
currentStep: Step; | ||
}; | ||
|
||
Blocks: { | ||
default: []; | ||
}; | ||
} | ||
|
||
export default class PreviousStepsIncompleteOverlayComponent extends Component<Signature> { | ||
@tracked modalWasDismissed = false; | ||
@tracked lastSeenStepId: string | null = null; | ||
|
||
@service declare coursePageState: CoursePageStateService; | ||
|
||
get shouldShowModal(): boolean { | ||
// This _shouldn't_ happen as long as we're always rendered in the course page, but let's be safe | ||
if (!this.coursePageState.activeStep) { | ||
return false; | ||
} | ||
|
||
return !this.modalWasDismissed && this.args.currentStep.status === 'locked'; | ||
} | ||
|
||
@action | ||
handleModalDismissed() { | ||
this.modalWasDismissed = true; | ||
} | ||
|
||
@action | ||
handleStepIdUpdated() { | ||
if (this.args.currentStep.id === this.lastSeenStepId) { | ||
return; | ||
} | ||
|
||
this.lastSeenStepId = this.args.currentStep.id; | ||
this.modalWasDismissed = false; | ||
} | ||
} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
'CoursePage::PreviousStepsIncompleteOverlay': typeof PreviousStepsIncompleteOverlayComponent; | ||
} | ||
} |
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
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,3 +1,3 @@ | ||
<div class="pt-8 pb-16"> | ||
<div class="pt-8 pb-16 px-3 md:px-6 lg:px-10"> | ||
<CoursePage::BaseStagesCompletedCard @repository={{@model.activeRepository}} /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{{! @glint-nocheck: not typesafe yet !}} | ||
<div class="pt-8 pb-16"> | ||
<div class="pt-8 pb-16 px-3 md:px-6 lg:px-10"> | ||
<CoursePage::CourseCompletedCard @repository={{@model.activeRepository}} /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div class="pt-8 pb-16"> | ||
<div class="pt-8 pb-16 px-3 md:px-6 lg:px-10"> | ||
<CoursePage::ExtensionCompletedCard @repository={{@model.activeRepository}} @extension={{@model.extension}} /> | ||
</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
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,3 +1,5 @@ | ||
<div class="w-full pt-8 pb-32"> | ||
<CoursePage::SetupStep::RepositorySetupCard @repository={{@model.activeRepository}} /> | ||
</div> | ||
<CoursePage::PreviousStepsIncompleteOverlay @currentStep={{this.currentStep}}> | ||
<div class="w-full pt-8 pb-32 px-3 md:px-6 lg:px-10"> | ||
<CoursePage::SetupStep::RepositorySetupCard @repository={{@model.activeRepository}} /> | ||
</div> | ||
</CoursePage::PreviousStepsIncompleteOverlay> |
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
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,101 +1,103 @@ | ||
<div class="pt-6 pb-32"> | ||
{{#if this.shouldShowUpgradePrompt}} | ||
<CoursePage::CourseStageStep::UpgradePrompt @featureSlugToHighlight="content" class="mb-6" /> | ||
{{/if}} | ||
<CoursePage::PreviousStepsIncompleteOverlay @currentStep={{this.currentStep}}> | ||
<div class="pt-6 pb-32 px-3 md:px-6 lg:px-10"> | ||
{{#if this.shouldShowUpgradePrompt}} | ||
<CoursePage::CourseStageStep::UpgradePrompt @featureSlugToHighlight="content" class="mb-6" /> | ||
{{/if}} | ||
|
||
{{#if this.shouldShowFeedbackPrompt}} | ||
<CoursePage::CourseStageStep::FeedbackPrompt | ||
@courseStage={{@model.courseStage}} | ||
@repository={{@model.activeRepository}} | ||
@onSubmit={{this.handleStageFeedbackSubmitted}} | ||
class="mb-6" | ||
/> | ||
{{/if}} | ||
|
||
{{#if (gt this.badgeAwards.length 0)}} | ||
<CoursePage::CourseStageStep::EarnedBadgeNotice @badgeAwards={{this.badgeAwards}} class="mb-6" /> | ||
{{/if}} | ||
{{#if this.shouldShowFeedbackPrompt}} | ||
<CoursePage::CourseStageStep::FeedbackPrompt | ||
@courseStage={{@model.courseStage}} | ||
@repository={{@model.activeRepository}} | ||
@onSubmit={{this.handleStageFeedbackSubmitted}} | ||
class="mb-6" | ||
/> | ||
{{/if}} | ||
|
||
{{#if @model.courseStage.isFirst}} | ||
<CoursePage::CourseStageStep::FirstStageTutorialCard @repository={{@model.activeRepository}} @courseStage={{@model.courseStage}} class="mb-6" /> | ||
{{/if}} | ||
{{#if (gt this.badgeAwards.length 0)}} | ||
<CoursePage::CourseStageStep::EarnedBadgeNotice @badgeAwards={{this.badgeAwards}} class="mb-6" /> | ||
{{/if}} | ||
|
||
{{#if @model.courseStage.isSecond}} | ||
<CoursePage::CourseStageStep::SecondStageInstructionsCard | ||
@repository={{@model.activeRepository}} | ||
@courseStage={{@model.courseStage}} | ||
class="mb-6" | ||
/> | ||
{{/if}} | ||
{{#if @model.courseStage.isFirst}} | ||
<CoursePage::CourseStageStep::FirstStageTutorialCard @repository={{@model.activeRepository}} @courseStage={{@model.courseStage}} class="mb-6" /> | ||
{{/if}} | ||
|
||
{{#if this.shouldShowTestRunnerCard}} | ||
<div class="mb-6"> | ||
<CoursePage::CourseStageStep::TestRunnerCard | ||
@isCollapsible={{or this.shouldSuppressTestRunnerCardExpands (not-eq this.currentStep.testsStatus "passed")}} | ||
{{#if @model.courseStage.isSecond}} | ||
<CoursePage::CourseStageStep::SecondStageInstructionsCard | ||
@repository={{@model.activeRepository}} | ||
@stage={{@model.courseStage}} | ||
@onExpand={{if this.shouldSuppressTestRunnerCardExpands this.handleTestRunnerCardExpandedOnFirstStage undefined}} | ||
@courseStage={{@model.courseStage}} | ||
class="mb-6" | ||
/> | ||
{{/if}} | ||
|
||
{{#if this.shouldSuppressTestRunnerCardExpands}} | ||
<EmberPopover @popperContainer="body"> | ||
<div class="prose prose-sm prose-invert text-white"> | ||
{{#if (eq this.currentStep.testsStatus "failed")}} | ||
<p> | ||
This failure is expected! Check the | ||
<a href="#first-stage-tutorial-card">How to pass this stage</a> | ||
section for instructions. | ||
</p> | ||
{{else}} | ||
<p> | ||
Check the | ||
<a href="#first-stage-tutorial-card">How to pass this stage</a> | ||
section for instructions. | ||
</p> | ||
{{/if}} | ||
</div> | ||
</EmberPopover> | ||
{{/if}} | ||
</div> | ||
{{/if}} | ||
{{#if this.shouldShowTestRunnerCard}} | ||
<div class="mb-6"> | ||
<CoursePage::CourseStageStep::TestRunnerCard | ||
@isCollapsible={{or this.shouldSuppressTestRunnerCardExpands (not-eq this.currentStep.testsStatus "passed")}} | ||
@repository={{@model.activeRepository}} | ||
@stage={{@model.courseStage}} | ||
@onExpand={{if this.shouldSuppressTestRunnerCardExpands this.handleTestRunnerCardExpandedOnFirstStage undefined}} | ||
/> | ||
|
||
{{! TODO: Bring this back? }} | ||
{{!-- {{#if this.shouldShowPrerequisites}} | ||
<CoursePage::CourseStageStep::PrerequisitesCard @repository={{@model.activeRepository}} @courseStage={{@model.courseStage}} class="mb-6" /> | ||
{{/if}} --}} | ||
{{#if this.shouldSuppressTestRunnerCardExpands}} | ||
<EmberPopover @popperContainer="body"> | ||
<div class="prose prose-sm prose-invert text-white"> | ||
{{#if (eq this.currentStep.testsStatus "failed")}} | ||
<p> | ||
This failure is expected! Check the | ||
<a href="#first-stage-tutorial-card">How to pass this stage</a> | ||
section for instructions. | ||
</p> | ||
{{else}} | ||
<p> | ||
Check the | ||
<a href="#first-stage-tutorial-card">How to pass this stage</a> | ||
section for instructions. | ||
</p> | ||
{{/if}} | ||
</div> | ||
</EmberPopover> | ||
{{/if}} | ||
</div> | ||
{{/if}} | ||
|
||
<CoursePage::CourseStageStep::YourTaskCard @repository={{@model.activeRepository}} @courseStage={{@model.courseStage}} /> | ||
{{! TODO: Bring this back? }} | ||
{{!-- {{#if this.shouldShowPrerequisites}} | ||
<CoursePage::CourseStageStep::PrerequisitesCard @repository={{@model.activeRepository}} @courseStage={{@model.courseStage}} class="mb-6" /> | ||
{{/if}} --}} | ||
|
||
{{#if this.shouldShowLanguageGuide}} | ||
<CoursePage::CourseStageStep::LanguageGuideCard @repository={{@model.activeRepository}} @courseStage={{@model.courseStage}} class="mt-6" /> | ||
{{/if}} | ||
<CoursePage::CourseStageStep::YourTaskCard @repository={{@model.activeRepository}} @courseStage={{@model.courseStage}} /> | ||
|
||
<div data-percy-hints-section> | ||
<div class="border-b dark:border-white/5 pb-2 mb-6 mt-8 flex items-center justify-between"> | ||
<h2 class="font-semibold text-lg text-gray-800 dark:text-gray-200">Hints</h2> | ||
{{#if this.shouldShowLanguageGuide}} | ||
<CoursePage::CourseStageStep::LanguageGuideCard @repository={{@model.activeRepository}} @courseStage={{@model.courseStage}} class="mt-6" /> | ||
{{/if}} | ||
|
||
{{#if @model.activeRepository.language}} | ||
<div class="flex items-center gap-1"> | ||
<span class="text-xs text-gray-500 mr-2">Filter by {{@model.activeRepository.language.name}}</span> | ||
<Toggle @isOn={{this.commentListIsFilteredByLanguage}} {{on "click" this.handleCommentListFilterToggled}} /> | ||
<div data-percy-hints-section> | ||
<div class="border-b dark:border-white/5 pb-2 mb-6 mt-8 flex items-center justify-between"> | ||
<h2 class="font-semibold text-lg text-gray-800 dark:text-gray-200">Hints</h2> | ||
|
||
<EmberTooltip> | ||
{{#if this.commentListIsFilteredByLanguage}} | ||
You're currently viewing hints that are relevant to | ||
{{@model.activeRepository.language.name}}. Turn this off to view hints for all languages. | ||
{{else}} | ||
You're currently viewing hints for all languages. Turn this on to filter hints that are relevant to | ||
{{@model.activeRepository.language.name}}. | ||
{{/if}} | ||
</EmberTooltip> | ||
</div> | ||
{{/if}} | ||
</div> | ||
{{#if @model.activeRepository.language}} | ||
<div class="flex items-center gap-1"> | ||
<span class="text-xs text-gray-500 mr-2">Filter by {{@model.activeRepository.language.name}}</span> | ||
<Toggle @isOn={{this.commentListIsFilteredByLanguage}} {{on "click" this.handleCommentListFilterToggled}} /> | ||
|
||
<EmberTooltip> | ||
{{#if this.commentListIsFilteredByLanguage}} | ||
You're currently viewing hints that are relevant to | ||
{{@model.activeRepository.language.name}}. Turn this off to view hints for all languages. | ||
{{else}} | ||
You're currently viewing hints for all languages. Turn this on to filter hints that are relevant to | ||
{{@model.activeRepository.language.name}}. | ||
{{/if}} | ||
</EmberTooltip> | ||
</div> | ||
{{/if}} | ||
</div> | ||
|
||
<CoursePage::CommentList | ||
@courseStage={{@model.courseStage}} | ||
@language={{@model.activeRepository.language}} | ||
@shouldFilterByLanguage={{this.commentListIsFilteredByLanguage}} | ||
/> | ||
<CoursePage::CommentList | ||
@courseStage={{@model.courseStage}} | ||
@language={{@model.activeRepository.language}} | ||
@shouldFilterByLanguage={{this.commentListIsFilteredByLanguage}} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</CoursePage::PreviousStepsIncompleteOverlay> |
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
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.
💡 Codebase verification
Missing Tests for PreviousStepsIncompleteOverlay Component
No associated tests were found for the
PreviousStepsIncompleteOverlay
component. It's recommended to add tests to verify its functionality and ensure reliability.🔗 Analysis chain
Approve the addition of PreviousStepsIncompleteOverlay component
The addition of the
<CoursePage::PreviousStepsIncompleteOverlay>
component is a good approach to manage the visibility of content based on the completion status of previous steps. This can help ensure that users follow the intended learning path.Could you provide more information about how this overlay behaves? Specifically:
To verify the implementation, please run the following script:
Also applies to: 103-103
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 824
Script:
Length of output: 1264
Script:
Length of output: 1398