Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search page #14

Open
github-learning-lab bot opened this issue Mar 5, 2020 · 3 comments
Open

Search page #14

github-learning-lab bot opened this issue Mar 5, 2020 · 3 comments

Comments

@github-learning-lab
Copy link

Search page

Branch: search

Introduction

image

We've just implemented our product page and are moving on to the search page. Both are similar in the sense that both have blocks that are unique in this context. We will explore this block in a disorderly fashion for now, just to get an idea of its behavior. Then, we'll look at improving the layout.

Search Layout

Same as other templates, store.search can also be flexible. To build a unique layout you'll need to use a block called search-result-layout.

{
 "store.search": {
    "blocks": ["search-result-layout"]
 }
}

The search-result-layout, in turn, must receive 3 other blocks:

  • search-result-layout.desktop
  • search-result-layout.mobile
  • search-not-found-layout

As you've already notice, the first two define which layout will be displayed on desktop and mobile respectively, while the third defines the layout of the no results found search page.

{
 "store.search": {
    "blocks": ["search-result-layout"]
 },
 "search-result-layout": {
    "blocks": [
       "search-result-layout.desktop",
       "search-result-layout.mobile",
       "search-not-found-layout"
    ]
 }
}

In the course, we'll focus on desktop layout implementation.

Search blocks

The search results documentation offers a good reference for blocks that can be use in a search context. This step will focus on highlighting the main ones:

  • Search breadcrumb (breadcrumb.search);
  • Search title (search-title.v2);
  • Total products found (total-products.v2);
  • Product ordering (order-by.v2);
  • Show more results button (search-fetch-more);
  • Show previous results button (search-fetch-previous);
  • Navigation filter (filter-navigator.v3);
  • Search results (search-content)

Although quite many, all these blocks are relatively simple and work very well without an express need to configure their props.

Activity

image

Copy the code above in search.jsonc and define a search-result-layout.desktop with the following characteristics:

  • Pagination type such as 'Show more' (more on the pagination prop here);

Having the following, in the order mentioned below:

  • breadcrumb.search;
  • search-title.v2;
  • total-products.v2;
  • order-by.v2;
  • search-fetch-previous;
  • search-content;
  • filter-navigator.v3;
  • search-fetch-more.

ℹ️ Remember to go through the Search Result documentation if you have any questions during the activity.


If you're still unsure as to how to send your answers, click here.

@vtex-course-hub
Copy link

Oopsie, something went wrong 😿

Results

✅✅✅✅✅❌✅

Tests

✅ Code compilation
✅ Use search-result-layout on the store.search
✅ Define search-result-layout
✅ Use search-result-layout.desktop on the search-result-layout
✅ Define search-result-layout.desktop
❌ You did't use all of the expected components (breadcrumb.search, search-title.v2, total-products.v2, order-by.v2, search-fetch-previous, search-content, filter-navigator.v3, search-fetch-more)
✅ Use the correct layout props

Try again 😁

@vtex-course-hub
Copy link

You did great! 😁

Results

✅✅✅✅✅✅✅

Tests

✅ Code compilation
✅ Use search-result-layout on the store.search
✅ Define search-result-layout
✅ Use search-result-layout.desktop on the search-result-layout
✅ Define search-result-layout.desktop
✅ Define search components
✅ Use the correct layout props

@github-learning-lab
Copy link
Author

You have successfully completed this step!

Go to the next step!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants