Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add a basic product category block #136

Merged
merged 12 commits into from
Nov 19, 2018
Merged

Conversation

ryelle
Copy link
Member

@ryelle ryelle commented Nov 17, 2018

This PR creates a basic, early iteration of the "Products by Category" block. This adds a basic preview UI, the inspector controls, and the alignment controls. This does not add the "edit state"/initial view. This also uses the core TreeSelect for picking a category, not the custom search/checkboxes. Both of those will be done in future PRs.

Fixes #116, also adds support for menu_order ordering, so fixes #125. This is build upon #135.

Screenshots

The whole block with all settings sections:
block-w-settings

An example of full-width in Gutenberg
full-width

These use the shortcode to display on the frontend, and in Twenty Nineteen look like this:

frontend
full-width-frontend

I've also added basic support for "loading" and "empty" states:

loading

nothing-found

Code notes

I've introduced some utilities that I think will be shared across blocks. shared-attributes has definitions for rows, columns, etc; and I'll use these plus block-specific settings like this. I've also introduced getQuery and getShortcode, which are used to generate the API query and shortcode string respectively.

How to test the changes in this Pull Request:

  1. Build this branch
  2. Expect: you now have another Product block, "Products by Category"
  3. Add "Products by Category" – initially an empty state
  4. Choose a category (or multiple)
  5. Your products should display in the preview
  6. Edit the Layout (rows/columns), this should update the preview
  7. Edit the ordering, this should update the preview
  8. Save the block
  9. View on the front end of your site, preview and frontend should match (unless you have draft products, see Draft products are shown in the block preview #124 )
  10. Run the tests, npm test, for the added component & getQuery tests (a shortcode test suite will be added later).

There are probably edge cases I'm not testing with, so feel free to use strange combinations of settings 😆

@ryelle ryelle added this to the 1.2.0 milestone Nov 17, 2018
@ryelle ryelle self-assigned this Nov 17, 2018
@ryelle ryelle requested review from tiagonoronha, LevinMedia and a team November 17, 2018 19:47
Copy link
Contributor

@LevinMedia LevinMedia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start, testing well for me!

Copy link
Contributor

@tiagonoronha tiagonoronha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, looking good! 👍

@ryelle ryelle changed the base branch from update/legacy-component to master November 19, 2018 16:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow ordering products by menu order Product Category Block
3 participants