IMPR: Fontawesome SVG option

This commit is contained in:
Tony Air 2021-11-23 14:38:31 +02:00
parent 1ed6b65909
commit fcaa06a930
2 changed files with 8 additions and 2 deletions

View File

@ -9,6 +9,7 @@ A2nt\CMSNiceties\Templates\DeferredRequirements:
noreact: false
nojquery: true
jquery_version: '3.4.1'
fontawesome_svg: true
SilverStripe\FontAwesome\FontAwesomeField:
version: '5.12.0'

View File

@ -22,6 +22,7 @@ class DeferredRequirements implements TemplateGlobalProvider
private static $nojquery = false;
private static $jquery_version = '3.4.1';
private static $nofontawesome = false;
private static $fontawesome_svg = true;
private static $custom_requirements = [];
/**
@ -86,8 +87,12 @@ class DeferredRequirements implements TemplateGlobalProvider
? Config::inst()->get(FontAwesomeField::class, 'version')
: $config['fontawesome_version'];
if ($config['fontawesome_svg']) {
Requirements::customScript('FontAwesomeConfig={searchPseudoElements:true}');
self::loadJS('//use.fontawesome.com/releases/v'.$v.'/js/all.js');
} else {
self::loadCSS('//use.fontawesome.com/releases/v'.$v.'/css/all.css');
}
}
self::loadCSS($mainTheme.'.css');