bootstrap_italia-8.x-0.x-dev/modules/bootstrap_italia_views_timeline/templates/views-bootstrap-italia-views-timeline.html.twig
modules/bootstrap_italia_views_timeline/templates/views-bootstrap-italia-views-timeline.html.twig
{#
/**
* Default theme implementation for Views to output a splide carousel.
*
* Available variables:
* - options.bi_timeline_settings: View plugin style options:
* - date_format
* - today_check
* - today_check_period
* - pin_heading_tag
* - icon_past_event
* - icon_event
*
* @see template_preprocess_views_bootstrap_italia_views_timeline()
*
* @ingroup themeable
*/
#}
{% apply spaceless %}
{% if options.bi_timeline_settings.today_check_period == 'day' %}
{% set _check_period = 86400 %}
{% elseif options.bi_timeline_settings.today_check_period == 'week' %}
{% set _check_period = 604800 %}
{% else %}
{# Default: Month. #}
{% set _check_period = 2592000 %}
{% endif %}
{% embed '@bi-bcl/timeline/timeline.html.twig' with {
timeline_attributes: attributes
} %}
{% block timelineItems %}
{# Only one "now" event. #}
{% set _check_first_now_event = false %}
{% for item in rows %}
<div class="col-12">
{% set _time_passed = "now"|date("U") - item['#node'].getCreatedTime() %}
{% set _is_past_event = _time_passed > _check_period ? true : false %}
{% set _is_now_event = _time_passed < _check_period and _time_passed > 1 ? true : false %}
{% embed '@bi-bcl/timeline/timeline-item.html.twig' with {
past_event: _is_past_event,
now_event: _is_now_event and options.bi_timeline_settings.today_check and not _check_first_now_event ? true : false,
pin_text: item['#node'].getCreatedTime()|date(options.bi_timeline_settings.date_format),
pin_icon: _is_past_event ? options.bi_timeline_settings.icon_past_event : options.bi_timeline_settings.icon_event,
timeline_pin_heading_tag: options.bi_timeline_settings.pin_heading_tag ?? 'h3'
} %}
{% block timelineItemContent %}
{{ item }}
{% endblock %}
{% endembed %}
</div>
{# If the first now_event is checked. #}
{% if _is_now_event and not _check_first_now_event %}
{% set _check_first_now_event = true %}
{% endif %}
{% endfor %}
{% endblock %}
{% endembed %}
{% endapply %}
