Inline icon fetcher module for Phospher Icons. Returns SVG for a Phospher icon based on name and style.
ph = require("phospher")
ph.icon(name, [style], [class], [fill])
ph = require("phospher")
atom_svg = ph.icon("atom")
github_svg = ph.icon("github-logo", "duotone")
blue_icon = ph.icon("bell", "bold", "my-icon", "blue")
Returns SVG string for the requested Phospher icon.
Parameters:
name (string, required) - Icon namestyle (string, optional) - Icon style. Defaults to cfg_default_style or "bold" if not configuredclass (string, optional) - CSS class to add to SVG element. Default: "icon-inline"fill (string, optional) - SVG fill color. Default: "currentColor"Returns:
string - SVG markup for the icon with injected class and fill attributes, or placeholder SVG if icon not foundthin, light, regular, bold, filled, duotoneboldSet defaults in the phospher.du datastore. All optional.
ph_ds = datastore("phospher.du")
ph_ds.set("cfg_local", "path to store / load cached icon files")
ph_ds.set("cfg_default_style", "icon style to default to")
ph_ds.set("cfg_class", "CSS class to inject into SVG elements")
ph_ds.set("cfg_fill", "SVG fill color to inject into elements")
ph_ds.set("cfg_placeholder", "svg source for icons not found by name")
ph_ds.set("cfg_cdn", "url for icon CDN source")
The module supports caching. Be aware if you bundle inside your app you will want to define a true local path to use for storing new icons. Otherwise it will default to the bundled folder. This works for loading but not for saving since the local vfs of a bundled app is read-only.
Icons provided by Phosphor Icons — a free, extensive icon set under the MIT License.
Source: phosphor-icons/core