Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Implement Initial Collections Artwork Filter Navigation Stack #2096

Merged
merged 12 commits into from
Feb 21, 2020

Conversation

ashleyjelks
Copy link
Contributor

@ashleyjelks ashleyjelks commented Feb 20, 2020

#skip_new_tests

Kapture 2020-02-20 at 14 47 09

@ashleyjelks ashleyjelks self-assigned this Feb 20, 2020
@ashleyjelks ashleyjelks changed the title Filter nav stack WIP Do Not Merge Implement Initial Collections Artwork Filter Navigation Stack Feb 20, 2020
@ashleyjelks ashleyjelks assigned sweir27 and unassigned ashleyjelks Feb 20, 2020
@ashleyjelks ashleyjelks marked this pull request as ready for review February 20, 2020 18:02
Copy link
Contributor

@sweir27 sweir27 left a comment

Choose a reason for hiding this comment

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

Few comments (mostly on tests) but this is looking great!!

<SortOptions navigator={mockNavigator as any} />
</Theme>
)
expect(SortOptionsScreen).toMatchSnapshot()
Copy link
Contributor

Choose a reason for hiding this comment

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

I tend to find snapshots not super helpful. Doesn't have to be for this PR, but instead could we test a meaningful aspect of the component? (Such as that the correct number of OptionListItems show up)?

navigationBarHidden={true}
initialRoute={{
component: FilterOptions,
title: "",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this.

<FilterOptions navigator={mockNavigator as any} closeModal={jest.fn()} />
</Theme>
)
expect(FilterOptionsScreen).toMatchSnapshot()
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too, I think this test would be more meaningful with more explicit assertions! (But not a blocker)

<FilterOptions closeModal={jest.fn()} navigator={mockNavigator as any} />
</Theme>
)
const filterListItem = filterScreen.root.findByProps({ "data-test-filter-item": "item" })
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems a little odd to pass props in order to find the item. Can we select for this based on the component's text or class name? (this applies to the other places as well!)

.create(
const getNextScreenTitle = component => component.root.findByType(Sans).props.children

expect(getNextScreenTitle(filterScreen)).toEqual("Sort")
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

expect(getPreviousScreenTitle(filterScreen)).toEqual("Filter")
})

it("allows users to eit filter modal when selecting close icon", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

#superminor eit -> exit

Copy link
Contributor

@ds300 ds300 left a comment

Choose a reason for hiding this comment

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

Looking really good for a start!

const { filterOptions } = this.state

return (
<Flex flexGrow={1} data-test-filter-title="item">
Copy link
Contributor

@ds300 ds300 Feb 21, 2020

Choose a reason for hiding this comment

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

this data-test-[element-id]="item" pattern confused me a little. React Native elements have a prop called testID that people use for the same thing but it uses the form testID="[element-id]", so in this case instead of data-test-filter-title="item" it would be testID="filter-title"

Although, having said that, our palette components use the web typings (😬) so typescript would not allow testID, but you could do data-test-id="filter-title" to keep the same naming pattern which would probably be less surprising to other folks reading this code later.

edit: sarah's suggestion is also good 👍 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was trying to avoid creating aliased styled-components simply for test purposes as there are multiple instances of the same component type and I needed a way to grab a specific instance. But it seems like there are trade-offs either way.

Comment on lines 17 to 25
renderSortOption = ({ item }) => {
return (
<OptionListItem>
<Flex p={2} flexDirection="row" justifyContent="space-between" flexGrow={1}>
<Serif size="3">{item}</Serif>
</Flex>
</OptionListItem>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to have this typed, or personally I'd just move the jsx inline into the renderItem prop so you get the typing for free

<Flex flexGrow={1}>
<SortHeader>
<Flex alignItems="flex-end" mt={0.5} mb={2}>
<Box ml={2} mt={2} onTouchStart={() => this.handleBackNavigation()} data-test-sort-back-nav="item">
Copy link
Contributor

Choose a reason for hiding this comment

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

normally on mobile we wouldn't handle presses using onTouchStart because it fires as soon as the user's finger hits the area, but they might not have intended to press the button. It's best to use something like <TouchableWithOpacity onPress={...}> which handles this situation.

export const SortHeader = styled(Flex)`
flex-direction: row;
justify-content: space-between;
padding-right: 20px;
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 probably use the space helper from palette here

Suggested change
padding-right: 20px;
padding-right: ${space(2)}px;

<Flex flexGrow={1}>
<SortHeader>
<Flex alignItems="flex-end" mt={0.5} mb={2}>
<ArrowLeftIconContainer onTouchStart={() => this.handleBackNavigation()}>
Copy link
Contributor

Choose a reason for hiding this comment

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

again, would be good to use TouchableOpacity here

onPress={() => {
this.closeModal()
<ModalBackgroundView>
<Flex onTouchStart={this.props.closeModal} style={{ flexGrow: 1 }} />
Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to use TouchableWithoutFeedback with onPress here

<OptionListItem>
<Flex p={2} flexDirection="row" justifyContent="space-between" flexGrow={1}>
<Serif size="3">{type}</Serif>
<TouchableOptionListItemRow onTouchStart={() => onTap()}>
Copy link
Contributor

Choose a reason for hiding this comment

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

again, would be good to use TouchableOpacity with onPress

Comment on lines +87 to +96
const filterOptions = []

filterOptions.push({
type: "Sort by",
onTap: this.handleNavigationToSortScreen,
})

this.setState({
filterOptions,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this state value never changes so you can just inline it in the render method.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ashleyjelks this is another opportunity for cleanup!

<Flex flexGrow={1}>
<Flex flexDirection="row" justifyContent="space-between">
<Flex alignItems="flex-end" mt={0.5} mb={2}>
<CloseIconContainer onTouchStart={() => this.props.closeModal()}>
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 TouchableOpcaity + onPress

@sweir27
Copy link
Contributor

sweir27 commented Feb 21, 2020

Cool! @ashleyjelks I'm going to merge this in 😄 but it's worth revisiting the few remaining items from @ds300's review in one of your subsequent PRs!

@sweir27 sweir27 merged commit bab77fb into master Feb 21, 2020
@sweir27 sweir27 deleted the filter-nav-stack branch February 21, 2020 19:37
@artsyit
Copy link
Collaborator

artsyit commented Feb 21, 2020

🚀 PR was released in v1.21.52 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants