-
Notifications
You must be signed in to change notification settings - Fork 683
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
Swatch Treatments #1512
Swatch Treatments #1512
Conversation
|
* Converted item component to stateless. * Converted items component to stateless. * Converted list component to stateless. * Removing variable name shortcuts. * useMemo syntax changes. * updateSelection return value change. * Moved functional logic into custom useListState hook. * Syntax change. * Creating handlers only when key changes. * Using const instead of function. * Importing useMemo. * Prettier changes. * Memoizing handleSelectionChange function. * Moving hooks out of loops. * Prettier changes. * Added onSelectionChange to useEffect deps array. * Minor changes. * Implemented onClick and onFocus functions. * Added uniqueID to props to be removed from DOM. * Removing uniqueID from custom props. * Moving useListState custom hook to separate file. * Added jsdocs to useListState custom hook. * Minor change. * Refactored items.spec.js * Refactored list.spec.js * Revert "List component refactor." * fixed eslint issues
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.
Leaving you some initial feedback. Please fix the tests as well.
Also I'm out of office next week so someone else on the team will need to pick up the review.
* fixed eslint issues * prettier and tests corrected
options component made as function component and test updated
This pull request is automatically deployed with Now. Latest deployment for this branch: https://pwa-studio-git-fork-dani97-feature-1390-update-swatc-538576.mmansoor.now.sh |
…1390-update-swatch-treatments
…ni97/pwa-studio into feature/1390-update-swatch-treatments
@jimbo As per @sirugh comment I refactored options component into function component but I could not fix tests |
@dani97 Thanks for taking this on. Those tooltips were bothering me for a long time! 😅 I've updated the tests for you; have a look and let me know if you have any questions. Make sure to use I also made some minor changes to the |
const optionType = getOptionType({ attribute_code, values }); | ||
|
||
return optionType === 'swatch' ? SwatchList : TileList; | ||
}; |
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.
Note that I extracted this function from the component body. If it can exist statically, it should.
]); | ||
|
||
const valuesMap = useMemo(() => { | ||
return new Map( |
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.
Good use of useMemo
here. 👍
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. Credits to @sirugh. Now I have got understanding of useMemo hook :)
selection => { | ||
const [selectedValue] = Array.from(selection); | ||
|
||
setSelection(valuesMap.get(selectedValue)); |
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.
Note that we're now storing the selected label in state, rather than the set of indices.
I made changes, need a different reviewer to lookie.
…e-swatch-treatments
ba8d8a1
to
2b03d65
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.
@sirugh Thanks for taking this one across the finish line. 👍
Thanks @sirugh . I couldn't contribute for over a month. I hope I will join you soon :) |
Description
Update Swatch Treatments.
Related Issue
Closes #1390 .
Verification Steps
Screenshots / Screen Captures (if appropriate)
Proposed Labels for Change Type/Package
Checklist: