Commit Graph

588 Commits

Author SHA1 Message Date
Albert Juhé Lluveras 69f49760a8 Create CountyInput component (https://github.com/woocommerce/woocommerce-blocks/pull/1727)
* Split CountryInput and Select

* Create County Input

* Show text input when there are no county options

* Reset county value when changing country

* Fix keyboard navigation

* Hide checkmark

* Add reset styles for several popular themes

* Add country prop to ShippingCountyInput
2020-02-14 13:30:33 +01:00
Albert Juhé Lluveras a30615e2cb Hook up shipping methods to API (https://github.com/woocommerce/woocommerce-blocks/pull/1468)
* Create ShippingMethodsControl component

* Hook up shipping methods to API

* Add support for several packages

* Add tests to useShippingRates

* Fix shipping_rates property name

* Only show the products list if there are several packages

* Use <FormattedMonetaryAmount> to display shipping rate prices

* Make 'country' optional in CartShippingRates

* Make CartShippingRate API return currency info

* Minor improvements

* Fix shipping fields hidden in editor

* Fix missing currency in Checkout shipping rates selector

* Add links to issues in @todo comments

* Improve ShippingRatesControl useEffect

* Remove unnecessary tab

* Remove unnecessary id in RadioControl

* API: Add error when country is invalid

* Debounce shipping rates API requests

* 'Country key' -> 'Country code'

* Don't display radio input when there is only one option

* Add message when there are no results

* Minor enhacements

* Remove unnecessary Fragment

* Simplify RadioControlOption export

* Refactor 'renderOptions' and split it into several components

* Prevent Card sidebar from taking too much width

* Move country request check outside of the loop

* Fix failing test
2020-02-14 04:43:13 +01:00
Albert Juhé Lluveras 722599004a Change 'country' to 'country / region' label (https://github.com/woocommerce/woocommerce-blocks/pull/1721) 2020-02-11 18:33:41 +01:00
Albert Juhé Lluveras 85291159ae Fix Reviews blocks loading @wordpress/element in the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/1719) 2020-02-11 15:41:50 +01:00
Albert Juhé Lluveras b5638ce87c Update Attribute Filter strings to ease translation (https://github.com/woocommerce/woocommerce-blocks/pull/1718) 2020-02-11 15:41:42 +01:00
Seghir Nadir a39426495d Give Woo Icon special treatment by making it a component (https://github.com/woocommerce/woocommerce-blocks/pull/1702)
* fix broken woo icon

* treat woo icon in a special way

* fix propType typo
2020-02-10 14:24:02 +01:00
Seghir Nadir 8e3ac17585 Introduce feature flags (https://github.com/woocommerce/woocommerce-blocks/pull/1631)
* introduce feature flags

* move config to webpack-helper

* add flag to deploy command

* remove package default

* add cross-env

* add gating to frontendConfig and coreConfig

* exclude entries from being built on stable mode

* add feature gating to PHP

* add flag to start command

* add flags to travis

* add endpoints

* add better defaults for php

* move code to Bootstrap.php

* no need to spread single object

* ignore blocks.ini

* type check feature flag

* remove blocks.ini

* sanitize flag

* remove flag from npm start

* format condition

* keep spaces for package-lock.json

* check for env before going to block ini

* add env vars to travis

* whitelist env var
2020-01-31 21:04:37 +01:00
Seghir Nadir bfb2f33bfd add new icons and remove old ones (https://github.com/woocommerce/woocommerce-blocks/pull/1644)
* add new icons and remove old ones

* add docs

* add notes and remove gridicons

* update to folderStarred

* typos

* reorder imports

* update prop name to srcElement

* validate element

* fix bad import

* lowecase folderStarred

* add propTypes
2020-01-31 19:20:33 +01:00
Mike Jolley ca8efd7c3e Add API fetch error handling (https://github.com/woocommerce/woocommerce-blocks/pull/1687)
* initial experiment for fetch error handling

* throw error from api response error (this allows for catching it in the stream)

* Add ERROR action type

* Controls: resolve with an error response object rather than throw exception

* remove try catch from resolver; just yield correct object based on presence of any errors

* Make the use collection hook return an error.

* Small tidy up in use-store-products

* Throw exception from Use Collection - useState is needed for the exception to work inside a hook (see comments)

* Show error code from API in error message

* Update assets/js/base/components/block-error-boundary/block-error.js

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

* Update assets/js/base/components/block-error-boundary/style.scss

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

* Remove comment

* Handle api error in boundry

* Use reject in promise

* Return error message by default which may be undefined (this is ok)

* Update mocks so tests pass again

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-01-31 13:01:34 +00:00
Mike Jolley b569f53083 Add and/or labelling to active filters block (https://github.com/woocommerce/woocommerce-blocks/pull/1630)
* Add And/or labelling

* Revised design

* Update assets/js/blocks/active-filters/utils.js

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

* Add prefix so name is not changed - fixes duplicate items

* Update BEM css classes

* Update styling to handle nested lists

* Remove extra padding within chips

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-01-31 10:15:22 +00:00
Rua Haszard 7f44458418 Basic storybook implementation (https://github.com/woocommerce/woocommerce-blocks/pull/1636)
* install & configure storybook (via magic npx script)

* fix indentation in storybook generated files

* eslint ignore generated storybook files (for now at least)

* unhide storybook folder, consistent with Gutenberg project

* demo story for one of our components (with no css/styles)

* hack in scss webpack config & add story for button:
- fixes scss imports breaking storybook build
- note scss / styling doesn't work yet
+ organise our component stories into folder

* git ignore storybook-static build folder

* pin dependencies for storybook

* piggy-back off main webpack config for storybook module.rules (for scss)

* use gutenberg (wp-components) styles in storybook

* use system font for storybook, consistent with wp-admin/gberg and reasonable default for components in front end

* add --ci flag to prevent storybook opening new browser tab…
- see also https://github.com/storybookjs/storybook/issues/6201

* rename default stories to Default (following Gutenberg pattern)

* add story for ErrorPlaceholder

* failing ProductPreview story (committing to PR as an example for discussion)

* storybook for components/icons

* fix aliased dependencies in components for storybook:
append our webpack aliases to storybook webpack config

* basic story for PriceSlider (looks right but interaction broken)

* fix PriceSlider user interaction:
- PriceSlider expects client to handle onChange and pass in new min/max

* add comment about priceslider max/min (todoish)

* remove default stories from storybook scaffolding

* organise stories by module (aka folder in codebase)

* package-lock update after rebase

* remove unnecessary ignores (default stories are gone)

* delete experimental/risky/broken stories:
- icons components are changing in woocommerce/woocommerce-blocks#1644
- we need to refactor/do more work to get ProductPreview working (settings globals)

* remove unnecessary import

* clarify PriceSlider component intended usage comment in story

* remove redundant wrapper divs from stories

* add common storybook addons (used by Gutenberg storybook)

* rebuild package.lock after rebase

* remove unnecessary wrapper div

* package fixes after rebase

* add configuration for storybook source loader

* add decorators for a11y and knobs plugins

* remove unnecessary react import & import useState from WP

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-01-31 09:59:14 +13:00
Albert Juhé Lluveras c8f297a700 All Products & filters accessibility improvements (https://github.com/woocommerce/woocommerce-blocks/pull/1656)
* Add aria-label to All Products ratings

* Add specific screen reader text to some buttons

* Increase All Products regular price color constrast

* Remove invalid CSS declaration

* Make styleint-disable comment more specific

* Attributes Filter: make input non-focusable if we display the 'change filter' button

* Improve translator documentation

* Hide price slider from screen readers if price inputs are enabled

* Linting fixes

* Price slider: make it non-focusable if input fields are displayed

* All Products: announce how many products were found

* All Products: announce when a filter is removed

* Revert "All Products: announce when a filter is removed"

This reverts commit 2c861bf1b988155313ad44bafbcaf3f4f1549296.

* Pagination component: improve screen reader texts

* Filter submit button: improve screen reader texts

* Remove unnecessary text

* Improve comment

* Use %d for numeric values

* Add label and screenReaderLabel props to FilterSubmitButton component
2020-01-30 11:04:39 +01:00
Albert Juhé Lluveras aa4bc302a5 Replace three dots with an ellipsis in Product Search placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/1672) 2020-01-30 10:28:17 +01:00
Mike Jolley 29600c501f Summary/description consistency update (https://github.com/woocommerce/woocommerce-blocks/pull/1639)
* Audit atomic block labels

* Add summary, descrtiption, and short description to API and use for summary block

* Add summary to cart item api

* Respect short description

* Tweak label of summary block

* Revert product rating label

* One description vs 3

* Update sample content with more appropriate values, and match in cart items sample

* Move summary generation to class

* Tests

* Prevent extending `ProductSummary`

* Tweak $paragraph handling

* More accurate word counting

* add tear down for filter
2020-01-29 10:59:33 +00:00
Mike Jolley b65b93e7e7 Rename the "Align Buttons" option for the All Products Block (https://github.com/woocommerce/woocommerce-blocks/pull/1659)
* Allow css to work for any element

* Rename option to specific last block rather than button
2020-01-29 10:28:40 +00:00
Mike Jolley dcf5bfa67e Fix RTL price slider display issues (https://github.com/woocommerce/woocommerce-blocks/pull/1651)
* Fix slider image direction with RTL

* Fix track position under RTL
2020-01-27 15:16:19 +00:00
Albert Juhé Lluveras 7f048ec9c4 Product grid blocks: display rating stars in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/1650) 2020-01-27 13:56:32 +01:00
Darren Ethier d54340a90e Only populate default attributes on initial mount of block. (https://github.com/woocommerce/woocommerce-blocks/pull/1640)
* Avoid looping through attributes after defaults have been set.

* remove extra method I missed and fix when state updates happen

* don’t update state if we’re not in woo blocks

This prevents non woo blocks from being re-rendered unnecessarily with the state update.

* avoid re-renders and use class property instead
2020-01-24 11:53:15 -05:00
Albert Juhé Lluveras ab51bffaa0 All Products: fix 'Add to Cart' in IE11 (https://github.com/woocommerce/woocommerce-blocks/pull/1642)
* All Products: fix 'Add to Cart' in IE11

* Default Event to null
2020-01-23 19:32:48 +01:00
Mike Jolley 24d2600d43 Move default population to class function instead of using constructor (https://github.com/woocommerce/woocommerce-blocks/pull/1638) 2020-01-23 14:11:15 +00:00
Albert Juhé Lluveras 069b42dc39 Make 'Add order notes?' string localizable (https://github.com/woocommerce/woocommerce-blocks/pull/1629) 2020-01-22 21:35:29 +01:00
Mike Jolley d1737e76c2 Change default rows for product grid blocks to 3 (https://github.com/woocommerce/woocommerce-blocks/pull/1613)
* Change default rows to 3

* Handle all products rows change via deprecation

* Prevent errors if object is undefined

* HOC to set default attribute values

* Separate default attributes from attribute definitions

* Filters to set defaults

* Fix deprecation so attributes are not reordered

* Move flters to index file and limit which blocks are affected

* Fix object assign

* Use typeof for undefined checks

* Move hoc to filter file so it has context

* Fix up comment

* Avoid mutating props

* Prevent multiple `attributes` by cloning props

* Force attributes to be saved to HTML in a specific order, and handle migration

* useEffect to set attributes and avoid prop mutation

* Switch to class component
2020-01-22 16:58:25 +00:00
Mike Jolley 69a509f184 Improved cart styling for desktop and mobile (https://github.com/woocommerce/woocommerce-blocks/pull/1587)
* Style mobile qty selector

* Add dedicated column for image and remove duplicate elements

* Tweak column headers

* Refactor cart styles to use CSS grid, and use nesting for organisation

* adjust column widths

* Remove unused div

* Fix wrapping and flexbox styles

* Add decodeEntities to alt attribute

* Use % basis

* Tweak min widths
2020-01-20 16:43:22 +00:00
Albert Juhé Lluveras e607ce2d1a Preserve query key order in All Products (https://github.com/woocommerce/woocommerce-blocks/pull/1611) 2020-01-20 13:04:13 +01:00
Mike Jolley 8b28a77f01 Consistent HTML entities in Store API (https://github.com/woocommerce/woocommerce-blocks/pull/1597)
* Wrap HTML responses with helper method

* Remove unused get_attribute_taxonomy_name method

* Create prepare_html_response method

* Decode product and attribute names

* Check is_scalar to leave objects alone
2020-01-19 19:19:59 -05:00
Seghir Nadir 7e81841e83 Fix issue in order by date (https://github.com/woocommerce/woocommerce-blocks/pull/1598)
* fix order by of date order in products
2020-01-20 00:00:43 +01:00
Rua Haszard d7be99b520 fix issue when user re-selects same attr when setting up filter block: (https://github.com/woocommerce/woocommerce-blocks/pull/1596)
- exit early if there's no selected attr passed in
2020-01-20 07:58:26 +13:00
Albert Juhé Lluveras 09f2c626f9 Make TextInput respect prefers-reduced-motion preference (https://github.com/woocommerce/woocommerce-blocks/pull/1588)
* Make TextInput respect prefers-reduced-motion preference

* Reverse prefers-reduced-motion check
2020-01-18 10:39:13 +01:00
Albert Juhé Lluveras cad3e72769 Create CountryInput component (https://github.com/woocommerce/woocommerce-blocks/pull/1585)
* Create initial CountryInput component

* Create ShippingCountryInput

* Create BillingCountryInput

* Make backgrounds white

* Correctly align options

* Add CSS resets for 20xy themes

* Fix wrong defaults in countries constants

* Make CountryInput respect 'prefers-reduced-motion'

* Reverse prefers-reduced-motion check

* Set max-width to CountryInput dropdown

* Use decodeEntities to print country names

* Avoid unnecessary JSON enconding and later parsing

* Make sure country name is also encoded when selected

* Fix countries default value
2020-01-17 17:58:08 +01:00
Rua Haszard eaa6b42d89 UI for removing cart items (not including hooking up to API) (https://github.com/woocommerce/woocommerce-blocks/pull/1579)
* correct typography styles for remove link (based on design)

* add trashcan icon from material icons, for removing cart items on mobile

* add & style trash icon for remove cart item on mobile

* a11y - use darker grey for trashcan icon button to improve contrast

* rename IconDelete -> IconTrash

* remove unnecessary div

* use <button> for remove action buttons + add link-button scss mixin

* fix editor styles for cart line items - total column should be right-aligned

* fix various visual issues with cart line items table in editor:
- rows should align hard left and right (first/last child no padding)
- totals should be align-bottom on small screen
- correct vertical padding on column headings
- re-add row border separator lines
2020-01-17 13:46:56 +00:00
Seghir Nadir 4a8c57fbe1 Focus on Full Cart mode after inserting (https://github.com/woocommerce/woocommerce-blocks/pull/1582)
* focus on the cart main block
2020-01-17 13:23:33 +01:00
Rua Haszard f3e4fc2bd4 fix react runtime js error when all products productLink=off: (https://github.com/woocommerce/woocommerce-blocks/pull/1593)
- renderedSalesAndImage is a js var holding react element;
- don't surround with (), converts to obj { renderedSalesAndImage: bla }
2020-01-17 09:50:48 +13:00
Mike Jolley 0e752e9e0d Introduce view switcher component for the cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1576)
* View switcher on cart block

* Dedicated component and styling

* Views and selected should be required

* Rename to ViewSwitcher

* Implement views via render prop

* Remove defaults for required props
2020-01-16 14:50:48 +00:00
Albert Juhé Lluveras 3f0368e63b Checkout: Fix city input field showing country value (II) (https://github.com/woocommerce/woocommerce-blocks/pull/1580) 2020-01-16 12:31:00 +01:00
Mike Jolley 86b8b7779c Add Quantity selector component for cart line items (https://github.com/woocommerce/woocommerce-blocks/pull/1558)
* Implement quantity selector component

* Improve default appearance

* Remove underline

* Add aria speak

* Improved keycode handling

* Add focus styles to buttons and inputs

* Increase constrast
2020-01-15 11:32:54 +00:00
Rua Haszard 5c85ee23cf follow up fixes on cart low stock warning badge (https://github.com/woocommerce/woocommerce-blocks/pull/1564)
* rename low stock prop inside lineitem to avoid unnecessary renders

* remove unnecessary span in low stock warning badge
2020-01-15 12:54:32 +13:00
Rua Haszard 86dca691e5 show discount on cart line items & price styling (https://github.com/woocommerce/woocommerce-blocks/pull/1548)
* show discount on cart line items (no styling)

* style line item discount badge + use correct colors for prices

* show full price inline on mobile

* move all responsive tweaks for cart prices to explicit breakpoints

* add nowrap to FormattedMoneyAmount so prices don't ever wrap

* fix misaligned full price on mobile when prices are large (edge case):
- if price strings are long, the full price stacks above line total
- previous right-margin on full price showed prices misaligned

* allow client code to add class(es) to FormattedMonetaryAmount

* add nowrap so discount badge doesn't wrap

* remove unnecessary span from discount badge +
+ more explicit `display` style for different price column elements
2020-01-15 09:52:42 +13:00
Rua Haszard b9bfef0ba4 show low stock warning badge on cart line items (incl fake test data) (https://github.com/woocommerce/woocommerce-blocks/pull/1557) 2020-01-15 09:50:32 +13:00
Albert Juhé Lluveras 11a033d862 Make RadioControl id optional (https://github.com/woocommerce/woocommerce-blocks/pull/1563) 2020-01-14 21:21:29 +01:00
Albert Juhé Lluveras 1dfcb18a90 Make TextInput id optional (https://github.com/woocommerce/woocommerce-blocks/pull/1560) 2020-01-14 20:10:50 +01:00
Rua Haszard f23dee503f show product details in cart line items: attributes (variations), product short description (https://github.com/woocommerce/woocommerce-blocks/pull/1549)
* show product variation attributes in cart line item + styling:
+ adjust font sizes & colors to match design

* show product description in cart line items…
- this commit also adds descriptions to test cart-items data
- note API does not currently return description/excerpt

* add a class to product attributes to allow custom styling
2020-01-14 12:07:52 +13:00
Seghir Nadir 5c82b2d718 add fieldset and legend to FormStep component (https://github.com/woocommerce/woocommerce-blocks/pull/1400)
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-01-13 10:21:20 -05:00
Darren Ethier 22f423866e fix errors caused by demo payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/1547) 2020-01-13 10:08:14 -05:00
Mike Jolley 5926a56602 Add Empty Placeholder for the on-sale product block (https://github.com/woocommerce/woocommerce-blocks/pull/1519)
* Add EmptyResponsePlaceholder for on sale block

* Linting

* Address feedback
2020-01-10 14:40:15 +00:00
Albert Juhé Lluveras bd2b8cb279 Add Cart totals to Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1411)
* Add Cart totals to Cart block

* Accessibility improvements

* Load vendors styles separately

* Use same shipping placeholders for cart and checkout

* Refactor how we import @wordpress/components styles so only panel styles are imported

* Remove style-loader from vendors styles build process

* Add htmlFor attribute to TotalsCouponCodeInput

* Update totalItems shape to match API

* Fix wrong total items shape using numbers instead of strings

* Rename wc-blocks classes to wc-block

* Remove unnecessary parseInt()

* Add radix to parseInt()

* Rename totalRows to totalRowsConfig

* Move placeholder content out of the component

* Use Card component for cart's sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/1423)

* Use Card component for cart's sidebar

* Split RadioControl component

* No need to use Label in RadioControlOption

* Remove no longer valid @todo comment

* Use 'checked' prop instead of 'selected' in RadioControlOption

* Rename wc-blocks classes to wc-block

* Rename wc-blocks classes to wc-block (II)

* Make sure radio control ids are unique using withComponentId

* Load PanelBody and PanelRow from last version of @wordpress/components

* Create vendors-frontend.js file

* Load wordpress-component instead of @wordpress/components from <Button> component

* Only load 'withRestApiHydration' HOC

* Make vendors-frontend a dependency of cart-frontend script

* Revert "Only load 'withRestApiHydration' HOC"

This reverts commit 9f9b9759a98047b26e7d8f04189ffe78c1d5bb06.

* Fix fieldset background
2020-01-10 15:37:27 +01:00
Albert Juhé Lluveras f339e28310 Fix prices showing two currencies in some occasions (https://github.com/woocommerce/woocommerce-blocks/pull/1515) 2020-01-10 11:22:09 +01:00
Albert Juhé Lluveras 016b6b97ec Rename wc-blocks to wc-block classname prefix (https://github.com/woocommerce/woocommerce-blocks/pull/1541) 2020-01-10 10:42:53 +01:00
Albert Juhé Lluveras aa1d8e3e56 Fix Attribute Filter not reacting to query changes (https://github.com/woocommerce/woocommerce-blocks/pull/1540) 2020-01-10 10:42:37 +01:00
Rua Haszard 0763655d42 Cart block: line-items front end initial work (https://github.com/woocommerce/woocommerce-blocks/pull/1333)
* render block on front end, add `Shopping cart` heading (baby steps)

* fake data for editing full cart + show line count in header

* add note about core/html using `is-active` class for toggle state

* reinstate work-in-progress full cart component (lost in rebase)

* reinstate full cart from master

* component for full cart title & item count + margin tweaks:
- add margin between main cart & sidebar
- add margin after cart block

* add cart items sample data + factor sample product image to module

* use sample cart data for item count

* basic table of cart line items (no styling)

* prettification

* show images for cart line items + initial table styling

* cart quantity selector component (work in progress)

* use state for cart product quantity, allow incr/decr from UI (WIP)

* replace WIP custom quantity control with number edit (temporary)

* correctly format cart line item total price

* align cart item columns with headings + indent image on desktop

* tweak css for cart line item padding on mobile so it's more explicit

* show cart line item full price if discounted

* add placeholder for cart remove item link

* switch cart table to flex layout (was table)…
This will allow us to move things around for mobile/responsive layout.

* only show cart items table header on desktop

* more cart items styling - row borders, appropriate padding +
+ move image width to variable
+ fix class name plurality for row (item not items)

* use standard $gap instead of 1em for padding/margins

* responsive (mobile) layout for cart line items:
- shift line $ total to bottom right
- stack quantity selector in product info column

* remove extraneous cart table padding on mobile

* comment about unused styles for quantity selector component

* add follow up issue for todo

* remove inappropriate href

* render srcset & sizes for cart line item product image

* remove todo comment

* switch back to table markup for cart items (in progress):
- table is more semantic, associates headers with columns

* cart line items column widths - product column is larger (60%)

* reinstate table row borders

* bottom-align line item price on mobile

* cart contents heading should be H2 + prettify

* remove unused QuantitySelector code/styles, rename main class in line with BEM

* defaults for QuantitySelector props

* variable/property name tidies - match conventions/API

* fix bug: line total price is only bottom-align on small screen

* move QuantitySelector to root of components, intended to be generally useful

* use lineItem directly for cart, specify shape in PropTypes

* rename cart components to align with "line item" rather than "product"

* rejig class names to better align with new component names & BEM style

* show cart item image correct size:
- use single column for product image and info, with flex container
- specify image width (rem instead of px)

* fix safari issue - cart product images displaying vertically stretched

* shift product name left margin from image, to account for no-image case

* experiment: bump bundlewatch size limit for cart temporarily:
- our fake data inline image is heavy
- when we switch to real API we will no longer need it

* fix issue introduced when moving margin from image to details div:
- product details needs margin on left (not right)

* fix react props issues:
- explicitly destructure image props for srcSet (vs srcset)
- use API key field for line item key instead of id, fix duplicate test id
- CartLineItemsTable takes an array of lineItems (incorrect PropTypes)

* remove redundant divs + use conventional `null` (when no full price)

* override editor styles to ensure cart product image is correct size

* move cart items editor style override to editor.css

* add an explicit readable heading for cart heading to match visual layout
2020-01-10 11:50:14 +13:00
Albert Juhé Lluveras 24fba4880b Fix minor issues with TextInput component (https://github.com/woocommerce/woocommerce-blocks/pull/1523)
* Set default value to TextInput component

* Set TextInput label transition origin

* Set default onChange function prop to noop

* Fix wrong propType name

* Remove default onChange and set it required
2020-01-09 19:06:49 +01:00
Darren Ethier b68b66542b add padding zeros to displayed prices (https://github.com/woocommerce/woocommerce-blocks/pull/1520) 2020-01-08 15:10:29 -05:00
Albert Juhé Lluveras 4be59b5ad1 Add ESLint radix rule (https://github.com/woocommerce/woocommerce-blocks/pull/1512) 2020-01-08 10:48:43 +00:00
Albert Juhé Lluveras 41633e136c Fix withFeedbackPrompt JSDoc definition (https://github.com/woocommerce/woocommerce-blocks/pull/1513) 2020-01-08 10:48:35 +00:00
Darren Ethier 8627b81c16 Add payment method api and components to checkout steps (https://github.com/woocommerce/woocommerce-blocks/pull/1349)
This adds a payment methods api to the checkout block that allows for extension to register payment methods with the block.
2020-01-06 17:28:09 -05:00
Albert Juhé Lluveras 44f70d8438 Fix Cart buttons misalignment in Firefox (https://github.com/woocommerce/woocommerce-blocks/pull/1446) 2020-01-06 12:46:00 +01:00
Albert Juhé Lluveras e082a14e3b Rename checkout classes from 'wc-blocks-xyz' to 'wc-block-xyz' (https://github.com/woocommerce/woocommerce-blocks/pull/1449)
* Rename checkout classes from 'wc-blocks-checkout' to 'wc-block-checkout'

* Rename form components classes from 'wc-blocks-checkout' to 'wc-block-checkout'

* Rename 'wc-components' class names to 'wc-block'
2020-01-03 15:23:49 +01:00
Albert Juhé Lluveras 892a56364c Fix empty cart inner blocks disabled (https://github.com/woocommerce/woocommerce-blocks/pull/1447) 2020-01-03 15:22:50 +01:00
Albert Juhé Lluveras 0a78174d25 Checkout: Fix city input field showing country value (https://github.com/woocommerce/woocommerce-blocks/pull/1467) 2020-01-02 17:36:56 +01:00
Albert Juhé Lluveras 5701f7d6c9 Price filter: allow any numeric input (https://github.com/woocommerce/woocommerce-blocks/pull/1457)
* Price filter: allow any numeric input in inputs

* Price filter: allow negative numbers in input fields (https://github.com/woocommerce/woocommerce-blocks/pull/1458)

* Price filter: allow negative numbers in input fields

* Always update input fields based on minPrice and maxPrice

* Don't default values to 0
2020-01-02 14:07:59 +01:00
Albert Juhé Lluveras 03bfa7d5a5 Remove outdated comments from useStoreProducts (https://github.com/woocommerce/woocommerce-blocks/pull/1466) 2020-01-02 14:00:50 +01:00
Albert Juhé Lluveras a538771bc1 Make price slider accurately represent the selected price independently from step (https://github.com/woocommerce/woocommerce-blocks/pull/1453) 2020-01-02 12:10:41 +01:00
Garrett Hyder 21f1d03199 Fix double 'yet yet' (https://github.com/woocommerce/woocommerce-blocks/pull/1421)
Found during translation of WooCommerce 
Permalink - https://translate.wordpress.org/projects/wp-plugins/woocommerce/dev/en-ca/default/?filters%5Bstatus%5D=either&filters%5Boriginal_id%5D=8771164&filters%5Btranslation_id%5D=68202906
2019-12-20 10:35:08 +01:00
Seghir Nadir aaddf13494 Add type to checkout input fields (https://github.com/woocommerce/woocommerce-blocks/pull/1401)
* add input type

* fix css issues with types and better change default position
2019-12-19 13:59:34 +01:00
Seghir Nadir cf495a775e Fix Price Filter constraints by rounding up and down (https://github.com/woocommerce/woocommerce-blocks/pull/1419)
* fix problem with price not rounding up right

* add test
2019-12-19 13:52:49 +01:00
Albert Juhé Lluveras 548b2b80a9 Update filter blocks descriptions to explain they only work with the All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/1420) 2019-12-19 13:46:30 +01:00
Seghir Nadir ca506d0a48 fix translation quantities (https://github.com/woocommerce/woocommerce-blocks/pull/1415)
* fix translation quantities

* update i18n comments and add variable
2019-12-19 10:22:53 +01:00
Mike Jolley cfe55418b1 Translator string feedback (https://github.com/woocommerce/woocommerce-blocks/pull/1412)
* Translator comments need to immedietely precede strings

* Add some extra context to "chips"
2019-12-18 12:59:22 +00:00
Mike Jolley 6a47b2232a More API price formatting and currency handling (https://github.com/woocommerce/woocommerce-blocks/pull/1394)
* Consistent currency data and formatting for product prices

* Consistent get_store_currency_properties usage

* Update tests with schema changes

* min_price and max_price to subunit format

* Product query of min and max prices using subunit

* Cart item totals

* Collection data schema object and currency data inclusion

* Handle subunits and new API in product prices

* Update price slider to format numbers using library and new API responses for subunits

* Product query of min and max prices using subunit

* Fix indents in readme

* Add todo for currency formatting

* Handle step for subunits, fixes min/max constraints

* Handle subunit conversion on display, using consistent currency object and wrapped NumberFormat component.

* Prettier ran

* Update usePriceConstraints tests so rounding doesn't make all values be 0

* Rename to minorUnitValue

* Move currencyToNumberFormat to index file

* siteCurrencySettings to constant rather than function

* remove cents term

* cents->minor unit

* typo in todo note

* Switch to FormattedMonetaryAmount

* Formatting

* wrong case
2019-12-18 11:29:20 +00:00
Mike Jolley 9470caed80 Remove extra colon in active filter widget (https://github.com/woocommerce/woocommerce-blocks/pull/1399) 2019-12-17 18:32:32 +01:00
Darren Ethier b38c45787a fix incorrect property name for price format (https://github.com/woocommerce/woocommerce-blocks/pull/1397) 2019-12-17 10:25:37 +00:00
Albert Juhé Lluveras 506f964463 Update several blocks so they don't support HTML edition (https://github.com/woocommerce/woocommerce-blocks/pull/1395) 2019-12-17 09:38:31 +01:00
Seghir Nadir d58712ee2b Add Checkout Form components (https://github.com/woocommerce/woocommerce-blocks/pull/1351)
* initial commit at fields

* add radio control

* change input to be uncotrolled

* tweak styles

* populate block with boilerplate

* update aria in radio

* remove comment

* fix typo

* add missing colors

* put reminder to put Disabled back

* wrap text in i18n __

* reorder styles

* rename wc-components to wc-blocks

* use value instead of index for keys

* add no shipping placeholder

* change isEditor default to false

* fix problem with responsive
2019-12-16 23:13:41 +01:00
Albert Juhé Lluveras af5af78266 Price filter: preserve previous constraints while loading (https://github.com/woocommerce/woocommerce-blocks/pull/1386)
* Typo

* Save previous constraint while loading

* Add tests for formatPrice

* Small code refactor

* Refactor usePriceConstraints to DRY and add tests

* Add base-hooks to jest config
2019-12-16 17:48:02 +01:00
Albert Juhé Lluveras 77bb23bf32 Add Feedback Prompt in Cart & Checkout blocks sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/1356)
* Add Feedback Prompt in Cart & Checkout blocks sidebar

* Add border

* Move getInspectorControls out of the component function

* Move feedback prompt to a HOC

* Add @todo comment to feedback link

* Use filter for withFeedbackPrompt

* Export withFeedbackPrompt from hocs index.js

* Typo

* Try moving the feedback texts to context

* Revert "Try moving the feedback texts to context"

This reverts commit 21f889b021ceea6fef722efab9663799829bc769.

* Revert "Use filter for withFeedbackPrompt"

This reverts commit 96bba029d61a383eafa2c0a1c08f7988e319b50d.

* Set feedback text in the HOC function

* Use arrow-function to simplify code

* Refactor
2019-12-16 15:59:16 +01:00
Albert Juhé Lluveras 6d383bee73 Fix Attribute Fiter count misalignment (https://github.com/woocommerce/woocommerce-blocks/pull/1391) 2019-12-16 14:58:29 +01:00
Albert Juhé Lluveras ec77f88a72 Reformat files (https://github.com/woocommerce/woocommerce-blocks/pull/1389) 2019-12-16 14:58:19 +01:00
Darren Ethier 25c32dff45 make sure we only allow one cart/checkout block per page/post (https://github.com/woocommerce/woocommerce-blocks/pull/1384) 2019-12-16 08:27:17 -05:00
Albert Juhé Lluveras a4be92ec15 Always filter attribute filters based on price filter (https://github.com/woocommerce/woocommerce-blocks/pull/1390) 2019-12-16 14:04:19 +01:00
Darren Ethier 80d76944cc account for default orderby changes in editor (https://github.com/woocommerce/woocommerce-blocks/pull/1385) 2019-12-16 07:35:13 -05:00
Darren Ethier 10c27e928d Only allow one instance of the All Products block per page/post. (https://github.com/woocommerce/woocommerce-blocks/pull/1383)
* only allow one instance of the all products block per page.

* limit filter blocks to one instance per page/post
2019-12-16 07:31:38 -05:00
Darren Ethier 762caa5aae Fix messaging when there are no attributes (https://github.com/woocommerce/woocommerce-blocks/pull/1382) 2019-12-16 07:28:03 -05:00
Darren Ethier 5ac157b14a Normalize set minPrice and maxPrice values by step (https://github.com/woocommerce/woocommerce-blocks/pull/1379)
* normalize set minPrice and maxPrice values by step

* follow standards for comment blocks
2019-12-13 16:54:35 -05:00
Albert Juhé Lluveras 5485e4c51c Use wc_review_ratings_enabled() API function to check if review ratings are enabled (https://github.com/woocommerce/woocommerce-blocks/pull/1374) 2019-12-13 18:13:11 +01:00
Albert Juhé Lluveras 810341d084 Add Cart block checkout button (https://github.com/woocommerce/woocommerce-blocks/pull/1366) 2019-12-12 20:46:56 +01:00
Albert Juhé Lluveras b5791d9c53 Rename SubmitButton to FilterSubmitButton (https://github.com/woocommerce/woocommerce-blocks/pull/1369) 2019-12-12 20:16:39 +01:00
Albert Juhé Lluveras bd4b57074e Load ErrorPlaceholder CSS only in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/1368) 2019-12-12 20:16:11 +01:00
Darren Ethier cd25b1be07 Install bundlecop and configure in package.json size-check script (https://github.com/woocommerce/woocommerce-blocks/pull/1364)
* install bundlecop and configure in package.json size-check script

* update js doc to test bundlecop

* uninstall bundlesize package
2019-12-11 09:58:49 -05:00
Mike Jolley 5a1bbbefb9 Update NPM dependencies and script dependency handling (https://github.com/woocommerce/woocommerce-blocks/pull/1337)
* Update NPM packages

* Switch JSON dependencies to new PHP files

* include->require

* include->require

* Remove from package and run audit fix

* Update wp-prettier

* Use version from asset file

* Fix eslint issues and test failures

* Update OriginalComponent docblocks

* Props are objects, not arrays

* Array to Object

* fix tests throwing unhandled rejection errors in node.

These tests were all testing Promise.rejects but then not properly catching the reject in the assertions.

* exclude rule for no short array syntax allowed

This is a WordPress core standard that we choose to ignore because it’s silly in our context to follow that rule (and we’re being consistent with WooCommerce Admin).
2019-12-10 12:17:46 -05:00
Albert Juhé Lluveras bf260b0838 Add Empty Cart View with inner blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1350)
* Add Empty Cart View with inner blocks

* Add logic so empty cart is always saved and only displayed when cart is empty

* Make cart hidden until the correct display is loaded

* Add missing propTypes

* Remove is-loading class

* Import InnerBlocks from @wordpress/block-editor

* Add explanation for always rendering EmptyCart in the editor
2019-12-10 16:41:57 +01:00
Albert Juhé Lluveras 0fa4dd05a5 Add 'Go' button to Attribute Filter (https://github.com/woocommerce/woocommerce-blocks/pull/1332)
* Add 'Go' button to Attribute Filter

* Code cleanup

* Fixes

* Avoid onSubmit being called in the editor

* Update attributes help texts

* Fix wrong input check box width
2019-12-06 16:36:55 +01:00
Seghir Nadir 58d4d73b51 Introduce Checkout Form skeleton and Checkout Form Step Component (https://github.com/woocommerce/woocommerce-blocks/pull/1329)
* introduce form steps

* add last step

* add prop types

* fix css color variable naming

* add label for a11y

* use :last-child

* white space

* use direct args in classnames

* typo

* rename ids for steps

* fix line height to match title

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

* heading-content

* rename css var

* move vars to file

* move components within file

* move imports

* rename prop name to kebabCase

* update prop name

* make components responsive with storefront

* fix some compatiblity problems with 2020

* battle in the CSS ground

* move import to correct place

* turn stepHeadingContent to render prop

* styling
2019-12-06 14:18:55 +01:00
Rua Haszard 6afd947631 allow merchant to toggle cart empty/full modes in block editor (https://github.com/woocommerce/woocommerce-blocks/pull/1327)
* allow merchant to toggle cart empty/full modes in block editor

* use text `Button` for empty/full toolbar buttons

* fix highlighting of current cart state (empty/full) in editor:
- use new custom TextToolbarButton for empty/full mode buttons

* use color variables from css/abstracts/_colors

* Update assets/js/components/text-toolbar-button/index.js

Co-Authored-By: Seghir Nadir <nadir.seghir@gmail.com>

* fix className now props is separated out
2019-12-06 10:08:48 +13:00
Albert Juhé Lluveras 578ddbe94d Minor code style fixes in All Products blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1330) 2019-12-05 17:03:31 +01:00
Albert Juhé Lluveras aa43840f13 Add 'AND' display format to Attribute filter dropdown (https://github.com/woocommerce/woocommerce-blocks/pull/1309)
* Add 'AND' display format to Attribute filter dropdown

* Add translators comments

* Remove 'assertive' from speak calls

* Wrap some functions in useCallback

* Only filter available filters if style=list and query=and

* Show placeholder in AND query type

* Add default cursor to list-item elements

* Fix issues with 20xx themes

* Fix issues with 20xx themes (II)
2019-12-05 14:58:44 +01:00
Albert Juhé Lluveras 41374cf5ea Fix price slider layout in narrow columns 2019-12-03 21:18:11 +01:00
Seghir Nadir ee1cdf7e0d Skeleton Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/1308)
* add checkout block

* prevent block from loading in wrong page

* remove block limitation

* exclude file from build

* rename todo

* remove fragment

* move files

* refactor example file
2019-12-03 15:12:46 +01:00
Rua Haszard 8e2b94fd69 Skeleton shopping cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1306)
* basic empty cart block

* use a real placeholder for placeholder editor content

* remove unnecessary Fragment

* updates to config and frontend script

* enqueue frontend script

* add example config to block registration

* change name typo
2019-12-03 08:57:56 -05:00
Albert Juhé Lluveras f7c807a0c6 Add dropdown display style to Attribute Filter block (https://github.com/woocommerce/woocommerce-blocks/pull/1255)
* Add dropdown display style to Attribute Filter block

* Unify filter blocks margin

* Show attribute label inside dropdown input

* Minor CSS reorganization

* Refactor code to smaller files

* Preserve input values on blur

* Only save data-display-style if it's different than 'list'

* Remove inputRef prop in DropdownSelectorInputWrapper

* Accessibility: fix missing label

* Prevent input field being unselected when removing an item with the backspace

* Remove isLoading styles and don't set isDisabled when it's not actually disabled

* Accessibility: increase color contrast

* Add package-lock.json

* Prevent input field being unfocused when removing an item with its chip card

* Don't show menu when input is unfocused
2019-12-03 14:39:11 +01:00
Darren Ethier 1670757534 Remove with-query-string-values hoc implementation (https://github.com/woocommerce/woocommerce-blocks/pull/1287)
* remove with-query-string-values hoc implementation

* remove unnecessary passed in props and clean up proptypes

* remove dead code
2019-12-02 07:52:10 -05:00
Albert Juhé Lluveras aaa37637c2 Replace 'isPreview' with 'isEditor' when it refers to the editor (https://github.com/woocommerce/woocommerce-blocks/pull/1276)
* Replace 'isPreview' with 'isEditor' in several places

* Explicitly set props to true

* Add missing propTypes
2019-12-02 11:27:44 +01:00
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