-
Notifications
You must be signed in to change notification settings - Fork 5
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
[UEPR-8] feat: add categories to tutorial page #28
Conversation
@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 |
There was a problem hiding this 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 :)
// 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
cca8167
into
scratchfoundation:integration-branch-kaloyan
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