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

Collections Artwork Filter Container #2073

Merged
merged 7 commits into from
Feb 11, 2020
Merged

Collections Artwork Filter Container #2073

merged 7 commits into from
Feb 11, 2020

Conversation

ashleyjelks
Copy link
Contributor

@ashleyjelks ashleyjelks commented Feb 3, 2020

This PR combines #2067 and #2068 into a single branch to support building the collections artwork filter container as outlined in FX-1474

Includes:

With Feature Flag Enabled (Modal Visible)
Kapture 2020-02-06 at 17 52 01

With Feature Flag Disabled (Modal Not Visible)
Kapture 2020-02-06 at 17 57 46

@ashleyjelks ashleyjelks self-assigned this Feb 3, 2020
@ashleyjelks ashleyjelks changed the title Collections filter [WIP] Collections Artwork Filter Feb 3, 2020
@ashleyjelks ashleyjelks changed the title [WIP] Collections Artwork Filter [WIP] Collections Artwork Filter Container Feb 5, 2020
@ashleyjelks ashleyjelks force-pushed the collections-filter branch 2 times, most recently from 89fac70 to a8d5cb4 Compare February 6, 2020 23:01
@ashleyjelks ashleyjelks assigned sweir27 and unassigned ashleyjelks Feb 6, 2020
@ashleyjelks ashleyjelks requested review from brainbicycle and removed request for sweir27 February 6, 2020 23:08
@ashleyjelks ashleyjelks marked this pull request as ready for review February 6, 2020 23:08
@ashleyjelks ashleyjelks changed the title [WIP] Collections Artwork Filter Container Collections Artwork Filter Container Feb 6, 2020
Copy link
Contributor

@pepopowitz pepopowitz left a comment

Choose a reason for hiding this comment

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

I have several questions, but this is really great work. 💪


import { FilterModal } from "lib/Components/FilterModal"

it("looks like expected", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple more-specific tests would be valuable for this component. Things like...

  • It only renders when the visible prop is true
  • It can be closed

default:
return null
}
}
onViewableItemsChanged = ({ viewableItems }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

There's kind of a lot going on in this function, and I don't really know what it all is doing. It's possible that this is a common pattern in Emission and I just don't have experience with it, but if that's not the case, is there anything we could do to make it more clear?

Copy link
Contributor Author

@ashleyjelks ashleyjelks Feb 10, 2020

Choose a reason for hiding this comment

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

Hmm, I don't think the objective is to always have code be pretty clear. The function takes an array of all objects that are currently in the viewport and updates the state if the conditionally rendered component we are looking to show/hide is/is not on the screen. I'm happy to add some comments for added clarity. Would you be interested in pairing on a re-factor?

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually feel the opposite - the main point of code review, IMO, is to make sure the code is clear enough that anyone without context can understand when they come across it in a few months.

I'm definitely up for pairing to refactor!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Woops! DEFINITELY a typo, I meant I think the objective is to always have code be pretty clear. This is what I get for multitasking!

@ashleyjelks ashleyjelks force-pushed the collections-filter branch 2 times, most recently from 55d0818 to 4e988f1 Compare February 10, 2020 17:00
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.

Will echo some of Steve's comments! But this is looking awesome!

/*
https://app.zeplin.io/project/5aabc5e0786bbb29b6e3dc7f/screen/5dba03df09bf3f5547162ac9

Next steps:
Copy link
Contributor

Choose a reason for hiding this comment

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

#minor but given we've tasked these out in Jira I don't think you need to commit these "Next Steps" comments into code!

@ashleyjelks ashleyjelks force-pushed the collections-filter branch 2 times, most recently from 8702ca3 to 1df5e3f Compare February 11, 2020 17:57
Copy link
Contributor

@pepopowitz pepopowitz left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for digging into the test coverage.

default:
return null
}
}
onViewableItemsChanged = ({ viewableItems }) => {
;(viewableItems || []).map(viewableItem => {
const artworksRenderItem = viewableItem?.item?.type || ""
Copy link
Contributor

Choose a reason for hiding this comment

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

A #minor comment (feel free to punt until a later PR!) but the variable naming here is a little bit confusing (artworksRenderItem feels a little too specific given we may or may not be handling the artwork filter).

Something like

const itemType = viewableItem?.item?.type || ""
const itemIsVisible = viewableItem?.isViewable || false

if (itemType === "collectionsArtworks" && itemIsVisible)..

could be clearer!

@sweir27
Copy link
Contributor

sweir27 commented Feb 11, 2020

Nice work!!!

@sweir27 sweir27 merged commit ba9d3cb into master Feb 11, 2020
@sweir27 sweir27 deleted the collections-filter branch February 11, 2020 21:00
@artsyit
Copy link
Collaborator

artsyit commented Feb 11, 2020

🚀 PR was released in v1.21.44 🚀

Copy link
Member

@anandaroop anandaroop left a comment

Choose a reason for hiding this comment

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

Thanks for setting this up! I finally got a chance to fully read through this.

Looks great, though I did notice a couple of quirks around how we invoke setState — something to revisit next time we're in here.

width: 100%;
background-color: white;
height: ${({ visible }) => (visible ? "auto" : "0")};
padding: ${({ visible }) => (visible ? "20px" : "0")};
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for the padding to differ depending on the visibility state?

<ModalInnerView visible={this.state.isComponentMounted}>
<Flex flexDirection="row" justifyContent="space-between">
<Flex alignItems="flex-end" mt={0.5} mb={2}>
<Box onTouchStart={() => this.closeModal()}>
Copy link
Member

Choose a reason for hiding this comment

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

#minor could just be

<Box onTouchStart={this.closeModal}>

since the function is simply being executed without any args.

Comment on lines +89 to +92
return this.setState(_prevState => ({ isArtworkGridVisible: true }))
}

return this.setState(_prevState => ({ isArtworkGridVisible: false }))
Copy link
Member

Choose a reason for hiding this comment

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

These setState calls seem to be unnecessarily using an updater function (the previous state stored in _prevState is not being used here.)

On the other hand... (see next comment)

})
}
handleFilterArtworksModal() {
this.setState({ isFilterArtworksModalVisible: !this.state.isFilterArtworksModalVisible })
Copy link
Member

Choose a reason for hiding this comment

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

...This call actually would require the updater function, since the new state does depend on previous state.

So I'd change this as follows:

this.setState((prevState) => ({ isFilterArtworksModalVisible: !prevState.isFilterArtworksModalVisible }))

This fuller explanation from the React docs might help! See the State Updates May Be Asynchronous section under https://reactjs.org/docs/state-and-lifecycle.html

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.

6 participants