

{% liquid
  assign product = block.settings.product
-%}

{% capture children %}
  {% content_for 'blocks', closest.product: product %}
{% endcapture %}

{% render 'product-card', children: children, product: product %}

{% schema %}
{
  "name": "t:names.product_card",
  "blocks": [
    {
      "type": "group"
    },
    {
      "type": "text"
    },
    {
      "type": "image"
    },
    {
      "type": "buy-buttons"
    },
    {
      "type": "price"
    },
    {
      "type": "review"
    },
    {
      "type": "swatches"
    },
    {
      "type": "_product-card-gallery"
    },
    {
      "type": "product-title"
    }
  ],
  "tag": null,
  "settings": [
    {
      "type": "product",
      "id": "product",
      "label": "t:settings.product"
    },
    {
      "type": "range",
      "id": "product_card_gap",
      "label": "t:settings.vertical_gap",
      "min": 0,
      "max": 50,
      "step": 1,
      "unit": "px",
      "default": 16
    },
    {
      "type": "checkbox",
      "id": "inherit_color_scheme",
      "label": "t:settings.inherit_color_scheme",
      "default": true
    },
    {
      "type": "color_scheme",
      "id": "color_scheme",
      "label": "t:settings.color_scheme",
      "default": "scheme-1",
      "visible_if": "{{ block.settings.inherit_color_scheme == false }}"
    },
    {
      "type": "header",
      "content": "t:content.borders"
    },
    {
      "type": "select",
      "id": "border",
      "label": "t:settings.style",
      "options": [
        {
          "value": "none",
          "label": "t:options.none"
        },
        {
          "value": "solid",
          "label": "t:options.solid"
        }
      ],
      "default": "none"
    },
    {
      "type": "range",
      "id": "border_width",
      "min": 0,
      "max": 100,
      "step": 1,
      "unit": "px",
      "label": "t:settings.thickness",
      "default": 1,
      "visible_if": "{{ block.settings.border != 'none' }}"
    },
    {
      "type": "range",
      "id": "border_opacity",
      "min": 0,
      "max": 100,
      "step": 1,
      "unit": "%",
      "label": "t:settings.opacity",
      "default": 100,
      "visible_if": "{{ block.settings.border != 'none' }}"
    },
    {
      "type": "range",
      "id": "border_radius",
      "label": "t:settings.border_radius",
      "min": 0,
      "max": 32,
      "step": 1,
      "default": 0
    },
    {
      "type": "header",
      "content": "t:content.padding"
    },
    {
      "type": "range",
      "id": "padding-block-start",
      "label": "t:settings.top",
      "min": 0,
      "max": 50,
      "step": 1,
      "unit": "px",
      "default": 0
    },
    {
      "type": "range",
      "id": "padding-block-end",
      "label": "t:settings.bottom",
      "min": 0,
      "max": 50,
      "step": 1,
      "unit": "px",
      "default": 0
    },
    {
      "type": "range",
      "id": "padding-inline-start",
      "label": "t:settings.left",
      "min": 0,
      "max": 50,
      "step": 1,
      "unit": "px",
      "default": 0
    },
    {
      "type": "range",
      "id": "padding-inline-end",
      "label": "t:settings.right",
      "min": 0,
      "max": 50,
      "step": 1,
      "unit": "px",
      "default": 0
    }
  ],
  "presets": [
    {
      "name": "t:names.product_card",
      "category": "t:categories.product",
      "settings": {
        "product": "{{ closest.product }}"
      },
      "blocks": {
        "product-card-gallery": {
          "type": "_product-card-gallery",
          "settings": {
            "product": "{{ closest.product }}"
          }
        },
        "group": {
          "type": "group",
          "settings": {
            "content_direction": "column"
          },
          "blocks": {
            "product_title": {
              "type": "product-title",
              "settings": {
                "product": "{{ closest.product }}",
                "width": "100%",
                "type_preset": "h5"
              }
            },
            "price": {
              "type": "price",
              "settings": {
                "product": "{{ closest.product }}"
              }
            }
          },
          "block_order": ["product_title", "price"]
        }
      },
      "block_order": ["product-card-gallery", "group"]
    }
  ]
}
{% endschema %}
