Skip to content

Commit dd30f3c

Browse files
authored
Merge pull request #3330 from codecrafters-io/pk-branch-7
feat(autofix-request-card): add toggle button to show/hide fixed code
2 parents a20005c + 5aa6bdb commit dd30f3c

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

app/components/course-page/test-results-bar/autofix-request-card.hbs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
<:overlay>
3434
{{#if (eq @autofixRequest.status "success")}}
35-
<SecondaryButton class="bg-gray-900 mt-6" {{on "click" this.handleShowExplanationButtonClick}}>
35+
<SecondaryButton @size="small" class="bg-gray-900 mt-6" {{on "click" this.handleShowExplanationButtonClick}}>
3636
<div class="flex items-center gap-2">
3737
<div class="flex">{{svg-jar "eye" class="size-6"}}</div>
3838
Explain more?
@@ -43,31 +43,33 @@
4343
</BlurredOverlay>
4444

4545
{{#animated-if (not this.explanationIsBlurred) use=this.transition duration=200}}
46-
<BlurredOverlay @isBlurred={{this.diffIsBlurred}} @overlayClass="bg-gray-950/20" class="-mx-4 -mb-4">
47-
<:content>
48-
<div class="p-4 flex flex-col gap-6">
49-
{{#each this.changedFilesForRender key="filename" as |changedFile|}}
50-
<FileDiffCard
51-
@code={{changedFile.diff}}
52-
@filename={{changedFile.filename}}
53-
@forceDarkTheme={{true}}
54-
{{! @glint-expect-error language can be nullable }}
55-
@language={{@autofixRequest.submission.repository.language.slug}}
56-
/>
57-
{{/each}}
46+
<div class="w-full flex items-center justify-center mt-4">
47+
<SecondaryButton @size="small" class="bg-gray-900" {{on "click" this.handleToggleFixedCodeButtonClick}}>
48+
<div class="flex items-center gap-2">
49+
<div class="flex">{{svg-jar "eye" class="size-6"}}</div>
50+
51+
{{#if this.diffIsHidden}}
52+
Show fixed code
53+
{{else}}
54+
Hide fixed code
55+
{{/if}}
5856
</div>
59-
</:content>
60-
<:overlay>
61-
{{#if (eq @autofixRequest.status "success")}}
62-
<SecondaryButton class="bg-gray-900 mt-10" {{on "click" this.handleShowFixedCodeButtonClick}}>
63-
<div class="flex items-center gap-2">
64-
<div class="flex">{{svg-jar "eye" class="size-6"}}</div>
65-
Show fixed code
66-
</div>
67-
</SecondaryButton>
68-
{{/if}}
69-
</:overlay>
70-
</BlurredOverlay>
57+
</SecondaryButton>
58+
</div>
59+
60+
{{#animated-if (not this.diffIsHidden) use=this.transition duration=200}}
61+
<div class="flex flex-col gap-6 pt-4">
62+
{{#each this.changedFilesForRender key="filename" as |changedFile|}}
63+
<FileDiffCard
64+
@code={{changedFile.diff}}
65+
@filename={{changedFile.filename}}
66+
@forceDarkTheme={{true}}
67+
{{! @glint-expect-error language can be nullable }}
68+
@language={{@autofixRequest.submission.repository.language.slug}}
69+
/>
70+
{{/each}}
71+
</div>
72+
{{/animated-if}}
7173
{{/animated-if}}
7274
</div>
7375
{{/if}}

app/components/course-page/test-results-bar/autofix-request-card.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class AutofixRequestCard extends Component<Signature> {
4444
}
4545
}
4646

47-
get diffIsBlurred() {
47+
get diffIsHidden() {
4848
// We never show a diff unless the autofix request is successful
4949
if (this.args.autofixRequest.status !== 'success') {
5050
return true;
@@ -71,12 +71,13 @@ export default class AutofixRequestCard extends Component<Signature> {
7171
}
7272

7373
@action
74-
handleShowFixedCodeButtonClick() {
75-
if (this.diffIsBlurred) {
74+
handleToggleFixedCodeButtonClick() {
75+
if (this.diffIsHidden) {
7676
this.analyticsEventTracker.track('revealed_autofix_diff', { autofix_request_id: this.args.autofixRequest.id });
77+
this.diffWasUnblurred = true;
78+
} else {
79+
this.diffWasUnblurred = false;
7780
}
78-
79-
this.diffWasUnblurred = true;
8081
}
8182
}
8283

0 commit comments

Comments
 (0)