1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-07 17:33:32 +02:00

[ticket/15538] Add iconify

PHPBB3-15538
This commit is contained in:
mrgoldy 2019-11-06 14:51:36 +01:00
parent 8e8532561b
commit 0eb9912af8
3 changed files with 37 additions and 1 deletions

View File

@ -56,7 +56,7 @@ class icon extends \Twig\Extension\AbstractExtension
* Generate icon HTML for use in the template, depending on the mode.
*
* @param environment $environment Twig environment object
* @param string $type Icon type (font|png|svg)
* @param string $type Icon type (font|iconify|png|svg)
* @param string $icon Icon name (eg. "bold")
* @param string $title Icon title
* @param bool $hidden Hide the icon title from view
@ -72,6 +72,7 @@ class icon extends \Twig\Extension\AbstractExtension
switch ($type)
{
case 'font':
case 'iconify':
$source = '';
break;

View File

@ -0,0 +1,4 @@
{% spaceless %}
<i class="iconify o-icon {{ ICON ~ (CLASSES ? ' ' ~ CLASSES) }}"{% if S_HIDDEN %}{% if TITLE %} title="{{ lang(TITLE) }}"{% endif %} aria-hidden="true"{% endif %}{{ ATTRIBUTES }}></i>
{% if TITLE %}<span{% if S_HIDDEN %} class="sr-only"{% endif %}>{{ lang(TITLE) }}</span>{% endif %}
{% endspaceless %}

View File

@ -302,6 +302,37 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
'<i class="o-icon font fa-pencil a-class another-class" title="Pencil icon" aria-hidden="true" data-attr-1="true" data-attr-2="two"></i>
<span class="sr-only">Pencil icon</span>'
],
/** Iconify: default */
[
[
'type' => 'iconify',
'icon' => 'phone',
'title' => '',
'hidden' => false,
'classes' => '',
'attributes' => [],
],
[],
'<i class="iconify o-icon phone"></i>',
],
/** Iconify: all options */
[
[
'type' => 'iconify',
'icon' => 'pencil',
'title' => 'ICON_PENCIL',
'hidden' => true,
'classes' => 'icon-lg',
'attributes' => [
'data-swap' => 'Swap text',
],
],
[
'ICON_PENCIL' => 'Pencil icon',
],
'<i class="iconify o-icon pencil icon-lg" title="Pencil icon" aria-hidden="true" data-swap="Swap text"></i>
<span class="sr-only">Pencil icon</span>',
],
/** PNG: default */
[
[