Raynos / mercury

A truly modular frontend framework
http://raynos.github.io/mercury/
MIT License
2.82k stars 143 forks source link

mercury

Deprecated: Not actively being worked on.

Instead tonic and https://tonic.technology/ are actively being worked on.

mercury has some interesting ideas but they are not very practical at scale. tonic is a lightweigth component system on top of web components that leverages the browsers HTML parser for the heavy lifting instead of virtual-dom.

It comes with a set of components which help with building apps more quickly by having some re-usable components out of the box.

Description

A truly modular frontend framework

To understand what I mean by truly modular just read the source

Examples

Hello world

'use strict';

var document = require('global/document');
var hg = require('mercury');
var h = require('mercury').h;

function App() {
    return hg.state({
        value: hg.value(0),
        channels: {
            clicks: incrementCounter
        }
    });
}

function incrementCounter(state) {
    state.value.set(state.value() + 1);
}

App.render = function render(state) {
    return h('div.counter', [
        'The state ', h('code', 'clickCount'),
        ' has value: ' + state.value + '.', h('input.button', {
            type: 'button',
            value: 'Click me!',
            'ev-click': hg.send(state.channels.clicks)
        })
    ]);
};

hg.app(document.body, App(), App.render);

Basic Examples

Intermediate Examples

Unidirectional examples

The following examples demonstrate how you can mix & match mercury with other frameworks. This is possible because mercury is fundamentally modular.

Disclaimer: The following are neither "good" nor "bad" ideas. Your milage may vary on using these ideas

Motivation

Mercury vs React

mercury is similar to react, however it's larger in scope, it is better compared against om or quiescent

Modules

mercury is a small glue layer that composes a set of modules that solves a subset of the frontend problem.

If mercury is not ideal for your needs, you should check out the individual modules and see if you can re-use something.

Alternatively if the default set of modules in mercury doesn't work for you, you can just require other modules. It's possible to for example, swap out vtree with react or swap out observ-struct with backbone

See the modules README for more information.

Documentation

See the documentation folder

FAQ

See the FAQ document

API

WIP. In lieu of documentation please see examples :(

Installation

npm install mercury

Development

If you want to develop on mercury you can clone the code

git clone git@github.com:Raynos/mercury
cd mercury
npm install
npm test

npm run tasks

Inspirations

A lot of the philosophy and design of mercury is inspired by the following:

Contributors

MIT Licenced