Skip to content

Commit

Permalink
feat(junior): add reload on embed-simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
rouxxi committed Dec 13, 2024
1 parent 07e0e56 commit 215597c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{did-render this.setIframeHtmlElement}}
>
</iframe>
{{#unless @hideSimulator}}
{{#if @shouldDisplayRebootButton}}
<div class="reboot-container">
<button
type="button"
Expand All @@ -25,5 +25,5 @@
{{t "components.challenge.embed-simulator.actions.reset"}}
</button>
</div>
{{/unless}}
{{/if}}
</div>
15 changes: 15 additions & 0 deletions junior/app/components/challenge/item/component.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

export default class Item extends Component {
@tracked isRebootable = false;

constructor() {
super(...arguments);
window.addEventListener('message', ({ data }) => {
if (data?.from === 'pix' && data?.type === 'init') {
this.isRebootable = !!data.rebootable;
}
});
}
get isMediaWithForm() {
return this.args.challenge.hasForm && this.hasMedia && this.args.challenge.type !== undefined;
}
Expand All @@ -12,4 +23,8 @@ export default class Item extends Component {
this.args.challenge.hasWebComponent
);
}

get shouldDisplayRebootButton() {
return this.isRebootable && !this.args.isDisabled;
}
}
1 change: 1 addition & 0 deletions junior/app/components/challenge/item/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@height={{@challenge.embedHeight}}
@hideSimulator={{@isDisabled}}
@isMediaWithForm={{this.isMediaWithForm}}
@shouldDisplayRebootButton={{this.shouldDisplayRebootButton}}
/>
</div>
{{/if}}
Expand Down

0 comments on commit 215597c

Please sign in to comment.