{% from "_bytesize_icons.html" import bytesize_icon %}

{%- macro icon_for_material(material) -%}
    {%- if material.type == 'lesson' -%}
        {{- bytesize_icon('chevron-right') -}}
    {%- elif material.type == 'cheatsheet' -%}
        {{- bytesize_icon('eye') -}}
    {%- elif material.type == 'homework' -%}
        {{- bytesize_icon('edit') -}}
    {%- elif material.type == 'special' -%}
        {{- bytesize_icon('flag') -}}
    {%- else %}
        {{- bytesize_icon('link') -}}
    {%- endif -%}
{%- endmacro -%}

{%- macro material_li(material) %}
    {%- set url = material.url_or_none() %}
    <li>
        {% if url %}
            
        
        
        <a href="{{ url }}">
        {% endif %}
            {{- icon_for_material(material) | sanitize }}
            {#- XXX: no need to sanitize the icon #}
            {{- material.title -}}
        {% if url %}
        </a>
        {% endif %}
    </li>
{%- endmacro -%}

{%- macro material_list(materials, filter_type=None) %}
    <ul class="material-list">
        {% for mat in materials %}
            {% if filter_type == None or mat.type == filter_type %}
                {{ material_li(mat) }}
            {% endif %}
        {% endfor %}
    </ul>
{%- endmacro -%}
