1.0.2 • Published 8 years ago

svg-icon-component v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

icon-component

A simple icon component

Built with fastn.js

Usage

Initialise

var createIcon = require('svg-icon-component')({

        // Function to resolve the url location of an icon.
        resolvePath: function(iconName){

            return 'foo/bar/baz' + iconName + '.svg';

        }

    });

Settings

{
    name: String. iconName passed to resolvePath.
}

Standalone

// Create the icon
var icon = createIcon({
        name: 'tick'
    });

// Put the icon's element somewhere in the DOM.
document.body.appendChild(icon.element);

Fastn component

var fastn = require('fastn')({
    ... other components...
    icon: require('svg-icon-component/iconComponent')({
        resolvePath: function(iconName){
            return 'foo/bar/baz' + iconName + '.svg'; // Example path
        }
    })
});

var icon = fastn('icon', { options... });

icon will attempt to use the _generic component provided by fastn.

Inserting

someDomNode.appendChild(icon.element);

Properties

Name

// retrieve value
icon.name(); // returns value of name

// set value
icon.name(newValue); -// returns icon.name property

// watch for changes
icon.name.on('change', function(name){
    // Do something
});
1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago