Giter Site home page Giter Site logo

elm-html's Introduction

HTML in Elm

Create composable widgets with the full power of HTML and CSS. This library lets you:

Embedding Elm widgets in existing applications and JS interop are both really easy, so this library takes the next logical step in improving Elm's interop story.

Check out the TodoMVC app for a larger example.

Reusable Widgets

With this library, you have the full power of Elm to create nice abstractions to make your view code modular. Creating a list of user profiles is a matter of can be nicely abstracted with something like this:

import Html (..)

profiles : [User] -> Html
profiles users =
    node "div" [] [] (map profile users)

profile : User -> Html
profile user =
    node "div" [] []
    [ node "img" [ "src" := user.picture ] [] []
    , text user.name
    ]

Of course you may want to use more complex styles, but those can be abstracted out and reused too!

import Html
import Html (..)

profiles : [User] -> Html
profiles users =
    node "div" [] (font ++ background) (map profile users)

font : [(String,String)]
font =
    [ "font-family" := "futura, sans-serif"
    , "color"       := Html.color charcoal
    , "font-size"   := em 1.2
    ]

background : [(String,String)]
background =
    [ "background-color" := Html.color lightGrey ]

With these basic building blocks, it becomes possible to start building stronger abstractions on top of basic HTML and CSS. For example, it may be possible to recreate Elm's Element abstraction using this framework. But more importantly, it is possible for anyone to experiment with other ways to make views modular and pleasant to specify.

Performance

We have written a TodoMVC app with this library and benchmarked it against other popular entries. The benchmark shows that elm-html is really fast, thanks entirely to the virtual-dom project it is built on top of.

Influences

Huge thanks to React and Om which popularized the idea of virtual DOM and came up with optimizations to make it really fast. Another huge thanks to Matt Esch and Jake Verbaten who created virtual-dom and mercury which this library is based on!

elm-html's People

Contributors

process-bot avatar halohalospecial avatar

Watchers

 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.