Commit Graph

588 Commits

Author SHA1 Message Date
Albert Juhé Lluveras 5698e123d3 Fix Price Filter block if minPrice or maxPrice are null (https://github.com/woocommerce/woocommerce-blocks/pull/1278) 2019-11-29 15:28:14 +01:00
Jeff Stieler fb8a21ba81 Add getAdminLink() to shared settings export. (https://github.com/woocommerce/woocommerce-blocks/pull/1244)
* Add getAdminLink() to shared settings export.

* Import getAdminLink from @woocommerce/settings

* Uninstall @woocommerce/navigation
2019-11-28 17:33:29 +01:00
Albert Juhé Lluveras ed4e4ad7b9 Use attribute label instead of slug in Filter by Attribute title (https://github.com/woocommerce/woocommerce-blocks/pull/1271) 2019-11-27 14:29:28 +01:00
Albert Juhé Lluveras ec4ae1269d Filter by Attribute: Allow reselecting unselected attribute (https://github.com/woocommerce/woocommerce-blocks/pull/1264)
* Filter by Attribute: Allow reselecting unselected attribute

* Run prettier
2019-11-26 17:43:27 +01:00
Seghir Nadir e8f0a071ba Fix bug with cart not updating (https://github.com/woocommerce/woocommerce-blocks/pull/1258)
* fix bug with add to cart

* prettier

* migrate to Event

* prettier

* Update assets/js/atomic/components/product/button/index.js

update to fix on sequential adds

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Avoid dispatching cart update event on initial mount

* add condition to check if Event is defined
2019-11-26 11:26:53 -05:00
Seghir Nadir 998d3920c9 Fix color on pagination caused by Twenty Twenty (https://github.com/woocommerce/woocommerce-blocks/pull/1257)
* fix color on pagination caused by twentytwenty
2019-11-26 12:45:00 +01:00
Albert Juhé Lluveras ea1a31123f Fix wrong proptypes definition in BlockTitle component (https://github.com/woocommerce/woocommerce-blocks/pull/1259) 2019-11-26 12:16:28 +01:00
Rua Haszard 1ec624f2d7 Fix inconsistent heading editor styles for filter blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1256)
* override title bg to transparent in editor for filter blocks
2019-11-26 11:56:14 +01:00
Mike Jolley c55a387657 Prevent multiple collection data requests using debounce (https://github.com/woocommerce/woocommerce-blocks/pull/1233)
* Add context for collection data query

* Introduce useCollectionData hook

* Implement hook in filter blocks

* Update API to handle nuances of counts instead of client side

* Clone requests so original is untouched

* Prevent dupe requests is working

* Cleanup

* Update assets/js/base/hooks/use-collection-data.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update assets/js/base/hooks/use-collection-data.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Feedback

* Remove context
2019-11-23 17:04:30 +00:00
Mike Jolley c595444b7f Hydrate REST endpoint data in the stores (https://github.com/woocommerce/woocommerce-blocks/pull/1206)
* Helper to get namespace routes from the REST Api

* Add routes to store settings

* HydrateRestApiData component

* Correct usage of useSelect

* Remove lodash

* Move code to HOC
2019-11-23 16:29:35 +00:00
Darren Ethier 5c26249e26 don’t mutate default state constant. (https://github.com/woocommerce/woocommerce-blocks/pull/1245)
There was no need to have a const for the default state and also needed to make sure we’re not mutating it because it would result in the mutation of the default state.  This in turn meant that on the initial reducing action, the default state in the store would have a ghost value.
2019-11-22 15:18:45 -05:00
Seghir Nadir aa2e2d8f1e introduce block title component (https://github.com/woocommerce/woocommerce-blocks/pull/1240)
* introduce block title component

* style with prettier

* rename component class

* update readme
2019-11-21 18:21:14 +01:00
Mike Jolley 2f3c4623b7 Update `useQueryStateByContext` to remove need for context when setting values (https://github.com/woocommerce/woocommerce-blocks/pull/1239)
* Don't require context for set

* Update tests
2019-11-21 16:06:52 +01:00
Mike Jolley 6e2978413e level -> headingLevel (https://github.com/woocommerce/woocommerce-blocks/pull/1230) 2019-11-21 12:19:34 +00:00
Mike Jolley b96f568c2e Price Slider -- Only do instant updates if filter button is disabled (https://github.com/woocommerce/woocommerce-blocks/pull/1228)
* Only do instant updates if filter button is disabled

* Update assets/js/blocks/price-filter/block.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>
2019-11-21 11:53:08 +00:00
Albert Juhé Lluveras e3eebe89c2 Move ErrorBoundary to renderFrontend() function (https://github.com/woocommerce/woocommerce-blocks/pull/1226) 2019-11-21 09:09:14 +01:00
Albert Juhé Lluveras 4652ce1547 Honor CSS classes in editor (https://github.com/woocommerce/woocommerce-blocks/pull/1227)
* Honor CSS classes in editor

* Remove is-loading classes from editor

* Make sure we always destructure all attributes
2019-11-21 08:50:30 +01:00
Albert Juhé Lluveras 6f4a9e7782 Remove minConstraint and maxConstraint from price filter state (https://github.com/woocommerce/woocommerce-blocks/pull/1192)
* Remove minConstraint and maxConstraint from price filter state

* Remove 'useMemo' from minConstraint and maxConstraint

* Make sure minConstraint and maxConstraint are numbers before updating min/max prices

* Make sure non-valid price constraints don't make it to usePrevious

* Remove again track min/max constraint useEffect
2019-11-21 08:42:58 +01:00
Mike Jolley 0272c4472b Add no result templates (https://github.com/woocommerce/woocommerce-blocks/pull/1178)
* All Products block with filters: avoid showing loading placeholders if there are no results

* Hide sort select and show message when no products are available

* Add no result templates

* Remove product-grid

* Move images to assets dir

* Update images

* Switch functions to Components

* Capitals

* add missing context
2019-11-19 15:47:46 +00:00
Seghir Nadir bb0227edb1 Show number of reviews in each category in Reviews per Category block (https://github.com/woocommerce/woocommerce-blocks/pull/1177)
* Add reviews to Category endpoint

* add option to show categories with reviews

* update label text if we're using reviews for counting

* update reviews count to use raw sql

* add flag before querying review count

* add review_count to collection data & schema

* fix PR code review problems

* update tests to it expects the new collection param

* add note about review_count is schema
2019-11-19 16:22:16 +01:00
Albert Juhé Lluveras dceb2c6a0f All Products: avoid pagination disappearing when switching pages/changing sort value (take 2) (https://github.com/woocommerce/woocommerce-blocks/pull/1201)
* Use same query for headers collection

* All Products: avoid pagination disappearing when switching pages/changing sort value (take 2)

* Cleanup

* fixes after rebase

* Make it work after last rebase

* only do page change when queryState.page has changed.

* Fix woocommerce/woocommerce-blocks#1198 again

* Remove previousPage and isInitialized checks
2019-11-19 16:14:34 +01:00
Mike Jolley 8eec47e241 Use same query for headers collection (https://github.com/woocommerce/woocommerce-blocks/pull/1196) 2019-11-19 13:17:03 +01:00
Darren Ethier 2ca9f5eca2 Fix: Page selection will reset to 1 after deselecting filterable item, re-sorting products, and selecting new page. (https://github.com/woocommerce/woocommerce-blocks/pull/1205)
* initial commit

* change initialization state when user triggered page change
2019-11-19 06:20:23 -05:00
Darren Ethier 652aa0caa2 Fix paging issues (https://github.com/woocommerce/woocommerce-blocks/pull/1202) 2019-11-19 04:55:16 -05:00
Darren Ethier 3189a9483b Implement useProductLayoutContext for layout prefix in atomic blocks. (https://github.com/woocommerce/woocommerce-blocks/pull/1183)
* implement product layout context for product button

* convert product image component to functional component

- also implements useProductLayoutContext

* ensure edit context for AllProducts block has appropriate providers wrapping it.

* update price block with useProductLayoutContext

* convert ProductRating block to functional component and add useProductLayoutContext

* add useProductLayoutContext to ProductSummary

* update sale badge component adding useProductLayoutContext

* add useProductLayoutContext to ProductTitle component

* update ProductListItem component to add useProductLayoutContext

* update ProductList component to add useProductLayoutContext
2019-11-18 15:25:29 +01:00
Mike Jolley abd92e0c32 Filter block previews (https://github.com/woocommerce/woocommerce-blocks/pull/1184)
* Enable preview for price filter block

Using the defaults works fine, so no options required.

* Attribute preview via block attribute

* Add sample content for preview

* remove unnecessary key

* remove unneeded export
2019-11-15 16:10:49 -05:00
Darren Ethier cd3914b9a1 don’t use deprected imports (https://github.com/woocommerce/woocommerce-blocks/pull/1186) 2019-11-15 15:57:20 -05:00
Seghir Nadir 1d67ec5ce9 Add on_sale to Store API for it to work. (https://github.com/woocommerce/woocommerce-blocks/pull/1185)
* add on sale to store api

* fix onsale to on_sale

* update preview to use on_sale

* update tests to use on_sale
2019-11-15 19:11:03 +01:00
Darren Ethier b4df4e056c Enhance useCollection for conditionally returning previous results (https://github.com/woocommerce/woocommerce-blocks/pull/1182)
* add new config to `useCollection` options for controlling whether to invoke select or not.

also adds tests.

* update inline docs
2019-11-15 11:11:48 -05:00
Mike Jolley bf370806ed Add grid block previews using an SVG image (https://github.com/woocommerce/woocommerce-blocks/pull/1118)
* Implement preview for on-sale products

* Previews for other grid blocks

* Shared previews

* Fix SVG

* add svg as asset

* Add image via path

* cleanup
2019-11-15 15:16:18 +00:00
Mike Jolley d613d2fde6 Active filters block (https://github.com/woocommerce/woocommerce-blocks/pull/1168)
* Basic block construction

* Register on PHP side

* wc-active-filters script

* Price utils

* Refactor price slider so state reflects the query

Moves some logic from the component to the block so that min and max price can change (via query) and be reflected by the price sliders.

This allows the active filters block to change the query and have those new values reflected by the slider.

* Fix type checking of numbers

* Styles for filter block

* Improved attribute helper for getting attribute taxonomy data from ID/taxonomy

* Refactor attribute filter to use updateAttributeFilter helper

* Disable checkboxes when loading to avoid multiple queries

* Add todos - this is blocked

* Remove checked state from Attribute Filter so it gets updated from the store (https://github.com/woocommerce/woocommerce-blocks/pull/1170)

* isLoading check

* active price filtering rendering

* Block heading

* Implement block options; chip display with clear button

* Clear all should remove all attributes

* Enable previews

* Introduce a component to look up terms from slugs using collections (which are cached)

* Correct all docblocks

* activePriceFilters null return

* renderRemovableListItem

* Remove useMemo for hasFilters

* Switch classnames notation

* Ensure slug is array in removeAttributeFilterBySlug

* null -> undefined return types for attributes

* Remove fragment

* Check we have a termObject in ActiveAttributeFilters

* Refactor formatPriceRange return statements

* Ensure query array index will exist

* Only sort when adding a query

* Remove aria-label with dupe text

* hasFilters is function

* Update useQueryStateByKey usage

* More doc block fixes

* Update getAttributeFromTaxonomy return and docblock

* getAttributeFromID return/docblock
2019-11-15 14:41:23 +00:00
Albert Juhé Lluveras 0739e4c536 Add block error boundary to JS-rendered blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1166)
* Add block error boundary to All Products and Reviews blocks

* Add block error boundary to Price Filter and Attributes Filter blocks

* Add image

* Make block error component use props instead of hardcoded values

* Add props to BlockErrorBoundary

* Change 'text' prop to 'content'

* Add docs to proptypes

* Replace 'content' prop with 'text'
2019-11-15 15:15:55 +01:00
Darren Ethier 534d8f6fdd Add context for query state context string. (https://github.com/woocommerce/woocommerce-blocks/pull/1172)
* ensure useProductLayoutContext actually returns the context!

* add query state context and export provider and hook.

* implement useQueryStateContext in existing querySTate hooks and refactor other implementations

* add back in documentation removed in rebase

* default layout context to empty string (no need to add additional classes by default

* fix jsdoc
2019-11-14 12:16:27 -05:00
Darren Ethier 380019f489 Rename modelName to resourceName everywhere (https://github.com/woocommerce/woocommerce-blocks/pull/1173)
* rename modelName to resourceName

* fix inline doc alignment
2019-11-14 11:10:50 -05:00
Darren Ethier 7ae6d78ea5 Add context value validation for context apis that receive an object. (https://github.com/woocommerce/woocommerce-blocks/pull/1174)
* add a context value validator and tests

This handles validation incoming value prop on a context provider with an object.

* implement context validator and fix related bugs

* rename context to better match it’s purpose

* correct spelling

* Update assets/js/base/context/utils.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* tighten up the iteration
2019-11-14 09:51:32 -05:00
Mike Jolley 7e98aaf391 Set loading state when searching (https://github.com/woocommerce/woocommerce-blocks/pull/1171)
* Set loading state when searching

* Remove 2nd loading state setter

* isLargeCatalog should be 100
2019-11-14 14:40:04 +00:00
Seghir Nadir f6401a87c4 Remove h1 from atomic title (https://github.com/woocommerce/woocommerce-blocks/pull/1167)
* remove option to use H1
2019-11-14 14:26:35 +01:00
Mike Jolley a84990d10f Add editable filter widget headings (https://github.com/woocommerce/woocommerce-blocks/pull/1169)
* Move heading toolbar component so it can be resused

* Add heading to attribute block

* Add heading to price filter block

* Fix missing loading state
2019-11-13 16:15:20 +00:00
Mike Jolley f1153ccea8 Move renderFrontend to internal dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/1152) 2019-11-11 15:38:57 +00:00
Mike Jolley 8f0bef5516 Use placeholder when contraints are invalid (https://github.com/woocommerce/woocommerce-blocks/pull/1145)
* Use placeholder when contraints are invalid

* Update assets/js/base/components/price-slider/style.scss

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update assets/js/base/components/price-slider/style.scss

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Move hasValidConstraints
2019-11-11 11:05:18 +00:00
Mike Jolley c038a7fed4 Filter all products block by attribute (https://github.com/woocommerce/woocommerce-blocks/pull/1127)
* Block setup

* Working filtering and intersection of arrays

* Implement block settings and no attribute placeholder

* Correctly toggle counts

* Implement filtering

* Fix price slider constraints

* Fix price slider constraints

* Edit mode

* Rename ProductAttributeControl to ProductAttributeTermControl

* Attribute ID saving

* fix incorrect test fixtures

* fix incorrect regex for parsing model (or resource names) from the route.

* Fix query classes for some endpoints

* Style improvements

* Update inline comments

* use previous tests

* Show attribute control in sidebar

* Remove displayStyle option

* Sort attributes by name

* Show more/less toggle

* Use renderFrontend

* Only sort when adding values

* Rename memo placeholder

* More specific CSS for pointer

* Update assets/js/base/hooks/use-query-state.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Remove always true taxonomy check

* Update assets/js/blocks/attribute-filter/block.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Remove lodash join

* native js for string casting

* Move internal deps

* hyphenate attributes

* Correct data set names

* Remove unwanted dependency

* Moving imports

* Missing deps

* replace yoda conditonal

* Missing deps

* Missing deps

* Check value exists

* Remove undefined filter

* renderedOptions usememo

* Set defaults in checkbox list

* Show more/less refactor

* Use getAdminLink

* Fix object length check

* Correct AND query handling for counts

* useQueryStateByContext

* Add store rest endpoints

* Update assets/js/base/components/checkbox-list/index.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update assets/js/base/components/checkbox-list/index.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update assets/js/base/components/checkbox-list/index.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update assets/js/blocks/attribute-filter/block.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Feedback

* feedback

* API readme

* Fix API relation queries for multiple attributes

* Prevent all options flashing visible during loads

* null check

* Improve loading state

* Remove null options change - it's no longer needed
2019-11-11 10:32:56 +00:00
Albert Juhé Lluveras 2f04c61223 Update dependencies order (https://github.com/woocommerce/woocommerce-blocks/pull/1146)
* Update dependencies order

* Create eslint WooCommerce plugin with dependency group rule

* Update WCPackageLocality definition so it only includes External and Internal

* Rename WPPackageLocality to WCPackageLocality

* Delete old typedef
2019-11-08 17:30:11 +01:00
Albert Juhé Lluveras 2dbb1a0ca5 All Products: avoid pagination disappearing when switching pages/changing sort value (https://github.com/woocommerce/woocommerce-blocks/pull/1144) 2019-11-08 13:40:09 +00:00
Darren Ethier 0b61988487 Add anti yoda conditional eslint rule (https://github.com/woocommerce/woocommerce-blocks/pull/1142)
* add anti yoda rule

* apply eslint fix to all existing yoda conditional uses
2019-11-07 09:45:45 -05:00
Darren Ethier 46fceae0d7 rename useQueryState to useQueryStateByContext (https://github.com/woocommerce/woocommerce-blocks/pull/1140)
this is more precise and removes ambuiguity about whether this returns React Context or not.
2019-11-07 08:58:32 -05:00
Albert Juhé Lluveras 1bd60ebaab Use renderFrontend function to render the Price Filter block in the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/1136)
* Fix minor issues in comments

* Use renderFrontend function for price filter
2019-11-07 11:18:56 +00:00
Mike Jolley c824b481e2 Fix price slider constraints (https://github.com/woocommerce/woocommerce-blocks/pull/1125)
* Fix price slider constraints

* Update inline comments

* use previous tests
2019-11-06 13:25:37 -05:00
Darren Ethier b21efcb233 Fix incorrect parsing of routes from placeholder route strings. (https://github.com/woocommerce/woocommerce-blocks/pull/1124)
* fix incorrect test fixtures

* fix incorrect regex for parsing model (or resource names) from the route.
2019-11-05 14:55:49 +00:00
Mike Jolley f1299cf0d9 Add featured category preview (https://github.com/woocommerce/woocommerce-blocks/pull/1122) 2019-11-05 10:33:07 +00:00
Mike Jolley a1e6184bee Add previews for the category list and product search (https://github.com/woocommerce/woocommerce-blocks/pull/1123)
* Enable preview for product search block

* Enable category preview
2019-11-05 10:32:53 +00:00
Darren Ethier a7beb3b845 Followup: switch namespace on useStoreProducts hook. (https://github.com/woocommerce/woocommerce-blocks/pull/1102)
* add missing `add_to_cart` properties to product schema

Also camelcase properties.

* switch namespace to `/wc/store/`

* add experimental action for perisisting and item to a given collection

* refactor ProductButton to use hooks (initial pass)

This is just the initial refactor to figure out the logic.  I’m going to do another pass to see about extracting some of this to a custom hook (because it’s kind of gnarly to have to repeat… and it’s possible it can be simplified as well).

* add new properties to tests and ensure test is using the same product instance values as the rest request

* refactor to add custom internal only useAddToCart hook.

* fix value extraction from product object

* revert casing changes
2019-11-04 10:47:14 +00:00
Darren Ethier aca8189e51 fix bug with product title component (https://github.com/woocommerce/woocommerce-blocks/pull/1119) 2019-11-02 08:01:34 -05:00
Darren Ethier 8625e418a9 Install dompurify and use to sanitize product title for review blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1117)
* install dompurify and use to sanitize product title for reviews

* remove dompurify

* remove dompurify implementation and add jsdoc covering what data is trusted
2019-11-01 18:00:19 -05:00
Mike Jolley 83925b48e6 New block: Filter Products by Price (https://github.com/woocommerce/woocommerce-blocks/pull/853)
* Basic component setup

* Working slider

* Validation

* styling

* Update webpack config to fix ie11

* ie progress

* styling improvements

* improve events

* IE shim

* Fix samsung internet styles

* Add aria

* remove old methods

* event handling

* Tweak size and width of inputs

* reset progress

* shorthand notation for setstate

* Inline comment for textare usage

* Remove pointless comparison

* destruct from state

* zindex comment

* Move out currency settings and validation

* enforce int for min and max state

* Use woocommerce/settings

* showInputFields prop

* Filter Products by Price: Block creation (https://github.com/woocommerce/woocommerce-blocks/pull/865)

* Prevent interaction with slider

* Show input fields toggle

* Placeholder content and icons

* Update dependency rimraf to v2.7.0 (https://github.com/woocommerce/woocommerce-blocks/pull/858)

* placeholder styling

* remove unnecessary config (https://github.com/woocommerce/woocommerce-blocks/pull/862)

* Filter button and styling

* Show/hide placeholder based on product count

* Update dependency rimraf to v2.7.1 (https://github.com/woocommerce/woocommerce-blocks/pull/867)

* Use correct parameter order for implode. Solves deprecation notice in PHP 7.4 (https://github.com/woocommerce/woocommerce-blocks/pull/857)

* Add description to blocks added in last releases (https://github.com/woocommerce/woocommerce-blocks/pull/869)

* Limit max width

* Prevent wrap

* handles src file

* Introduce withCategory HOC for featured category block (https://github.com/woocommerce/woocommerce-blocks/pull/846)

* Introduce withCategory hoc

* Refactor featured category to use new hoc

* Update docblocks

* Add README note for PHP deprecation notices

* Remove screen-reader-text css rules (https://github.com/woocommerce/woocommerce-blocks/pull/849)

* Align stars left (https://github.com/woocommerce/woocommerce-blocks/pull/866)

* bool

* Create Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/658)

* Create Reviews by Product block

* Honor Content settings

* Fix wrong className

* Load new wc-packages file

* Add reviews-by-product JS files to webpack config

* Cleanup

* Remove error messages

* Add Reviews by Product icon

* Update sort options

* Allow additional CSS classes attribute

* Refactor block styles

* Fix wrong default for reviews_orderby

* Don't enforce CSS chunks

* Add reviews count to Reviews by Product controls (https://github.com/woocommerce/woocommerce-blocks/pull/671)

* Add label to Reviews by Product controls count (https://github.com/woocommerce/woocommerce-blocks/pull/677)

* Add reviews count to Reviews by Product controls

* Add label to Reviews by Product controls count

* Add label to Reviews by Product controls count

* Update components package

* Review ordering and placeholders (https://github.com/woocommerce/woocommerce-blocks/pull/688)

* Add support for comment_count ordering and add to productcontrol

* Add a placeholder if rating count is 0

* Update assets/js/components/utils/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/blocks/reviews-by-product/block.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* grammar

* Fix some linting errors and warnings (https://github.com/woocommerce/woocommerce-blocks/pull/693)

* Create Reviews by Product block placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/691)

* Create Reviews by Product block placeholder

* Reviews by Product: load and render reviews with JS (https://github.com/woocommerce/woocommerce-blocks/pull/696)

* Reviews by Product: load and render reviews with JS

* Add dangerouslySetInnerHTML explanatory comment

* Fix wrong dependency source

* Debounce getReviews call when creating the Reviews by Product block

* Rename 'Reviewer Picture' with 'Avatar' (https://github.com/woocommerce/woocommerce-blocks/pull/702)

* Lint errors

* Replace stringify query with addQueryArgs (https://github.com/woocommerce/woocommerce-blocks/pull/707)

* Add reviews endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/705)

* Prevent state updates on unmounted components (https://github.com/woocommerce/woocommerce-blocks/pull/715)

* Add Order by and Load more controls in Reviews by Product frontend (https://github.com/woocommerce/woocommerce-blocks/pull/716)

* Export IconReviewsByProduct (https://github.com/woocommerce/woocommerce-blocks/pull/721)

* Fix Reviews by Product layout in IE11 (https://github.com/woocommerce/woocommerce-blocks/pull/723)

* Set minimum to per page input field (https://github.com/woocommerce/woocommerce-blocks/pull/731)

* Hide avatars in Reviews by Products if 'show_avatars' settings is false (https://github.com/woocommerce/woocommerce-blocks/pull/730)

* Blocks API - Reviews endpoint with rating sort and category filtering (https://github.com/woocommerce/woocommerce-blocks/pull/726)

* Move file to correct location

* We are only using the reviews endpoint not revioews/id

* Remove sensistive data and make endpoint public

* Allow guest access to approved reviews

* Add support for rating sorting

* category filtering

* update arg name

* fix category query

* Reviews by Product: add placeholders when loading reviews (https://github.com/woocommerce/woocommerce-blocks/pull/732)

* Add placeholder animation (https://github.com/woocommerce/woocommerce-blocks/pull/733)

* Hook up Reviews by Product 'Order by' with endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/736)

* Hook up Reviews by Product 'Order by' with endpoint

* Use onChange instead of onBlur in select control

* Reviews by Product: Hide ratings if they are disabled in settings (https://github.com/woocommerce/woocommerce-blocks/pull/740)

* Hide ratings in Reviews by Product if disabled in settings

* Hide order by select if ratings are disabled

* Reviews by Product cleanup (https://github.com/woocommerce/woocommerce-blocks/pull/773)

* Fix wrong method name

* Reduce the number of dependencies used in Reviews by Product (https://github.com/woocommerce/woocommerce-blocks/pull/774)

* Reduce the number of dependencies used in Reviews by Product

* Use 'withComponentId' HOC

* Remove debounce

* Fix wrong proptype

* Get rid of JS warning

* Load render from react-dom

* Add formatted_date_created item schema (https://github.com/woocommerce/woocommerce-blocks/pull/788)

* Fix import of WithComponentID

* Add new settings to Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/787)

* Add new settings to Reviews by Product block

* Remove helpText and add notices

* Use RangeControl for numeric settings

* Prevent fetching new reviews if all were already fetched

* Enable product image in reviews

* Remove unnecessary catch

* Refactor getReviews

* Move getReviews back to block's code

* Cleanup

* Fix wrong order in editor

* Hide 'Load More Reviews' if showLoadMore is false

* Move getReviews to utils.js

* Add @woocommerce/navigation to package.json

* Make notices non-dismissable

* Reviews by Product: prevent importing all HOCs and import only withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/811)

* Reviews by product: Update review styling and content (https://github.com/woocommerce/woocommerce-blocks/pull/806)

* Add new settings to Reviews by Product block

* Remove helpText and add notices

* Use RangeControl for numeric settings

* Prevent fetching new reviews if all were already fetched

* Enable product image in reviews

* Remove unnecessary catch

* Refactor getReviews

* Move getReviews back to block's code

* Cleanup

* Fix wrong order in editor

* Hide 'Load More Reviews' if showLoadMore is false

* Move getReviews to utils.js

* Add @woocommerce/navigation to package.json

* Make notices non-dismissable

* Review design/layout

* verified icons

* Read more component

* remove comment

* expanded -> isExpanded

* Localise and change default elipses

* Simplify ReadMore

* Support children rather than passing content

* remove outside

* remove list style

* Update assets/js/components/read-more/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/components/read-more/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* merge set state

* Add missing parameter doc in renderReview (https://github.com/woocommerce/woocommerce-blocks/pull/820)

* Fix Reviews by Product order by select not honoring default setting (https://github.com/woocommerce/woocommerce-blocks/pull/818)

* Read more component - change how clamped content is shown (https://github.com/woocommerce/woocommerce-blocks/pull/821)

* Pass review as components

* Build summary from content and track both

* Toggle display after inital load

* remove unused variable

* remove componentDidUpdate

* Simplify clampLines

* Put back componentDidUpdate, but store final summary in state

* clampEnabled

* Call clampLines from componentDidMount (https://github.com/woocommerce/woocommerce-blocks/pull/826)

* truncate html tests

* implement trimHTML and pass test

* Feedback

* test short content

* Use withProduct HOC in ReviewsByProductEditor (https://github.com/woocommerce/woocommerce-blocks/pull/828)

* Use withProduct HOC

* Convert ReviewsByProductEditor to a functional component

* Add loading and error states

* Prevent loading screen appearing when changing products

* Reviews: only save wrapper element to post (https://github.com/woocommerce/woocommerce-blocks/pull/830)

* Fix bundlesize config not picking frontend files (https://github.com/woocommerce/woocommerce-blocks/pull/840)

* Reviews by Product: split 'block.js' into smaller chunks (https://github.com/woocommerce/woocommerce-blocks/pull/841)

* Split 'block.js' into smaller chunks

* Move frontend blocks to their specific folder

* Order imports

* Typo

* Add frontend components proptypes

* Fix indentation

* Call 'this.getDefaultArgs' directly inside 'getReviews'

* Move access to wc_product_block_data to the top of the file

* Rename 'frontend' folder to 'base'

* Rename base components and move styles to their folder

* Fix Reviews by Product using rating count instead of review count (https://github.com/woocommerce/woocommerce-blocks/pull/860)

* Improve Reviews by Product accessibility (https://github.com/woocommerce/woocommerce-blocks/pull/861)

* Improve Reviews by Product accessibility

* Make 'onClick' prop not required in <LoadMoreButton>

* Wrap Reviews by Product editor block with <Disabled>

* Reviews: fix reviews without rating not appearing when sorting by rating (https://github.com/woocommerce/woocommerce-blocks/pull/863)

* Update assets/css/style.scss

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Pin dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/872)

* Update dependency webpack to v4.39.2 (https://github.com/woocommerce/woocommerce-blocks/pull/855)

* Update dependency @woocommerce/components to v3.2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/875)

* Update Reviews styles so it looks the same in the editor and the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/871)

* Update Node.js to v10.16.3 (https://github.com/woocommerce/woocommerce-blocks/pull/874)

* Move wc_product_block_data variables to constants file (https://github.com/woocommerce/woocommerce-blocks/pull/870)

* Update dependency webpack-cli to v3.3.7 (https://github.com/woocommerce/woocommerce-blocks/pull/880)

* Add changelog script (https://github.com/woocommerce/woocommerce-blocks/pull/878)

* Add changelog script

* Adapt changelog script to WooCommerce Blocks

* Minor improvements

* Update dependency lint-staged to v9.2.3 (https://github.com/woocommerce/woocommerce-blocks/pull/879)

* Pin dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/883)

* Update dependency eslint to v6.2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/881)

* Reviews by category block (https://github.com/woocommerce/woocommerce-blocks/pull/804)

* Create Reviews by Product block

* Honor Content settings

* Fix wrong className

* Load new wc-packages file

* Add reviews-by-product JS files to webpack config

* Cleanup

* Remove error messages

* Add Reviews by Product icon

* Update sort options

* Allow additional CSS classes attribute

* Refactor block styles

* Fix wrong default for reviews_orderby

* Don't enforce CSS chunks

* Add reviews count to Reviews by Product controls (https://github.com/woocommerce/woocommerce-blocks/pull/671)

* Add label to Reviews by Product controls count (https://github.com/woocommerce/woocommerce-blocks/pull/677)

* Add reviews count to Reviews by Product controls

* Add label to Reviews by Product controls count

* Add label to Reviews by Product controls count

* Update components package

* Review ordering and placeholders (https://github.com/woocommerce/woocommerce-blocks/pull/688)

* Add support for comment_count ordering and add to productcontrol

* Add a placeholder if rating count is 0

* Update assets/js/components/utils/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/blocks/reviews-by-product/block.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* grammar

* Fix some linting errors and warnings (https://github.com/woocommerce/woocommerce-blocks/pull/693)

* Create Reviews by Product block placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/691)

* Create Reviews by Product block placeholder

* Reviews by Product: load and render reviews with JS (https://github.com/woocommerce/woocommerce-blocks/pull/696)

* Reviews by Product: load and render reviews with JS

* Add dangerouslySetInnerHTML explanatory comment

* Fix wrong dependency source

* Debounce getReviews call when creating the Reviews by Product block

* Rename 'Reviewer Picture' with 'Avatar' (https://github.com/woocommerce/woocommerce-blocks/pull/702)

* Lint errors

* Replace stringify query with addQueryArgs (https://github.com/woocommerce/woocommerce-blocks/pull/707)

* Add reviews endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/705)

* Prevent state updates on unmounted components (https://github.com/woocommerce/woocommerce-blocks/pull/715)

* Add Order by and Load more controls in Reviews by Product frontend (https://github.com/woocommerce/woocommerce-blocks/pull/716)

* Export IconReviewsByProduct (https://github.com/woocommerce/woocommerce-blocks/pull/721)

* Fix Reviews by Product layout in IE11 (https://github.com/woocommerce/woocommerce-blocks/pull/723)

* Set minimum to per page input field (https://github.com/woocommerce/woocommerce-blocks/pull/731)

* Hide avatars in Reviews by Products if 'show_avatars' settings is false (https://github.com/woocommerce/woocommerce-blocks/pull/730)

* Blocks API - Reviews endpoint with rating sort and category filtering (https://github.com/woocommerce/woocommerce-blocks/pull/726)

* Move file to correct location

* We are only using the reviews endpoint not revioews/id

* Remove sensistive data and make endpoint public

* Allow guest access to approved reviews

* Add support for rating sorting

* category filtering

* update arg name

* fix category query

* Reviews by Product: add placeholders when loading reviews (https://github.com/woocommerce/woocommerce-blocks/pull/732)

* Add placeholder animation (https://github.com/woocommerce/woocommerce-blocks/pull/733)

* Hook up Reviews by Product 'Order by' with endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/736)

* Hook up Reviews by Product 'Order by' with endpoint

* Use onChange instead of onBlur in select control

* Reviews by Product: Hide ratings if they are disabled in settings (https://github.com/woocommerce/woocommerce-blocks/pull/740)

* Hide ratings in Reviews by Product if disabled in settings

* Hide order by select if ratings are disabled

* Reviews by Product cleanup (https://github.com/woocommerce/woocommerce-blocks/pull/773)

* Fix wrong method name

* Reduce the number of dependencies used in Reviews by Product (https://github.com/woocommerce/woocommerce-blocks/pull/774)

* Reduce the number of dependencies used in Reviews by Product

* Use 'withComponentId' HOC

* Remove debounce

* Fix wrong proptype

* Get rid of JS warning

* Load render from react-dom

* Add formatted_date_created item schema (https://github.com/woocommerce/woocommerce-blocks/pull/788)

* Inital block setup

* Fix import of WithComponentID

* Render the category reviews

* Add new settings to Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/787)

* Add new settings to Reviews by Product block

* Remove helpText and add notices

* Use RangeControl for numeric settings

* Prevent fetching new reviews if all were already fetched

* Enable product image in reviews

* Remove unnecessary catch

* Refactor getReviews

* Move getReviews back to block's code

* Cleanup

* Fix wrong order in editor

* Hide 'Load More Reviews' if showLoadMore is false

* Move getReviews to utils.js

* Add @woocommerce/navigation to package.json

* Make notices non-dismissable

* Reviews by Product: prevent importing all HOCs and import only withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/811)

* Reviews by product: Update review styling and content (https://github.com/woocommerce/woocommerce-blocks/pull/806)

* Add new settings to Reviews by Product block

* Remove helpText and add notices

* Use RangeControl for numeric settings

* Prevent fetching new reviews if all were already fetched

* Enable product image in reviews

* Remove unnecessary catch

* Refactor getReviews

* Move getReviews back to block's code

* Cleanup

* Fix wrong order in editor

* Hide 'Load More Reviews' if showLoadMore is false

* Move getReviews to utils.js

* Add @woocommerce/navigation to package.json

* Make notices non-dismissable

* Review design/layout

* verified icons

* Read more component

* remove comment

* expanded -> isExpanded

* Localise and change default elipses

* Simplify ReadMore

* Support children rather than passing content

* remove outside

* remove list style

* Update assets/js/components/read-more/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/components/read-more/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* merge set state

* Add missing parameter doc in renderReview (https://github.com/woocommerce/woocommerce-blocks/pull/820)

* Fix Reviews by Product order by select not honoring default setting (https://github.com/woocommerce/woocommerce-blocks/pull/818)

* Read more component - change how clamped content is shown (https://github.com/woocommerce/woocommerce-blocks/pull/821)

* Pass review as components

* Build summary from content and track both

* Toggle display after inital load

* remove unused variable

* remove componentDidUpdate

* Simplify clampLines

* Put back componentDidUpdate, but store final summary in state

* clampEnabled

* Call clampLines from componentDidMount (https://github.com/woocommerce/woocommerce-blocks/pull/826)

* truncate html tests

* implement trimHTML and pass test

* Feedback

* test short content

* Use withProduct HOC in ReviewsByProductEditor (https://github.com/woocommerce/woocommerce-blocks/pull/828)

* Use withProduct HOC

* Convert ReviewsByProductEditor to a functional component

* Add loading and error states

* Prevent loading screen appearing when changing products

* Reviews: only save wrapper element to post (https://github.com/woocommerce/woocommerce-blocks/pull/830)

* Update based on product reviews

* Cleanup after master merge

* Implement content hiding and placeholder states for reviews blocks

* Output product names and adjust css

* Review permalink

* Remove old read-more component which was moved

* showProductName is already part of passed attributes

* CSS tweaks for missing elements

* Move dir

* Move product reviews block

* Move shared uitils

* update paths

* frontend paths

* Update paths

* shared attributes

* switch to constants

* Shared review block code

* Replace constants

* Fix hidden content bug

* star alignment

* Update dependency eslint to v6.2.1 (https://github.com/woocommerce/woocommerce-blocks/pull/890)

* remove JSON parse

* remove comment

* No need for important rules

* Fix error appearing on Reviews by Product when there were no reviews (https://github.com/woocommerce/woocommerce-blocks/pull/884)

* Fix error appearing on Reviews by Product when there were no reviews

* Revert "Fix error appearing on Reviews by Product when there were no reviews"

This reverts commit 73e95b39aa9a318888d08bb51faeff8bb51259d7.

* Move withProduct() HOC to editor-block.js

* Revert "Move withProduct() HOC to editor-block.js"

This reverts commit ae9515792d4870cc5cf1d92a2d6acc91198b5f62.

* Move renderNoReviews back to edit.js

* Move no reviews placeholder to its own component

* Remove usage of 'RawHTML'

* Fix propTypes

* Remove unnecessary escapeHTML

* revise labels

* Move component to base

* Add price text

* Update design to latest figma

* update from master

* Fixed merge conflicts with settings

* Fix formatting

* Update to use react hooks

* Progress hooking up price slider

* Fixes usage of data store for min/max

* Added loading state

* Fix useQueryStateByKey setter

* Product list integration

* Inital state and preventing too many queries

* Style fixes

* Button loading styles

* Package conflict

* useCallback

* Remove duplication

* variable name feedback

* Implement useCallback on functions

* useMemo for getProgressStyle

* Block feedback

* Use get_block_asset_build_path

* Remove old settings from merge conflict

* Move sketch file to .prefixed dir

* Removed render methods

* Exclude price filter from legacy build

* Feedback
2019-11-01 13:56:14 +00:00
Mike Jolley 85faacd120 Update `useQueryStateByKey` to return callback which wraps the dispatcher (https://github.com/woocommerce/woocommerce-blocks/pull/1115)
* Update useQueryStateByKey to return callback wrapping dispatch

* Fix test
2019-11-01 12:33:42 +00:00
Darren Ethier c85078366d Fix bugs in useCollection hook (https://github.com/woocommerce/woocommerce-blocks/pull/1103)
* export new hooks

* fix bug with isLoading result on useCollection
2019-10-30 09:57:39 +00:00
Darren Ethier 7e3f5e8ab9 Add useCollection and useCollectionHeader hooks (closes: woocommerce/woocommerce-blocks#1096) (https://github.com/woocommerce/woocommerce-blocks/pull/1099)
* add use-collection hook and tests

* Add use-collection-header hook

* update use-store-products hook to implement useCollection and useCollection header under the hood
2019-10-29 08:01:13 -04:00
Mike Jolley f851a6ef9b All Products with Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1032)
* Inital block creation

* Update labels

* Columns, rows, sample data json

* Output data from API

* thumbnail_html

* Split into smaller components of grid

* Price handling

* Image handling

* Remove !

* frontend

* Work on cart api

* Cart error handling and product type conditions

* innerblock progress

* Implement layoutConfig as set from innerblocks shape.

Note:

- this is just a poc
- where things are configured likely needs changed
- will still need to work out how this gets persisted for the frontend and how things get displayed there (but likely will work fairly similar in terms of mapping to components).

* use correct prop name

* Working edit button

* Clean up block controls and edit view

* Add link with innerblocks

* update link description

* correctly handle components with inner blocks as children

* Re-organise atomic components and blocks into own directories

* Unique keys for components

* Fix default layout when inserting block for first time

* Working layoutconfig save

* Save attributes

* Move sale badge to image component

* Add disabled to render preview and blocks

* icons

* Editor view styling

* Update withComponetId to stop component ID incrementing too many times

Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>

* Improve key generation

* done/cancel buttons on edit

* Create withProducts HOC for All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/994)

* Create withProducts HOC for All Products block

* Add order select and pagination to All Products block

* Go to first page when changing order

* Add HOC test

* Make sure block is updated whem columns/rows change in the editor

* Fix 'SALE' badge positioning

* Remove unnecessary key

* Honor 'perPage' value when generating placeholders

* Make placeholder sizes match rendered block item

* Several CSS improvements

* Remove unused CSS properties

* Move getProducts to hocs utils

* Remove All Products sample-data.json

* Fix order select wrong margin in the editor

* Refactor how loading image gets its size

* Clear products when loadProducts start

* Enhance pagination logic

* Fix placeholder width

* Fix regular_price check

* Set product link max-width

* Implement querystrings for the All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/997)

* Implement querystrings for the All Products block

* Create withWindow HOC

* Add with-window tests

* Use renderFrontend util in All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/1003)

* Add with-window tests

* Use renderFrontend util in All Products block

* Rename properties and components from 'order' to 'sort' (https://github.com/woocommerce/woocommerce-blocks/pull/1012)

* Rename properties and components from 'order' to 'sort'

* Rename onOrderChange to onSortChange

* Remove unnecessary stylint-disable-line (https://github.com/woocommerce/woocommerce-blocks/pull/1016)

* Create withBrowserLocation and withBrowserHistory HOC (https://github.com/woocommerce/woocommerce-blocks/pull/1022)

* Create withBrowserWindowProp HOC

* Remove unnecessary expect's

* Always pass window prop to propMap if it exists

* Scroll to top when switching pages in All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/1011)

* Scroll to top when switching pages in All Pages block

* Improve keyboard navigation in the All Products block

* Create withScrollToTop HOC

* Fix variable name typo

* Update paths with aliases

* Avoid first and last page being included in pagination 'pagesToDisplay' (https://github.com/woocommerce/woocommerce-blocks/pull/1015)

* Update lock

* constants

* linting

* Clean up styling

* Prettier

* Block options for title/image

* Prettier

* Remove shared content controls

* Update atomic block descriptions

* Summary block

* Prettier

* Impoved template edit appearance and added inline tips

* Apply prettier

* Reset and cancel buttons

* Improved keys

* Tweak tip placement

* Remove incorrect comments

* Remove disabled ofr non interactive elements

* Fragment not needed

* Update assets/js/atomic/components/product-list/title/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Move componentId hoc

* Comment

* Implement onImageLoaded

* Pagination: disable first/last page if they are active (https://github.com/woocommerce/woocommerce-blocks/pull/1041)

* Update assets/js/atomic/components/product-list/rating/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Sale badges refactoring

Adds sale badges blocks and improves how the default blocks are defined.

* revert changes in withComponentId

* fix flexbox alignment

* Create withQueryStringValues HOC and use it in ProductGrid component (https://github.com/woocommerce/woocommerce-blocks/pull/1040)

* Create withQueryStringValues HOC and use it in ProductGrid component

* Add tests

* Add comment explaining urlParameterSuffix

* Don't destructure props if only used once

* Move dependencies check outside the HOC

* Update test description

* Remove HOCs no longer used

* Update assets/js/atomic/blocks/product-list/image/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/atomic/components/product-list/sale-badge/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/atomic/utils/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/atomic/utils/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Feedback

* Grid to List

* Improved badge handling

* update package-lock after merge from master

* Add wp.data store for schema and lists. (https://github.com/woocommerce/woocommerce-blocks/pull/1008)

* install @wordpress/data-controls and deepFreeze

* add schema store

* add query-state store

* add collections store

* add bundle entry point (and export store keys and constants)

* add master README.md for new stores

* add bundle configuration and register asset php side

* Add missing param name

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* code style fixes

* remove unnecessary period from test description

* Simplify conditional

* reorder imports (code style)

* reorder imports and codestyle

* refactor using lodash for state utils

* reorder imports

* reorder imports

* reorder dependencies

* reorder dependnecies an remove duplication block

* remove errant tab

* reorder dependencies

* Modify collections store to add headers to the store state. (https://github.com/woocommerce/woocommerce-blocks/pull/1073)

* add control for getting unparsed response from apiFetch

* Modify action so it recieves a response object.

* modify reducer to handle response object

* improve selectors to make headers accessible

- modifys existing `getCollection` to retrieve items from state.
- adds `getCollectionHeader` selector

* update resolvers to handle full response from request

- also adds resolver for `getCollectionHeader`

* update docs for changes

* Improve spacing in doc

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Fix spacing in inline docs

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* change `getFromState` to receive an object instead of arguments list.

* Prepare All Products block to accept extension inner blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1047)

* Simplify BLOCK_MAP

* Prepare All Products block to accept extension inner blocks

* Change filter name

* Update filter name

* Add check that block exists in BLOCK_MAP

* Create REVERSED_BLOCK_MAP instead of searching blocks each time

* Change how child blocks are registered for All Products block

* Refactor All Products block so reverse map isn't needed

* Remove getDefaultBlocks

* Make sure getRegisteredInnerBlocks always returns an object and add checks to registerInnerBlock

* Add missing blockName arg

* Add inline docs to block registry

* Move 'blockName' prop to context

* Typos

* Improve registerInnerBlock error messages and create a validation function

* Refactor context

* Rename validateOption to assertOption

* refactor where new context lives and add alias for base-context

* fix doc block

* remove todo block (there’s an issue for it)

* rename context

* Update assets/js/atomic/components/product-list/sale-badge/index.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* HeadingToolbar comment

* Tweak bool comparison

* Improve how default layouts are set so all blocks can be removed and the no-content message is correct

* Sale centering

* Fix default template

* Product example switch to preview

* Update preview schema and image data to match latest schema

* Add @woocommerce/atomic-components alias

* Alias for previews to prevent need for relative paths

* Drop `align` for sale block

Align disrupts other blocks in unexpected and unavoidable ways. Drop support so the sale block is a block level item.

* Rename atomic components and blocks (and create ProductLayoutContext) (https://github.com/woocommerce/woocommerce-blocks/pull/1089)

* rename atomic blocks and components to be more generic (drop list)

* create new context for productlayout and implement provider

* Rename ProductSalesBadge to ProductSaleBadge

* Add php5.3 restriction for All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/1090)

* enable legacy builds and add handling for AllProducts to be wp5.3 only

* fix legacy builds

* Prevent filemtime notice

* Implement new data stores with All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/1067)

* add new hooks and tests and alias for hooks

* various fixes for stores after implementation tests

* implement new stores for ProductList component

* add doc blocks for useStoreProducts hooks

* fix typo in property on returned object
2019-10-28 09:53:09 -04:00
Darren Ethier dee8dcb296 ensure function is not re-created unnecessarily. (https://github.com/woocommerce/woocommerce-blocks/pull/1093) 2019-10-28 08:44:25 -04:00
Darren Ethier 73f5355b28 fix function passed through as prop is a class property (https://github.com/woocommerce/woocommerce-blocks/pull/1088) 2019-10-25 12:57:04 +01:00
Darren Ethier a6c150a11c Add WP 5.3 preview for Feature Product Block (https://github.com/woocommerce/woocommerce-blocks/pull/1034)
* fix space in setting retrieval

* allow for previews via `withProduct`

* add example property to block registration

* add preview handling

* fix typo

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Added product preview JSON

* Add example.js file for preview content

* Update HOC to handle preview.

* Move preview check
2019-10-24 14:55:44 +01:00
Mike Jolley 00ab1d1913 Add responsive product grid styles (https://github.com/woocommerce/woocommerce-blocks/pull/1066)
* Add responsive grid styles

* Tweak 2 column padding.

* Use mixin
2019-10-24 14:39:50 +01:00
Mike Jolley 18c8c96172 Fix homeUrl variable (https://github.com/woocommerce/woocommerce-blocks/pull/1065) 2019-10-23 11:51:10 +01:00
Albert Juhé Lluveras 15b330d36e Add previews for Reviews blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1059)
* Add previews for Reviews blocks

* Use double negation instead of Boolean

* Refactor withReviews to use class properties

* Fix tests

* Make example data translatable
2019-10-22 16:13:14 +02:00
Mike Jolley 5f4949ac6b Add empty content messages (https://github.com/woocommerce/woocommerce-blocks/pull/717)
* Return empty result if no products are found

* Add empty response handler

* Update to latest PR

* Pass render prop
2019-10-16 14:13:10 +01:00
Mike Jolley e227dff18e Use Server Side Rendering for Product Category List block (https://github.com/woocommerce/woocommerce-blocks/pull/1024)
* Convert product list to SSR block

* Remove PRODUCT_CATEGORIES from block data

* onclick event handling

* Empty placeholder

* code style

* depth css class

* hasCount handling

* Deprecation handling of old saved markup

* Code style

* Legacy attribute mapping
2019-10-16 13:02:43 +01:00
Darren Ethier 007039c5b9 Expose wp_version on settings api and provide a js version compare function (https://github.com/woocommerce/woocommerce-blocks/pull/1033)
* install compare-versions and export on `@woocommerce/settings` external

* expose `wp_version` on wcSettings

* export a compareWithWpVersion function for easier version checking

* improve semver coercing for wp version check

also add tests

* fix for code standards around imports

* switch to camelcase for version option
2019-10-11 11:29:27 -04:00
Albert Juhé Lluveras 725b447944 Fix ProductAttributeControl not reacting to clicks (https://github.com/woocommerce/woocommerce-blocks/pull/1021) 2019-10-06 15:37:48 +02:00
Darren Ethier f3bd3e6a09 Introduce legacy build system and new aliases (https://github.com/woocommerce/woocommerce-blocks/pull/1018)
* install directory-named-webpack-plugin

* create new plugin for fallback legacy imports

* implement webpack configuration for fallback legacy imports and legacy builds

Note: legacy builds are currently disabled, we can enable by just commenting out when we need them.

* removed unused webpack plugin experimented with in earlier iteration

* prettier fixes

* add legacy folder with readme for explanation

* add some info on legacy builds to `CONTRIBUTING.md`

* refactor imports to use new aliases

* fix link in doc

* update jest test config for new aliases

* use native string.startsWith instead of custom function

* reformat file for spacing/code style

* add slash to alias

* clean up webpack config and make things more dry

* update indent style for json files to be tab not spaces

- adjusts editorconfig rules
- reformat jest.config.json

* simplify conditional
2019-10-06 08:36:15 -04:00
Albert Juhé Lluveras 99416e945e Update Products on Sale and Products Tag icons (https://github.com/woocommerce/woocommerce-blocks/pull/987)
* Update Products on Sale and Products Tag icons

* Update on sale icon
2019-10-01 10:20:52 +01:00
Darren Ethier 3aafd4ec35 remove unnecessary logic (https://github.com/woocommerce/woocommerce-blocks/pull/999) 2019-09-28 14:50:28 -04:00
Albert Juhé Lluveras 01412e6af0 Update ProductControl to use HOCs (https://github.com/woocommerce/woocommerce-blocks/pull/974)
* Update ProductControl to use HOCs

* Only show variations in certain ProductControls

* Cleanup

* Refactor withSingleSelected selected prop logic

* Fix selected values not being respected

* Fix wrong propTypes notation

* Set parent: 0 in getProducts util func

* Use static properties in withProductVariations

* Move messages outside of the functional component

* Check that variations is an array

* Fix debounced search

* Fix broken tests

* Rename withSingleSelected to withTransformSingleSelectToMultipleSelect
2019-09-25 16:22:36 +02:00
Darren Ethier 57fdb8fe9c Implement PHP DI container and refactor. Also implements new Asset data interface for extendable settings passed to js. (https://github.com/woocommerce/woocommerce-blocks/pull/956)
* Add dependency injection container for blocks

* Add new Pacakge and Bootstrap classes.

- Bootstrap for bootstrapping the plugin.
- Package will replace `src/Package` and added as a dependency for any classes needing package info.

* Introduce AssetsDataRegistry for managing asset data

* refactor existing classes to use new DIC and Asset Data Registry

- this is the bare minimum needed to make this pull viable.
- further refactors will be done in more atomic smaller pulls for easier review.

* add new settings handling and export `@woocommerce/settings` as an alias to wc.wcSettings

- the export is exposed php side on the `wc-settings` handle.

* Remove unnecessary concatenation

* Fix typos and improve doc blocks

* fix php linting issue

* Use better escaping function.

* improve jsdoc spacing

* improve test assertion

* use fully qualified class names in bootstrap

* improve comment block to account for dynamic version string replace on build

* handle exceptions a bit differently

* correct dependency reference in webpack config

* remove blank lines

* fix doc block comment alignment

* Various doc/grammar/spacing fixes from code review.

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* improve naming, documentation and logic of filter callbacks

While this is intended for sanitization/validation, the callback ultimately provides flexibility for filtering the value before returning or setting in state so `filter` is a better name for this.
2019-09-23 14:07:13 -04:00
Albert Juhé Lluveras 574b5230d9 Fix product grids overflowing in some themes (https://github.com/woocommerce/woocommerce-blocks/pull/978) 2019-09-23 12:03:07 +02:00
Albert Juhé Lluveras ddd272867e Create renderFrontend utils function (https://github.com/woocommerce/woocommerce-blocks/pull/954)
* Create renderFrontend utils function

* Avoid unnecessary variable assignment
2019-09-09 15:25:22 +02:00
Albert Juhé Lluveras 7d29cdf570 Fix product categories list displaying [Object] instead of count (https://github.com/woocommerce/woocommerce-blocks/pull/950)
* Fix product list display [Object] instead of count

* Make it easier to style product-categories
2019-09-09 15:25:12 +02:00
Albert Juhé Lluveras 26a387d35f Rename ApiErrorPlaceholder to ErrorPlaceholder (https://github.com/woocommerce/woocommerce-blocks/pull/955) 2019-09-09 14:04:54 +02:00
Albert Juhé Lluveras 85df274523 Reformat files with new tabwidth (https://github.com/woocommerce/woocommerce-blocks/pull/953)
* Reformat files with new tabwidth

* Review featured product background position so it doesn't break
2019-09-09 12:52:48 +02:00
Albert Juhé Lluveras 616293deb0 Fix review block icons not having foreground color (https://github.com/woocommerce/woocommerce-blocks/pull/952) 2019-09-09 12:47:33 +02:00
Darren Ethier e4ff6eb606 Fix increment bug in withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/951)
* fix bug with component and add test coverage

* code style spacing on doc block

* fix prettier config
2019-09-07 08:04:34 -04:00
Albert Juhé Lluveras d4cfd644b8 Remove colors from icons displayed in the shortcuts inserter (https://github.com/woocommerce/woocommerce-blocks/pull/949)
* Remove colors from inserter icons

* Prettier
2019-09-06 18:03:41 +02:00
Albert Juhé Lluveras 6ab7834f59 Install prettier and reformat files (https://github.com/woocommerce/woocommerce-blocks/pull/945)
* Install prettier

* Reformat all files

* Add prettier to precommit hook

* Update prettier settings to match Gutenberg code standards

* Reformat files with new settings

* Improve legibility in some line breaks
2019-09-05 17:09:31 +02:00
Albert Juhé Lluveras dc232e87d6 Add withCategories and withAttributes HOCs (https://github.com/woocommerce/woocommerce-blocks/pull/935)
* Add withCategories HOC and show API errors in Product Category Control

* Create withAttributes HOC and display errors in Product Attribute Control

* Refactor formatError so it handles JS errors and API errors

* Rename 'onSelectAttribute' with 'onExpandAttribute'

* Add and update tests

* Fix error in product attributes endpoint

* Refactor ProductCategoryControl into a functional component

* Refactor ProductAttributeControl into a functional component

* Refactor formatError to use a 'message' and 'type' properties

* Replace enzyme with TestRenderer

* Fix formatErrors doctype format

* Rename 'frontend' error type to 'general'
2019-09-04 18:07:00 +02:00
Albert Juhé Lluveras 4489b50774 Add Product Search Icon (https://github.com/woocommerce/woocommerce-blocks/pull/944) 2019-09-04 15:18:07 +02:00
Albert Juhé Lluveras 04c9933030 RTL fixes (https://github.com/woocommerce/woocommerce-blocks/pull/938)
* Install webpack-rtl-plugin

* Rotate arrow buttons on RTL sites

* Minify in safe mode
2019-09-03 19:55:20 +02:00
Albert Juhé Lluveras 73f8f15bb3 Create Pagination and ProductOrderSelect components (https://github.com/woocommerce/woocommerce-blocks/pull/926)
* Create ProductOrderSelect component

* Create Pagination component

* Add description to props

* Use BEM class name

* Use < > instead of ← →

* Update product order select options to match Shop core page

* Refactor pagination so it behaves like core pagination

* Update snapshots
2019-09-03 16:41:05 +02:00
Albert Juhé Lluveras 3829707bf9 Add error states to all components/blocks which use HOCs (https://github.com/woocommerce/woocommerce-blocks/pull/928)
* Show errors in Products Control component

* Export error formatting logic into a util
2019-08-30 11:36:06 +02:00
Albert Juhé Lluveras 05ef21861d Fix color of All Reviews block icon (https://github.com/woocommerce/woocommerce-blocks/pull/919)
* Fix color of All Reviews block icon

* Fix lint notice
2019-08-28 11:29:43 +02:00
Mike Jolley ea0ce0e915 Fix wcSettings conflicts with wc-admin (https://github.com/woocommerce/woocommerce-blocks/pull/916)
* Add inline settings script later than init

* Rename to shared-settings for clarity - other extensions filter these

* Implement block settings

* tweak used hooks

* update comment

* Shared settings should be dependency

* Make Webpack output shared and block settings (https://github.com/woocommerce/woocommerce-blocks/pull/918)
2019-08-27 16:25:32 +01:00
Albert Juhé Lluveras 67cfa47b30 Fix order by and load more buttons not hidden in frontend review blocks (https://github.com/woocommerce/woocommerce-blocks/pull/914) 2019-08-27 15:56:07 +02:00
Albert Juhé Lluveras d1db64362a Cleanup withComponentId from base components (https://github.com/woocommerce/woocommerce-blocks/pull/907) 2019-08-27 12:24:50 +02:00
Albert Juhé Lluveras a6bf6d7fc0 Update review block icons (https://github.com/woocommerce/woocommerce-blocks/pull/913) 2019-08-27 12:01:35 +02:00
Albert Juhé Lluveras 20e3052d1c Show API errors in reviews editor block (https://github.com/woocommerce/woocommerce-blocks/pull/909)
* Show API errors in reviews editor block

* Update tests
2019-08-27 11:38:41 +02:00
Albert Juhé Lluveras ce30a9f1ff Reviews blocks: Fix warnings with components state (https://github.com/woocommerce/woocommerce-blocks/pull/908) 2019-08-27 11:38:28 +02:00
Albert Juhé Lluveras e19cd56c7f Remove RawHTML used for notice translations (https://github.com/woocommerce/woocommerce-blocks/pull/889)
* Remove RawHTML used for notice translations

* Revert "Remove RawHTML used for notice translations"

This reverts commit e28e082c2eefd8c29e982ee34ac27f99267171c3.

* Escape translation strings before using them

* Add translator notices
2019-08-26 12:11:50 +02:00
Albert Juhé Lluveras 4a1171364d Create OrderSelect and Label components (https://github.com/woocommerce/woocommerce-blocks/pull/905)
* Create Label and OrderSelect components

* Update review list item so it uses 'classnames'

* Split review order select styles from generic component

* Update snapshots

* Refactor Label so we don't need to check Symbol

* Add description to Label and OrderSelect components

* Use prop-types instead of prop-types-elementtype

* Simplify Label propTypes

* Update package-lock
2019-08-23 18:35:34 +02:00
Albert Juhé Lluveras 9d8d083363 All Reviews block (https://github.com/woocommerce/woocommerce-blocks/pull/902)
* Make all reviews block share the same frontend script

* Create 'All Reviews' block

* Create All Reviews no reviews placeholder

* Create EditorContainerBlock and move some shared logic there

* Update icon

* Address PR feedback
2019-08-23 16:48:48 +02:00
Darren Ethier 72f0ed470f Refactor: Introduce `wc-block-settings` bundle serving as `@woocommerce/settings` external. (https://github.com/woocommerce/woocommerce-blocks/pull/903)
* export new @woocommerce/settings external on `wc.blockSettings` global

- This handles reading data from the dom and assigning it to the global used in all packages dependent on `@woocommerce/settings` which is registered as an external pointing to the global.
- ensures that server data is only loaded on a route if needed.

* switch all direct imports of constants to use new `@woocommerce/settings` external

* enqueu new `wc-block-settings` script and attach inline data to it.

* fix test configuration and adjust test to use new external

* fix bad merge resolution after rebase

* switch constants import to `@woocommerce/settings` external after rebase

* reorder imports for convention

* improve method name
2019-08-22 16:56:47 -04:00
Albert Juhé Lluveras 46934d2946 Create withReviews base HOC (https://github.com/woocommerce/woocommerce-blocks/pull/877)
* Create withReviews base HOC

* Add tests

* Make Reviews by Category use withReviews HOC

* Move componentDidUpdate and debounce dependency to decouple HOC from components

* Spaces

* Rename 'delayMethod' to 'delayFunction'

* Refactor withReviews HOC

* Update tests

* Minor fixes

* Undo fix being handled in woocommerce/woocommerce-blocks#884

* Remove hardcoded from withReviews

* Update delay comment

* Use callbacks instead of announceUpdates prop

* Move props check to a 'shouldReplaceReviews' method

* Fix productId propType

* Move per_page and offset args to 'getArgs'

* Update withReviews displayName

* Fix tests

* Add callback propsTypes

* Use is-shallow-equal
2019-08-22 13:36:20 +02:00
Darren Ethier 0b9559e2db Install @babel/plugin-proposal-class-properties. (https://github.com/woocommerce/woocommerce-blocks/pull/856)
* add @babel/plugin-proposal-class-properties plugin

* refactor ProductByCategoryBlock to use class properties
2019-08-21 09:05:17 -04:00
Albert Juhé Lluveras df9840a108 Review blocks: fix attribute notices not appearing (https://github.com/woocommerce/woocommerce-blocks/pull/888)
* Review blocks: fix attribute notices not appearing

* Classes and CSS cleanup
2019-08-21 12:48:22 +02:00
Albert Juhé Lluveras 9250d31227 Fix error appearing on Reviews by Product when there were no reviews (https://github.com/woocommerce/woocommerce-blocks/pull/884)
* Fix error appearing on Reviews by Product when there were no reviews

* Revert "Fix error appearing on Reviews by Product when there were no reviews"

This reverts commit 73e95b39aa9a318888d08bb51faeff8bb51259d7.

* Move withProduct() HOC to editor-block.js

* Revert "Move withProduct() HOC to editor-block.js"

This reverts commit ae9515792d4870cc5cf1d92a2d6acc91198b5f62.

* Move renderNoReviews back to edit.js

* Move no reviews placeholder to its own component

* Remove usage of 'RawHTML'

* Fix propTypes

* Remove unnecessary escapeHTML
2019-08-21 09:48:22 +02:00
Mike Jolley 3a9c5ba1cd Reviews by category block (https://github.com/woocommerce/woocommerce-blocks/pull/804)
* Create Reviews by Product block

* Honor Content settings

* Fix wrong className

* Load new wc-packages file

* Add reviews-by-product JS files to webpack config

* Cleanup

* Remove error messages

* Add Reviews by Product icon

* Update sort options

* Allow additional CSS classes attribute

* Refactor block styles

* Fix wrong default for reviews_orderby

* Don't enforce CSS chunks

* Add reviews count to Reviews by Product controls (https://github.com/woocommerce/woocommerce-blocks/pull/671)

* Add label to Reviews by Product controls count (https://github.com/woocommerce/woocommerce-blocks/pull/677)

* Add reviews count to Reviews by Product controls

* Add label to Reviews by Product controls count

* Add label to Reviews by Product controls count

* Update components package

* Review ordering and placeholders (https://github.com/woocommerce/woocommerce-blocks/pull/688)

* Add support for comment_count ordering and add to productcontrol

* Add a placeholder if rating count is 0

* Update assets/js/components/utils/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/blocks/reviews-by-product/block.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* grammar

* Fix some linting errors and warnings (https://github.com/woocommerce/woocommerce-blocks/pull/693)

* Create Reviews by Product block placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/691)

* Create Reviews by Product block placeholder

* Reviews by Product: load and render reviews with JS (https://github.com/woocommerce/woocommerce-blocks/pull/696)

* Reviews by Product: load and render reviews with JS

* Add dangerouslySetInnerHTML explanatory comment

* Fix wrong dependency source

* Debounce getReviews call when creating the Reviews by Product block

* Rename 'Reviewer Picture' with 'Avatar' (https://github.com/woocommerce/woocommerce-blocks/pull/702)

* Lint errors

* Replace stringify query with addQueryArgs (https://github.com/woocommerce/woocommerce-blocks/pull/707)

* Add reviews endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/705)

* Prevent state updates on unmounted components (https://github.com/woocommerce/woocommerce-blocks/pull/715)

* Add Order by and Load more controls in Reviews by Product frontend (https://github.com/woocommerce/woocommerce-blocks/pull/716)

* Export IconReviewsByProduct (https://github.com/woocommerce/woocommerce-blocks/pull/721)

* Fix Reviews by Product layout in IE11 (https://github.com/woocommerce/woocommerce-blocks/pull/723)

* Set minimum to per page input field (https://github.com/woocommerce/woocommerce-blocks/pull/731)

* Hide avatars in Reviews by Products if 'show_avatars' settings is false (https://github.com/woocommerce/woocommerce-blocks/pull/730)

* Blocks API - Reviews endpoint with rating sort and category filtering (https://github.com/woocommerce/woocommerce-blocks/pull/726)

* Move file to correct location

* We are only using the reviews endpoint not revioews/id

* Remove sensistive data and make endpoint public

* Allow guest access to approved reviews

* Add support for rating sorting

* category filtering

* update arg name

* fix category query

* Reviews by Product: add placeholders when loading reviews (https://github.com/woocommerce/woocommerce-blocks/pull/732)

* Add placeholder animation (https://github.com/woocommerce/woocommerce-blocks/pull/733)

* Hook up Reviews by Product 'Order by' with endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/736)

* Hook up Reviews by Product 'Order by' with endpoint

* Use onChange instead of onBlur in select control

* Reviews by Product: Hide ratings if they are disabled in settings (https://github.com/woocommerce/woocommerce-blocks/pull/740)

* Hide ratings in Reviews by Product if disabled in settings

* Hide order by select if ratings are disabled

* Reviews by Product cleanup (https://github.com/woocommerce/woocommerce-blocks/pull/773)

* Fix wrong method name

* Reduce the number of dependencies used in Reviews by Product (https://github.com/woocommerce/woocommerce-blocks/pull/774)

* Reduce the number of dependencies used in Reviews by Product

* Use 'withComponentId' HOC

* Remove debounce

* Fix wrong proptype

* Get rid of JS warning

* Load render from react-dom

* Add formatted_date_created item schema (https://github.com/woocommerce/woocommerce-blocks/pull/788)

* Inital block setup

* Fix import of WithComponentID

* Render the category reviews

* Add new settings to Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/787)

* Add new settings to Reviews by Product block

* Remove helpText and add notices

* Use RangeControl for numeric settings

* Prevent fetching new reviews if all were already fetched

* Enable product image in reviews

* Remove unnecessary catch

* Refactor getReviews

* Move getReviews back to block's code

* Cleanup

* Fix wrong order in editor

* Hide 'Load More Reviews' if showLoadMore is false

* Move getReviews to utils.js

* Add @woocommerce/navigation to package.json

* Make notices non-dismissable

* Reviews by Product: prevent importing all HOCs and import only withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/811)

* Reviews by product: Update review styling and content (https://github.com/woocommerce/woocommerce-blocks/pull/806)

* Add new settings to Reviews by Product block

* Remove helpText and add notices

* Use RangeControl for numeric settings

* Prevent fetching new reviews if all were already fetched

* Enable product image in reviews

* Remove unnecessary catch

* Refactor getReviews

* Move getReviews back to block's code

* Cleanup

* Fix wrong order in editor

* Hide 'Load More Reviews' if showLoadMore is false

* Move getReviews to utils.js

* Add @woocommerce/navigation to package.json

* Make notices non-dismissable

* Review design/layout

* verified icons

* Read more component

* remove comment

* expanded -> isExpanded

* Localise and change default elipses

* Simplify ReadMore

* Support children rather than passing content

* remove outside

* remove list style

* Update assets/js/components/read-more/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/components/read-more/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* merge set state

* Add missing parameter doc in renderReview (https://github.com/woocommerce/woocommerce-blocks/pull/820)

* Fix Reviews by Product order by select not honoring default setting (https://github.com/woocommerce/woocommerce-blocks/pull/818)

* Read more component - change how clamped content is shown (https://github.com/woocommerce/woocommerce-blocks/pull/821)

* Pass review as components

* Build summary from content and track both

* Toggle display after inital load

* remove unused variable

* remove componentDidUpdate

* Simplify clampLines

* Put back componentDidUpdate, but store final summary in state

* clampEnabled

* Call clampLines from componentDidMount (https://github.com/woocommerce/woocommerce-blocks/pull/826)

* truncate html tests

* implement trimHTML and pass test

* Feedback

* test short content

* Use withProduct HOC in ReviewsByProductEditor (https://github.com/woocommerce/woocommerce-blocks/pull/828)

* Use withProduct HOC

* Convert ReviewsByProductEditor to a functional component

* Add loading and error states

* Prevent loading screen appearing when changing products

* Reviews: only save wrapper element to post (https://github.com/woocommerce/woocommerce-blocks/pull/830)

* Update based on product reviews

* Cleanup after master merge

* Implement content hiding and placeholder states for reviews blocks

* Output product names and adjust css

* Review permalink

* Remove old read-more component which was moved

* showProductName is already part of passed attributes

* CSS tweaks for missing elements

* Move dir

* Move product reviews block

* Move shared uitils

* update paths

* frontend paths

* Update paths

* shared attributes

* switch to constants

* Shared review block code

* Replace constants

* Fix hidden content bug

* star alignment
2019-08-19 15:13:07 +01:00
Albert Juhé Lluveras a6a131f8fd Move wc_product_block_data variables to constants file (https://github.com/woocommerce/woocommerce-blocks/pull/870) 2019-08-17 11:14:11 +02:00
Albert Juhé Lluveras fb842d2596 Update Reviews styles so it looks the same in the editor and the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/871) 2019-08-16 16:12:06 +01:00
Albert Juhé Lluveras ad38f9d327 Create Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/658)
* Create Reviews by Product block

* Honor Content settings

* Fix wrong className

* Load new wc-packages file

* Add reviews-by-product JS files to webpack config

* Cleanup

* Remove error messages

* Add Reviews by Product icon

* Update sort options

* Allow additional CSS classes attribute

* Refactor block styles

* Fix wrong default for reviews_orderby

* Don't enforce CSS chunks

* Add reviews count to Reviews by Product controls (https://github.com/woocommerce/woocommerce-blocks/pull/671)

* Add label to Reviews by Product controls count (https://github.com/woocommerce/woocommerce-blocks/pull/677)

* Add reviews count to Reviews by Product controls

* Add label to Reviews by Product controls count

* Add label to Reviews by Product controls count

* Update components package

* Review ordering and placeholders (https://github.com/woocommerce/woocommerce-blocks/pull/688)

* Add support for comment_count ordering and add to productcontrol

* Add a placeholder if rating count is 0

* Update assets/js/components/utils/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/blocks/reviews-by-product/block.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* grammar

* Fix some linting errors and warnings (https://github.com/woocommerce/woocommerce-blocks/pull/693)

* Create Reviews by Product block placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/691)

* Create Reviews by Product block placeholder

* Reviews by Product: load and render reviews with JS (https://github.com/woocommerce/woocommerce-blocks/pull/696)

* Reviews by Product: load and render reviews with JS

* Add dangerouslySetInnerHTML explanatory comment

* Fix wrong dependency source

* Debounce getReviews call when creating the Reviews by Product block

* Rename 'Reviewer Picture' with 'Avatar' (https://github.com/woocommerce/woocommerce-blocks/pull/702)

* Lint errors

* Replace stringify query with addQueryArgs (https://github.com/woocommerce/woocommerce-blocks/pull/707)

* Add reviews endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/705)

* Prevent state updates on unmounted components (https://github.com/woocommerce/woocommerce-blocks/pull/715)

* Add Order by and Load more controls in Reviews by Product frontend (https://github.com/woocommerce/woocommerce-blocks/pull/716)

* Export IconReviewsByProduct (https://github.com/woocommerce/woocommerce-blocks/pull/721)

* Fix Reviews by Product layout in IE11 (https://github.com/woocommerce/woocommerce-blocks/pull/723)

* Set minimum to per page input field (https://github.com/woocommerce/woocommerce-blocks/pull/731)

* Hide avatars in Reviews by Products if 'show_avatars' settings is false (https://github.com/woocommerce/woocommerce-blocks/pull/730)

* Blocks API - Reviews endpoint with rating sort and category filtering (https://github.com/woocommerce/woocommerce-blocks/pull/726)

* Move file to correct location

* We are only using the reviews endpoint not revioews/id

* Remove sensistive data and make endpoint public

* Allow guest access to approved reviews

* Add support for rating sorting

* category filtering

* update arg name

* fix category query

* Reviews by Product: add placeholders when loading reviews (https://github.com/woocommerce/woocommerce-blocks/pull/732)

* Add placeholder animation (https://github.com/woocommerce/woocommerce-blocks/pull/733)

* Hook up Reviews by Product 'Order by' with endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/736)

* Hook up Reviews by Product 'Order by' with endpoint

* Use onChange instead of onBlur in select control

* Reviews by Product: Hide ratings if they are disabled in settings (https://github.com/woocommerce/woocommerce-blocks/pull/740)

* Hide ratings in Reviews by Product if disabled in settings

* Hide order by select if ratings are disabled

* Reviews by Product cleanup (https://github.com/woocommerce/woocommerce-blocks/pull/773)

* Fix wrong method name

* Reduce the number of dependencies used in Reviews by Product (https://github.com/woocommerce/woocommerce-blocks/pull/774)

* Reduce the number of dependencies used in Reviews by Product

* Use 'withComponentId' HOC

* Remove debounce

* Fix wrong proptype

* Get rid of JS warning

* Load render from react-dom

* Add formatted_date_created item schema (https://github.com/woocommerce/woocommerce-blocks/pull/788)

* Fix import of WithComponentID

* Add new settings to Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/787)

* Add new settings to Reviews by Product block

* Remove helpText and add notices

* Use RangeControl for numeric settings

* Prevent fetching new reviews if all were already fetched

* Enable product image in reviews

* Remove unnecessary catch

* Refactor getReviews

* Move getReviews back to block's code

* Cleanup

* Fix wrong order in editor

* Hide 'Load More Reviews' if showLoadMore is false

* Move getReviews to utils.js

* Add @woocommerce/navigation to package.json

* Make notices non-dismissable

* Reviews by Product: prevent importing all HOCs and import only withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/811)

* Reviews by product: Update review styling and content (https://github.com/woocommerce/woocommerce-blocks/pull/806)

* Add new settings to Reviews by Product block

* Remove helpText and add notices

* Use RangeControl for numeric settings

* Prevent fetching new reviews if all were already fetched

* Enable product image in reviews

* Remove unnecessary catch

* Refactor getReviews

* Move getReviews back to block's code

* Cleanup

* Fix wrong order in editor

* Hide 'Load More Reviews' if showLoadMore is false

* Move getReviews to utils.js

* Add @woocommerce/navigation to package.json

* Make notices non-dismissable

* Review design/layout

* verified icons

* Read more component

* remove comment

* expanded -> isExpanded

* Localise and change default elipses

* Simplify ReadMore

* Support children rather than passing content

* remove outside

* remove list style

* Update assets/js/components/read-more/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/components/read-more/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* merge set state

* Add missing parameter doc in renderReview (https://github.com/woocommerce/woocommerce-blocks/pull/820)

* Fix Reviews by Product order by select not honoring default setting (https://github.com/woocommerce/woocommerce-blocks/pull/818)

* Read more component - change how clamped content is shown (https://github.com/woocommerce/woocommerce-blocks/pull/821)

* Pass review as components

* Build summary from content and track both

* Toggle display after inital load

* remove unused variable

* remove componentDidUpdate

* Simplify clampLines

* Put back componentDidUpdate, but store final summary in state

* clampEnabled

* Call clampLines from componentDidMount (https://github.com/woocommerce/woocommerce-blocks/pull/826)

* truncate html tests

* implement trimHTML and pass test

* Feedback

* test short content

* Use withProduct HOC in ReviewsByProductEditor (https://github.com/woocommerce/woocommerce-blocks/pull/828)

* Use withProduct HOC

* Convert ReviewsByProductEditor to a functional component

* Add loading and error states

* Prevent loading screen appearing when changing products

* Reviews: only save wrapper element to post (https://github.com/woocommerce/woocommerce-blocks/pull/830)

* Fix bundlesize config not picking frontend files (https://github.com/woocommerce/woocommerce-blocks/pull/840)

* Reviews by Product: split 'block.js' into smaller chunks (https://github.com/woocommerce/woocommerce-blocks/pull/841)

* Split 'block.js' into smaller chunks

* Move frontend blocks to their specific folder

* Order imports

* Typo

* Add frontend components proptypes

* Fix indentation

* Call 'this.getDefaultArgs' directly inside 'getReviews'

* Move access to wc_product_block_data to the top of the file

* Rename 'frontend' folder to 'base'

* Rename base components and move styles to their folder

* Fix Reviews by Product using rating count instead of review count (https://github.com/woocommerce/woocommerce-blocks/pull/860)

* Improve Reviews by Product accessibility (https://github.com/woocommerce/woocommerce-blocks/pull/861)

* Improve Reviews by Product accessibility

* Make 'onClick' prop not required in <LoadMoreButton>

* Wrap Reviews by Product editor block with <Disabled>

* Reviews: fix reviews without rating not appearing when sorting by rating (https://github.com/woocommerce/woocommerce-blocks/pull/863)
2019-08-15 16:55:57 +02:00
Mike Jolley d9c2b4d4c6 Align stars left (https://github.com/woocommerce/woocommerce-blocks/pull/866) 2019-08-15 13:20:06 +01:00
Mike Jolley aa65f19a46 Remove screen-reader-text css rules (https://github.com/woocommerce/woocommerce-blocks/pull/849) 2019-08-15 13:19:09 +01:00
Mike Jolley 1ed14cdc01 Introduce withCategory HOC for featured category block (https://github.com/woocommerce/woocommerce-blocks/pull/846)
* Introduce withCategory hoc

* Refactor featured category to use new hoc

* Update docblocks
2019-08-15 10:36:24 +01:00
Mike Jolley 5f5797dc3d Add global data helpers (https://github.com/woocommerce/woocommerce-blocks/pull/848)
* Extract global settings to assets/js/data

* add alias

* Fix alias

* Rename to settings
2019-08-13 15:43:48 +01:00
Claudio Sanches dddadb895f Fix duplicated translatable string (https://github.com/woocommerce/woocommerce-blocks/pull/843)
* Fix duplicated translatable string

* Fixed more duplicated strings in descriptions

* Merge similar strings
2019-08-13 11:29:00 +01:00
Mike Jolley 84a464fc62 Allow hidden products in handpicked products block (https://github.com/woocommerce/woocommerce-blocks/pull/803)
* Allow hidden products in handpicked block

* Simplify set_visibility_query_args
2019-08-12 12:54:51 +01:00
Albert Juhé Lluveras a36608d9dc Make react-test-renderer name consistent (https://github.com/woocommerce/woocommerce-blocks/pull/836) 2019-08-12 13:41:18 +02:00
Albert Juhé Lluveras e7180dfc7b Product Categories: prevent importing all HOCs and import only withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/834) 2019-08-12 10:44:51 +01:00
Albert Juhé Lluveras e5f73b05e8 Add eslint JSDoc checks (https://github.com/woocommerce/woocommerce-blocks/pull/819)
* Add eslint JSDoc checks

* Use @wordpress/eslint-plugin for ESLint config

* Rename 'augments' with 'extends'

* Remove '@wordpress/eslint-plugin' from package.json
2019-08-09 18:18:46 +02:00
Mike Jolley 9a23b81204 Reduce CSS specificity (https://github.com/woocommerce/woocommerce-blocks/pull/796)
* Reduce CSS specificity

* 2019 fixes
2019-08-09 15:07:05 +01:00
Albert Juhé Lluveras 708fb72288 Disable HTML editing on Featured Category (https://github.com/woocommerce/woocommerce-blocks/pull/816) 2019-08-08 17:09:41 +02:00
Albert Juhé Lluveras 6e91656677 Featured Product: hide background opacity control if there is no image (https://github.com/woocommerce/woocommerce-blocks/pull/813)
* Featured Product: hide background opacity control if there is no image

* Add explanation for FocalPointPicker check
2019-08-08 17:09:32 +02:00
Albert Juhé Lluveras 6f88bb85a2 Add tests to utils/products.js (https://github.com/woocommerce/woocommerce-blocks/pull/817)
* Add tests to utils/products.js

* Make getImageSrcFromProduct return an empty string instead of 0 when there are no images
2019-08-08 14:48:34 +01:00
Albert Juhé Lluveras 3097bb0901 Create a constants.js file with the NAMESPACE value (https://github.com/woocommerce/woocommerce-blocks/pull/799)
* Create a constants.js file with the  NAMESPACE value

* Created 'ENDPOINTS' constant instead of 'NAMESPACE'

* Use NAMESPACE in constants.js
2019-08-07 16:47:01 +02:00
Darren Ethier 2d5b06f07a Introduce withSearchedProducts higher order component and refactor ProductsControl Component (https://github.com/woocommerce/woocommerce-blocks/pull/791)
* add new withSearchedProducts hoc

includes tests

* convert to functional component and wrap with new hoc

* remove dependency between tests

* Fix typo with PropTypes bool

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* remove unnecessary specific import

* fix bug introduced on refactor for selected prop recalc

* fix tests that were testing the wrong expectation

- also improved mocks a bit so they are a bit more realistic for the purpose of the test coverage.

* remove unnecessary Fragment

* tweak propType definitions and remove defaults

- this keeps argument expectations in sync with wrapped component and reduces chance of unexpected behaviour if `SearchListControl` logic changes.

* remove lodash.find dependency.
2019-08-06 11:34:13 -04:00
Mike Jolley 918f822128 Disable HTML editing on dynamic blocks (https://github.com/woocommerce/woocommerce-blocks/pull/801)
* Disable HTML editing on dynamic blocks

* Tabindex case
2019-08-06 15:10:01 +01:00
Mike Jolley 6a6d280eb0 Add product search block (https://github.com/woocommerce/woocommerce-blocks/pull/697)
* basic scaffold

* Progress

* Fix saving

* Move data to form

* Update assets/js/blocks/product-search/editor.scss

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/blocks/product-search/block.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* hex case

* Use a span element

* Move render method

* CSS

* Update buttons

* Fix navigation buttons

* remove webkit appearance styles for buttons

* Swap rich to plain text component

* Improved attribute handling

* Update assets/js/blocks/product-search/block.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>
2019-08-05 11:25:57 +01:00
Albert Juhé Lluveras 8a187db5d9 Move withComponentId to hocs directory (https://github.com/woocommerce/woocommerce-blocks/pull/797) 2019-08-05 10:37:16 +01:00
Albert Juhé Lluveras 2504bffdfa Create `withProduct` HOC (https://github.com/woocommerce/woocommerce-blocks/pull/779)
* Reset 'loaded' state in Featured Product and Category blocks

* Minor code improvements

* Remove state from ApiErrorPlaceholder

* Move getProduct to a HOC

* Undo changes in Featured Category

* Update proptypes

* Move error messages to <ApiErrorPlaceholder>

* Reorder props

* Move lifecycle methods to HOC

* Make <FeaturedProduct> component presentational

* Move withProduct to js/hocs

* Create NAMESPACE constant in utils

* Create getProduct util function

* Set 'error' and 'product' state to null instead of 'false' when they have no value

* Prevent getImageSrcFromProduct and getImageIdFromProduct returning an error when 'product' is not an object

* Add HOC tests

* Use 'toBe' and 'toBeNull' jest expect methods instead of 'toEqual' when possible

* Export HOCs from index

* Move mock implementation to beforeEach
2019-08-02 13:56:53 +02:00
Albert Juhé Lluveras c1c4d235b1 Fix ComponentId camelCase 2019-07-30 16:26:35 +01:00
Mike Jolley 5789a74409 Reduce number of dependencies for the product categories list block (https://github.com/woocommerce/woocommerce-blocks/pull/771)
* unqiueID helper to replace compose

* move get categories function to own file

* fix svg styling

* remove lodash dependency

* Refactor block/edit to use less dependencies

* Babel config to skip wp.element

* update comments

* Update assets/js/blocks/product-categories/frontend.js

ie11 compatible for each on nodelist

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* move id generation to constructor

* simplify webpack config

* Remove components CSS dependency

* use HOC for component ID

* Correct case on ComponentId
2019-07-29 13:00:26 +01:00
Albert Juhé Lluveras 9d4a76c841 Use radio buttons instead of checkboxes in Featured Category control (https://github.com/woocommerce/woocommerce-blocks/pull/756) 2019-07-22 13:41:35 +02:00
Albert Juhé Lluveras 1cbef7dd39 Cancel debounced functions on unmount (https://github.com/woocommerce/woocommerce-blocks/pull/725) 2019-07-12 12:20:42 +01:00
Mike Jolley ac74504400 Experiment: Handling API fetch errors (https://github.com/woocommerce/woocommerce-blocks/pull/679)
* error handling

* Update assets/js/blocks/featured-product/block.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/blocks/featured-product/block.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Move to dedicated component

* escape messages and remove debug code

* merge conflict

* move renderApiError

* Revert "move renderApiError"

This reverts commit 2d5ffdecf2fae66434ac16b71d9b349fa1b61783.

* Revert "merge conflict"

This reverts commit bdc8eb4bd0f8dd5e4525c758fe3e79ffeefff3f5.

* Update assets/js/components/api-error-placeholder/index.js

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update error notice
2019-07-11 11:12:44 +01:00
Mike Jolley c7b608a3d0 Introduce a new Products by Tag(s) block (https://github.com/woocommerce/woocommerce-blocks/pull/554)
* Introduced WGPB_Extend_Core class to modify shortcodes and API requests of core

* Require the new class

* WC_REST_Blocks_Products_Controller_V2 to override the wc-blocks API to support new tags properties

* Register new products by tag block type

* Modify utils to support tags and tag_operators

* Add ProductTagControl to handle tag searching

* Add the actual products by tag block

* Set limitTags to 100

* Create Package class and use in main plugin file

* Move and refactor library class - split asset methods into new Assets class.

* Add jetpack autoloader dependency

* fix tests

* Update from master

* AbstractBlock class for general block registration

* remove test autoloader so tests do not break

* Create AbstractProductGrid

* FeaturedProduct

* HandpickedProducts

* ProductBestSellers

* ProductCategory

* ProductNew

* ProductOnSale

* ProductTopRated

* ProductsByAttribute

* Remove old base and render functions

* Allow non-dynamic blocks and register category block

* Fix products-by-attribute due to wrong naming

* Remove no dev

* test phpunit dir

* Update testing framework

* Update with new abstract classes and build in API

* Undo edit to attribute block

* Move edit mode

* No need to support shortcodes

* correct linting errors

* Update tests/bootstrap.php

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update code comment to make more sense.

* Correct test package

* docblock

* Fix cancel button class

* Fix classname schema

* Set loading state so spinner is shown

* Add placeholder element when no tags are selected

* No tags placeholder

* Update rest endpoints
2019-07-09 14:42:22 +01:00
Mike Jolley b528868ea1 Featured Category Block (https://github.com/woocommerce/woocommerce-blocks/pull/676)
* Block JS

* Add block to library and configure build

* Update API to return image and link

* Limit category selection to 1

* Frontend

* Fix variable

* Add icon

* Rename to isSingle

* Standardize naming

* fix wrapping issue
2019-07-09 12:38:44 +01:00
Albert Juhé Lluveras e54a33b501 Add pre-commit CSS and JS linting (https://github.com/woocommerce/woocommerce-blocks/pull/699) 2019-07-09 11:50:09 +01:00
Albert Juhé Lluveras 8af3fa0ed2 Fix Featured Product block using a Handpicked Products block CSS class (https://github.com/woocommerce/woocommerce-blocks/pull/700) 2019-07-09 11:02:18 +01:00
Mike Jolley 5362b468dc Featured Product Block: Make it possible to feature a specific product variation (https://github.com/woocommerce/woocommerce-blocks/pull/608)
* Duplicate SearchListControl into ProductSearchListControl component

* Undo control copy; it's not needed

* Variation search + counts showing

* Dropdown styling (also fixed SVG icon markup in SCSS file)

* Style the variation count

* Handle variation display on frontend and backend

* Fixed selection callbacks hooray

* Extend v3 api to return name. Use v3 API for featured product block.

* Switch description based on type

* Fix isSelected check

* Define a11yProps

* Variations rest endpoint

* Remove isTertiary

* REST endpoints with variation handling

* Handle variation data frontend

* Handle variation data in editor

* renamed description schema

* tweak variation display

* Update assets/js/components/product-control/style.scss

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Flip icon direction

* Use classnames

* fix isSingle warning

* standards

* Only try to load variations if product has them
2019-07-09 10:48:31 +01:00
Mike Jolley dc8d1f4c0a Add placeholder when no categories exist to list (https://github.com/woocommerce/woocommerce-blocks/pull/678)
* Add placeholder when no cats exist

* remove pointless backgrounc color rule

* remove lodash isempty call
2019-07-04 16:05:59 +01:00
Mike Jolley 882e8ad322 Introduce `ToggleButtonControl` for Product Category List display type (https://github.com/woocommerce/woocommerce-blocks/pull/675)
* Toggle control component

* README

* Use toggle component for list settings
2019-07-03 15:39:10 +01:00
Mike Jolley 55f9951d2e Abstract block refactor (https://github.com/woocommerce/woocommerce-blocks/pull/656)
* Create Package class and use in main plugin file

* Move and refactor library class - split asset methods into new Assets class.

* Add jetpack autoloader dependency

* fix tests

* Update from master

* AbstractBlock class for general block registration

* remove test autoloader so tests do not break

* Create AbstractProductGrid

* FeaturedProduct

* HandpickedProducts

* ProductBestSellers

* ProductCategory

* ProductNew

* ProductOnSale

* ProductTopRated

* ProductsByAttribute

* Remove old base and render functions

* Allow non-dynamic blocks and register category block

* Fix products-by-attribute due to wrong naming

* Remove no dev

* test phpunit dir

* Update testing framework

* Update package name

* Classname changes from master

* get_schema_string/classname from master

* Update tests/bootstrap.php

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update src/BlockTypes/AbstractProductGrid.php

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>
2019-07-01 15:26:06 +01:00
Mike Jolley 3678beab97 Move main controllers from assets/php to src (https://github.com/woocommerce/woocommerce-blocks/pull/655)
* Create Package class and use in main plugin file

* Move and refactor library class - split asset methods into new Assets class.

* Add jetpack autoloader dependency

* fix tests

* Update from master

* Update testing framework

* Update package name

* Classname changes from master

* Indent
2019-07-01 13:52:44 +01:00
Albert Juhé Lluveras a398ab6b09 Allow additional CSS classes to Featured Product block 2019-07-01 12:37:50 +01:00
Albert Juhé Lluveras 0ad3d661d0 Changes from woocommerce/woocommerce-blocks#661 2019-07-01 12:37:43 +01:00
Albert Juhé Lluveras 33e806ea9e Display Product Categories List block additional CSS class in the editor 2019-07-01 12:33:28 +01:00
Mike Jolley 5b9b91d4bc Merge branch 'experiment/cancel-button' 2019-06-27 12:22:07 +01:00
Mike Jolley 0c1ad3e995 Add button alignment option to product grid blocks (https://github.com/woocommerce/woocommerce-blocks/pull/606)
* Add alignButtons handling and styling to grid-base

* Add ToggleControl and alignButtons attribute to handpicked products

* Pass alignButtons to the blocks with sharedattributes

* Add alignButtons to shared-attributes.js

* Add alignButtons to products-by-attributes block

* Add alignButtons to attributes on the PHP side

* Add alignButtons control to grid-layout-control

* Remove alignButtons from deprecated definitions

* has-aligned-buttons

* Update comment

* package lock
2019-06-27 12:13:02 +01:00
Mike Jolley 51ece61df6 Update namespaces to include Automattic prefix (https://github.com/woocommerce/woocommerce-blocks/pull/653)
* Update namespaces with Automattic prefix.

* Use static methods for stateless class
2019-06-27 11:28:52 +01:00
Mike Jolley 8bc02c3b0c Include blocks api in feature plugin (https://github.com/woocommerce/woocommerce-blocks/pull/628)
* Progress moving endpoints

* Handle rest api registration

* Add tag_operator to blocks API

From https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/555

* Unit tests

* update travis

* Composer before install

* Travis config

* switch dir running composer

* nodev mode
2019-06-27 11:03:21 +01:00
Kelly Dwan 4c941191ba Release version 2.2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/651)
* Version bump to RC

* Add json files to built package

* Center images in product columns

* Update changelog, bump version to final
2019-06-26 12:37:50 -04:00
Kelly Dwan 559bbc6858 Product Categories List: add a placeholder on save (https://github.com/woocommerce/woocommerce-blocks/pull/650)
* Product Categories List: add a placeholder on save

This is saved to the database so that we have a placeholder view while waiting for the categories component to render.

* Use `classList.remove` for better readability

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>
2019-06-26 09:27:57 -04:00
Kelly Dwan 58cd36a35c Product Categories List: Update dropdown view (https://github.com/woocommerce/woocommerce-blocks/pull/647)
* Add the hierarchy display to the dropdown

* Add navigation for when a category is selected in the dropdown

* Use forEach from lodash for ie11 compat

* Switch to a button-click navigation pattern for better keyboard support

* Try the hidden attribute on option
2019-06-25 10:16:04 -04:00
Kelly Dwan 6526e398f0 Product Categories List: Add the links into the rendered block (https://github.com/woocommerce/woocommerce-blocks/pull/637)
* Add `isPreview` prop to be used when in editor preview

* Add product category link to the categories object

* Add the link to the `a` if we're not in the preview mode
2019-06-24 08:52:43 -04:00
Kelly Dwan 27345f93a2 Add/block product categories (https://github.com/woocommerce/woocommerce-blocks/pull/613)
* Add initial work for Product Categories List block

* Add empty category toggle

* Add option to show list as a dropdown

* Fix console warnings

* Only show proptypes linter warning if the component declares proptypes

* Add frontend script to render the product categories

* Split wcSettings & wc_product_block_data globals so that the later can be used from the frontend

* Remove wp dependencies, these are added by the webpack script now

* Capture all "woo packages" into a separate script chunk

These require `wcSettings`, which can't be available on the frontend - but we do need vendors on the frontend.

* Rewrite component into a function

* Fix validation error on editor reload
2019-06-17 10:23:59 -04:00
Kelly Dwan ed36d76ff9 Try dependency plugin (https://github.com/woocommerce/woocommerce-blocks/pull/626) 2019-06-12 11:50:57 -04:00
Kelly Dwan aca692d49a Add `menu_order` as a valid orderby value (https://github.com/woocommerce/woocommerce-blocks/pull/625) 2019-06-12 10:41:29 +01:00
Kelly Dwan 30f171f707 Update all dynamic blocks (https://github.com/woocommerce/woocommerce-blocks/pull/609)
* Use the `name` prop in place of writing out the string

* Pull out `orderby` schema into reusable function

* Correct version tag

* Extract some more schema property defs into shared functions

* Move the `print_script_settings` function so the schema-related functions follow the block registration

* Set all the schema functions to be `protected`

* Remove version tags from docs

* Fix default rows fallback value
2019-06-11 09:50:42 -04:00
Mike Jolley 3a73be7dbb Introduce transient caching to grid block queries (https://github.com/woocommerce/woocommerce-blocks/pull/605)
* Utlise WC Query to handle sorting rather than setting query args manually

* Implement transient caching
2019-06-11 09:10:32 -04:00
Kelly Dwan 75ec6a48c2 Remove the styles build target in webpack (https://github.com/woocommerce/woocommerce-blocks/pull/610)
The CSS can be imported into the “global” JS file now
2019-06-10 12:47:14 -04:00
Kelly Dwan bfa7724fe3 Add dynamic rendering + SSR to Products by Attribute (https://github.com/woocommerce/woocommerce-blocks/pull/602)
* Add dynamic rendering + SSR to Products by Attribute

* Fix spacing lint issue
2019-05-28 13:11:25 +01:00
Kelly Dwan e0ff109781 Add dynamic rendering + SSR to the Top Rated Products block (https://github.com/woocommerce/woocommerce-blocks/pull/600) 2019-05-28 13:06:12 +01:00
Kelly Dwan 9cb681fcf2 Add dynamic rendering + SSR to Best Selling Products block (https://github.com/woocommerce/woocommerce-blocks/pull/599) 2019-05-28 13:00:49 +01:00
Kelly Dwan 751bbfcbb2 Add dynamic rendering + SSR to Hand-picked Products block (https://github.com/woocommerce/woocommerce-blocks/pull/595)
* Move the contentVisibility schema into a separate function

This attribute is common even amongst blocks that don’t use shareAttributes, so we should make it reusable

* Add dynamic rendering + SSR to Hand-picked Products block

* Add block deprecation

* Update the posts_per_page to include all selected products
2019-05-28 11:43:57 +01:00
Mike Jolley 1fb893e3f4 Add Woo icon and branding to block categories (https://github.com/woocommerce/woocommerce-blocks/pull/581)
* remove php insertion of block category

* Add an SVG icon for the woo logo

* Add block-category.js to import into blocks

This creates the category icon complete with a Woo SVG icon

* Import block-category to all blocks that use it

* Style woocommerce blocks in woo purple

* Lint error

* fillRule case

* Update propTypes

* Use foreground prop instead of css

* Convert Woo Logo to ICON type component

* Add shared blocks.js to house the category code

* Calculate width from height
2019-05-28 11:18:07 +01:00
Mike Jolley 2eb750881a Update dynamic block styles and markup for default themes (https://github.com/woocommerce/woocommerce-blocks/pull/576)
* Add missing escape

* Revise product structure and introduce woocommerce_blocks_product_grid_item_html filter

* Add missing block-button/price styles

* Add a themename body class to allow per-theme styling

* Add WC style dependencies so block styles are loaded last

* Styles with greater specificicity, for 2019

* Default theme styling

* SF styles

* Ensure dependencies exist

* Split sale badge HTML to allow it to be moved more easily

* Load stylesheet via WooCommerce filters to ensure they load later than core styles

* Make structure in the editor match the product lists on frontend so styles are inherited

* Remove quotes around single fontnames (linting rules)

* Ensure there is spacing between blocks

* Use parent theme name in body class

* Fix column alignment in editor by removing inline max width

* Put back block styles

* Started adding shared styles

* Update default styles/add missing shared styles

* lint errors

* fix indent

* No longer a need for shared since we're loading style.css in the editor too

* Update tests
2019-05-28 11:17:45 +01:00
Mike Jolley 18d81328c1 Add text when no categories are selected 2019-05-24 12:38:26 +01:00
Mike Jolley a14ab46778 Merge branch 'master' into experiment/cancel-button 2019-05-24 12:06:07 +01:00
Mike Jolley bff9b8bf00 Overwrite changes when using sidebar 2019-05-24 12:01:24 +01:00
Kelly Dwan 40c551dba4 Add dynamic rendering + SSR to Products By Category block (https://github.com/woocommerce/woocommerce-blocks/pull/596) 2019-05-23 12:23:15 +01:00
Mike Jolley 0d3bce262f Styling 2019-05-23 11:34:13 +01:00
Mike Jolley 7f1e8acb78 Fixed panel editing/feedback 2019-05-23 11:28:24 +01:00
Kelly Dwan f6e5457f4b Dynamic grid blocks: Try using ServerSideRender component for preview (https://github.com/woocommerce/woocommerce-blocks/pull/565)
* Add grid block base class to handle rendering all grid blocks

Using code from the shortcode handler to create the query, subclass into newest product to show use

* Update preview content to match rendering from the new grid block handler

* Fix the categories query builder

* Update order of rating/price

* Remove center alignment

* Extract rating & button into separate functions

* Wrap the content in a link

* Add the current class names for better theme support

* Fix some styling in editor preview & frontend

* Add back the deprecated cols support for existing blocks

* Add multiple-rows class, style tweaks

* Switch Newest Products to dynamic rendering, deprecate existing shortcode method

* Add “On Sale” flag

* Switch “On Sale Products” to dynamic rendering

* Fix reusable block preview

* Add correct classes to On Sale Products

* Remove dynamic blocks from CSS hidden content rules

Content is not output to browser now, so we don’t need to hide it

* Fix undefined parameters

* Fix attributes for on sale

* Add deprecation comment, use more descriptive function name

* Addressing review feedback

* Update test: classnames have changed, image now wrapped in div

* Disable HTML editing for dynamic blocks

* Moved rendering logic into block library

* Try using ServerSideRender component for preview

* Define the schema for contentVisibility

This ensures the API correctly uses boolean instead of “true”/“false” strings

* Move the star rating CSS to the general grid-blocks section

* Remove the list styling, which is added back by core GB styles

* Fix stylelint issues
2019-05-21 16:34:48 -04:00
Mike Jolley ad1d47f3fd Implement cancel button + state management 2019-05-21 13:58:52 +01:00
Mike Jolley 7e19eefa82 Cancel styles 2019-05-21 13:58:35 +01:00
Mike Jolley e096666211 Update/dynamic grid blocks html (https://github.com/woocommerce/woocommerce-blocks/pull/567)
* Add grid block base class to handle rendering all grid blocks

Using code from the shortcode handler to create the query, subclass into newest product to show use

* Update preview content to match rendering from the new grid block handler

* Fix the categories query builder

* Update order of rating/price

* Remove center alignment

* Extract rating & button into separate functions

* Wrap the content in a link

* Add the current class names for better theme support

* Fix some styling in editor preview & frontend

* Add back the deprecated cols support for existing blocks

* Add multiple-rows class, style tweaks

* Switch Newest Products to dynamic rendering, deprecate existing shortcode method

* Add “On Sale” flag

* Switch “On Sale Products” to dynamic rendering

* Fix reusable block preview

* Add correct classes to On Sale Products

* Remove dynamic blocks from CSS hidden content rules

Content is not output to browser now, so we don’t need to hide it

* Fix undefined parameters

* Fix attributes for on sale

* Add deprecation comment, use more descriptive function name

* Addressing review feedback

* Update test: classnames have changed, image now wrapped in div

* Disable HTML editing for dynamic blocks

* Moved rendering logic into block library

* Update HTML rendering for products and remove core template functions

* Update styling

* Put the wp block class back

* Remove style import

* Move container classes to div not the ul

* Remove visibility classes

* Avoid rending non-visible items

* Revert style additons for visbility

* Fix CSS now that class names have shifted
2019-05-16 17:30:40 +01:00
Kelly Dwan a03a9d759b Try dynamic blocks for rendering content (replacing shortcode output) (https://github.com/woocommerce/woocommerce-blocks/pull/558)
* Add grid block base class to handle rendering all grid blocks

Using code from the shortcode handler to create the query, subclass into newest product to show use

* Update preview content to match rendering from the new grid block handler

* Fix the categories query builder

* Update order of rating/price

* Remove center alignment

* Extract rating & button into separate functions

* Wrap the content in a link

* Add the current class names for better theme support

* Fix some styling in editor preview & frontend

* Add back the deprecated cols support for existing blocks

* Add multiple-rows class, style tweaks

* Switch Newest Products to dynamic rendering, deprecate existing shortcode method

* Add “On Sale” flag

* Switch “On Sale Products” to dynamic rendering

* Fix reusable block preview

* Add correct classes to On Sale Products

* Remove dynamic blocks from CSS hidden content rules

Content is not output to browser now, so we don’t need to hide it

* Fix undefined parameters

* Fix attributes for on sale

* Add deprecation comment, use more descriptive function name

* Addressing review feedback

* Update test: classnames have changed, image now wrapped in div

* Disable HTML editing for dynamic blocks

* Moved rendering logic into block library

* Remove unnecessary !important on styles
2019-05-16 14:03:11 +01:00
Kelly Dwan 0e68c9b12c Update and add documentation in READMEs (https://github.com/woocommerce/woocommerce-blocks/pull/551) 2019-05-09 10:45:09 -04:00
Kelly Dwan fccb6737eb ProductControl: Update product search performance (https://github.com/woocommerce/woocommerce-blocks/pull/547)
* Move the products API utilities to a shared folder

* Use the `onSearch` callback when we have a “large catalog”
2019-05-03 10:38:13 -04:00
Kelly Dwan e8fb6e7c94 Add "FocalPointPicker" to Featured Product block (https://github.com/woocommerce/woocommerce-blocks/pull/544)
* Add FocalPointPicker to featured product block

* Disable the media icon if no product is selected

* Use the focal point on the frontend display

* Check for `FocalPointPicker` before using it (compat for WP 5.1)

* Check if focalPoint attribue is an array before trying to use it
2019-05-03 10:37:52 -04:00
Kelly Dwan 8bc7adbee4 Grid Blocks: Prevent invalid parameter passed to API (https://github.com/woocommerce/woocommerce-blocks/pull/543)
* Prevent invalid parameter passed to API

per_page cannot be greater than 100, but the frontend does support a larger limit

* Add tests
2019-04-30 16:30:43 -04:00
Kelly Dwan 7bac46f286 Move conflict check to init action (https://github.com/woocommerce/woocommerce-blocks/pull/534)
Checking the feature plugin version on `init` ensures the constant is defined before we get to it, which is not guaranteed in `__construct` due to potential different load orders.
2019-04-19 12:33:04 -04:00
Kelly Dwan 3920836287 Update ProductsControl to use API search when product catalog is large (https://github.com/woocommerce/woocommerce-blocks/pull/515)
* Move query path into constant

* Add catalog size as a preloaded setting

* Pass a search callback to SearchListControl

This will limit the number of products loaded, and update the product list via an API call, when there are over 200 products

* Extract the API requests into a separate file

* Fix proptype warning

* Only trigger the selected request if there are selected products

* Add new `@wordpress/*` dependencies from wc package bumps

* Move the "large catalog" check to the server side

* Update to components@2.0.0
2019-04-12 11:47:29 -04:00
Kelly Dwan 23532701dd Fix fatal with 1.x versions of the feature plugin (https://github.com/woocommerce/woocommerce-blocks/pull/502)
* Add plugin version check to prevent fatal error with core + 1.4

* Version bump
2019-03-22 10:42:01 -04:00
Kelly Dwan d2f1aa6c44 Update grid blocks preview to match width of products on the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/489)
* Update grid blocks preview to match width of products on the front end

* Remove max-width from CSS, set it on the preview itself so we can use the dynamic theme width

* Override block thumbnail width for multiple column layouts

Previously larger thumbnails would cause multiple column layouts to break and wrap early. This enforces the column width for those cases

* Add the thumbnail size to images, to prevent larger images in multiple col layouts

* Update snapshot to new preview markup
2019-03-15 12:48:46 -04:00
Kelly Dwan 8ea719b140 Grid blocks: Use a different theme option name for block column/row values (https://github.com/woocommerce/woocommerce-blocks/pull/481)
* Use a different theme option name for block column/row values

* Update the default columns value
2019-03-14 10:22:29 -04:00
Kelly Dwan 7dc5187b4b Check for the existence of productId before using it (https://github.com/woocommerce/woocommerce-blocks/pull/480) 2019-03-07 17:01:53 -05:00
Kevin Killingsworth 245f472a4b Category block: select categories when none selected (https://github.com/woocommerce/woocommerce-blocks/pull/458)
* Category block: open category panel when no categories

When no categories are selected, open the category panel on initial
render.

* Add check for editMode

Don't open categories if in edit mode because the block itself has a
category selection.
2019-03-06 13:51:21 -05:00
Kelly Dwan 9fa9257430 Blocks: Add rating to grid previews (https://github.com/woocommerce/woocommerce-blocks/pull/472)
* Add rating stars to the product preview

* Add rating to the visibility controls
2019-03-06 13:50:32 -05:00
Kelly Dwan 7f78a79698 Set up plugin to be published on npm (https://github.com/woocommerce/woocommerce-blocks/pull/456)
* Move block rendering class into assets

* Update package.json for npm

* Move script registration into publish-able file

* Fix phpcs issue

* Add note about source of file

* Add wcSettings back in

* Rename files to match class name

* Add languages & includes back, so we can use this for publishing zip files

* Update documentation, versions, and add hook for wc components settings

* Update wcSettings output to use fitler

* Update version to `alpha`

* Make block library class into a singleton
2019-03-04 09:30:06 -08:00
Timmy Crawford db79f75376 Update/wc blocks/v1/products (https://github.com/woocommerce/woocommerce-blocks/pull/459)
* Update products endpoint to match core.

* Update usage of cat_operator and attr_operator

* Fix phpcs issue

* Update parameter in tests
2019-02-28 10:07:38 -08:00
Kevin Killingsworth 1288fe1c75 Remove legacy block (https://github.com/woocommerce/woocommerce-blocks/pull/457)
* Remove legacy block

This removes the legacy products block and sets the version to
v2.0.0-dev

* Remove legacy product block test

* Update plugin header version
2019-02-26 14:16:21 -06:00
Timmy Crawford 8e3d19ee6d REST API: Update usage of attributes/<id>/terms to match core. (https://github.com/woocommerce/woocommerce-blocks/pull/453)
* REST API: Update usage of attributes/<id>/terms to match core.

* phpcs fixes, i think
2019-02-26 08:11:31 -08:00
Kevin Killingsworth 7ffc11d987 Fix html in preview of product titles (https://github.com/woocommerce/woocommerce-blocks/pull/444)
* Fix html in preview of product titles

Previously the html wasn't rendered in the preview for product titles.
This renders the html.

* Update test snapshot

* Also decode html for featured preview name.

* Un-escape HTML for featured post title render
2019-02-25 23:32:04 -06:00
Kevin Killingsworth ffc19e26ec Add transforms for shared attributes. (https://github.com/woocommerce/woocommerce-blocks/pull/448)
* Add transforms for shared attributes.

This adds transforms for the 5 blocks which share attributes:

- woocommerce/product-best-sellers
- woocommerce/product-category
- woocommerce/product-new
- woocommerce/product-on-sale
- woocommerce/product-top-rated

* Use createBlock directly and rowColumnBlockTypes

This adds rowColumnBlockTypes as an array of woocommerce/* block types
that use row and column layouts

* Move block types into utils, and use without

This uses lodash instead of without instead of difference
It also moves the block types from an index into the shared-attributes
in utils.
2019-02-25 23:31:25 -06:00
Timmy Crawford 57155e685f REST API: Change namespeace to reflect what will exist in Woo core. (https://github.com/woocommerce/woocommerce-blocks/pull/451) 2019-02-25 12:23:29 -08:00
Kelly Dwan 17ff1aa886 Blocks: Add new content controls to grid blocks (https://github.com/woocommerce/woocommerce-blocks/pull/440)
* Component: GridContentControl for controlling visibility of product content

* Add the content control to all grid blocks

* Use CSS to hide the content on the front end

* Fix missing translation functions
2019-02-21 14:00:47 -05:00
Kelly Dwan 2a00a897d5 Components: Move SearchListControl to woocommerce/components (https://github.com/woocommerce/woocommerce-blocks/pull/442)
* Switch to using the SearchListControl from woocommerce/components

* Remove unused mixin
2019-02-21 13:07:08 -05:00
Kelly Dwan b14a37f7b5 Update CSS build process (https://github.com/woocommerce/woocommerce-blocks/pull/439)
* Split apart editor and frontend styles

* Remove the empty JS files after each build

* Pull out editor and style CSS files into two single, separate files
Rename products-grid CSS, add a “global” front end stylesheet

* Update style registration to use these two new global CSS files

* Merge style JS files into vendors before deleting them

* Remove empty file to fix lint error

* Check for file before reading from it

When watching, not all the file stubs are created, so this errors out.
2019-02-19 16:09:36 -05:00
Kevin Killingsworth ecb0f7741b Add catalog_visibility param to products api (https://github.com/woocommerce/woocommerce-blocks/pull/406)
* Add catalog_visibility param to products api

This adds a catalog_visibility=visible option to the product api which
will filter out any products that are excluded from the catalog.

* Add product_visibility phpunit test

* Add catalog_visibility for catalog, search, hidden

* Fix util js test

The util js test checks for query parameters, so this adds the
category_visibility = 'visible' param.

* Updated for comments

1. Added collection params
2. moved catalog_visibility default with others
2019-02-19 10:09:16 -06:00
Kelly Dwan a503af9e51 Add space between the icon and placeholder title (https://github.com/woocommerce/woocommerce-blocks/pull/421) 2019-02-18 09:48:34 -05:00
Kelly Dwan ee8e185e4d Featured Product: Remove ability to change source product (https://github.com/woocommerce/woocommerce-blocks/pull/415) 2019-02-12 10:04:36 -05:00
Kelly Dwan 299412bb0f Featured Product: Try using Button block for button (https://github.com/woocommerce/woocommerce-blocks/pull/398)
* Try using Button block for the product button

* Use the permalink for the selected product

* Fix use of templateLock prop

* Fix button component alignment
2019-02-08 18:57:58 -05:00
Kelly Dwan 1f880b309a ProductAttributeControl: Polish style, screen reader interaction (https://github.com/woocommerce/woocommerce-blocks/pull/412)
* Save attribute terms per attribute, so we don’t need to do duplicate API requests for previously fetched terms. Add spinner to loading items.

* Add count to API response

* Use terms count in displaying attribute type

* Update attribute selection code to collapse already-selected attributes

* Add a chevron icon indicating open-able attributes

* Center the loading indicator

* Remove count from attribute type & re-add it to the terms themselves
2019-02-08 14:57:56 -05:00
Kelly Dwan 388d083c2b Products by Attribute: Update block to use API, shortcode rendering (https://github.com/woocommerce/woocommerce-blocks/pull/405)
* Add “attribute selection” step before allowing terms to be selected

* Update query builder

* Use shortcode to render block

* Styling for child list items
2019-02-07 15:26:47 -05:00
Kelly Dwan 6bf837ff7a Featured Product: Allow to resize the block height (https://github.com/woocommerce/woocommerce-blocks/pull/397)
* Add ResizeableBox wrapper to component to adjust height

* Use the fixed height on the front end display of the block

* Fix display of resize handle

* Allow the default & min featured product heights to be customized by setting a new theme support keyword, `featured_block`.

* Use `min-height` on the front end display, so content is not clipped on smaller screens

* Add a wrapper div to the content, to prevent it from breaking out of the block display
2019-02-05 15:49:24 -05:00
Kevin Killingsworth dc2b4485f4 Add placeholder image for product preview (https://github.com/woocommerce/woocommerce-blocks/pull/382)
* Add placeholder image for product preview

This adds the designated placeholder image url from settings into the
wcSettings global for the blocks to use. Then uses the placeholder url
when a product doesn't have any images.

* Updated based on review notes

Using `$block_settings` instead of `$settings`
Using '' alt tag
Updated snapshot

* Add the placeholder global to test that it passes through to the preview
2019-02-01 10:45:53 -05:00
Kelly Dwan 017f0df5b7 Blocks: Restrict row/column values to only valid values (https://github.com/woocommerce/woocommerce-blocks/pull/386)
* Add a new LayoutControl component

* Use new LayoutControl to handle rows & columns settings

* Fix errors when rows or columns is empty (silently fall back to default to prevent breaking the block)

* Rename `LayoutControl` to `GridLayoutControl`
2019-01-31 17:55:54 -05:00
Kelly Dwan 5f4b6c74db Use defaultProps to set up the taxonomy control operators (https://github.com/woocommerce/woocommerce-blocks/pull/381) 2019-01-31 15:43:55 -05:00
Kelly Dwan ac96484f7a New block: Products by Attribute (https://github.com/woocommerce/woocommerce-blocks/pull/378)
* Add Products by Attribute block

* Remove attributes property from sharedAttributes

* Add operator control to Products Attribute selector

* Fix default operator queries

* Add the initial “edit mode” placeholder screen

* Style attribute selector better

* Add ‘edit mode’ toggle to toolbar

* Add orderby control
2019-01-30 16:27:56 -05:00
Kelly Dwan eee1359cc0 Fix translations, bundle complete JS translation files (https://github.com/woocommerce/woocommerce-blocks/pull/339)
* Update the translation file with strings in new JS files

* Automatically build the translation files when building the JS files

* Reorganize script+style registration so that all files for each block are grouped together

* Bundle the finished translations into the plugin

* Fix untranslated strings

* Remove the edit-blocks dependency from featured product CSS file (https://github.com/woocommerce/woocommerce-blocks/pull/342)
2019-01-17 11:58:53 -05:00
Kelly Dwan 7a67ad3c26 SearchListControl: Use the “radio” role for selecting just one item (https://github.com/woocommerce/woocommerce-blocks/pull/337) 2019-01-17 10:58:41 -05:00
renovate[bot] 0dfece4fd6 Update dependency @woocommerce/components to v1.4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/333)
* Update dependency @woocommerce/components to v1.4.0

* Fix test snapshots
2019-01-16 18:58:37 -05:00
Kelly Dwan ea4996267c Add catOperator to remaining blocks (https://github.com/woocommerce/woocommerce-blocks/pull/328) 2019-01-15 13:52:34 -05:00
Kelly Dwan 6267b32772 Featured Product block: Allow custom background image selecton (https://github.com/woocommerce/woocommerce-blocks/pull/322)
* Add media icon to toolbar, save selected media ID and src as attributes

* Use the selected image instead of the product image, if set

* Unset the selected image when a new product is selected
2019-01-14 17:22:00 -05:00
Kelly Dwan 71b448f8b6 Build: Split out vendor files into separate, shared JS & CSS files (https://github.com/woocommerce/woocommerce-blocks/pull/314)
* Add splitchunks to webpack config to combine node_modules imports into a vendors script

* Move legacy CSS into legacy folder

* Get components css without needing to use relative path

* Add vendors css file
2019-01-14 15:33:17 -05:00
Kelly Dwan 162c55d0cc Hide the legacy products block from the block inserter (https://github.com/woocommerce/woocommerce-blocks/pull/143) 2019-01-14 15:03:12 -05:00
Kelly Dwan 2201fe7db7 Remove the “Filter by Attribute” panel from products by category block (https://github.com/woocommerce/woocommerce-blocks/pull/321) 2019-01-14 14:53:55 -05:00
Kelly Dwan 6f2719d36b Featured Product Block: Use real product short description (https://github.com/woocommerce/woocommerce-blocks/pull/315) 2019-01-14 14:53:30 -05:00
James Koster 9c414cac0a Featured Products style tweaks (https://github.com/woocommerce/woocommerce-blocks/pull/316)
* Update search list item padding

* Fix search list item radio alignment

* Star icon: Material -> Dashicons

* Featured product min height

* placeholder icon + explanation of explicit height value

* Fix linter errors

* Remove unnecessary Icon from block registration

* Remove the star icon
2019-01-14 14:37:35 -05:00
Kelly Dwan 0d720183aa Add "Featured Product" block preview (https://github.com/woocommerce/woocommerce-blocks/pull/308)
* Add classnames package

* Add background image & initial styles

* Only show inspector controls when not in edit-mode

* Add overlay color + opacity controls

* Add content alignment

* Fix display of content

* Add content toggles

* Update styles from feedback

* Display the "Featured Product" block on the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/310)

* Add render_callback to dynamically render product

* Set a size for the product description

* Remove fallback placeholder image

* Reset the background color for the placeholder component

Previously this was overriding storefront's custom background color CSS

* Update nested conditional

* Remove unnecessary style

* "Featured Product" Block: Add link to the product to the block (https://github.com/woocommerce/woocommerce-blocks/pull/311)

* Featured Product Block: Add link to the product to the block

* Add a better link label for screen reader users

* Match core button styles, fix alignment of button-link
2019-01-13 12:22:15 -05:00
Kelly Dwan 64e46b8f8e Add ProductControl, update SearchListControl to pick a "single item" (https://github.com/woocommerce/woocommerce-blocks/pull/304)
* Add a prop to turn on “single choice” mode

* Create new ProductControl to select a single product

* Remove align from shared attributes

This is given to us by default for using supports.align

* Add Featured Product block

* Fix spelling mistake & copy-paste issue

* Fix lint warning

* Add featured product script to build process, register block in PHP
2019-01-10 14:01:49 -05:00
Kelly Dwan 6a1c1490cb Split blocks into separate JS files (https://github.com/woocommerce/woocommerce-blocks/pull/305)
This lets us use the functionality of `register_block_type` to automatically enqueue the scripts and styles used by blocks in the editor, and eventually, styles on the frontend as well. Also adds cssnano to minify our CSS.
2019-01-10 13:16:37 -05:00
Kelly Dwan 86874a64e6 Icons: add star and radio button icons, organize folder (https://github.com/woocommerce/woocommerce-blocks/pull/303)
* Split out icons into individual files, add radio icons

* Add star icon

* Fix SVG output in tests
2019-01-09 15:33:10 -05:00
Kelly Dwan 79574a6450 Products by Category: don't show products if no category is selected, better message (https://github.com/woocommerce/woocommerce-blocks/pull/281)
* Prevent Products by Category from showing all products when no category is selected

* Update string when no categories are selected

* Update button text

* Revert button change, Done is more appropriate
2019-01-04 16:34:37 -05:00
Kelly Dwan bc53626f1d Hide the selected items section until the content is loaded (https://github.com/woocommerce/woocommerce-blocks/pull/282)
This will prevent the inaccurate “0 items selected” message
2019-01-03 11:16:00 -05:00
Kelly Dwan 03eaddd197 New block: add "Hand-picked Products" block (https://github.com/woocommerce/woocommerce-blocks/pull/276)
* Add ProductsControl component to search and select products

* Add “Hand-picked Products” block

* Update hand-picked & new product icons

* Prevent API request when no products are selected

* Remove rows setting

* Update shortcode/query helpers for the handpicked products

* Remove shortcode from post if no product IDs are passed

Rendering a shortcode with `ids=‘’` will show all products, as if the ids param wasn’t there. The expected outcome would be no products are shown, we we achieve by removing the shortcode.

* Remove unused rows attribute

* Update accessible spoken notice

* Add a variable to hold whether there are selected products

* Fix copy-paste comments
2018-12-21 19:10:17 -05:00
Kelly Dwan 6d06990123 Visually hide the “any”/“all” categories selector when less than 2 categories are selected (https://github.com/woocommerce/woocommerce-blocks/pull/279) 2018-12-21 12:45:07 -05:00
Kelly Dwan 32b5b07c23 Add ProductAttributeControl for selecting product attributes (https://github.com/woocommerce/woocommerce-blocks/pull/266)
* Add initial attribute selector control

* Make the attribute group name unselectable

* Update selected map to reflect attribute syntax

* Add the attributes selector to the product category block

* Update copy-paste comment

* Update variable name to be more clear

* Move & rename the attribute selector in Products by Category

* Reorganize the API calls to fetch attributes + attribute terms
2018-12-20 17:26:51 -05:00
Kelly Dwan c8775aa4e1 Fix the spacing around the “edit mode” of Products by Category (https://github.com/woocommerce/woocommerce-blocks/pull/273) 2018-12-19 17:35:41 -05:00
Kelly Dwan ba8ce223cf Use em-dashes to indent child categories/attributes instead of padding (https://github.com/woocommerce/woocommerce-blocks/pull/265) 2018-12-19 17:34:28 -05:00
Kelly Dwan 18f99101e2 Fix multiple API calls returning out of order, causing set rows to be incorrect (https://github.com/woocommerce/woocommerce-blocks/pull/264) 2018-12-19 17:18:13 -05:00
Kelly Dwan aa9f543834 Add new SearchListItem component (https://github.com/woocommerce/woocommerce-blocks/pull/258)
* Add new SearchListItem component

Extract the custom functionality from product categories, for re-use in product attributes

* Fix error when no breadcrumbs are set

* Update snapshot

* Remove unnecessary key
2018-12-19 11:56:44 -05:00
David Levin 5af019bcd7 New Block: Add "Newest Products" Block (https://github.com/woocommerce/woocommerce-blocks/pull/255)
* add newest products block

* update class name in index.js and product-new.js

* Add a new WooCommerce block category and include all blocks within.

* Fix shortcode product order

* Show block category on all post types
2018-12-18 14:45:49 -05:00
Kelly Dwan 48cd95d64d Move icon components to a shared component, add New Releases SVG (https://github.com/woocommerce/woocommerce-blocks/pull/257) 2018-12-17 15:51:10 -05:00
Kelly Dwan 3bccfda459 Category Selection: Add support for category operator (https://github.com/woocommerce/woocommerce-blocks/pull/251)
* Add core breakpoint 480px, remove non-core breakpoints

* Add the optional operator & save callback

* Add the catOperator as a valid attribute

* Enable cat operator for Products by Category

* Add cat_operator support the products API endpoint

* Enable cat_operator in the shortcode and query utils

* Pluralize the “nothing found” string if we have multiple categories

* Fix style in the inspector panel

* Add category operator support to the Best Sellers product block

* Add cat_operator support to On Sale Products block

* Update label & margin
2018-12-17 15:16:01 -05:00
Michael Rogowski fef17476c8 Fix undefined error when selecting a product without an image (https://github.com/woocommerce/woocommerce-blocks/pull/254)
prior to this commit, an 'individual product' block would produce
an error if associated with a product with no image.
2018-12-17 15:15:32 -05:00
Kelly Dwan 395888a521 Fix mix of tabs/spaces 2018-12-15 11:41:39 -05:00
David Levin 0c9e3eb6ba resolving conflicts 2018-12-14 18:12:13 -08:00
David Levin 1bf9ab1fb5 resolve conflicts 2018-12-14 18:08:58 -08:00
David Levin 3b770feb90 remove unnecessary function from get-shortcode.js 2018-12-14 17:48:46 -08:00
Kelly Dwan 381752734b New Block: Add "On Sale Products" block (https://github.com/woocommerce/woocommerce-blocks/pull/239)
* Add “On Sale Products” block

* Remove categories requirement from fetching products on mount
2018-12-14 18:47:16 -05:00
David Levin cae9799ffc update ordering by rating 2018-12-14 12:21:56 -08:00
David Levin d30761ba2f Add top rated products block 2018-12-14 11:45:19 -08:00
Kelly Dwan 58f3764c36 Move product order list into a shared component (https://github.com/woocommerce/woocommerce-blocks/pull/238) 2018-12-14 09:57:32 -05:00
Kelly Dwan 43675515af Block: Add new "Best Selling Products" block (https://github.com/woocommerce/woocommerce-blocks/pull/221)
* Move from a JS file per block registration to one file registering all blocks

This will let webpack combine shared libraries, like gridicons

* Move global block settings to the “before all scripts” section

These shouldn’t be tied to a specific block file, since they’re used across all blocks

* Register both block types

We can also remove the scripts, since we enqueue these below

* Update getShortcode & getQuery to handle different block types

* Pass block type name to getQuery

* Update shared attributes - edit_mode is not a universal option, but categories will be

Categories is shared, but orderby is not

* Add “Best Selling Products” block

* Add a shared class name for product grid blocks

* Fix failing tests
2018-12-13 12:19:55 -05:00
Kelly Dwan e3dab1cbcc Product preview: Update "Add to cart" button to inherit theme's button styles (https://github.com/woocommerce/woocommerce-blocks/pull/223)
* Remove button styling & add classes to inherit style from core button

* Update to CSS grid

* Prevent warnings when running autoprefixer

* Update spacing in preview

* Update snapshots to reflect button markup change

* Switch to flexbox for IE 11 support

* Remove CSS grid autoprefixer support

* Fix spacing on preview items

* Fix stylelint issue

* Remove unnecessary rule
2018-12-13 12:19:06 -05:00
Joshua T Flowers fed2de790c Add key prop to dropdown elements (https://github.com/woocommerce/woocommerce-blocks/pull/229) 2018-12-11 17:29:15 -05:00
Kelly Dwan a92ae1477b Remove “center” alignment option (https://github.com/woocommerce/woocommerce-blocks/pull/214) 2018-12-05 12:00:40 -05:00
Kelly Dwan 02f8aa1091 Add styles for better reusable block preview (https://github.com/woocommerce/woocommerce-blocks/pull/210)
* Add styles for better reusable block preview

* Fix class names for legacy block preview style

* Check that `products` exists before checking length

* Fix stylelint issues
2018-12-04 15:40:00 -05:00
Kelly Dwan 723c8eedab Update textdomain to plugin slug (https://github.com/woocommerce/woocommerce-blocks/pull/199)
* Update textdomain in JS files

* Update textdomain in PHP files

* Add babel plugin to create pot & php files from JS

* Update textdomain in plugin header

* Update translations after rebase
2018-12-04 09:51:21 -05:00
Kelly Dwan 6572b79708 Category Selection: Add loading & no results states (https://github.com/woocommerce/woocommerce-blocks/pull/197)
* Add gridicons dependency

* Add loading & no results states

* Update test snapshots

* Remove redundant setState call
2018-12-03 19:17:22 -05:00
Kelly Dwan 5966050367 Add `woocommerce` as a supported keyword for the block (https://github.com/woocommerce/woocommerce-blocks/pull/198) 2018-12-03 19:17:10 -05:00
Kelly Dwan f0f62b5caa Category Selection: Always show "selected" section (https://github.com/woocommerce/woocommerce-blocks/pull/192)
* Always show the selected tags section, with a min-height to prevent jumping when selecting tags

* Only show the “clear all” button if there are selected items

* Update snapshot tests

* Update height for sidebar category selection
2018-12-03 16:05:12 -05:00