{#
  Template for UnLondon block.

  An image, a title, some text and a CTA with a link with three layouts:

  image_left: a card with image to the left and text to the right, the whole card is the link.
  image_right: as above but text on the left and image on the right.
  stacked: not a card just title, image, text and CTA above one another with just the CTA as the link.

  block_title: optional block title, plain text. In card type layouts this title is before the card.
  title: the card title, plain text.
  image: the image, media.
  text: the main text, formatted text.
  cta_text: the CTA text, plain text.
  cta_icon: the CTA icon, plain text.

  url: the URL to link to, string.
  layout: the layout to render, string.
  coloured_bg: whether the block has a coloured background, boolean.
  flush: whether this block should be flush to the one below it, boolean.
  featured: whether to show the featured tag on the image, boolean (only for the image layouts).
#}

{# EXTENDS #}
{% extends "@organisms/tm-ul/ul-base/ul-base.twig" %}

{% set block_title = block_title|default('') %}
{% set layout = layout|default('image_left') %}
{% set featured = featured|default(false) %}
{% set base_class = (block_title ? ' has-block-title' : '') ~ (featured ? ' is-feaured': '') %}

{% set title_heading_tag = block_title == '' ? 'h2' : 'h3' %}

{% block content_block %}
  {{ attach_library('ui_patterns/ul_block.ul_block_lib') }}

  {% if layout == 'stacked' %}
    <div class="col col-lg-8 ul-block ub-stacked ul-c">
  {% endif %}
  {% if block_title %}<h2 class="ul-title">{{ block_title }}</h2>{% endif %}

  {% if layout == 'stacked' %}
      {% include '@organisms/tm-ul/ul-block/includes/ul-block-stacked.twig' with {
        'title': title,
        'image': image,
        'text': text,
        'cta_text': cta_text,
        'cta_icon': cta_icon,
        'url': url,
        'title_heading_tag': title_heading_tag,
      } only %}
    </div>
  {% else %}
    {% include '@organisms/tm-ul/ul-block/includes/ul-block-card.twig' with {
      'title': title,
      'image': image,
      'text': text,
      'cta_text': cta_text,
      'cta_icon': cta_icon,
      'url': url,
      'title_heading_tag': title_heading_tag,
      'layout': layout,
      'coloured_bg': not coloured_bg,
      'featured': featured,
    } only %}
  {% endif %}
{% endblock %}
