-
Notifications
You must be signed in to change notification settings - Fork 115
refactor!: create renderers for each product type #1014
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
refactor!: create renderers for each product type #1014
Conversation
858a7ee to
e740db5
Compare
sethidden
left a comment
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.
Given you've mentioned you still want to work on this in future iterations, don't you want to make a separate feature branch? I'm reluctant to merge this to develop directly because of all the duplication in template duplication between product variants
(not requesting changes or approving for now)
| }, | ||
| props: { | ||
| product: { | ||
| type: [Object, null] as PropType<Product>, |
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.
| type: [Object, null] as PropType<Product>, | |
| type: [Object, null] as PropType<Product | null>, |
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.
Fixed.
| import { useImage } from '~/composables'; | ||
| import { Product } from '~/modules/catalog/product/types'; | ||
|
|
||
| export function useGallery(product: Product) { |
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.
| export function useGallery(product: Product) { | |
| export function useGallery(product: Ref<Product>) { |
Is this reactive? I remember when I was creating useProductsWithCommonCardProps.ts I needed to pass a ref through the argument, not a regular value
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 don't understand ;) this is MY NEW composable ;) Param is not a ref but the output is a computed value (at least partially).
packages/theme/modules/catalog/product/components/types/bundle/BundleProduct.vue
Show resolved
Hide resolved
packages/theme/modules/catalog/product/components/tabs/ProductTabs.vue
Outdated
Show resolved
Hide resolved
packages/theme/modules/catalog/product/components/tabs/ProductTabs.vue
Outdated
Show resolved
Hide resolved
| @@ -0,0 +1,189 @@ | |||
| .product { | |||
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 assume this is going to be broken down later but it's pretty scary that all the product variant components use the same styles. Like, if I change one thing I'd be scared of the collateral damage leaking into other components.
But as I said, I assume you're going to be extracting certain shared things to separate components
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.
Do you suggest that I should move it back to components? Or maybe add style file for each group?
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.
Do you suggest that I should move it back to components?
I mean move it to even more deeply nested components, so the component tree would look like
product.vue > BundledProduct.vue > ProductReviews.vue
product.vue > ConfigurableProduct.vue > ProductReviews.vue
etc.
for more strict encapsulation in a component instead of sharing styles
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.
Ok, I will create a task for that too.
7c05a84 to
af40762
Compare
- split root product page into a separate components - move styles to shared file - reduce the amount of unused code in different component types - add useGallery composable - add useProductTabs composable - add canAddToCart method on useCart composable
af40762 to
9080c1e
Compare
Description
Currently, we are handling logic for any type of product directly inside the page component which is messy, hard to maintain, modify and understand. Because each product in Magento has its own features, we should add dedicated renderers with dedicated logic
refactor: create renderers for each product type
- split root product page into a separate components
- move styles to shared file
- reduce the amount of unused code in different component types
- add useGallery composable
- add useProductTabs composable
- add canAddToCart method on useCart composable
Related Issue
#804
Motivation and Context
Improvement
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: