v0.0.2
Demos (demo panel, opens in a new tab)

Category card

A card leading to a category page, with the category's picture, name and number of products.

zb:shop.category-card zubazar/ui-pro

PRO

This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →

One card

One card: view
BLADE

The card takes an Zubazar\Commerce\Data\Category and fills the width of its box.

blade
<zb:shop.category-card :category="$category" />

Category grid

Category grid: view
BLADE

Shop::categories() returns the categories in menu order; the home page lays them out in two columns on phones and four on wide screens.

blade
<div class="grid grid-cols-2 gap-3 sm:gap-5 md:grid-cols-4">
    @foreach (\Zubazar\Commerce\Shop::categories() as $category)
        <zb:shop.category-card :category="$category" />
    @endforeach
</div>

Category data

PHP

The categories come from the store's categories() method; the card takes the name, the link, the drawing and the colour family from this data.

php
use Zubazar\Commerce\Data\Category;

public function categories(): Collection
{
    return collect([
        Category::fromArray(['id' => 1, 'slug' => 'shop-electronics', 'name' => 'Electronics', 'icon' => 'cpu-chip', 'hue' => 'violet', 'shape' => 'headphones']),
        Category::fromArray(['id' => 2, 'slug' => 'shop-home-living', 'name' => 'Home & Living', 'icon' => 'home', 'hue' => 'amber', 'shape' => 'lamp']),
    ]);
}
PropValues
nameThe card's title (a string or one value per language)
slugThe address of the category page
shape, hueThe card's picture (zb:shop.product-visual)
iconThe icon in the menus and on the categories page; the card does not use it

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
category— — The category shown (Zubazar\Commerce\Data\Category); required

Developer notes

Events, hooks and details
  • The categories section of the home page lays these cards out; the picture is drawn from the category's drawing (shape) and colour family (hue).
  • The number of products comes from the store's productCount() method.
  • The card's link is made from the web.categories.show route and the category's slug.
Zubazar UI · ZubazarDesigned for people.