Coder Social home page Coder Social logo

evandisoft / decjs Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 20 KB

Library for composing UI's using pure javascript. Easy to get references from nested elements. Uses the ES6 Proxy feature.

License: MIT License

JavaScript 49.33% HTML 50.67%
javascript html user-interface declarative-ui declarative pure-javascript javascript-ui compnent

decjs's Introduction

This is a library that uses the ES6 Proxy feature to easily make UI's in declarative javascript.

Here is an example:

let c=decjs.create,elements={},proxies=decjs.ElementProxies(elements)


// This creates a div in the body element of class 'maindiv' that has an input, a label, and a button.
// It saves references for the input and the button. The references can be retrieved even if the 
// input or the button are arbitrarily nested.
decjs.body.div({class:'maindiv'},
    proxies.nameInput=c.input({value:"Input!"}),
    c.label("Click this button:"),
    proxies.doneButton=c.button("Click me!")
)

// The references to the input and the button were copied over to the 'elements' object automatically.
// 'proxies' is a proxy object that is used to store ElementProxies by name, as well as copy those 
// references into an object holding elements by the same name. (So they can be accessed later)
elements.doneButton.onclick=function(){
    decjs.body.div(c.label("Input was "),c.label(elements.nameInput.value))
}

More features and information is in tutorial.html. (The tutorial is in the source code. You can run it to verify the examples work.)

This is still a work in progress. I'm certain that almost any conceivable feature could be implemented, but I'm not yet sure exactly what features are desired in practice, or how they should be structured. I will come back to this after I've created a few projects with it.

decjs's People

Contributors

evandisoft 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.