{# ========================================================================== #}
{# :: Section #}
{# ========================================================================== #}
{#
	Sub section to display the different assets based on the type defined in
	the CMS.
#}

{# ========================================================================== #}
{# :: Imports #}
{# ========================================================================== #}
{% import "components/download-list.njk" as downloadList %}
{% import "components/download-grid.njk" as downloadGrid %}
{% import "components/download-all.njk" as downloadAll %}
{% import "components/wysiwyg.njk" as wysiwyg %}

{# ========================================================================== #}
{# :: Variables #}
{# ========================================================================== #}
{% set overlayId = item.data.title | replace(" ", "-") | lower %}

{# ========================================================================== #}
{# :: Partial #}
{# ========================================================================== #}
<section class="bp-l-section bp-l-section--sub">
	{% if item.data.title or item.data.assets %}
		<header class="bp-l-section__header bp-l-section__header--split-space">
			{% if item.data.title %}
				<h2 class="bp-l-section__title u-h1">{{item.data.title}}</h2>
			{% endif %}

			{% if item.data.assets | length > 1 %}
				{{downloadAll.default("", {
					zip: item.data.title,
					items: item.data.assets,
					folders: item.data.folders,
					button: {
						text: "Download all",
						iconAfter: "download"
					}
				})}}
			{% endif %}
		</header>
	{% endif %}

	{% if item.data.description %}
		<div class="bp-l-section__content bp-s-wysiwyg-default">
			{{wysiwyg.default("", {
				content: item.data.description
			})}}
		</div>
	{% endif %}

	<div class="bp-l-section__content">
		{% if item.data.type === "table" %}

			{{downloadList.default("", {
				items: item.data.assets,
				folders: item.data.folders,
				id: overlayId
			})}}

		{% elseif item.data.type === "grid" %}

			{{downloadGrid.default("", {
				items: item.data.assets,
				folders: item.data.folders,
				id: overlayId
			})}}

		{% endif %}
	</div>
</section>
