All Projects → MajorLeagueBaseball → g5-component

MajorLeagueBaseball / g5-component

Licence: other
Event based Browserify component scaffold. ⚾

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to g5-component

Phaser Node Kit
Rapid Game Development with PhaserJS and Node for Modern Browsers
Stars: ✭ 39 (+160%)
Mutual labels:  browserify, scaffold
lnv-mobile-base
移动端开发脚手架-基于gulp的使用zepto、handlebars、sass并且带移动端适配方案(flexible.js)的前端工作流,旨在帮助移动端项目的开发
Stars: ✭ 41 (+173.33%)
Mutual labels:  scaffold
browserify-bower
A browserify plugin, to enable you use bower components just like node modules
Stars: ✭ 20 (+33.33%)
Mutual labels:  browserify
hbuild
⚔repaid build web/vue/react project starter kit with cli
Stars: ✭ 37 (+146.67%)
Mutual labels:  scaffold
generator-go
A Yeoman generator to scaffold a simple golang application
Stars: ✭ 46 (+206.67%)
Mutual labels:  scaffold
modular
Scaffold a react monorepo and its component parts.
Stars: ✭ 13 (-13.33%)
Mutual labels:  scaffold
sentiment-analysis
🎈 A Node.js AFINN-111 based sentiment analysis module
Stars: ✭ 26 (+73.33%)
Mutual labels:  browserify
browserify-persist-fs
Efficient & stable persistent filesystem cache for browserify
Stars: ✭ 16 (+6.67%)
Mutual labels:  browserify
facebook-clone
Building Facebook clone. As usual, any additional styling will be up to you but the really important stuff is to get the data and back end working properly.
Stars: ✭ 14 (-6.67%)
Mutual labels:  scaffold
memo-async-lru
Memoize Node.js style callback-last functions, using an in-memory LRU store
Stars: ✭ 17 (+13.33%)
Mutual labels:  browserify
ts-scaffold
🏗 ts-scaffold - Scaffold project for Typescript projects, with Unit Tests and basic dependencies set up
Stars: ✭ 13 (-13.33%)
Mutual labels:  scaffold
scaffold
Scaffold for laravel
Stars: ✭ 51 (+240%)
Mutual labels:  scaffold
makes
A tool to scaffold new projects, simple enough that you would want to define your own skeletons (aka generators).
Stars: ✭ 18 (+20%)
Mutual labels:  scaffold
browserify-aes
aes, for browserify
Stars: ✭ 56 (+273.33%)
Mutual labels:  browserify
uniapp-scaffold
基于Vue.js的跨平台小程序脚手架、设计语言、组件库及插拔式模板
Stars: ✭ 87 (+480%)
Mutual labels:  scaffold
scaffold-command
Generates code for post types, taxonomies, blocks, plugins, child themes, etc.
Stars: ✭ 149 (+893.33%)
Mutual labels:  scaffold
sitio
imperative static site generator powered by React and browserify
Stars: ✭ 49 (+226.67%)
Mutual labels:  browserify
generator-deepexi-spring-cloud
deepexi java scaffold(spring cloud) generator
Stars: ✭ 30 (+100%)
Mutual labels:  scaffold
laravel-scaffold-v1
The base for developing awesome projects
Stars: ✭ 15 (+0%)
Mutual labels:  scaffold
VineRelayStore
🔥 VineRelay is Content Management Boilerplate which enables you to quickly scaffold a shop with the basic features using React, Relay and GraphQL.
Stars: ✭ 16 (+6.67%)
Mutual labels:  scaffold

g5-component.js

Event based Browserify component scaffold.

NPM version NPM license GitHub issues



Setup

Install the package and use it as a module

Development tools are dependencies of g5-component to allow you to install g5-component as a devDependency and still be able to run all the command line build scripts.

npm i g5-component --save-dev

Or clone the repo and use it as a scaffold/boilerplate for your component

git clone https://github.com/MajorLeagueBaseball/g5-component.git && cd g5-component

Install

Install dependencies, run the initial build, and start the development server

npm i && npm run build && npm run start-dev

You can also separately npm run serve and npm run watch instead of start-dev to see server and build information in different tabs.


Usage Example

Based on the provided linescore example

<section class="g5-component g5-component--linescore"></section>
let linescoreComponent = g5Component({
    component: 'g5-component--linescore',
    container: document.querySelector('.g5-component--linescore'),
    css: 'g5-component--linescore-initiated',
    interval: 15000,
    path: '/src/data/linescore.json'
});

linescoreComponent.init();

Options

A single shared options Object

Option Type Description Default
component String component name/class ''
container Element primary container ''
css String classes to add after instantiation g5-component
i18n String localization en
interval Number polling interval 40000
path String data path to fetch (remote or local) ''
enableFetch Boolean flag to enable/disable initial data fetch true
enablePolling Boolean flag to enable/disable data polling true
extendListeners Function callback executed after all event listeners have been added undefined
log Function an arbitrary log function (memory sink)

Methods

Simple set of core methods

linescoreComponent.init(); // initiates component
linescoreComponent.hasInstance(); // checks if container has an instance of g5-component
linescoreComponent.detachEvents(); // detaches all events
linescoreComponent.attachEvents(); // attaches all events
linescoreComponent.log(...args); // by default, logs to a memory array. Can be overridden in opts.
linescoreComponent.log.toConsole(); // print default memory array to console.
linescoreComponent.destroy(); // kills component instance, cleans everything out to prevent memory leaks

Events / Listen

Events must be attached before the component is instantiated

linescoreComponent.on('ready', (obj) => {
    // console.log('component model and viewModel have been initiated', obj);
});

linescoreComponent.on('data', (data) => {
    // console.log('component data from model', data);
});

linescoreComponent.on('data-error', (err) => {
    // console.log('component model data error', err);
});

linescoreComponent.on('destroy', (obj) => {
    // console.log('component instance killed', obj);
});

linescoreComponent.on('start', () => {
    // console.log('component start fetch');
});

linescoreComponent.on('stop', () => {
    // console.log('component stop fetch');
});

Events / Trigger

Events must be triggered after the component is instantiated

//
// Used with the `enableFetch` option (which toggles the initial data fetch), this
// event allows direct passing of a data Object via an event
//
linescoreComponent.emit('synthetic-data', data);

//
// stops data polling on component
// event is ignored if data polling is already stopped
//
linescoreComponent.emit('stop');

//
// resumes data polling on component
// event is ignored if already polling data
//
linescoreComponent.emit('start');

Server / Development

Server running on http://localhost:9966 with automatic split builds (vendor dependencies are built separately for faster build times) [Ctrl+C] to kill server

npm run start-dev

Server

Server running on http://localhost:9966 with full build [Ctrl+C] to kill server

npm run start

Commands

build

Builds JS, CSS, and compresses images

npm run build

test

runs test directory through the babel-tape-runner

npm test

lint

lint via JSHint, options set in .jshintrc

npm run lint

compress-images

compresses all images in src/images/ and outputs to src/images/build

npm run compress-images

Browser Support

Chrome Firefox IE Opera Safari
10+ 6.1+






            ______
            _\ _~-\___
    =  = ==(____G5____D
                \_____\___________________,-~~~~~~~`-.._
                /     o O o o o o O O o o o o o o O o  |\_
                `~-.__        ___..----..                  )
                      `---~~\___________/------------`````
                      =  ===(_________D





Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].