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

vape

v1.0.6

Published

## ToDo's

Downloads

7

Readme

Vape JavaScript Framework

ToDo's

  • [ ] Add a better method to register component names, because uglifiers will rename all classes e.G. class Button will be converted to function z() in ES5.
  • [ ] Use EventEmitter3 instead of the custom implementation.
  • [ ] Implement unit-tests with Chai and Mocha.
  • [ ] Adding a continous integration service like Travis and Code quality tool like codeclimate.
  • [ ] Do something against memory leaking and for better performance with e.g. disposables.
  • [ ] Adding static modules without event bindings in register method e.g. for Accordeons.

About it

Vape offers all frontend developer the access to write modern and class based ES6 code for the browser by splitting the Website into tiny modules. Each module will be represented as an ES6 class, which can inherit from other base Classes. There are a lot more features like the Utility class, automatic bootstrapping and autobinding module context to each class.

Contents

Installation

You can install this package via Bower (coming soon) or via NPM (recommended)

npm install --save vape
bower install --save vape

Information: It is highly recommended to use vape with a transpiler such as babel to adapt the written code to the current browsers.

Getting started

There are only a few simple steps to follow.

1. Create your Module classes

You have to inherit from the base vape Component class and export it back.

// components/atoms/Foo/js/Foo.js
import Component from vape;

class Foo extends Component {
    constructor() {
        super();
    }
}

export { Foo };

2. Register your Module and create Application

Next up you'll need an instance of vape's Application class, where you can register your custom modules afterwards.

import Application from vape;
import Foo from 'atoms/Foo/js/Foo';

const MyApp = new Application();

MyApp.registerComponent(Foo);

export { MyApp as App };

3. Annotate your HTML Markup

Next up you have to annotate the Markup with some attributes to enable autoloading your whole application.

<html>
<body data-v-application="MyTestApp">
    <div class="a-foo a-foo--modifier" data-v-component="Foo">
        <strong>Hellow there!</strong>
    </div>
</body>
</html>

4. Have some fun, but ...

Finally you need to transpile your application file, which imports all your modules, to ES5!

Advanced

Inheritance

Vape Components can inherit from each other, for example you have a normal Button, a ButtonLink and ButtonTargetLink. Take a look at the three classes below and their usage in the final HTML to learn how the inheritance in vape works.

Note: We use jQuery in this example

Button.js

import $ from jquery;
import Component from vape;

class Button extends Component {
    constructor() {
        super();

        $(this._ctx).on('click', function() {
            self.onClickAction();
        });
    }

    onClickAction() {
        // Do nothing here ...
    }
}

export { Button };

ButtonLink.js

import $ from jquery;
import Button from 'Button';

class ButtonLink extends Button {
    constructor() {
        super();
    }

    onClickAction() {
        window.location.href = $(this._ctx).text();
    }
}

export { ButtonLink };

ButtonLink.js

import ButtonLink from 'ButtonLink';

class ButtonLinkAction extends ButtonLink {
    constructor() {
        super();
    }

    onClickAction() {
        alert('Some action happening!');
    }
}

export { ButtonLinkAction };

Register the modules

import Application from vape;

import Button from 'Button';
import ButtonLink from 'ButtonLink';
import ButtonLinkAction from 'ButtonLinkAction';

const ButtonApp = new Application({
    context: document
});

ButtonApp.registerComponents([
    Button,
    ButtonLink,
    ButtonLinkAction
]);

export { ButtonApp as App };

Custom annotation names

You can also use your own annotations inside the HTML if you don't like the default data-v-component or data-v-id attributes. For example: You're working on a project which name is Healthy Shop System you could use the shortened name hss.

Setting your custom prefix is pretty simple and you can do it even if your project is already up and running:

import Application from vape;
import { Calculator, Button } from 'components/bundle';

const HSSApp = new Application({
    domAttrPrefix: 'data-hss'
});

HSSApp.registerComponents([
    Calculator,
    Button
]);

export { HSSApp as App };

So, now you can change your HTML annotations the the following example:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Healthy Shop System - Home</title>
</head>
<body data-hss-application="ECommerce">
    <div class="a-calculator" data-hss-component="Calculator">
        <h2>Calculate something!</h2>
        <input type="number" name="calcin" placeholder="e.g. 12345">
    </div>
</body>
</html>