1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/15538] Create macro and remove icons

PHPBB3-15538
This commit is contained in:
mrgoldy
2019-09-30 16:42:03 +02:00
committed by Marc Alexander
parent 094f0f663c
commit d8274c19c8
14 changed files with 200 additions and 178 deletions

View File

@@ -0,0 +1,33 @@
{# Wrapper function #}
{% macro Icon(type, icon, classes = '', title = '', hidden = false, attributes = {}) %}
{% set type = type|capitalize %}
{% if type in ['Fa', 'Png', 'Svg'] %}
{{ attribute(_self, type, [icon, classes, title, hidden, attributes]) }}
{% endif %}
{% endmacro Icon %}
{# FA icons #}
{% macro Fa(icon, classes = '', title = '', hidden = false, attributes = {}) %}
<i class="o-icon font fa-{{ icon ~ Implode_classes(classes) }}"{% if hidden %}{% if title %} title="{{ lang(title) }}"{% endif %} aria-hidden="true"{% endif %}{{ _self.attributes(attributes) }}></i>
{% if title %}<span{% if hidden %} class="sr-only"{% endif %}>{{ lang(title) }}</span>{% endif %}
{% endmacro Fa %}
{# PNG icons #}
{% macro Png(icon, classes = '', title = '', hidden = false, attributes = {}) %}
<img class="o-icon png png-{{ icon ~ Implode_classes(classes) }}" src="{{ icon|png_path }}" alt="{{ lang(title) }}"{{ _self.attributes(attributes) }}
{% endmacro Png %}
{# SVG icons #}
{% macro Svg(icon, classes = '', title = '', hidden = false, attributes = {}) %}
{% set title_id = title ? title|lower|replace({' ': '_'}) ~ '-' ~ random() %}
<svg class="o-icon svg svg-{{ icon ~ Implode_classes(classes) }}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"{% if title %}{% if hidden %} aria-hidden="true"{% endif %} aria-labelledby="{{ title_id }}"{% endif %} role="img"{{ _self.attributes(attributes) }}>
{% if title %}
<title id="{{ title_id }}">{{ lang(title) }}</title>
{% endif %}
{{ svg_clean(icon) }}
</svg>
{% endmacro Svg %}