Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c14be3c
Created a HTMLHelper to render an icon
hans2103 Sep 28, 2020
7b27c78
clean code
hans2103 Sep 28, 2020
7d651df
remove hard coded icon
hans2103 Sep 28, 2020
67495f6
https://github.com/joomla/joomla-cms/pull/30792#pullrequestreview-497…
hans2103 Sep 28, 2020
37679ba
Update libraries/src/HTML/HTMLHelper.php
hans2103 Sep 28, 2020
de4d0a1
Update libraries/src/HTML/HTMLHelper.php
hans2103 Sep 28, 2020
a3d7b64
remove $html and $children. Add $srOnly
hans2103 Oct 1, 2020
3babe70
apply HTMLHelper icon including sr-only
hans2103 Oct 1, 2020
a39a884
move function to libraries/src/HTML/Helpers/Icons.php
hans2103 Oct 2, 2020
883cbd0
:wastebasket: housecleaning and apply suggestions by @degobbis
hans2103 Oct 21, 2020
0595258
add missing className
hans2103 Oct 21, 2020
9788848
Merge branch '4.0-dev' into feature/htmlhelper-for-an-icon
hans2103 Oct 21, 2020
93feeb3
Merge branch 'upstream/4.0-dev' into feature/htmlhelper-for-an-icon
hans2103 Oct 21, 2020
7b15551
Update libraries/src/HTML/Helpers/Icons.php
hans2103 Oct 21, 2020
247e055
Update libraries/src/HTML/Helpers/Icons.php
hans2103 Oct 21, 2020
1a950bf
apply Joomla! Coding Standards for DocBlock
hans2103 Oct 21, 2020
7bdf486
replace null by '', since variable is a string and default value null…
hans2103 Oct 21, 2020
c2bf10e
check if variable isset and not empty
hans2103 Oct 21, 2020
b4b4358
Update libraries/src/HTML/Helpers/Icons.php
hans2103 Oct 21, 2020
a38142d
Update libraries/src/HTML/Helpers/Icons.php
hans2103 Oct 22, 2020
22e613d
Update libraries/src/HTML/Helpers/Icons.php
hans2103 Oct 22, 2020
a414b84
removal trim
hans2103 Oct 22, 2020
846466f
#30707 has not been merged yet. :-)
hans2103 Oct 22, 2020
62c833c
remove default icon and add if-then statement to check existence of icon
hans2103 Oct 23, 2020
1df96a3
Merge branch 'upstream/4.0-dev' into feature/htmlhelper-for-an-icon
hans2103 Oct 24, 2020
04c3854
replace return '' by throw
hans2103 Oct 26, 2020
6465af8
Update libraries/src/HTML/Helpers/Icons.php
hans2103 Oct 26, 2020
5589002
Update administrator/language/en-GB/lib_joomla.ini
hans2103 Oct 26, 2020
2a943c4
Update libraries/src/HTML/Helpers/Icons.php
hans2103 Oct 26, 2020
b1660ab
Merge branch 'upstream/4.0-dev' into feature/htmlhelper-for-an-icon
hans2103 Oct 26, 2020
631ab06
added translation to frontend too
hans2103 Oct 27, 2020
cb05e07
removal period
hans2103 Oct 27, 2020
f884d3f
Merge branch 'upstream/4.0-dev' into feature/htmlhelper-for-an-icon
hans2103 Oct 27, 2020
c6e07c6
Merge branch 'upstream/4.0-dev' into feature/htmlhelper-for-an-icon
hans2103 Oct 28, 2020
8947ace
reapply change
hans2103 Oct 28, 2020
d37a47c
Merge branch 'upstream/4.0-dev' into htmlhelper-for-an-icon
hans2103 Nov 26, 2020
2fd362e
FontAwesome provides svg icons... use them
hans2103 Nov 26, 2020
8ddfcde
no idea how to explain the test instructions for this. :-)
hans2103 Nov 26, 2020
7043049
easier for test instructions... after apply path the icons on dashboa…
hans2103 Nov 26, 2020
413191f
add new parameter $type to trigger svg icons
hans2103 Nov 26, 2020
83551d9
adjust settings.json
hans2103 Nov 26, 2020
3b0314c
call helper icons.icon with svg
hans2103 Nov 26, 2020
c91b14c
optimize icons.icon for svg
hans2103 Nov 26, 2020
4a765c5
only set sr-only text when aria-hidden is true
hans2103 Nov 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions administrator/language/en-GB/lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ JLIB_HTML_FEATURED_PENDING_ITEM="Featured, but is Pending."
JLIB_HTML_FEATURED_STARTED="Start: %s"
JLIB_HTML_GOTO_PAGE="Go to page %s"
JLIB_HTML_GOTO_POSITION="Go to %s page"
JLIB_HTML_ICONS_NO_ICON="No icon provided."
JLIB_HTML_MOVE_DOWN="Move Down"
JLIB_HTML_MOVE_UP="Move Up"
JLIB_HTML_NO_PARAMETERS_FOR_THIS_ITEM="There are no parameters for this item."
Expand Down
1 change: 1 addition & 0 deletions build/build-modules-js/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
},
"filesExtra": {
"scss": "scss",
"svgs": "images",
"webfonts": "webfonts"
},
"provideAssets": [
Expand Down
1 change: 1 addition & 0 deletions language/en-GB/lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ JLIB_HTML_FEATURED_PENDING_ITEM="Featured, but is Pending."
JLIB_HTML_FEATURED_STARTED="Start: %s"
JLIB_HTML_GOTO_PAGE="Go to page %s"
JLIB_HTML_GOTO_POSITION="Go to %s page"
JLIB_HTML_ICONS_NO_ICON="No icon provided."
JLIB_HTML_MOVE_DOWN="Move Down"
JLIB_HTML_MOVE_UP="Move Up"
JLIB_HTML_NO_PARAMETERS_FOR_THIS_ITEM="There are no parameters for this item."
Expand Down
8 changes: 7 additions & 1 deletion layouts/joomla/quickicons/icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

$id = empty($displayData['id']) ? '' : (' id="' . $displayData['id'] . '"');
Expand Down Expand Up @@ -63,7 +64,12 @@
<a <?php echo $id . $class; ?> href="<?php echo $displayData['link']; ?>"<?php echo $target . $onclick . $title; ?>>
<?php if (isset($displayData['image'])): ?>
<div class="quickicon-icon d-flex align-items-end <?php echo $size ?>">
<div class="<?php echo $displayData['image']; ?>" aria-hidden="true"></div>
<?php echo HTMLHelper::_('icons.icon',
str_replace('icon-', '', $displayData['image']), [
'text' => Text::_($displayData['name']),
'svg' => true
]
); ?>
</div>
<?php endif; ?>
<?php if (isset($displayData['ajaxurl'])) : ?>
Expand Down
55 changes: 55 additions & 0 deletions libraries/src/HTML/Helpers/Icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Uri\Uri;
use Joomla\Filesystem\Path;
use Joomla\Utilities\ArrayHelper;

/**
* Utility class for icons.
Expand Down Expand Up @@ -128,4 +130,57 @@ public static function svg(string $file, bool $relative = true): ?string

return $file;
}

/**
* Method to write a `<span>` element for an icon
*
* @param string $icon The functional name for an icon.
* @param array $attribs Attributes to be added to the wrapping element
*
* @return string
*
* @throws \InvalidArgumentException
*
* @since __DEPLOY_VERSION__
*/
public static function icon(string $icon, array $attribs = []): string
{
if ($icon === '')
{
throw new \InvalidArgumentException(Text::_('JLIB_HTML_ICONS_NO_ICON'));
}

$class = $icon;

if (isset($attribs['class']))
{
$class .= ' ' . $attribs['class'];
}

$attribs['class'] = $class;

if (!isset($attribs['aria-hidden']))
{
$attribs['aria-hidden'] = 'true';
}

if (isset($attribs['text']) && $attribs['aria-hidden'] === 'true')
{
$text = htmlspecialchars($attribs['text'], ENT_COMPAT, 'UTF-8');
$text = '<span class="sr-only">' . $text . '</span>';
unset($attribs['text']);
}

$output = '<span ' . ArrayHelper::toString($attribs) . '></span>';

if (isset($attribs['svg']))
{
$provider = $attribs['svg']['provider'] ?? 'fontawesome-free';
$group = $attribs['svg']['group'] ?? 'regular';
$path = '/media/vendor/' . $provider . '/svgs/' . $group;
$output = HTMLHelper::_('icons.svg', $icon . '.svg', $path);
}

return $output . $text;
}
}