Skip to content

fix: mobile fixes and basic i18n support #127

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

Merged
merged 24 commits into from
Jul 11, 2024
Merged

fix: mobile fixes and basic i18n support #127

merged 24 commits into from
Jul 11, 2024

Conversation

Nemikolh
Copy link
Member

@Nemikolh Nemikolh commented Jul 10, 2024

This PR:

  • Makes a few changes to the rendering of the navigation dropdown on mobile (arrows on both sides are removed).

comparison-before-after

  • Fixes a couple of issues on the mobile version (like buttons not visible).
  • Adds transitions between dark / light themes.
  • Shows a page loading indicator when navigation between two page is greater than 500ms.
loading-indicator.webm
  • Adds a button to start the tutorial on platform where memory is more restricted.
  • Introduces i18n in the metadata that you typically want to configure on the tutorial level to change the text of the UI:
---
type: tutorial
i18n:
  partTemplate: Partie ${index}]: ${title}
  noPreviewNorStepsText: Pas d'aperçu ou d'étapes à montrer
  startWebContainerText: Lancer le tutoriel
---
  • Implements deep inheritance for the metadata for properties like terminal and i18n so that not every property must be specified again if only one changed. Note that this only works for objects. For arrays, string and numbers the value is always overriden (which is typically what you'd want from TutorialKit's metadata).

Nemikolh added 4 commits July 10, 2024 09:03
This commit also introduces an i18n property to the lesson object
which is used to customize the rendering of any string that would
inject a fixed string like "Next lesson: ". Support for string
interpolation is also possible.
Copy link

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

@Nemikolh Nemikolh changed the title fix: mobile fixes fix: mobile fixes and basic i18n support Jul 10, 2024
Copy link

cloudflare-workers-and-pages bot commented Jul 10, 2024

Deploying tutorialkit-demo-page with  Cloudflare Pages  Cloudflare Pages

Latest commit: f9dd9b4
Status: ✅  Deploy successful!
Preview URL: https://14810557.tutorialkit-demo-page.pages.dev
Branch Preview URL: https://joan-mobile-fixes.tutorialkit-demo-page.pages.dev

View logs

Copy link

cloudflare-workers-and-pages bot commented Jul 11, 2024

Deploying tutorialkit-docs-page with  Cloudflare Pages  Cloudflare Pages

Latest commit: ff7225e
Status: ✅  Deploy successful!
Preview URL: https://cedefcc6.tutorialkit-docs-page.pages.dev
Branch Preview URL: https://joan-mobile-fixes.tutorialkit-docs-page.pages.dev

View logs

@@ -272,21 +282,6 @@ export async function getTutorial(): Promise<Tutorial> {
return _tutorial;
}

function pick<T extends Record<any, any>>(objects: (T | undefined)[], properties: (keyof T)[]) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is replaced by squash and inheritProperties which perform a deeper inheritance. This was something we wanted for the terminal property but never got to implement. It was needed for the i18n property as otherwise you couldn't really override a single property for a chapter or lesson.

@@ -18,7 +18,7 @@ const { lesson, logoLink, navList, title } = Astro.props as Props;

<Layout title={title}>
<div id="previews-container"></div>
<main class="max-w-full flex flex-col h-screen overflow-hidden" data-swap-root>
<main class="max-w-full flex flex-col h-full overflow-hidden" data-swap-root>
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixed the issue of not seeing the buttons on the bottom of the page on mobile.

@@ -24,16 +24,35 @@ const baseURL = import.meta.env.BASE_URL;
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700&display=swap" rel="stylesheet" />
<ViewTransitions />
<script is:inline>
setTutorialKitTheme();
Copy link
Member Author

Choose a reason for hiding this comment

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

Calling this function as an inline script guarantee that we always add the theme attribute before any dom as been rendered which makes sure no transition animations are rendered.

Without this change, on dark mode a transition animation was visible on every page reload.

Copy link
Member

Choose a reason for hiding this comment

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

Seems to work nice! 👍

@Nemikolh Nemikolh marked this pull request as ready for review July 11, 2024 10:58
@Nemikolh Nemikolh requested review from AriPerkkio and d3lm July 11, 2024 10:58
@Nemikolh Nemikolh requested a review from AriPerkkio July 11, 2024 12:33
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.

Some optional improvement ideas but looks good to me! 🎉

progressEl.style.opacity = '1';

intervalId = setInterval(() => {
const elapsedTime = Date.now() - startTime;
Copy link
Member

Choose a reason for hiding this comment

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

Nice, that's the correct way to see elapsed time (instead of relying that setInterval(fn, 100) actually calls every 100ms.) 💪

@Nemikolh Nemikolh force-pushed the joan/mobile-fixes branch from c6b40f4 to f9dd9b4 Compare July 11, 2024 18:56
@Nemikolh Nemikolh merged commit f85e8eb into main Jul 11, 2024
10 checks passed
@Nemikolh Nemikolh deleted the joan/mobile-fixes branch July 11, 2024 19:19
data: {
template: 'default',
i18n: {
nextLessonPrefix: 'Next lesson: ',
Copy link
Member

Choose a reason for hiding this comment

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

@Nemikolh now that nextLessonPrefix was removed from source files, this test file is causing typescript errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh good find! Dang, we should typecheck those files in CI. I'll fix them in #133

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in b8c18c8

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.

2 participants