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

[UEPR-8] feat: add categories to tutorial page #28

Conversation

KManolov3
Copy link
Contributor

Resolves

https://scratchfoundation.atlassian.net/browse/UEPR-8

Proposed Changes

Adds a category prop to the deck components and uses it to group them in categories in the case when "?tutorial=all" filter is selected.

Reason for Changes

Test Coverage

@KManolov3 KManolov3 changed the title feat: uepr-8: add categories to tutorial page [UEPR-8] feat: add categories to tutorial page Sep 30, 2024
@KManolov3 KManolov3 requested a review from cwillisf September 30, 2024 04:47
@KManolov3
Copy link
Contributor Author

KManolov3 commented Sep 30, 2024

@cwillisf Had to make a few changes to the order of the decks to achieve the order defined in the task and decided to still use the current ordering mechanism - which is the order they are defined in the decks/index.jsx file. This has lead to a few order changes when one of the other tags is selected, wherever the order had to be changed for a category (for example, in Animation, Record a Sound was previously after Use Arrow Keys, now it's before) (see images below). To be clear, this only affects the deck order within a category - we first explicitly group by and sort the decks by category. I think it makes sense to have it like that, since this way the relative order of items within a category remains consistent between tags.
Let me know if we need to implement a separate ordering for the all category.

Old:
image
image

New:
image
image

@KManolov3 KManolov3 changed the base branch from develop to integration-branch-kaloyan October 2, 2024 15:38
Copy link
Contributor

@cwillisf cwillisf left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me. The groupBy / sort / map part is a little more complex than I expected, but I think that's an indication that decks/index.jsx is more complex than it should be, and we can consider fixing that separately :)

Comment on lines 28 to 31
// Unfortunately, can't seem to be able to generate those,
// since it looks like `defineMessages` is called on first render
// and (seemingly?) before any operations, such as object destructuring
// can happen.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you say more about this? Just want to make sure I understand the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if anything it shows I don't understand very well at what point defineMessages is called. What I tried to do was have a: (at that point CATEGORIES' values were the message we wanted to visualise)
const categoryMessagesInfo = Object.entries(CATEGORIES).reduce(([key, message], acc) => { acc[...] = { id:gui.library.${key}, defaultMessage: message, description: Label for ${message} category}, {}); const messages = { ...*currentMessages*, ...categoryMessagesInfo }
so that the category message construction is a bit more programmatic and we don't have to define, for example, the category id in two places, but that led to categoryMessagesInfo evaluating to an empty value inside messages. After some experimenting I "felt my way" to the conclusion that any time defineMessages is called with anything other than a statically constructed object, the messages aren't evaluated properly.

I searched for an explanation in the docs now and yeah - https://formatjs.io/docs/getting-started/message-declaration/#pre-declaring-using-definemessage-for-later-consumption-less-recommended - it says pretty clear that the strings need to be static. Though I'm not sure whether

But I suppose my comment is wrong - it seems likely that in our case the message definition happens on compile time, not on runtime - will update it - https://formatjs.io/docs/guides/advanced-usage/#pre-compiling-messages.

I apologize if the above is common knowledge to you :D

Are you okay with leaving the messages explicitly defined as they are right now?

@KManolov3 KManolov3 merged commit cca8167 into scratchfoundation:integration-branch-kaloyan Oct 7, 2024
1 check passed
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