Inline font styles, remove obsolete icon font

This commit is contained in:
Björn Fromme
2022-02-13 17:36:29 +01:00
parent 47ea384cf2
commit 259e3863ec
10 changed files with 101 additions and 123 deletions
@@ -0,0 +1,56 @@
<?php
namespace EP\EpTheme\ViewHelpers;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Service\ImageService;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class IconViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var bool
*/
protected $escapeOutput = false;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('icon', 'string', 'Icon name');
$this->registerArgument('class', 'string', 'CSS classes');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$imageService = self::getImageService();
$sprite = $imageService->getImage('EXT:ep_theme/Resources/Public/images/icons_sprite.svg', null, false);
$imageUrl = $sprite->getPublicUrl();
return sprintf(
'<svg class="%s"><use href="%s#icon-%s"></use></svg>',
$arguments['class'],
$imageUrl,
$arguments['icon']
);
}
protected static function getImageService()
{
return GeneralUtility::makeInstance(ImageService::class);
}
}