Code Monkey home page Code Monkey logo

yama.js's Introduction

Yama.js

Build Reusable UI in Javascript

Yama.js is an attempt to combine what I liked most of Angular, Knockout and React.

It gets :

  • from React: The "everything is a component" philosophy and UI description in javascript files,
  • from Angular : Observables with seamless js syntax. myComponent.title = "Hi" instead of myComponent.title("Hi")
  • from Knockout : Declarative binding attributes

Enhanced reusability

Yama encourages you to describe your UI as a component, that means you can reuse it later inside another component.

Declarative UI in js

Yama includes a simple templating syntax to build the dom tree of your UI, and it binds automatically events and observables to your view object.

Real observables

Observables with seamless js syntax. Yama uses native javascript accessors to handle changes in view objects. It means that you can't get in trouble with digest loop because there isn't one.

Free, open source

fork this repo

Vanilla JavaScript

works with any web framework and has no dependencies.

Not verbose

You only take care of writing the behaviour of your UI, nothing else. See "to do list" example

Lightweight

7 KB when minified

Examples

Hello world example

yama.register({
    name : 'myComponent1',
    draw : function(){
        /*!
        root
            div text:title
        !*/
    },

    title : "Hello, world !"
});

and you can use it like this :

var myComponent = new yama.components.myComponent1(document.body);

A simple To Do List

yama.register({
    name : 'toDoListComponent',
    draw : function(){
        /*!
        root
          input value:curTask avalue:curTask onenter:addTask
          div
            foreach:itVar taskItem:taskList
              div
                span text:taskItem
                span:close text:closeText onclick:onCloseClick
        !*/
    },

    curTask : "",
    closeText : "ร—",
    taskList : ["Go to Walmart", "Learn to Play Guitar", "Justin Bieber concert"],

    addTask : function(){
        this.taskList.unshift(this.curTask);
        this.curTask = '';
    },
    onCloseClick : function(g){
        this.taskList.splice(g('itVar'), 1);
    }
});

Result : Yama to do list See it live

See more examples on project website

License

MIT

yama.js's People

Contributors

celebio avatar

Watchers

James Cloos avatar Broch Stilley avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.