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

Swatch Treatments #1512

Merged

Conversation

dani97
Copy link
Contributor

@dani97 dani97 commented Aug 1, 2019

Description

Update Swatch Treatments.

Related Issue

Closes #1390 .

Verification Steps

  1. Go to the configurable PDP.
  2. Verify the tool-tips not shown when selecting the options and new treatment comes.
  3. Make sure the same working in cart.

Screenshots / Screen Captures (if appropriate)

image

Proposed Labels for Change Type/Package

  • major (e.g x.0.0 - a breaking change)
  • minor (e.g 0.x.0 - a backwards compatible addition)
  • patch (e.g 0.0.x - a bug fix)

Checklist:

  • I have updated the documentation accordingly, if necessary.
  • I have added tests to cover my changes, if necessary.

@PWAStudioBot
Copy link
Contributor

PWAStudioBot commented Aug 1, 2019

Messages
📖

Access a deployed version of this PR here. Make sure to wait for the "pwa-pull-request-deploy" job to complete.

📖 DangerCI Failures related to missing labels/description/linked issues/etc will persist until the next push or next nightly build run (assuming they are fixed).

Generated by 🚫 dangerJS against 19c398c

* 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
sirugh
sirugh previously requested changes Aug 2, 2019
Copy link
Contributor

@sirugh sirugh left a 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
@vercel
Copy link

vercel bot commented Aug 7, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://pwa-studio-git-fork-dani97-feature-1390-update-swatc-538576.mmansoor.now.sh

@PWAStudioBot PWAStudioBot added pkg:babel-preset-peregrine pkg:graphql-cli-validate-magento-pwa-queries pkg:peregrine pkg:pwa-buildpack pkg:upward-js Pertains to upward-js reference implementation of UPWARD. pkg:upward-spec Pertains to UPWARD specification package. labels Aug 7, 2019
@dani97
Copy link
Contributor Author

dani97 commented Aug 7, 2019

@jimbo As per @sirugh comment I refactored options component into function component but I could not fix tests
1 ) does not call onSelectionChange if not provided
2 ) calls onSelectionChange function with optionId and selection
These two tests get options instance and call handleSelectionChange method.
Since I refactored it into function component, I cannot access the instance in test. Please advise on this.

@dani97 dani97 marked this pull request as ready for review August 7, 2019 14:46
@jimbo
Copy link
Contributor

jimbo commented Aug 7, 2019

@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 createTestInstance from Peregrine, and use the Test Renderer docs to work with the returned instance.

I also made some minor changes to the Option component. In general, it's better to not keep the selection set in multiple components' state, so I swapped selection to be the derived state (the label of the selected option). Should simplify things a bit.

const optionType = getOptionType({ attribute_code, values });

return optionType === 'swatch' ? SwatchList : TileList;
};
Copy link
Contributor

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(
Copy link
Contributor

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. 👍

Copy link
Contributor Author

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));
Copy link
Contributor

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.

@sirugh sirugh removed their assignment Aug 26, 2019
@sirugh sirugh dismissed their stale review August 26, 2019 15:50

I made changes, need a different reviewer to lookie.

@sirugh sirugh added the version: Minor This changeset includes functionality added in a backwards compatible manner. label Sep 18, 2019
@awilcoxa awilcoxa added Progress: good first issue Good for newcomers and removed Progress: good first issue Good for newcomers labels Sep 19, 2019
@sirugh sirugh self-assigned this Sep 20, 2019
@sirugh sirugh force-pushed the feature/1390-update-swatch-treatments branch from ba8d8a1 to 2b03d65 Compare September 23, 2019 14:24
Copy link
Contributor

@jimbo jimbo left a 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. 👍

@dpatil-magento dpatil-magento merged commit 9d25740 into magento:develop Sep 23, 2019
@dani97
Copy link
Contributor Author

dani97 commented Sep 23, 2019

Thanks @sirugh . I couldn't contribute for over a month. I hope I will join you soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:venia-ui version: Minor This changeset includes functionality added in a backwards compatible manner.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature]: Update Swatch Treatments
8 participants