Code Monkey home page Code Monkey logo

angular2-rbi-dart's Introduction

angular2_rbi

This is a small library to use the excellent Material Design Lite (MDL) CSS system with Angular2 and Dart.

I translated the dynamic JavaScript parts of MDL into Dart and made corresponding Angular2 directives. These key on the same selectors as the JavaScript implementation. E.g, If you want a dynamic Material Button, include the 'mdl-js-button' class, just like in the instructions for Material Design Lite. Then, in your component metadata, use the MaterialButton directive provided in package:angular2_rbi/directives.dart to add the dynamic effects.

Caveats

RBI stands for 'Really Bad Idea.' This is a stopgap to make the dynamic stuff in MDL work acceptably in Angular2 for Dart until Angular2 has its own Material Design implementation. It is not an improvement on MDL. In use, it will have the same issues as MDL, which is a large and complex CSS system.

Usage

Follow the directions at http://www.getmdl.io to include the styles and fonts in your loading page. But don't include the MDL JavaScript link; this package substitutes for that functionality.

Use the MDL classes in component templates, and assure that the directives for the 'mdl-js-x...' classes are included in the component metadata. The directive names and selectors are in angular2_rbi/lib/directives.dart.

Here's some example code:

import 'package:angular2/angular2.dart';
import 'package:angular2_rbi/directives.dart';

@Component(selector: 'button-textchanger')
@View(
    template: '''
      <div class="mdl-card mdl-shadow--2dp">
      <div class="mdl-card__title">
      <h2 class="mdl-card__title-text">{{myText}}</h2>
      </div>
      <div class="mdl-card__actions mdl-card--border">
      <button (click)="changeText()" class="mdl-button
      mdl-js-button mdl-button--raised mdl-js-ripple-effect
      mdl-button--colored">Change the text!</button>
      </div>
      </div>
      ''',
    directives: const [MaterialButton])
class ButtonTextChanger {
  String myText = 'I have never been changed!';
  int count = 0;
  changeText() {
    count += 1;
    if (count == 1) {
      myText = 'I have been changed!';
    } else {
      myText = 'I have been changed $count times!';
    }
  }
}

Demo

There is a demo app using this at https://github.com/jwashin/angular2-rbi-demo.

Features and bugs

This currently (3 January, 2016) seems to work with MDL 1.0.6. I have not figured out testing yet, so a contributed test harness would be graciously accepted.

Please file issues with MDL at [Github: Material Design Lite] (https://github.com/google/material-design-lite). And be nice. They have a system to decide what needs to happen when.

You may file feature requests and bugs on this Dart code at my Github.

angular2-rbi-dart's People

Contributors

jwashin avatar mastodon0 avatar

Watchers

 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.