{% from "../image/macro.njk" import LBCamdenImage %}

{% set containerElement = params.element if params.element else 'div' %}
{% set headingLevel = params.heading.headingLevel if params.heading.headingLevel else 2 %}
<{{ containerElement }}
  class="lbcamden-card {{ params.classes if params.classes }}
  {% if params.type %}
  lbcamden-card--{{ params.type }}
  {% endif %}
  {% if params.clickable %} lbcamden-card--clickable{% endif %}
  {% if params.topBorder %} lbcamden-card--top-border{% endif %}
  {% if params.image %} lbcamden-card--image{% endif %}"
  data-module="lbcamden-card"
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
{% if params.image %}
  {{ LBCamdenImage(params.image) }}
  <div class="lbcamden-card__content_wrapper">
{% endif %}
{% if params.heading %}
<h{{ headingLevel }}
  class="govuk-heading-m">
  {% if params.heading.href %}
    <a href="{{ params.heading.href }}">
      {{ params.heading.title }}
    </a>
  {% else %}
    {{ params.heading.title }}
  {% endif %}
</h{{ headingLevel }}>
{% endif %}
{%- if params.content %}
  <div class="lbcamden-card__content">
    {% if params.content.text %}
      <p>{{ params.content.text }}</p>
    {% else %}
      <div>{{ params.content.html | safe }}</div>
    {% endif %}
  </div>
{%- endif %}
{% if params.image %}
  </div>
{% endif %}
</{{ containerElement }}>
