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(react): add button to reload a preview #305

Merged
merged 7 commits into from
Sep 2, 2024
Merged

Conversation

Nemikolh
Copy link
Member

@Nemikolh Nemikolh commented Sep 2, 2024

This PR replaces the globe icon with a reload button, to reload a preview. It uses the new reloadPreview function from @webcontainer/api/utils.

Closes #248

Note that this is best effort. Meaning that if the learner navigates within the preview to a location that does not render HTML (like an image or JSON), pressing the reload icon won't work as it will reset the iframe to its initial location. This can only be fixed at the WebContainer level.

@Nemikolh Nemikolh requested a review from AriPerkkio September 2, 2024 14:48
Copy link

stackblitz bot commented Sep 2, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@AriPerkkio AriPerkkio linked an issue Sep 2, 2024 that may be closed by this pull request
Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

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

Overall looks good! Great to have test case for this as well!

The background color inside the icon seems a bit weird to me. But after I noticed it, I saw that we already have similar background in Reset-button.

image

e2e/src/templates/default/index.mjs Outdated Show resolved Hide resolved
e2e/test/preview.test.ts Outdated Show resolved Hide resolved
e2e/test/preview.test.ts Outdated Show resolved Hide resolved
packages/types/src/schemas/i18n.ts Outdated Show resolved Hide resolved
testId?: string;
}

export function ButtonWriteToFile({ filePath, newContent, testId = 'write-to-file' }: Props) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice! I can imagine this utility component being useful in other future tests as well. It's good to have it accepting props like this. 🎉

Copy link

cloudflare-workers-and-pages bot commented Sep 2, 2024

Deploying tutorialkit-demo-page with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3214499
Status: ✅  Deploy successful!
Preview URL: https://c763c9a6.tutorialkit-demo-page.pages.dev
Branch Preview URL: https://joan-reload-preview.tutorialkit-demo-page.pages.dev

View logs

@henrikvilhelmberglund
Copy link
Contributor

The duotone icon looks strange to me too, https://icones.js.org/collection/ph?s=arrow&icon=ph:arrow-clockwise could be used instead, along with a dark:text-slate-100 or something if necessary for the color.

@Nemikolh
Copy link
Member Author

Nemikolh commented Sep 2, 2024

@henrikvilhelmberglund I'll change it to the arrow-clockwise then. Thanks for voicing your opinion 😃

@Nemikolh Nemikolh marked this pull request as ready for review September 2, 2024 15:56
@Nemikolh Nemikolh requested a review from AriPerkkio September 2, 2024 15:57
Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

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

Documentation for the new localization key should be added in docs/tutorialkit.dev/src/content/docs/reference/configuration.mdx. Once that's done, this is good to go!

We should create separate follow-up issue for updating the background of the old icon-buttons too.

@Nemikolh
Copy link
Member Author

Nemikolh commented Sep 2, 2024

We should create separate follow-up issue for updating the background of the old icon-buttons too.

@AriPerkkio Oh do you mean updating all the ph-duo icons for their non-duotone version?

@Nemikolh Nemikolh merged commit d14c404 into main Sep 2, 2024
11 checks passed
@Nemikolh Nemikolh deleted the joan/reload-preview branch September 2, 2024 16:24
@AriPerkkio
Copy link
Member

@AriPerkkio Oh do you mean updating all the ph-duo icons for their non-duotone version?

Yep, at least the reset button looks similarly weird now that I've seen how clear the refresh button looks after the change. 😄

Or maybe this in intentional?

image

@Nemikolh
Copy link
Member Author

Nemikolh commented Sep 3, 2024

@AriPerkkio It was, but we can also change them I think. It was not my choice 🤷‍♂️

Tbqh, I've always felt that, at the very least, they should be customizable. I'll open a ticket for that and another one to change them to their non-duotone versions.

EDIT: Created #311

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.

A small refresh button in the preview tab
3 participants