{# -*- coding: utf-8 -*-

  This file is part of Invenio.
  Copyright (C) 2015-2020 CERN.

  Invenio is free software; you can redistribute it and/or modify it
  under the terms of the MIT License; see LICENSE file for more details.
#}

{%- macro panel_start(title, icon='', btn_text='', btn='', btn_icon='',
                      btn_href='', btn_class='basic secondary', btn_name='',
                      btn2='', btn_icon2='', btn_href2='', btn_class2='basic secondary',
                      btn_name2='', id="", with_body=True, panel_extra_class="secondary") %}
{%- block panel_start scoped %}
<div class="ui segments" {% if id %} id="{{ id }}" {% endif %}>

  {%- block panel_heading scoped %}

    <div class="ui segment {{panel_extra_class}}">
      <div class="ui equal width grid">
        <div class="column">
          <strong class="header item">{%if icon %}<i class="{{ icon }}"></i>{% endif %} {{ title }}</strong>
        </div>
        <div class="right floated right aligned column">
          {%- if btn and (btn_href or btn_text) -%}
            {%- if btn_href %}
              <a class="ui compact tiny button {{ btn_class }}" href="{{ btn_href }}">
                {% if btn_icon %}<i class="{{ btn_icon }}"></i> {% endif %}{{ btn }}
              </a>
            {%- elif btn_name %}
              <button name="{{ btn_name }}" class="ui compact tiny button {{ btn_class }}">{% if btn_icon %}<i class="{{ btn_icon }}"></i> {% endif %}{{ btn }}</button>
            {%- endif %}
          {%- endif -%}

          {%- if btn2 and btn_href2 -%}
            {%- if btn_href2 %}
              <a class="ui compact tiny button {{ btn_class2 }}" href="{{ btn_href2 }}">{% if btn_icon2 %}<i class="{{ btn_icon2 }}"></i> {% endif %}{{ btn2 }}</a>
            {%- elif btn_name2 %}
              <button name="{{ btn_name2 }}" class="ui compact tiny button {{ btn_class2 }}">{% if btn_icon2 %}<i class="{{ btn_icon2 }}"></i> {% endif %}{{ btn2 }}</button>
            {%- endif %}
          {%- endif -%}
        </div>
      </div>
    </div>
  {%- endblock %}

  {%- if with_body %}
    <div class="ui segment">
  {%- endif %}

{%- endblock %}
{%- endmacro %}


{%- macro panel_end(with_body=True) %}
{%- block panel_end scoped %}
  {%- if with_body %}
    </div>
  {%- endif %}
</div>
{%- endblock %}
{%- endmacro %}
