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

Spritelab/Gamelab Animation Library changes for backgrounds #36578

Merged
merged 17 commits into from Sep 25, 2020

Conversation

JillianK
Copy link
Contributor

@JillianK JillianK commented Sep 2, 2020

This sets up everything we will need to get backgrounds safely included as part of the animation library in sprite lab without letting them show up when students are trying to add sprites in addition to adding a new block input backgroundPicker that will be used in a new set background as block. This PR should not change the behavior of any animation stuff in sprite or gamelab.

Links

Testing story

Added the extra fields to animation picker body tests and wrote tests for the actions show and showBackground in animation picker module.

Reviewer Checklist:

  • Tests provide adequate coverage
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@JillianK JillianK mentioned this pull request Sep 2, 2020
11 tasks
@JillianK JillianK requested a review from a team September 2, 2020 23:18
apps/src/p5lab/P5LabView.jsx Outdated Show resolved Hide resolved
Copy link
Contributor

@ajpal ajpal left a comment

Choose a reason for hiding this comment

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

Left a couple comments, but other than those lgtm!

@JillianK JillianK requested a review from a team as a code owner September 16, 2020 22:38
apps/i18n/common/en_us.json Outdated Show resolved Hide resolved
Comment on lines 111 to 113
newResults = newResults.filter(
animation => !animation.categories.includes('backgrounds')
);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we filter backgrounds in multiple places now, so we should pull this out into a helper method

also, question: this will currently filter a result that has ["backgrounds", "environments"] as its categories -- is that what we want? or should we only filter the result if its only category is "backgrounds"?

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 that we should filter it out if it has backgrounds as a category because we don't want them to be able to use a background as a sprite right?

onClick={this.onClearCategories}
style={animationPickerStyles.allAnimations}
>
{`${msg.animationPicker_allCategories()} > `}
Copy link
Contributor

Choose a reason for hiding this comment

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

we should move the carrot into the animationPicker_allCategories string so that it displays correctly in RTL languages (right now, the greater-than sign would be on the incorrect end of the string)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Elijah asked me to take it out, do you still want me to put it back in? #36578 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, sorry, i missed his comment -- he's our resident i18n expert, so i'll take his recommendation 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

The browser is (usually) capable of aligning things like this correctly in RTL, and this way we avoid confusing translators with non-language characters

apps/src/p5lab/AnimationTab/AnimationTab.jsx Outdated Show resolved Hide resolved
apps/src/p5lab/AnimationTab/AnimationList.jsx Outdated Show resolved Hide resolved
})
);
// if checkBackground, this means we don't want the selected animation to be a background
if (!checkBackground || !props.categories.includes('backgrounds')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe skipBackground instead of checkBackground?

now that we have this param, do we need to check props.categories? or can we just manipulate the param?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need to check props.categories to decide whether or not to set selected in the costume library. Otherwise, spritelab would never have default selected sprites showing up in the costume library (they'd have to scroll a bunch)

Comment on lines 27 to 35
if (backgrounds) {
return (
animation.categories && animation.categories.includes('backgrounds')
);
} else {
return !(
animation.categories && animation.categories.includes('backgrounds')
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: i think we can simplify this filter function as well (definitely double-check my logic here)

Suggested change
if (backgrounds) {
return (
animation.categories && animation.categories.includes('backgrounds')
);
} else {
return !(
animation.categories && animation.categories.includes('backgrounds')
);
}
return backgrounds && (animation.categories || []).includes('backgrounds')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the logic didnt quite work but I tried simplifying it, let me know what you think

import i18n from '@cdo/locale';
import spritelabMsg from '@cdo/spritelab/locale';

function sprites() {
function animations(backgrounds) {
Copy link
Contributor

Choose a reason for hiding this comment

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

it isn't clear what this param does by its name -- maybe skipBackgrounds again? or includeBackgrounds if we want the inverse (also open to suggestions)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about isBackgroundAnimations?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, i still misunderstood the param meaning lol. i think that's fine, or even just areBackgrounds since the function is called animations and now the param will communicate that it should be a boolean

Copy link
Contributor

@maddiedierker maddiedierker 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 jillian! especially for bearing with all my comments/nits 😜

@JillianK JillianK merged commit ef875b6 into staging Sep 25, 2020
@JillianK JillianK deleted the jk-background-logic branch September 25, 2020 16:55
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.

None yet

4 participants