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

Menu #23

Open
github-learning-lab bot opened this issue Oct 20, 2020 · 8 comments
Open

Menu #23

github-learning-lab bot opened this issue Oct 20, 2020 · 8 comments

Comments

@github-learning-lab
Copy link

Menu

Branch: menu

Introduction

Having already configured and implemented the header, let's now add it to the Menu. Configuring the Menu is an important step in building your theme, since it's the block that's responsible for the user's navigation in your store. Because of its function and relevance, the Menu possesses a complex hierarchical structure, which involves menu items, submenus and, based on the latter, any Store Framework block (such as other Menus e Menu Items). Below we can see an image highlighting the Menu block's structure in practice:

menu

Configuring the Menu

When compared to some of the other blocks, the Menu's configuration may seem more difficult due to its structure of menus, menu items and submenus. However the Menu does not necessarily need to be configured according to the most complex scenario. Below, we can check a basic implementation example for the block, containing just the following 3 Menu Items:

{
  "[email protected]:menu#categories": {
    "children": [
      "menu-item#major-appliances",
      "menu-item#small-appliances",
      "menu-item#electronics"
    ],

    "props":{
      "orientation": "horizontal"
    }
  }
},

Activity

This activity will help us understand more about configuring the Menu, in addition to its existing hierarchy based on building Menu Items and Submenus.

  1. In header.jsonc, add header-row#menu as the last item on the header-layout.desktop block's child list (configured during the previous activity), so that the Menu can be rendered by the store's Header;

  2. Copy and paste the code below to declare the header-row#menu block:

    "header-row#menu": {
      "children": [
        "header-spacer",
        "[email protected]:menu#categories",
        "header-spacer"
      ]
    },
  3. We also need to deal with the layout Menu for other devices, such as mobile. Therefore, add the drawer as the header-row#main-mobile block's first child;

  4. Copy the code in the menu.jsonc code to horizontally render the 3 main Menu items:

    {
      "[email protected]:menu#categories": {
        "children": [
          "menu-item#major-appliances",
          "menu-item#small-appliances",
          "menu-item#electronics"
        ],
    
        "props":{
          "orientation": "horizontal"
        }
    },
  5. As we've seen in the introduction, a Menu Item can allow the configuration of a Submenu which in turn can have another Menu with its own Menu Items. Therefore, create a Submenu for Major Appliances, still in menu.jsonc, according to the example below:

    "[email protected]:submenu#major":{
      "children":[
        "[email protected]:menu#major"
      ]
    },
  6. Following the format established by the [email protected]:menu#categories\ block, build a secondary Major Appliances Menu, declared in the last step in menu.jsonc. You must set the orientation prop value to vertical and configure the following Menu Items in the block's children list: menu-item#refrigerators, menu-item#ovens and menu-item#washers;

  7. In addition, create a Small Appliances submenu:

    "[email protected]:submenu#small":{
      "children":[
        "[email protected]:menu#small"
      ]
    },
  8. Now build the Small Appliances secondary menu in menu.jsonc. As with the Major Appliances, you must set the orientation prop value to vertical and configure the following Menu Items in the block children list: menu-item#mixers, menu-item#toasters and menu-item#coffee;

  9. Based on the previous steps, do the same with Electronics: create your Submenu ([email protected]:submenu#electronics) and secondary Menu. Thereafter, build the latter with the same prop value (vertical) and configure the following Menu Items in the block's children list: menu-item#cameras, menu-item#laptops and menu-item#tvs.

Expected result:

ℹ️ Remember to access the Menu's documentation if your have any questions during the activity.


🚫 Are you lost?

Is there any problem with this step? What about sending us a feedback? 🙏

Submit feedback


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

✅ Fetching files
✅ Code compilation: header.jsonc
✅ Code compilation: menu-items.jsonc
✅ Code compilation: menu.jsonc
❌ You havent declared [email protected]:submenu#major on your menu-item#major-appliances
❌ You havent declared [email protected]:submenu#small on your menu-item#small-appliances
❌ You havent declared [email protected]:submenu#electronics on your menu-item#electronics
✅ Main Category Menu must be stated
✅ Main Category Menu must have correct children
✅ Main Category Menu must be on horizontal orientation
✅ Major Appliances Menu must be stated
✅ Major Appliances must have correct children
❌ You havent declared props "orientation" as "vertical" on [email protected]:menu#major
✅ Small Appliances Menu must be stated
✅ Small Appliances must have correct children
❌ You havent declared props "orientation" as "vertical" on [email protected]:menu#small
✅ Electronics Menu must be stated
✅ Electronics Menu must have correct children
❌ You havent declared props "orientation" as "vertical" on [email protected]:menu#electronics
✅ Menu row must be placed as last child of header
❌ You havent declared drawer as first child of header-row#main-mobile
✅ Menu row must have correct children
✅ Major Submenu must have major menu as children
✅ Small Submenu must have small menu as children
✅ Electronics Submenu must have electronics menu as children

Try again 😁

@vtex-course-hub
Copy link

Oopsie, something went wrong 😿

Results

✅✅✅✅❌❌❌✅✅✅✅✅✅✅✅✅✅✅✅✅❌✅✅✅✅

Tests

✅ Fetching files
✅ Code compilation: header.jsonc
✅ Code compilation: menu-items.jsonc
✅ Code compilation: menu.jsonc
❌ You havent declared [email protected]:submenu#major on your menu-item#major-appliances
❌ You havent declared [email protected]:submenu#small on your menu-item#small-appliances
❌ You havent declared [email protected]:submenu#electronics on your menu-item#electronics
✅ Main Category Menu must be stated
✅ Main Category Menu must have correct children
✅ Main Category Menu must be on horizontal orientation
✅ Major Appliances Menu must be stated
✅ Major Appliances must have correct children
✅ Major Appliances Menu must be on vertical orientation
✅ Small Appliances Menu must be stated
✅ Small Appliances must have correct children
✅ Small Appliances Menu must be on vertical orientation
✅ Electronics Menu must be stated
✅ Electronics Menu must have correct children
✅ Electronics Menu must be on vertical orientation
✅ Menu row must be placed as last child of header
❌ You havent declared drawer as first child of header-row#main-mobile
✅ Menu row must have correct children
✅ Major Submenu must have major menu as children
✅ Small Submenu must have small menu as children
✅ Electronics Submenu must have electronics menu as children

Try again 😁

@vtex-course-hub
Copy link

Oopsie, something went wrong 😿

Results

✅✅✅✅❌❌❌✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅

Tests

✅ Fetching files
✅ Code compilation: header.jsonc
✅ Code compilation: menu-items.jsonc
✅ Code compilation: menu.jsonc
❌ You havent declared [email protected]:submenu#major on your menu-item#major-appliances
❌ You havent declared [email protected]:submenu#small on your menu-item#small-appliances
❌ You havent declared [email protected]:submenu#electronics on your menu-item#electronics
✅ Main Category Menu must be stated
✅ Main Category Menu must have correct children
✅ Main Category Menu must be on horizontal orientation
✅ Major Appliances Menu must be stated
✅ Major Appliances must have correct children
✅ Major Appliances Menu must be on vertical orientation
✅ Small Appliances Menu must be stated
✅ Small Appliances must have correct children
✅ Small Appliances Menu must be on vertical orientation
✅ Electronics Menu must be stated
✅ Electronics Menu must have correct children
✅ Electronics Menu must be on vertical orientation
✅ Menu row must be placed as last child of header
✅ Drawer must be placed as first child of header mobile
✅ Menu row must have correct children
✅ Major Submenu must have major menu as children
✅ Small Submenu must have small menu as children
✅ Electronics Submenu must have electronics menu as children

Try again 😁

2 similar comments
@vtex-course-hub
Copy link

Oopsie, something went wrong 😿

Results

✅✅✅✅❌❌❌✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅

Tests

✅ Fetching files
✅ Code compilation: header.jsonc
✅ Code compilation: menu-items.jsonc
✅ Code compilation: menu.jsonc
❌ You havent declared [email protected]:submenu#major on your menu-item#major-appliances
❌ You havent declared [email protected]:submenu#small on your menu-item#small-appliances
❌ You havent declared [email protected]:submenu#electronics on your menu-item#electronics
✅ Main Category Menu must be stated
✅ Main Category Menu must have correct children
✅ Main Category Menu must be on horizontal orientation
✅ Major Appliances Menu must be stated
✅ Major Appliances must have correct children
✅ Major Appliances Menu must be on vertical orientation
✅ Small Appliances Menu must be stated
✅ Small Appliances must have correct children
✅ Small Appliances Menu must be on vertical orientation
✅ Electronics Menu must be stated
✅ Electronics Menu must have correct children
✅ Electronics Menu must be on vertical orientation
✅ Menu row must be placed as last child of header
✅ Drawer must be placed as first child of header mobile
✅ Menu row must have correct children
✅ Major Submenu must have major menu as children
✅ Small Submenu must have small menu as children
✅ Electronics Submenu must have electronics menu as children

Try again 😁

@vtex-course-hub
Copy link

Oopsie, something went wrong 😿

Results

✅✅✅✅❌❌❌✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅

Tests

✅ Fetching files
✅ Code compilation: header.jsonc
✅ Code compilation: menu-items.jsonc
✅ Code compilation: menu.jsonc
❌ You havent declared [email protected]:submenu#major on your menu-item#major-appliances
❌ You havent declared [email protected]:submenu#small on your menu-item#small-appliances
❌ You havent declared [email protected]:submenu#electronics on your menu-item#electronics
✅ Main Category Menu must be stated
✅ Main Category Menu must have correct children
✅ Main Category Menu must be on horizontal orientation
✅ Major Appliances Menu must be stated
✅ Major Appliances must have correct children
✅ Major Appliances Menu must be on vertical orientation
✅ Small Appliances Menu must be stated
✅ Small Appliances must have correct children
✅ Small Appliances Menu must be on vertical orientation
✅ Electronics Menu must be stated
✅ Electronics Menu must have correct children
✅ Electronics Menu must be on vertical orientation
✅ Menu row must be placed as last child of header
✅ Drawer must be placed as first child of header mobile
✅ Menu row must have correct children
✅ Major Submenu must have major menu as children
✅ Small Submenu must have small menu as children
✅ Electronics Submenu must have electronics menu as children

Try again 😁

@vtex-course-hub
Copy link

Oopsie, something went wrong 😿

Results

✅✅✅✅❌❌❌✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅❌✅✅

Tests

✅ Fetching files
✅ Code compilation: header.jsonc
✅ Code compilation: menu-items.jsonc
✅ Code compilation: menu.jsonc
❌ You havent declared [email protected]:submenu#major on your menu-item#major-appliances
❌ You havent declared [email protected]:submenu#small on your menu-item#small-appliances
❌ You havent declared [email protected]:submenu#electronics on your menu-item#electronics
✅ Main Category Menu must be stated
✅ Main Category Menu must have correct children
✅ Main Category Menu must be on horizontal orientation
✅ Major Appliances Menu must be stated
✅ Major Appliances must have correct children
✅ Major Appliances Menu must be on vertical orientation
✅ Small Appliances Menu must be stated
✅ Small Appliances must have correct children
✅ Small Appliances Menu must be on vertical orientation
✅ Electronics Menu must be stated
✅ Electronics Menu must have correct children
✅ Electronics Menu must be on vertical orientation
✅ Menu row must be placed as last child of header
✅ Drawer must be placed as first child of header mobile
✅ Menu row must have correct children
❌ You havent declared [email protected]:menu#major as children of [email protected]:submenu#major
✅ Small Submenu must have small menu as children
✅ Electronics Submenu must have electronics menu as children

Try again 😁

@vtex-course-hub
Copy link

You did great! 😁

Results

✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅

Tests

✅ Fetching files
✅ Code compilation: header.jsonc
✅ Code compilation: menu-items.jsonc
✅ Code compilation: menu.jsonc
✅ Major Appliances Menu item must contain correct submenu
✅ Small Appliances Menu item must contain correct submenu
✅ Electronics Menu item must contain correct submenu
✅ Main Category Menu must be stated
✅ Main Category Menu must have correct children
✅ Main Category Menu must be on horizontal orientation
✅ Major Appliances Menu must be stated
✅ Major Appliances must have correct children
✅ Major Appliances Menu must be on vertical orientation
✅ Small Appliances Menu must be stated
✅ Small Appliances must have correct children
✅ Small Appliances Menu must be on vertical orientation
✅ Electronics Menu must be stated
✅ Electronics Menu must have correct children
✅ Electronics Menu must be on vertical orientation
✅ Menu row must be placed as last child of header
✅ Drawer must be placed as first child of header mobile
✅ Menu row must have correct children
✅ Major Submenu must have major menu as children
✅ Small Submenu must have small menu as children
✅ Electronics Submenu must have electronics menu as children

@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