vtex-apps / product-summary

VTEX Product Summary app
11 stars 52 forks source link

added new prop "target" to ProductSummaryCustom #341

Closed Lorenzo-Ienzi closed 2 years ago

Lorenzo-Ienzi commented 2 years ago

What problem is this solving?

The "product-summary.shelf" block cards when clicked only allows to open the link inside the same browser tab. Adding the prop "target" is possible to open the link inside a new tab.

How to test it?

By clicking on the add to cart button a modal with the block "product-summary.shelf" will appear.

Workspace

Screenshots or example usage:

Inside the page, click on this button: image This will open the modal: image when the cards are clicked, a new tab will be opened.

Describe alternatives you've considered, if any.

Related to / Depends on

How does this PR make you feel? :link:

![](put .gif link here - can be found under "advanced" on giphy)

vtex-io-ci-cd[bot] commented 2 years ago

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

vtex-io-docs-bot[bot] commented 2 years ago

Beep boop :robot:

I noticed you didn't make any changes at the docs/ folder

In order to keep track, I'll create an issue if you decide now is not a good time

Lorenzo-Ienzi commented 2 years ago
miguel-carrera commented 2 years ago
  • Version to release: Minor (backwards-compatible functionality);
  • Nothing changed in the CHANGELOG.md file.

@Lorenzo-Ienzi you need to a description for the change made in the CHANGELOG.md file If the description is not included there, the team will not review check this PR.

Lorenzo-Ienzi commented 2 years ago

@igorbrasileiro @victorhmp Thanks for your help. Actually I didn't change the target prop type into "Link['target']" since it gives me errors.

igorbrasileiro commented 2 years ago

Actually I didn't change the target prop type into "Link['target']" since it gives me errors.

Which kind of error? Can you fix it? The Link['target'] types string | undefined is the same added by this PR.

Lorenzo-Ienzi commented 2 years ago

@igorbrasileiro Here's the error: image Online solutions to this generic error suggest to rename the file into .tsx , but it's already .tsx . Do you have suggestions? Also tried with typeof, but another error pops up.

miguel-carrera commented 2 years ago

@igorbrasileiro do you know the cause of the error that @Lorenzo-Ienzi is receiving? Thanks

igorbrasileiro commented 2 years ago

@igorbrasileiro Here's the error: image Online solutions to this generic error suggest to rename the file into .tsx , but it's already .tsx . Do you have suggestions? Also tried with typeof, but another error pops up.

Yeah, @Lorenzo-Ienzi , the typescript is right. typeof Link probably is a function (props: Props) => ReactElement | AnchorHTMLElement. React returns interfaces called ComponentPropsWithRef and ComponentPropsWithoutRef, and those return the component props. Knowing this you can do something like that:

interface Props extends Pick<ComponentPropsWithoutRef<typeof Link>, 'target'> {
 // ... other properties
}

There are other ways to achieve the same behavior. For more info: https://codesandbox.io/s/typescript-forked-l7mwg?file=/src/Link.tsx

igorbrasileiro commented 2 years ago

closing this PR due to a lack of responses. If needed can be reopen