UNPKG

fontawesome-svg-sprite-generator

Version:

Generate custom SVG sprites for a selected number of Font Awesome 5 icons

137 lines 4.43 kB
import { AbstractElement, Icon, IconLookup, IconParams } from '@fortawesome/fontawesome-svg-core'; export declare type IconQuery = IconLookup | [IconLookup, IconParams]; export declare type IconDescriptor = IconQuery | Icon; export declare type IconDescriptors = IconDescriptor[] | { [id: string]: IconDescriptor; }; /** * Additional options for the SVG sprite generation. */ export interface Options { /** * Include a XML declaration (e.g. `<?xml version="1.0" encoding="UTF-8"?>`) * in the SVG output. * * @default true */ xmlDeclaration?: boolean; /** * A license string to include in the SVG document. Can be empty to disable. * Defaults to the usual attribution notice for Font Awesome Free. */ license?: string; } /** * A SVG sprite generated for a number of Font Awesome icons. */ export interface Sprite { /** * The abstract representation of the generated SVG document. * Can be used to make further modifications to the SVG document. */ readonly abstract: AbstractElement; /** * The raw SVG markup of the generated SVG document. */ readonly svg: string; /** * The symbols contained in this sprite. */ readonly symbols: IconSymbol[]; /** * A map with additional attributes for each symbol. * Can be serialized to JSON for use in various template languages. */ readonly attributes: { [id: string]: SymbolAttributes; }; } /** * Additional attributes for an {@link IconSymbol}. */ export interface SymbolAttributes { /** * (Optional) CSS classes for the icon. * Can be used to automatically set the correct size of the icon. * * To use them, load the stylesheet (`fa-svg-with-js.css`) and add * the specified list of classes to all uses of the SVG icon. You * can also add * {@link https://fontawesome.com/how-to-use/on-the-web/styling|further CSS classes} * to customize the style. * * @example * ```xml * * <svg class="... insert classes here"> * <use href="sprite.svg#id"></use> * </svg> * ``` * @see {@link https://github.com/Minecrell/fontawesome-svg-sprite-generator#styling|Styling} */ readonly class: string; /** * The SVG `viewBox` of the icon. Without a `viewBox` on the `<svg>` * element surrounding the `<use>` element on each usage, the icon won't * scale correctly unless both width and height are set using CSS * (e.g. using {@link #class}). * * To scale the icons while preserving their aspect ratio, the correct * `viewBox` must be supplied on each use of the icon. * * @example * ```xml * * <svg viewBox="... insert view box here"> * <use href="sprite.svg#id"></use> * </svg> * * ``` * @see {@link https://github.com/Minecrell/fontawesome-svg-sprite-generator#styling|Styling} */ readonly viewBox: string; /** * The title provided for accessibility for this icon. */ readonly title?: string; } /** * A single icon contained as `<symbol>` in a SVG {@link Sprite}. */ export interface IconSymbol { /** * The unique ID of this symbol. */ readonly id: string; /** * The {@link Icon} this symbol was generated for. */ readonly icon: Icon; /** * The abstract representation of this symbol in SVG. */ readonly symbol: AbstractElement; /** * Additional attributes for this symbol. */ readonly attributes: SymbolAttributes; } /** * Generates a SVG sprite for the selected icons. * * The first parameter may be either an object, mapping each icon to an * (unique) ID, or an array (in which case an ID will be generated * automatically for each icon). * * Icon selection generally works the same way as in the Font Awesome * JS API. Check README of module for usage examples. * * @param {IconDescriptors} icons The icons to include in the sprite * @param {Options} options Additional options * @returns {Sprite} The generated SVG sprite * * @see {@link https://fontawesome.com/how-to-use/font-awesome-api#findicondefinition|findIconDefinition()} * @see {@link https://fontawesome.com/how-to-use/font-awesome-api#icon|icon()} */ export declare function generate(icons: IconDescriptors, options?: Options): Sprite; //# sourceMappingURL=index.d.ts.map