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
⚛️ Introduce Product Element Blocks #2871
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8c839c9
Product selection when out of context for price and title blocks
mikejolley 6a33842
Move product element name/description/icons to constant files
mikejolley 9376973
Add attributes and hocs to all elements
mikejolley b0ab7d7
Standalone block rendering
mikejolley 4250935
Add a placeholder if title has no content
mikejolley 9095f53
Revert "Add a placeholder if title has no content"
mikejolley 29a0e68
parentClassName is not always present
mikejolley 33999db
Loading state
mikejolley c4b5575
Wrap description in P
mikejolley d807527
Fixed loading styles when nested
mikejolley 57406c6
Maintain product shape in useProductData
mikejolley a1bf1d1
feature gate elements from showing in inserter
senadir d437aae
fix feature flag
senadir 0889ede
include price PR
senadir 9690f63
edit withProductSelector to be a hoc
senadir 53f906d
fix lint issue
senadir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import './product/title'; | ||
import './product/price'; | ||
import './product/image'; | ||
import './product/rating'; | ||
import './product/button'; | ||
import './product/summary'; | ||
import './product/sale-badge'; | ||
import './product/sku'; | ||
import './product/category-list'; | ||
import './product/tag-list'; | ||
import './product/stock-indicator'; | ||
import './product/add-to-cart'; | ||
import './product-elements/title'; | ||
import './product-elements/price'; | ||
import './product-elements/image'; | ||
import './product-elements/rating'; | ||
import './product-elements/button'; | ||
import './product-elements/summary'; | ||
import './product-elements/sale-badge'; | ||
import './product-elements/sku'; | ||
import './product-elements/category-list'; | ||
import './product-elements/tag-list'; | ||
import './product-elements/stock-indicator'; | ||
import './product-elements/add-to-cart'; |
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
12 changes: 12 additions & 0 deletions
12
assets/js/atomic/blocks/product-elements/add-to-cart/constants.js
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,12 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { cart, Icon } from '@woocommerce/icons'; | ||
|
||
export const BLOCK_TITLE = __( 'Add to Cart', 'woo-gutenberg-products-block' ); | ||
export const BLOCK_ICON = <Icon srcElement={ cart } />; | ||
export const BLOCK_DESCRIPTION = __( | ||
'Displays an add to cart button. Optionally displays other add to cart form elements.', | ||
'woo-gutenberg-products-block' | ||
); |
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
File renamed without changes.
32 changes: 32 additions & 0 deletions
32
assets/js/atomic/blocks/product-elements/add-to-cart/index.js
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,32 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { registerExperimentalBlockType } from '@woocommerce/block-settings'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import sharedConfig from '../shared/config'; | ||
import edit from './edit'; | ||
import attributes from './attributes'; | ||
import { | ||
BLOCK_TITLE as title, | ||
BLOCK_ICON as icon, | ||
BLOCK_DESCRIPTION as description, | ||
} from './constants'; | ||
|
||
const blockConfig = { | ||
title, | ||
description, | ||
icon: { | ||
src: icon, | ||
foreground: '#874FB9', | ||
}, | ||
edit, | ||
attributes, | ||
}; | ||
|
||
registerExperimentalBlockType( 'woocommerce/product-add-to-cart', { | ||
...sharedConfig, | ||
...blockConfig, | ||
} ); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions
43
assets/js/atomic/blocks/product-elements/add-to-cart/style.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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.wc-block-components-product-add-to-cart { | ||
margin: 0; | ||
display: flex; | ||
flex-wrap: wrap; | ||
|
||
.wc-block-components-product-add-to-cart-button { | ||
margin: 0 0 em($gap-small) 0; | ||
|
||
.wc-block-components-button__text { | ||
display: block; | ||
|
||
> svg { | ||
fill: currentColor; | ||
vertical-align: top; | ||
width: 1.5em; | ||
height: 1.5em; | ||
margin: -0.25em 0 -0.25em 0.5em; | ||
} | ||
} | ||
} | ||
|
||
.wc-block-components-product-add-to-cart-quantity { | ||
margin: 0 1em em($gap-small) 0; | ||
width: 5em; | ||
padding: 0.618em; | ||
background: $white; | ||
border: 1px solid #ccc; | ||
border-radius: 2px; | ||
color: #43454b; | ||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.125); | ||
text-align: center; | ||
} | ||
} | ||
.wc-block-components-product-add-to-cart--placeholder { | ||
.wc-block-components-product-add-to-cart-quantity, | ||
.wc-block-components-product-add-to-cart-button { | ||
@include placeholder(); | ||
} | ||
} | ||
|
||
.wc-block-grid .wc-block-components-product-add-to-cart { | ||
justify-content: center; | ||
} |
8 changes: 8 additions & 0 deletions
8
assets/js/atomic/blocks/product-elements/button/attributes.js
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,8 @@ | ||
export const blockAttributes = { | ||
productId: { | ||
type: 'number', | ||
default: 0, | ||
}, | ||
}; | ||
|
||
export default blockAttributes; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 see we switched to the new purple?
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.
It was this way in the mocks. Should we keep old purple? Only affects new elements.
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.
We might as well migrate all of our blocks then?
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.
This is probably best answered by @nerrad or @LevinMedia, but shouldn't be blocking as it's a minor thing.