Git Product home page Git Product logo

elm-mdc's Introduction

Material Components for the Web for Elm

Port of Google's Material Components for the Web CSS/JS implementation of the Material Design Specification.

Live demo & package documentation (not released on package.elm-lang.org yet, see Building the documentation below).

The implementation is based on debois/elm-mdl, which uses the now abandoned Material Design Light framework.

Usage

This library depends on an external JavaScript asset elm-mdc.js which you have to require in your index.html. This library currently support MDC Web v0.37.1. Both assets, elm-mdc.js, and material-components-web.css are generated by running make.

Include elm-mdc.js before you include elm.js:

<body>
  <script src="elm-mdc.js"></script>
  <script src="elm.js"></script>

We recommend that you include the following resources as well:

<head>
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css" rel="stylesheet">
  <link href="material-components-web.css" rel="stylesheet">
</head>

We recommend that you load Roboto from Google Fonts and set .mdc-typography on <body>:

<head>
  <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
</head>
<body class="mdc-typography">
</body>

Example application

See examples/hello-world/ for a full example. You have to run make in the root repository before to create the files elm-mdc.js and material-components-web.css.

module Main exposing (..)

import Html exposing (Html, text)
import Material
import Material.Button as Button
import Material.Options as Options


type alias Model =
    { mdc : Material.Model Msg
    }


defaultModel : Model
defaultModel =
    { mdc = Material.defaultModel
    }


type Msg
    = Mdc (Material.Msg Msg)
    | Click


main : Program Never Model Msg
main =
    Html.program
    { init = init
    , subscriptions = subscriptions
    , update = update
    , view = view
    }


init : ( Model, Cmd Msg )
init =
    ( defaultModel, Material.init Mdc )


subscriptions : Model -> Sub Msg
subscriptions model =
    Material.subscriptions Mdc model


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        Mdc msg_ ->
            Material.update Mdc msg_ model

        Click ->
            ( model, Cmd.none )


view : Model -> Html Msg
view model =
    Html.div []
        [
          Button.view Mdc "my-button" model.mdc
              [ Button.ripple
              , Options.onClick Click
              ]
              [ text "Click me!" ]
        ]

Build instructions

Building the demo

$ make build-demo
$ open build/index.html

Building the demo on Windows

$ build.cmd build-demo
$ build/index.html

Building the documentation

$ make docs

Building the documentation on Windows

$ build.cmd docs

Contribute

Contributions are warmly encouraged - please get in touch! Use GitHub to report bugs, too.

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.