{% import "Toucan/macros/master.html" as master with context %}

{#

 Bootstrap

 A collection of some of Bootstrap components

 Most of the macros must be called in your template around the content to be wrapped in

 {% call collapsible('My Title') %}
    This is the body
 {% endcall %}


#}


{# -------------------------------------------------------------------------- #}

{%-  macro _format_key(val, def) -%}
    {{- val | default(def, true) | slug -}}
{%-  endmacro -%}

{#
Collapsible

    {%  call collapsible('title', key, collapse, parent) %}
        content
    {%  endcall %}

    params:
        - title: The title of the collapsible
        - key: a unique to identify this collapsible
        - collapse: (bool) to collapse or expend the component
        - parent: when using 'collapsible_accordion', pass the parent id
#}
{% macro collapsible(title, key=none,  collapse=false, parent="accordion") %}
     <div class="panel panel-default">
        <div class="panel-heading" role="tab" id="heading{{ _format_key(key, title) }}">
          <h4 class="panel-title">
            <a role="button"
               data-toggle="collapse"
               data-parent="#{{ parent }}"
               href="#wp-collapse{{ _format_key(key, title) }}"
               aria-expanded="true"
               aria-controls="wp-collapse{{ _format_key(key, title) }}">
              {{ title }}
            </a>
          </h4>
        </div>

        <div id="wp-collapse{{ _format_key(key, title) }}"
             class="panel-collapse collapse {% if not collapse %}in{%  endif %}"
             role="tabpanel"
             aria-labelledby="heading{{ _format_key(key, title) }}">
          <div class="panel-body">
            {{ caller() }}
          </div>
        </div>
    </div>
{%  endmacro %}


{#

 Accordion

 Requires the use of collapsable


     {%  call collapsible_accordion() %}
        {%  call collapsible('My Acc Name') %}
            ... content
        {%  endcall %}

     {%  endcall %}

     params:
        - id: a unique identifier
 #}
{%  macro collapsible_accordion(id="accordion") %}

        <div class="panel-group" id="{{ id }}" role="tablist" aria-multiselectable="true">
            {{ caller() }}
        </div>
{%  endmacro %}

{# -------------------------------------------------------------------------- #}

{% macro modal() %}

{% endmacro %}

{# -------------------------------------------------------------------------- #}

{%  macro panel(title) %}
    <div class="panel panel-default">
        <div class="panel-heading">{{ title }}</div>

        <div class="panel-body">
        {{ caller() }}
        </div>

    </div>
{%  endmacro %}



#-------------------------------------------------------------------------------

{% macro theme(name) %}
    {{ master.css_assets('Toucan/bootswatch/%s.css' % name) }}
{% endmacro %}
