Sources
Icon fonts
CSS icon fonts by class or by glyph.
register('fa', {
className: 'fa',
mapping: { heart: 'fa-heart', lock: 'fa-lock' }, // or (name, variant) => string
})
<ml-sigil-icon name="heart" library="fa"></ml-sigil-icon>
<!-- <i class="fa fa-heart" aria-hidden="true"></i> -->
Load the font's own CSS as usual; this only produces the <i>. A name a record mapping doesn't have isn't this library's, so the registry moves on - the same "not mine" answer every source gives. With no mapping at all, the name itself is the modifier class.
Glyph fonts
For fonts addressed by codepoint or ligature, use glyphs. The glyph becomes the text content:
register('mi', {
className: 'mi',
glyphs: {
heart: 'e001', // hex codepoint
menu: 'menu', // ligature
star: '★', // character
},
})
Values are hex codepoints, characters, or ligature names. Load the @font-face yourself:
@font-face {
font-family: 'mi';
src: url('/fonts/mi.woff2') format('woff2');
}
.mi {
font-family: 'mi';
line-height: 1;
}
Loading…
Loading…
Variants
Function-form mapping or glyphs receive variant:
register('toggle', {
className: 'mi',
glyphs: (name, variant) => (variant === 'active' ? '★' : '☆'),
})
Loading…
Default a variant in the function: (name, variant = 'regular') => ….