This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use product components as internal dependencies
- Loading branch information
1 parent
855d828
commit 4ea2400
Showing
10 changed files
with
147 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
assets/js/blocks/cart/cart-cross-sells-product-list/cart-cross-sells-item.tsx
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
assets/js/blocks/cart/cart-cross-sells-product-list/cart-cross-sells-product.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { | ||
InnerBlockLayoutContextProvider, | ||
ProductDataContextProvider, | ||
useProductDataContext, | ||
} from '@woocommerce/shared-context'; | ||
import { ProductResponseItem } from '@woocommerce/type-defs/product-response'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { Block as ProductImage } from '../../../atomic/blocks/product-elements/image/block'; | ||
import { Block as ProductName } from '../../../atomic/blocks/product-elements/title/block'; | ||
import { Block as ProductRating } from '../../../atomic/blocks/product-elements/rating/block'; | ||
import { Block as ProductSaleBadge } from '../../../atomic/blocks/product-elements/sale-badge/block'; | ||
import { Block as ProductPrice } from '../../../atomic/blocks/product-elements/price/block'; | ||
import { AddToCartButton } from '../../../atomic/blocks/product-elements/add-to-cart/shared'; | ||
|
||
interface CrossSellsProducProps { | ||
crossSellsProduct: ProductResponseItem; | ||
isLoading: boolean; | ||
} | ||
|
||
const CartCrossSellsProduct = ( { | ||
crossSellsProduct, | ||
isLoading, | ||
}: CrossSellsProducProps ): JSX.Element => { | ||
const { product } = useProductDataContext(); | ||
const { permalink } = product; | ||
|
||
return ( | ||
<div> | ||
<InnerBlockLayoutContextProvider | ||
parentName={ 'woocommerce/cart-cross-sells-block' } | ||
parentClassName={ 'wp-block-cart-cross-sells-product' } | ||
> | ||
<ProductDataContextProvider | ||
product={ crossSellsProduct } | ||
isLoading={ isLoading } | ||
> | ||
<a href={ permalink }> | ||
<ProductImage /> | ||
<ProductName /> | ||
<ProductRating /> | ||
<ProductSaleBadge product={ product } /> | ||
<ProductPrice /> | ||
</a> | ||
<AddToCartButton /> | ||
</ProductDataContextProvider> | ||
</InnerBlockLayoutContextProvider> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CartCrossSellsProduct; |
19 changes: 10 additions & 9 deletions
19
assets/js/blocks/cart/cart-cross-sells-product-list/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 34 additions & 29 deletions
63
assets/js/blocks/cart/inner-blocks/cart-cross-sells-products/editor.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,41 @@ | ||
.wp-block-woocommerce-cart-cross-sells-products-block { | ||
display: flex; | ||
flex-wrap: wrap; | ||
display: flex; | ||
flex-wrap: wrap; | ||
|
||
div { | ||
flex: 0 0 30%; | ||
list-style: none; | ||
padding-right: 5%; | ||
text-align: center; | ||
>div { | ||
flex: 0 0 30%; | ||
list-style: none; | ||
padding-right: 5%; | ||
text-align: center; | ||
|
||
&:nth-child(3n + 3) { | ||
padding-right: 0%; | ||
} | ||
&:nth-child(3n + 3) { | ||
padding-right: 0%; | ||
} | ||
|
||
a { | ||
display: block; | ||
color: unset; | ||
a { | ||
display: block; | ||
color: unset; | ||
|
||
.wc-block-components-product-name { | ||
font-weight: 600; | ||
} | ||
} | ||
.wc-block-components-product-name { | ||
font-weight: 400; | ||
} | ||
|
||
.wc-block-components-product-add-to-cart-button:not(.is-link) { | ||
background-color: #eeeeee; | ||
color: #333333; | ||
margin-top: 1em; | ||
.wc-block-components-product-price { | ||
display: block; | ||
} | ||
} | ||
|
||
&:focus, &:hover { | ||
background-color: #d5d5d5; | ||
border-color: #d5d5d5; | ||
color: #333333; | ||
} | ||
} | ||
} | ||
} | ||
.wc-block-components-product-add-to-cart-button:not(.is-link) { | ||
background-color: #eee; | ||
color: #333; | ||
margin-top: 1em; | ||
|
||
&:focus, | ||
&:hover { | ||
background-color: #d5d5d5; | ||
border-color: #d5d5d5; | ||
color: #333; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.