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: mobile support #91

Merged
merged 16 commits into from
Jul 3, 2024
Merged

feat: mobile support #91

merged 16 commits into from
Jul 3, 2024

Conversation

Nemikolh
Copy link
Member

This PR adds mobile support for TutorialKit following a similar approach as the excellent https://learn.svelte.dev/.

See the screencast below to see how it looks:

Screencast.from.2024-06-24.14-58-32.webm

Copy link

stackblitz bot commented Jun 24, 2024

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

Copy link

changeset-bot bot commented Jun 24, 2024

⚠️ No Changeset found

Latest commit: b38cc16

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -208,89 +233,3 @@ if (!hasSidePanel) {

customElements.define('resizable-panel', ResizablePanel);
</script>

<style>
Copy link
Member Author

Choose a reason for hiding this comment

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

I replaced the inline style from this component with unocss classes as it makes it easier to add breakpoints for mobile.

}

if (blocked) {
await blockingStatus.promise;
Copy link
Member Author

Choose a reason for hiding this comment

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

We now prevent WebContainer from booting on iOS to avoid crashing the page as it sometimes does. Instead the idea is to later let them proceeed with the boot by pressing a button.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we use the same logic as the editor?

Comment on lines 65 to 69
useEffect(() => {
const intervalId = setInterval(onResize, 20);

return () => clearInterval(intervalId);
}, []);
Copy link
Member Author

@Nemikolh Nemikolh Jun 24, 2024

Choose a reason for hiding this comment

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

With this code we make sure that the previews are correctly positioned. This is important on mobile when switching between the content and the editor.

I kept the existing ResizeObserver instances because they are smoother.

This also fix the edge case where the preview stop moving when increasing the size of the terminal section.

Comment on lines +53 to +54
// delete extraneous route announcer
document.querySelector('.astro-route-announcer')?.remove();
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated fix to this PR but I noticed that as you navigate between pages we were accumulating divs under the body.

Copy link
Contributor

@SamVerschueren SamVerschueren left a comment

Choose a reason for hiding this comment

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

Did a first initial review and added some questions. Looks very cool btw!

Copy link

cloudflare-workers-and-pages bot commented Jun 25, 2024

Deploying tutorialkit-demo-page with  Cloudflare Pages  Cloudflare Pages

Latest commit: a810b84
Status: ✅  Deploy successful!
Preview URL: https://1e48fbe7.tutorialkit-demo-page.pages.dev
Branch Preview URL: https://joan-mobile-support.tutorialkit-demo-page.pages.dev

View logs

@d3lm
Copy link
Contributor

d3lm commented Jun 26, 2024

@Nemikolh Could you merge latest master into this PR? I'd love to run this locally and fiddle with it when I review it and I'd love to have the latest state in it as well to make sure everything works and what not 🙏

Copy link

cloudflare-workers-and-pages bot commented Jun 26, 2024

Deploying tutorialkit-docs-page with  Cloudflare Pages  Cloudflare Pages

Latest commit: c7542cb
Status: ✅  Deploy successful!
Preview URL: https://257e4fdb.tutorialkit-docs-page.pages.dev
Branch Preview URL: https://joan-mobile-support.tutorialkit-docs-page.pages.dev

View logs

@Nemikolh
Copy link
Member Author

@d3lm It's updated now!

Copy link
Contributor

@SamVerschueren SamVerschueren left a comment

Choose a reason for hiding this comment

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

Looks pretty nice!

@SamVerschueren
Copy link
Contributor

Is it possible that this is broken now on desktop? If I open the preview, I only see the editor view and I can't toggle to the content either.

https://4c6936c9.tutorialkit-demo-page.pages.dev/forms-tutorial/introduction/welcome/

@Nemikolh
Copy link
Member Author

Nemikolh commented Jul 2, 2024

@SamVerschueren Oh wow, maybe a merge commit introduced a bug. I'll address all the feedback and test it again.

Copy link
Contributor

@d3lm d3lm left a comment

Choose a reason for hiding this comment

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

Generally looks good. I only left minor comments. Great work!

A few additional things I noticed while testing this on my end.

I noticed is that there's a visual bug with the iframes when moving between the two sides which doesn't look great. Maybe not a lot of people will notice but it caught my eye immediately. Would be cool if we could investigate a way to fix this or at least make it less noticeable.

CleanShot.2024-07-02.at.18.26.39.mp4

Another thing is that there's the border visible on the left when switched to the right side. Visually that looks a bit off IMO.

CleanShot 2024-07-02 at 18 25 20

Also, we may need to think about the menu if we ship mobile support because right now it's not really usable as you can't read the titles. So we may need to go back to the design drawing board. Elements usually need to be adjusted to work well on mobile. The breadcrumb was mostly tailored for Desktop use. So I'd prefer if we could fix before shipping mobile support. I mean we can always fix it later but to me, if a user can't properly read the tiles then they can't properly navigate between different lessons.

image

@Nemikolh
Copy link
Member Author

Nemikolh commented Jul 2, 2024

I noticed is that there's a visual bug with the iframes when moving between the two sides which doesn't look great. Maybe not a lot of people will notice but it caught my eye immediately. Would be cool if we could investigate a way to fix this or at least make it less noticeable.

I think that switching to requestAnimationFrame will make that bug disappear completely (it's the setInterval that's causing this because it does not update often enough). My worries was that it might cause a higher cpu usage but maybe it's fine.

Another thing is that there's the border visible on the left when switched to the right side. Visually that looks a bit off IMO.

Oh good catch! 🙏

Also, we may need to think about the menu if we ship mobile support because right now it's not really usable as you can't read the titles. So we may need to go back to the design drawing board. Elements usually need to be adjusted to work well on mobile. The breadcrumb was mostly tailored for Desktop use. So I'd prefer if we could fix before shipping mobile support. I mean we can always fix it later but to me, if a user can't properly read the tiles then they can't properly navigate between different lessons.

Good point. What if we just show the lesson titles in the dropdown on mobile?
Or maybe we split over two lines.

@Nemikolh Nemikolh requested a review from d3lm July 3, 2024 12:11
@Nemikolh
Copy link
Member Author

Nemikolh commented Jul 3, 2024

@d3lm I addressed all the comments in this PR and made simple changes. Namely:

  • The Breadcrumbs are now hidden and we only show the lesson title. We'll probably want to get some design there if we'd like to do something different.
  • The tiny border on mobile on the left is now gone. 🙌
  • The bug that Sam reported is fixed as well. Turns out that when you do a build, UnoCSS does not sees the same content and the astro files must be added manually. This is not great at all, I'll try to create a minimal reproduction for UnoCSS to get some feedback on whether this behaviour is expected or not.
  • I removed the resize logic and we now use requestAnimationFrame to update the iframe positions. Works like a charm.

Copy link
Contributor

@d3lm d3lm left a comment

Choose a reason for hiding this comment

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

Great work and thanks for addressing the feedback 🙏 This looks good 👏

@Nemikolh Nemikolh merged commit 030ca1e into main Jul 3, 2024
9 checks passed
@Nemikolh Nemikolh deleted the joan/mobile-support branch July 3, 2024 13:39
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.

4 participants