-
Notifications
You must be signed in to change notification settings - Fork 78
Conversation
f8aee31
to
6701c9d
Compare
6701c9d
to
a972e06
Compare
89fac70
to
a8d5cb4
Compare
0465149
to
900549f
Compare
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 have several questions, but this is really great work. 💪
|
||
import { FilterModal } from "lib/Components/FilterModal" | ||
|
||
it("looks like expected", () => { |
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.
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 }) => { |
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.
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?
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.
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?
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 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!
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.
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!
55d0818
to
4e988f1
Compare
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.
Will echo some of Steve's comments! But this is looking awesome!
src/lib/Components/FilterModal.tsx
Outdated
/* | ||
https://app.zeplin.io/project/5aabc5e0786bbb29b6e3dc7f/screen/5dba03df09bf3f5547162ac9 | ||
|
||
Next steps: |
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.
#minor but given we've tasked these out in Jira I don't think you need to commit these "Next Steps" comments into code!
8702ca3
to
1df5e3f
Compare
1df5e3f
to
bbea0cb
Compare
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 great! Thanks for digging into the test coverage.
default: | ||
return null | ||
} | ||
} | ||
onViewableItemsChanged = ({ viewableItems }) => { | ||
;(viewableItems || []).map(viewableItem => { | ||
const artworksRenderItem = viewableItem?.item?.type || "" |
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.
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!
Nice work!!! |
🚀 PR was released in v1.21.44 🚀 |
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.
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")}; |
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.
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()}> |
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.
#minor could just be
<Box onTouchStart={this.closeModal}>
since the function is simply being executed without any args.
return this.setState(_prevState => ({ isArtworkGridVisible: true })) | ||
} | ||
|
||
return this.setState(_prevState => ({ isArtworkGridVisible: false })) |
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.
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 }) |
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.
...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
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)

With Feature Flag Disabled (Modal Not Visible)
