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

Style selector basic functionality #76

Merged
merged 22 commits into from May 25, 2022
Merged

Style selector basic functionality #76

merged 22 commits into from May 25, 2022

Conversation

slargman
Copy link
Contributor

@slargman slargman commented May 23, 2022

Red: StyleSelector

  • Adds the basic functionality for the style selector component.
  • Allows clicking on a style to switch selected styles, which will populate its information into the product information.
    • Later this will also affect the AddToCart and ImageGallery components.

Screen Shot 2022-05-24 at 5 30 33 PM

  • Blue: ProductInformation
  • Red: StyleSelector <-- (this PR is for this component)
  • Green: AddToCart
  • Yellow: ImageGallery
  • Purple: ProductDetail (this may go in ProductInformation ultimately)

Relevant to:

@slargman slargman changed the title Style selector Style selector basic functionality May 23, 2022
@slargman slargman added this to the Sprint 2 milestone May 23, 2022
@slargman slargman added this to In progress in Serum board via automation May 23, 2022
@slargman slargman added this to In progress in Overview via automation May 23, 2022
@slargman slargman added the implementation task Individual implementation tasks have to be amply do-able, including dev-testing, in a single day. label May 23, 2022
@slargman slargman marked this pull request as draft May 23, 2022 16:15
@slargman slargman marked this pull request as ready for review May 24, 2022 22:37
@slargman slargman requested review from zman811 and rlargman May 24, 2022 23:47
Copy link
Collaborator

@rlargman rlargman left a comment

Choose a reason for hiding this comment

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

Having a hard time understanding what this is going to be used for. Screenshots / screen caps could be helpful


return (
<div>
{ stylesArray }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Put this directly in here for easier readability. But seems this component is maybe not even needed as it's essentially a map function over the <Style> component. Is this <StyleSelector> going into a lot of places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, StyleSelector is only used once. I did it like this to try to compartmentalize things and keep Overview simple by just including StyleSelector. Would you recommend replacing <StyleSelector /> by the map in Overview?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I realize now that's not even what I'm doing. Taking your other comment into account, I'll move <StyleSelector /> to <Overview />.

{/*TODO: show Product Overview*/}
{/*TODO: add Share buttons*/}
{selectedStyle?.original_price}
{selectedStyle?.sale_price !== 0 ? selectedStyle?.sale_price : null}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems this is specific to one product, so maybe <StyleSelector> shouldn't be inside of it. Would help with not having to pass down so many props to so many descendants


setProduct(productResponse.data);
setStyles(sortedStyles);
setSelectedStyleId(sortedStyles.find((style) => style['default?']).style_id);
setSelectedStyleId(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@slargman slargman May 25, 2022

Choose a reason for hiding this comment

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

Does this provide an advantage over useEffect without subscribers? I also need to set product and styles from data that I pull from an API. But the data is fetched only on the initial render since the subscribers array is empty. I'm now realizing that the useEffect hook should run when productId changes though, since the data should be refetched whenever a new product is being displayed.

@slargman
Copy link
Contributor Author

slargman commented May 25, 2022

Having a hard time understanding what this is going to be used for. Screenshots / screen caps could be helpful

Sorry, should've explained this better.

Overall this is what my Overview component should look like:
Screen Shot 2022-05-24 at 5 30 33 PM

  • Blue: ProductInformation
  • Red: StyleSelector <--(this PR is for this component)
  • Green: AddToCart
  • Yellow: ImageGallery
  • Purple: ProductDetail (this may go in ProductInformation ultimately)

There are issues that describe the specific functionality that the components and their subcomponents should have. I'll link the StyleSelector issue if you want to look at the details.

@slargman
Copy link
Contributor Author

Actually I don't want to close those issues yet, since they're still works in progress, but I'll link the relevant issues in the top message of the PR.

Copy link
Contributor

@zman811 zman811 left a comment

Choose a reason for hiding this comment

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

Looks good, looks like you have some other changes you are making as well so ill check back in later today or tmrw. Great job with the tests also


function StyleSelector({ styles, selectedStyleId, handleStyleSelect }) {
// TODO: use color-thief to extract average color of thumbnails server-side
const stylesArray = styles.map((style) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just directly return this and skip setting to a var then calling it later

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 good point. I think I had separated it in case I had more complicated logic in the return statement, but that ended up not being the case.

@slargman slargman requested review from rlargman and zman811 May 25, 2022 02:02
Copy link
Contributor

@zman811 zman811 left a comment

Choose a reason for hiding this comment

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

Looks good great job

Serum board automation moved this from In progress to Ready for production deploy May 25, 2022
Overview automation moved this from In progress to Reviewer approved May 25, 2022
@slargman slargman merged commit 0b0b80b into main May 25, 2022
@slargman slargman deleted the style-selector branch May 25, 2022 17:51
Serum board automation moved this from Ready for production deploy to Deployed to production May 25, 2022
Overview automation moved this from Reviewer approved to Done May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
implementation task Individual implementation tasks have to be amply do-able, including dev-testing, in a single day.
Projects
Serum board
Deployed to production
Development

Successfully merging this pull request may close these issues.

None yet

3 participants