E-commerce

Components specific to online stores - the product card, photo gallery, cart and checkout selection tiles. They require a separate molique-style-shop.css file, since they don't belong in the framework core. Ready-made layouts are in the examples.

1. What to choose

Five independent components - use as many as you need, none of them requires the others.

Component When What it's built on
.product-card Product grid - category listings, search results. Flexbox
.product-gallery Single product page - main photo + clickable thumbnails. Flexbox + JS (src swap)
.cart-item A cart row or order summary row. Flexbox + JS (quantity controller)
.selection-tile Picking a delivery or payment method at checkout. Native input[radio/checkbox], zero JS
.star-rating / .product-swatches Product rating and color-variant picker - usually inside a card. Pure CSS (SVG mask), zero JS

2. Product card

.product-price-block has margin-top: auto - regardless of the title's length, the price and button always land at the bottom edge of the card, so cards in the same grid row end at the same height.

<article class="product-card">
  <a href="#" class="product-image-wrapper">
    <div class="product-badges">
      <span class="badge badge-danger">-30%</span>
    </div>
    <img src="product.jpg" alt="Product" style="height: 250px;">
  </a>
  <div class="product-content">
    <a href="#" class="product-title">Product name</a>
    <div class="product-price-block">
      <span class="price-current">$49.00</span>
      <span class="price-old">$69.00</span>
    </div>
    <button class="btn-primary w-100">Add to cart</button>
  </div>
</article>
Class What it does
.product-card Wrapper. height: 100% - in a grid it stretches to match the tallest card in the row.
.product-image-wrapper On an <a>. The image inside has no default height (height: auto) - without an inline style="height:…" or your own rule, cards in a grid will have images of different heights.
.product-badges Absolutely positioned in the top-left corner. Plain .badge-*s go inside.
.product-content The rest of the card below the image. flex-grow: 1.
.product-title Text color switches to --primary on hover.
.product-price-block margin-top: auto - pins the price block to the bottom of the card. baseline alignment, so the price and the old price sit on a shared text line despite the different font sizes.
.price-current Current price - large, --primary.
.price-old Pre-discount price - struck through, muted.

List view instead of a grid

Add the class .product-list-view to the parent container (not to the card) - CSS rebuilds every .product-card inside it into a horizontal layout, with no changes to a single card's HTML. Below the sm breakpoint the layout automatically reverts to vertical.

3. Product gallery

A large photo + a row of clickable thumbnails. Clicking a thumbnail swaps the main photo's src - no reload, no lightbox, no external carousel library.

How it works

The molique-shop.js module (auto-loaded whenever .product-gallery is present) listens for clicks on .gallery-thumb. Each one reads the data-large attribute from its own <img> and inserts that value as the main photo's src - without that attribute, clicking does nothing. The thumbnail is a <button>, not an <a> or a <div>, so keyboard support (Tab, Enter) works without adding anything extra.

<div class="product-gallery">
  <div class="product-gallery-main">
    <img src="large-1.jpg" alt="Product">
  </div>
  <div class="product-gallery-thumbs">
    <button type="button" class="gallery-thumb is-active">
      <img src="small-1.jpg" data-large="large-1.jpg" alt="">
    </button>
    <button type="button" class="gallery-thumb opacity-50">
      <img src="small-2.jpg" data-large="large-2.jpg" alt="">
    </button>
  </div>
</div>
Class What it does
.product-gallery Wrapper. With no modifier: thumbnails in a row below the photo - works at every width, mobile included.
.product-gallery-left From the md breakpoint up: thumbnails as a column TO THE LEFT of the photo. Below md - reverts to the default layout (a row underneath). DOM order stays the same, only the visual order changes (order).
.product-gallery-right Same as -left, but the thumbnail column stays on the right (DOM order = visual order).
.product-gallery-main A square container for the main photo (aspect-ratio: 1/1), the image fills it via object-fit: cover.
.product-gallery-thumbs The thumbnail bar.
.gallery-thumb A single thumbnail (<button>, 64×64px). Requires an <img data-large="…"> inside.
.is-active / .opacity-50 Thumbnail state - applied by JS after a click (active one full, the rest dimmed). .opacity-50 is a ready-made utility class, not a separate component class.

Default (thumbnails below)

.product-gallery-left (from md)

<!-- Thumbnails on the left from the md breakpoint -->
<div class="product-gallery product-gallery-left">
  …
</div>

4. Ratings and color variants

Two micro-components for inside a product card. Both purely visual - zero JavaScript.

<!-- Rating of 4.5 out of 5 stars -->
<div class="star-rating" style="--rating: 4.5;"></div>

<!-- Color choice -->
<div class="product-swatches">
  <div class="swatch is-active" style="background-color: #000;" title="Black"></div>
  <div class="swatch" style="background-color: #ef4444;" title="Red"></div>
</div>
Class / variable What it does
.star-rating Five stars cut out with an SVG mask from a linear gradient. The value is set EXCLUSIVELY through the --rating variable (0-5, fractions allowed) - there's no class-based equivalent.
--star-color / --star-bg Color of the filled and empty part of the stars. Defaults are --warning and --border-color.
--star-size Size of a single star (16px by default) - scales the component's whole width (--star-size × 5).
.product-swatches A row of color circles, flex-wrap.
.swatch A 24px circle. Color via inline style="background-color:…" - there's no set of ready-made color classes (a product's palette is arbitrary, not limited to the theme's palette).
.swatch.is-active Outer --primary outline. Apply it manually in HTML or with your own JS - the shop module doesn't manage this.

5. Cart

A cart row with a built-in quantity controller. The +/- buttons are handled by the same module as the gallery - it respects the field's min and max attributes.

<div class="cart-item">
  <img src="product.jpg" alt="Product" class="cart-item-img">

  <div class="cart-item-info">
    <a href="#" class="fw-bold text-decoration-none">Product name</a>
  </div>

  <div class="cart-item-controls">
    <div class="qty-input">
      <button class="qty-btn">-</button>
      <input type="number" class="qty-val" value="1" min="1" max="99">
      <button class="qty-btn">+</button>
    </div>
    <div class="fw-black text-6">$49.00</div>
    <button class="btn-action text-danger" aria-label="Remove">&times;</button>
  </div>
</div>
Class What it does
.cart-item The row. Flexbox, flex-wrap - on narrow screens elements wrap instead of squeezing together.
.cart-item-img An 80×80px thumbnail, object-fit: cover.
.cart-item-info flex-grow: 1 - takes up the remaining space, pushing prices and controls to the right.
.cart-item-controls The group: quantity controller + price + remove.
.qty-input Wrapper for the controller. Height is forced to --target-size-min (44px, the B2B rule) - regardless of the button sizes inside.
.qty-btn A +/- button. JS treats the first .qty-btn as minus, the last one as plus - DOM order matters here, see the pitfall below.
.qty-val The number field between the buttons. It must be type="number" with a min attribute (and optionally max) - that's where JS reads the limits from. The browser's native spinner is hidden.

6. Selection tiles

For picking a delivery or payment method at checkout. A hidden native input[radio]/[checkbox] controls the look of the adjacent .tile-content - zero JavaScript, selection and form validation work natively.

<label class="selection-tile">
  <input type="radio" name="delivery" value="standard" checked>
  <div class="tile-content">
    <span class="fw-bold">Standard shipping</span>
    <span class="text-primary fw-bold">$12.99</span>
  </div>
</label>

<!-- Variant with an animated border on selection -->
<label class="selection-tile selection-tile-animated">
  <input type="radio" name="payment" value="blik">
  <div class="tile-content hover-border-trace">
    <span class="fw-bold">BLIK</span>
  </div>
</label>

<!-- A whole group locked -->
<fieldset disabled>
  <label class="selection-tile">…</label>
</fieldset>
Class What it does
.selection-tile On a <label>. The input inside is visually hidden (not display: none, so it stays in the accessibility tree and keyboard flow).
.tile-content The tile's visible content. Must be a direct sibling of the input - the CSS rule targets it via :checked + .tile-content.
input:disabled The tile dims and takes a not-allowed cursor. Also works for a whole group inside <fieldset disabled>. A checked tile keeps its full colour: “you cannot change this choice” is not the same as “nothing was chosen here”.
.selection-tile-animated On a <label>, alongside .selection-tile. Disables the immediate border change, handing the selection effect off to the .hover-border-trace (or -2) class added to .tile-content.

7. Pitfalls

1 A thumbnail without data-large

The JS module reads the large photo exclusively from the data-large attribute on the <img> inside the thumbnail. Without it, clicking a .gallery-thumb does nothing - no console error, the if (newSrc) check just never passes.

2 Thumbnail state isn't set automatically

The module only wires up click listeners - it doesn't run a startup pass over the photos. If you don't manually mark the first thumbnail as .is-active in the HTML, and the rest as .opacity-50, every thumbnail will look identical until the first click.

3 More than two .qty-btns inside a .qty-input

JS treats :first-child as minus and :last-child as plus. An extra button (e.g. a "Buy now" button dropped into the same container) throws this pair off - the third element becomes the new "plus", and the actual plus button stops working. Keep exactly two .qty-btns and one .qty-val inside .qty-input.

4 .product-list-view on the wrong element

The class must land on the container surrounding the cards (e.g. .grid-auto), not on a single .product-card. The SCSS selectors are of the form .product-list-view .product-card - nothing changes on the card itself.

8. Related pages