Skip to content

Latest commit

 

History

History
195 lines (143 loc) · 13.1 KB

README.md

File metadata and controls

195 lines (143 loc) · 13.1 KB

VTEX Minicart

All Contributors

Description

The VTEX minicart app is a store component that shows a list of all items that a customer added in our Checkout OrderForm API, and this app is used by store theme.

📢 Disclaimer: Don't fork this project; use, contribute, or open issue with your feature request.

Release schedule

Release Status Initial Release Maintenance LTS Start End-of-life Store Compatibility
[2.x] Current Release 2018-11-26 2.x
[1.x] Maintenance LTS 2018-08-17 2018-11-26 March 2019 1.x

See our LTS policy for more information.

Table of Contents

Usage

This app uses our store builder with the blocks architecture. To know more about Store Builder click here.

We add the minicart as a block in our Store Header.

To configure or customize this app, you need to import it in your dependencies in manifest.json.

  dependencies: {
    "vtex.minicart": "2.x"
  }

Then, add minicart block into your app theme as we do in our Store theme app.

Now, you can change the behavior of the minicart block that is in the store header. See an example of how to configure:

"minicart": {
  "blocks": [
    "product-summary"
  ],
  "props": {
    "type": "popup",
    "showDiscount": true,
    "labelMiniCartEmpty": "",
    "labelButtonFinishShopping": "Ir para o checkout",
  }
}

Blocks API

When implementing this app as a block, various inner blocks may be available. The following interface lists the available blocks within minicart and describes if they are required or optional.

  "minicart": {
    "required": [
      "product-summary"
    ],
    "allowed": [
      "sandbox"
    ],
    "component": "index"
  }
}

The minicart has as a required block the product-summary. So, any minicart block implementation created must add a product-summary as a block that is inside of minicart. (Similarly, product-summary has its own inner block structure that can be configured. There is a link to its API in the next section.)

Configuration

Through the Storefront, you can change the minicart's behavior and interface. However, you also can make in your theme app, as Store theme does.

Prop name Type Description Default value
type Enum Define Minicart mode. (values: 'popup' or 'sidebar') popup
showDiscount Boolean Shows the total discount of your cart false
labelMiniCartEmpty String Text that is displayed when the cart is empty Your cart is empty
linkButtonFinishShopping String Link to redirect after clicking on the finished shopping button undefined
labelButtonFinishShopping String Text displayed in the finish shopping button Go to checkout
iconClasses String The minicart's icon classes ''
iconLabel String The minicart's icon label undefined
labelClasses String The minicart's label classes gray
hideContent Boolean If the minicart should not show its contents once its icon is clicked false
showShippingCost Boolean If the shipping cost show be displayed on cart false
showTotalItemsQty Boolean If the cart should show the total quantity of items or just the quantity of different items in the cart false
showPrice Boolean If the total price of the items in the cart should be displayed at its side false
iconsProps { "viewBox": String, "size": Number } Props to be passed down to the icons from store-icons. -
openOnHover Boolean Whether the popup minicart should open when the user hovers over it. false

Also, you can configure the product summary that is defined on minicart. See here the Product Summary API.

Additionally, you may add a sandbox block on the footer of the minicart, for additional custom information.

Styles API

This app provides some CSS classes as an API for style customization.

To use this CSS API, you must add the styles builder and create an app styling CSS file.

  1. Add the styles builder to your manifest.json:
  "builders": {
    "styles": "1.x"
  }
  1. Create a file called vtex.minicart.css inside the styles/css folder. Add your custom styles:
.container {
  margin-top: 10px;
}

CSS namespaces

Below, we describe the namespaces that are defined in the minicart.

Class name Description Component Source
container The main container of minicart index
label Minicart icon label index
badge Minicart badge with the product quantity on it index
arrowUp Popup box arrow Popup
box The main container of the popup Popup
sidebarHeader Minicart sidebar header container Sidebar
sidebar Minicart sidebar main container Sidebar
sidebarOpen Active when the sidebar is opened Sidebar
content The container for the Minicart contents MinicartContent
contentSmall The container for the minicart contents when on desktop size MinicartContent
contentLarge The container for the minicart contents when on mobile size MinicartContent
contentDiscount The total discount on the minicart footer MinicartFooter
contentPrice Total price of the products on the minicart footer MinicartFooter
contentFooter The minicart footer main container MinicartFooter
itemContainer The container of a single item in the minicart MinicartContent
itemDeleteIcon The container of the delete item icon next to each item in the minicart MinicartContent
itemDeleteIconLoader The loading state for the delete item icon next to each item in the minicart MinicartContent
popupContentContainer The main container for content inside the popup variant of the minicart Popup
popupChildrenContainer The main container for children content inside the popup variant on the minicart Popup
footerShippingPriceContainer The shipping price main container MinicartFooter
footerShippingPriceLabelContainer The shipping price label container MinicartFooter
footerShippingPriceLabelContainer The shipping price label container MinicartFooter
sidebarRightCaretContainer The caret icon container in the sidebar variant of the minicart Sidebar
sidebarItemQuantityContainer The item quantity container in the sidebar variant of the minicart Sidebar

Troubleshooting

You can check if others are passing through similar issues here. Also feel free to open issues or contribute with pull requests.

Contributing

Check it out how to contribute with this project.

Tests

To execute our tests go to react/ folder and run yarn test

Travis CI

Build Status

Contributors (

Thanks goes to these wonderful people (emoji key):

Lucas Antônio Yamamoto Borges
Lucas Antônio Yamamoto Borges

This project follows the all-contributors specification. Contributions of any kind welcome!

Upcoming documentation: