npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@spiral-toolkit/core

v1.2.1

Published

Spiral Scout Frontend Framework

Downloads

15

Readme

#sf.js Spiral Frontend micro-framework (alpha)

Build Status devDependency Status

sf.js has been made to auto init javascript modules/components/plugins.

Based on DOM Mutations

API

Instances

-- sf.createModulePrototype() - creates prototype of new instance

-- sf.registerInstanceType(constructorFunction, cssClassName, isSkipInitialization) - register new instance type

  • @param {Function} constructorFunction - constructor function of instance
  • @param {String} [cssClassName] - css class name of instance. If class not provided that it can't be automatically controlled by DomMutation. But you still can use it from JS.
  • @param {Boolean} [isSkipInitialization=false] - skip component initialization, just adding, no init nodes.

-- sf.addInstance(instanceName, node, options) - add instance

  • @param {String} instanceName - name of instance
  • @param {Object} node - dom node
  • @param {Object} [options] all options for send to the constructor
  • @returns {boolean}

-- sf.removeInstance(instanceName, node) - remove instance

  • @param {String} instanceName - name of instance class
  • @param {Object|String} node - dom node ID
  • @returns {boolean}

-- sf.getInstance(instanceName, node) - get instance. Return instance object of this dom node

  • @param {String} instanceName - name of instance
  • @param {Object|String} node - dom node o dome node ID
  • @param {boolean} [isReturnObject] - return object or instance
  • @returns {boolean}

-- sf.getInstances(instanceName) - get instances. Return array of instances objects

  • @param {String} instanceName - name of instance
  • @returns {array|boolean}

Helpers

-- sf.closest(elem, selectors) - found first parent node with matched selector(s)

  • @param {Object} elem - dom node
  • @param {String|Array} selectors - selector or array of selectors
  • @returns {Object| Boolean} - node or false

#Examples:

sf.js includes ajax-form module by default

    <script src="sf.min.js"></script>
    <form class="js-sf-form" action="/someAPI">
        <label class="item-form">
            <span class="item-label">Email</span>
            <input type="text" name="email" class="item-input"/>
        </label>
        <label class="item-form">
            <span class="item-label">Password</span>
            <input type="text" name="password" class="item-input"/>
        </label>
        <button>Send</button>
    </form>

Custom module example (image cropper library)

    <script src="sf.min.js"></script>
    <script src="crop.sf.js"></script>
    <form class="js-sf-form" action="/someAPI">
        <input type="file" class="js-sf-crop"> 
        <button>Send</button>
    </form>

#How it works (in short) Each module is a constructor function and should be registered in sf.js

var Crop = function (sf, node, options) {
    this._construct(sf, node, options);
};
Crop.prototype = Object.create(sf.modules.core.BaseDOMConstructor.prototype);
...
sf.instancesController.registerInstanceType(Crop,"js-sf-crop");

Then, instancesController looks at DOM, and initialize new instance of module for each matched DOM node.
Also it will init new instances if DOM node will be added later.

#todo documentation #14

License

Copyright (c) 2015-2016 Andrew Logunov and contributors. Released under an MIT license.