This repository has been archived by the owner on Jan 8, 2023. It is now read-only.
Saxicon class
Lachlan McDonald edited this page Apr 30, 2018
·
20 revisions
The
Saxicon
class is used to process SVGs and returns aSaxiconData
class for outputting data URI's.
Initialise a new instance of the Saxicon class with the provided options (see following section.)
Parsers an array of paths to SVGs, returns a new SaxiconData
instance. Paths that do not exist, or cannot be read, will be captured as errors in the SaxiconData
instance. Files are read synchronously.
Files must be encoded with UTF-8 and byte-order-marks are removed.
Note: At present, there is not an asynchronous version of this method.
Returns a SVG document with all insignificant whitespace removed.
-
replaceColors (Boolean)
Whentrue
, hex colors are replaced with their related color keywords where possible. -
restrict (Array)
Limit replacement to only those color keywords within this array. If empty, all colors are replaced. -
ignore (Array)
Color keywords in this array are excluded from replacement. If empty, no colors are excluded. Colors in this array take precedence over colors in therestrict
option. -
iconName (Function)
Callback function used to generate icon names from the source SVG filenames.
By default, each icon will be named after the original filename without its extension. i.e.arrow-left.svg
becomesarrow-left
.
Function receives the filename as its only argument and should return the icon's name as a valid SASS string.
Advanced options:
-
removeVersion (Boolean)
When true, theversion
attribute is removed from the<svg>
element. -
presentationTags (Array)
List of tags that will have theirstroke
andfill
attributes replaced. -
structuralTags (Array)
List of tags which may contain astroke
orfill
attribute, that are inherited, but otherwise should not have that attribute set if not already present. This option is mainly to handle elements such as<g>
. -
ignoreTags (Array)
Tags to ignore. These tags, and their child tags, will not have their colours replaced (essentially skipped). This option is mainly to handle elements such as<mask>
.