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:
33
phpBB/styles/all/template/macros.html
Normal file
33
phpBB/styles/all/template/macros.html
Normal 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 %}
|
Reference in New Issue
Block a user