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

Tutorial: Refactor GestureDiagram condition #2364

Open
raineorshine opened this issue Sep 3, 2024 · 0 comments
Open

Tutorial: Refactor GestureDiagram condition #2364

raineorshine opened this issue Sep 3, 2024 · 0 comments
Assignees
Labels
refactor Refactor without changing behavior

Comments

@raineorshine
Copy link
Contributor

raineorshine commented Sep 3, 2024

Steps to Reproduce

Start the Tutorial and advance to Tutorial Step 2 on mobile.

Can be reproduced using the device toolbar in Chrome Dev Tools.

Current Behavior

The condition specifying all the tutorial steps in which the GestureDiagram should be rendered is defined in /src/components/Tutorial/index.tsx, separately from the tutorial step components:

const gesture = once(
() =>
((tutorialStep === TUTORIAL_STEP_FIRSTTHOUGHT ||
tutorialStep === TUTORIAL_STEP_SECONDTHOUGHT_HINT ||
tutorialStep === TUTORIAL2_STEP_CONTEXT1_PARENT_HINT ||
tutorialStep === TUTORIAL2_STEP_CONTEXT2_PARENT_HINT
? shortcutById('newThought')?.gesture
: tutorialStep === TUTORIAL_STEP_SUBTHOUGHT ||
tutorialStep === TUTORIAL2_STEP_CONTEXT1_HINT ||
tutorialStep === TUTORIAL2_STEP_CONTEXT1_SUBTHOUGHT_HINT ||
tutorialStep === TUTORIAL2_STEP_CONTEXT2_HINT ||
tutorialStep === TUTORIAL2_STEP_CONTEXT2_SUBTHOUGHT_HINT
? shortcutById('newSubthought')?.gesture
: tutorialStep === TUTORIAL2_STEP_CONTEXT_VIEW_TOGGLE
? shortcutById('toggleContextView')?.gesture
: null) || null) as GesturePath | null, // Why does it add 'string' to the type union without this?
)

Expected Behavior

The GestureDiagram condition for each tutorial step should be co-located within the tutorial step component itself. The tutorial index can therefore stay more agnostic towards the individual tutorial steps.

Note that the GestureDiagram needs to be rendered below the .tutorial element, whose height depends on the screen size of the device. The tutorial step component just contains the content of the tutorial step, not the paginator or Next/Prev buttons. You will need to do some refactoring to render the GestureDiagram in the right place while ensuring the condition is co-located in the tutorial step component.

@raineorshine raineorshine added the refactor Refactor without changing behavior label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactor without changing behavior
Projects
None yet
Development

No branches or pull requests

2 participants