Commit Graph

268 Commits

Author SHA1 Message Date
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