kravcik / latte-font-awesome-icon
Simple {icon} macro for Latte, which allow short entry of font-awesome icons.
Installs: 6 876
Dependents: 1
Suggesters: 1
Security: 0
Stars: 1
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- php: ^8.0
- latte/latte: ^3
- nette/utils: ^4
Requires (Dev)
- modul-is/coding-standard: ^4
- nette/caching: ^3.2
- nette/robot-loader: ^4
- nette/tester: ^2.4
- phpstan/phpstan: ^1
- tracy/tracy: ^2.9
README
New font awesome icons - latte generator. Replace older https://github.com/kravcik/nette-macro-fontawesome.
Register Extension
latte: extensions: - Kravcik\LatteFontAwesomeIcon\Extension
You can also set default values, it is quite simple:
latte: extensions: - Kravcik\LatteFontAwesomeIcon\Extension(defaultStyle: far, defaultFixedWidth: false, defaultElement: i)
Extension parameters
defaultStyle
- choose FA style (fas|far|fal|fab etc.), default isfal
defaultFixedWidth
- auto addingfa-fw
to icons, defaults istrue
defaultElement
- HTML element to generate icon, default isspan
Macro parameters
Parameters can be named or ordered by numeral indexes (see examples)
color
- color for current icon, generatetext-primary
for bootstrap colors, for others gocolor-xxx
size
- size for current icon, for numeric generatefa-2x
, for stringsfa-lg
fw
- fixed widthfa-fw
for current iconelement
- custom HTML element for current iconstyle
- style for current icon (fas|far|fal|fab etc.)class
- custom class add for current HTML element
Examples
Examples depends on default values, so we using default setting (fal, fw, span).
{icon star}
-> <span class="fal fa-star fa-fw"></i>
{icon star, primary}
-> <span class="fal fa-star text-primary fa-fw"></span>
{icon star, red}
-> <span class="fal fa-star color-red fa-fw"></span>
{icon star, null, lg}
-> <span class="fal fa-star fa-lg fa-fw"></span>
{icon star, yellow, 2}
-> <span class="fal fa-star color-yellow fa-2x fa-fw"></span>
{icon star, blue, size: 2, style: far}
-> <span class="fal fa-star color-blue fa-2x"></span>
{icon star, class: foo, color: green}
-> <span class="fal fa-star color-green foo"></span>