Giter Club home page Giter Club logo

ember-material-lite's Introduction

ember-material-lite

Build Status NPM Version

Google's Material Design Lite for Ember.js apps

This addon requires ember >= 1.11.0

Installation

# ember-cli < 0.2.3
ember install:addon ember-material-lite
# ember-cli >= 0.2.3
ember install ember-material-lite

Without SASS

This addon can be used without SASS (relying on pure CSS for styles). If you choose this path, you'll need to alter your app slightly.

  1. Delete the ember-cli-sass NPM dependency that the installation blueprint will add to your app.
  2. Add the following line to your ember-cli-build.js.
app.import('node_modules/material-design-lite/material.css');

Configuration

Colors

You can customize the colors of material design elements globally by setting sass variables prior to importing the main styles.

app/styles/app.scss

@import '_color-definitions';

$color-primary: $palette-teal-500;
$color-accent: $palette-pink-A200;

@import 'material-design-lite';

Load Material design icons fontfiles locally

Adding http://fonts.googleapis.com/icon?family=Material+Icons into the index.html just works. But in few scenarios(like running app offline) you would want to include these icon fonts from the project directories itself. To achieve the same, first edit ember-cli-build.js to include the following

var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var mergeTrees = require('broccoli-merge-trees');
var pickFiles = require('broccoli-static-compiler');

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    sassOptions: {
      includePaths: ['node_modules/material-design-lite/src']
    }
  });

  var googleFontFiles = pickFiles(
    'node_modules/material-design-icons/iconfont',
    {
      srcDir: '/',
      files: ['**/*.woff', '**/*.woff2', '**/*.eot', '**/*.ttf'],
      destDir: '/fonts'
    }
  );

  return mergeTrees([app.toTree(), googleFontFiles]);
};

Also Add below code on top of app/styles/app.scss file to import icon font files.

/*Material Icons css*/
@font-face {
  font-family: 'Material Icons';
  font-style: normal;
  font-weight: 400;
  src: url(../fonts/MaterialIcons-Regular.eot); /* For IE6-8 */
  src: local('Material Icons'), local('MaterialIcons-Regular'),
    url(../fonts/MaterialIcons-Regular.woff2) format('woff2'), url(../fonts/MaterialIcons-Regular.woff)
      format('woff'), url(../fonts/MaterialIcons-Regular.ttf) format('truetype');
}

Images

Several of the MDL components reference image assets. In order to include them in your project, edit ember-cli-build.js to include the following:

var mergeTrees = require('broccoli-merge-trees');
var pickFiles = require('broccoli-static-compiler');

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    sassOptions: {
      includePaths: ['node_modules/material-design-lite/src']
    }
  });

  var materialSVG = pickFiles('node_modules/material-design-lite/src/images', {
    srcDir: '/',
    files: ['**/*.svg'],
    destDir: '/images'
  });

  return mergeTrees([app.toTree(), materialSVG]);
};

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

Analytics

ember-material-lite's People

Contributors

batlefield avatar dustinfarris avatar ember-tomster avatar greenkeeper[bot] avatar greenkeeperio-bot avatar hdra avatar jessepinho avatar kategengler avatar kennethkalmer avatar leoeuclids avatar mike-north avatar patrickberkeley avatar remkoboschker avatar renovate-bot avatar rmachielse avatar semantic-release-bot avatar trabus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ember-material-lite's Issues

SASS compilation is missing vendor prefixes

I just noticed this issue when I tested my app on Safari few days ago, the page layout went haywire because the styles are missing some prefixes (most noticeably the lack of flexbox support).

Looking at Google's MDL gulpfile.js, I noticed the build process involves feeding the source through an auto-prefixer,, so I got around this by simply installing https://github.com/kimroen/ember-cli-autoprefixer.

So, what do you think about adding an auto-prefixer as a dependency?

Generator does a few outdated things

  1. Tries to add sassOptions to config/environment.js. New convention is for this to live in ember-cli-build.js.
  2. If you're using pods, you don't want app/templates/application.hbs. The installer adds it without asking.

Selectively import JavaScript

Some of the material lite javascript doesn't jive well with ember. Instead of bringing it all in wholesale, we should be able to opt in to certain modules. Others (i.e., progress, tabs), we'll likely need to write the ember equivalent of

Passing model for dynamic segment to {{mdl-nav-item}}

I was unable to pass the model for a dynamic segment to the {{mdl-nav-item}} component. This is b/c the mdl-nav template passes a route name to the {{link-to}} but no model parameter, which is essential for dynamic routing (e.g. users/:id).

{{link-to navItem.name navItem.route class='mdl-navigation__link'}}

I thought I could pass a string containing both the route name and the model, but was not able to get that to work:

{{mdl-nav-item name="Announcements by Date" action='announcements.day currentDay'}}

A fix would be wonderful. Thanks again for making all of these changes so fast!

I think I missed a step

After installing the addon and running ember generate ember-material-lite, I get this error message: "Uncaught Error: Assertion Failed: A helper named 'mdl-item' could not be found." I think I missed a step but I just not sure where.

Error when using mdl-tabs

Problem:

Getting the following module import error when using mdl-tabs:

Uncaught Error: Could not find module `ember-composability/mixins/parent-component-support` imported from `ember-material-lite/components/mdl-tabs`

Steps to reproduce:

  • $ ember new material-app
  • $ ember install ember-material-lite
  • $ ember generate ember-material-lite material-app
  • Copy the mdl-tabs example from the demo site into application.hbs:
{{#mdl-tabs active='Fruit'}}
  {{#mdl-tab title='Fruit'}}
    This is the fruit tab
  {{/mdl-tab}}
  {{#mdl-tab title='Vegetables'}}
    This is the vegetables tab
  {{/mdl-tab}}
{{/mdl-tabs}}
  • $ ember s

Solutions tried

I tried adding ember-composability to the consuming application however, I get the following helper not found error:

Uncaught Error: Assertion Failed: A helper named 'eq' could not be found

Environment:

OS -> OSX 10.10.4
ember-cli -> 1.13.6
ember -> 1.13.5

Missing icons

Hi,

I installed ember-material-lite on a new project today.
I ran the generating of the blueprint and followed install like in other issues here. Everything seemed to be working, but I could not get any icons !

The theming and components worked, but no icons nowhere.

No render Material Icon

Using the components {{mdl-*}} to display an icon renders [object Object]

ember-cli: 2.5.0
node: 5.7.1
os: darwin x64
Ember: 2.5.1
Ember Data : 2.5.2 
jQuery: 2.2.3

How to reproduce

{{mdl-textfield  isExpandable=true label='Address' expandableIcon='home'}}
{{mdl-button isFloating=true icon='add'}}
{{mdl-icon icon='add'}}
{{#mdl-menu align='bottom-right' class='right'}}
{{#link-to "projects.new" class="ember-view mdl-menu__item mdl-js-ripple-effect" tagName='li'}}New Project{{/link-to}}
{{/mdl-menu}}

Every component has a similar out, only changes the css.

Image render

html output

textfield / textarea do not bind variables from view to controller

First of all thanks for putting this work together.

I have an mdl-textfield that binds his value to a controller variable but when I change the value on the mdl-textfield the property in the controller never gets updated.

It does work the other way around, when I change the property value at the controller level I see the change in the textfield.

Tried also with a regular {{input type="text"}} to check if it was my set up but it worked correctly.

{{mdl-textfield value=identification}}
{{input type="text" value=identification}}

Changing identification on the regular input field does the job but not when I try using the mdl-textfield component.

Installation fails with ember 1.13

$ ember new mdl && cd mdl
...
...coffee break!

$ ember install ember-material-lite
version: 1.13.1
Installed packages for tooling via npm.
installing ember-material-lite
The `ember generate` command requires an entity name to be specified. For more details, use `ember help`.

Fails on Install

Hi I'm working with ember-cli 1.13.1 and I'm trying to install ember-material-lite into a fresh new ember project. I get the following error:

ember install ember-material-lite
version: 1.13.1
Installed packages for tooling via npm.
installing ember-material-lite
The `ember generate` command requires an entity name to be specified. For more details, use `ember help`.

I googled the error and read that it is a silent ember-cli error but my ember-material-lite still doesn't work. I saw in issue #6 that someone has a similar problem.

I'm working with OSX 10.10.4. Can you help me?

Error with 'ember generate' during installation step

I tried to install this addon via 'ember install ember-material-lite' command, and during installation I get this error:

$ ember install ember-material-lite
version: 1.13.5
Installed packages for tooling via npm.
installing ember-material-lite
The `ember generate` command requires an entity name to be specified. For more details, use `ember help`.

Radio buttons do not trigger properly

Clicking on radio buttons causes js error "Uncaught TypeError: Cannot read property 'updateClasses_' of undefined" and thus, it has no effect. The error can be fround in demo site also.

'is-checked' class name in mdl-switch not binded to value

I come to realise that the mdl-switch does not present the actual value. It means, even the value for mdl-switch is false, it still shows active(true). I got it fixed by adding classNameBindings in '-base-toggle-component.js' and extending it to mdl-switch component as below

import BaseToggleComponent from 'ember-material-lite/components/-base-toggle-component';

export default BaseToggleComponent.extend({
  classNames: ['is-upgraded'],
  classNameBindings: ['value:is-checked']
});

Could you please verify if this the only way or is there something i am missing?

Components

Component Reference Implementation Tests Complete
Badges
Buttons
Cards
Tabs
Navbar
Loading
Menus
Sliders
Toggles
Tables
Text Fields
Tooltips

is the project still under dev ?

Hi. The last commits do nothing unless update packges.

I know it's a very good addon but still missing some features. There is some roadmap or any chance to get bakc project activity?

Pass event handler attributes down

It'd be handy to be able to pass event handlers attrs defined on mdl components down onto the actual ember input. For example:

{{mdl-textfield
  focus-in='some-action'
}}

{{mdl-slider}} never updates - Not sure it actually works as expected

Trying this out in a new project and the slider does not seem to be bound to anything.

Setting value sets it originally but value doesn't change when interacting with the control.

This happened to me locally and when I use ember inspector in the mike.works/ demo app it also does not seem to update.

@mike-north or anyone else see this issue?

mdl-table-col component option to specify text-only column

All data cells within a data-table component are currently being formatted as numeric by default, which right-aligns the contents. I think it would be helpful if an option (e.g. isNonNumeric=true) could be included when adding a mdl-table-col component, which would add the mdl-data-table__cell--non-numeric class to both the th and td.

Using layoutName instead of layout.

Why not using layoutName in components instead of layout? For example, in my case I was used to extend your component.js for mdl-table to redefine layout, when all I wanted to do is to rewrite mdl-table template to change how looks.

Button href attribute binding (with tagName=a)

Hi!

I'm trying to achieve something like this:

{{#mdl-button tagName='a' href="http://www.website.com"}}open website{{/mdl-button}}

I'm still quite new to Ember, so perhaps I'm trying to do this all the wrong way, but I was wondering how one would recommend implementing this. Thanks!

Button type attribute

It'd be nice to be able to set the {{mdl-button}} type attribute. Currently, if this component is inside a <form> tag it will trigger a form submit, resulting in an array of side effects (such as page reloads) even if the component's action is handled.

The HTML solution is setting type="button" on the <button> tag, which causes it to no longer submit forms. <button> default type varies by browser (submit | reset | button), but type="button" is probably the safest default.

On the {{mdl-button}}, this just means adding "type" to attributeBindings with a default value of "button".

Radio button printing fixed name 'options'

Hello, do not no why but the radio button component is printing a fixed name='options'

{{input type="radio" id=_inputId class="mdl-radio__button" name="options" value=value disabled=disabled}}

Error when using mdl-menu

When i copy the mdl-menu example in my application i get an error.

The mdl-menu example:
{{#mdl-menu}}
{{#mdl-menu-item action='menuItemClicked' age=36}}Age: 36{{/mdl-menu-item}}
{{#mdl-menu-item action='menuItemClicked' age=42}}Age: 42{{/mdl-menu-item}}
{{#mdl-menu-item action='menuItemClicked' age=71}}Age: 71{{/mdl-menu-item}}
{{/mdl-menu}}

Error:
Could not find module ember-composability/mixins/parent-component-support imported from ember-material-lite/components/mdl-menu

The title field in Material Card should be optional.

It'll be great if you can make the title field in the card optional i.e. when no title is supplied to the handlebars helper the following part should not be rendered.

<div class="mdl-card__title">
  <h2 class="mdl-card__title-text">{{title}}</h2>
</div>

maybe changind it to something like this would work:

{{#if title}}
    <div class="mdl-card__title">
        <h2 class="mdl-card__title-text">{{title}}</h2>
    </div>
{{/if}}

2 actions sent on radio button click

I noticed that {{mdl-radio}} sends two actions when it is clicked. I extended the component (adding a change() and click() handler) and realized that it fires a click, then a change, then a click again. Since the component inherits from mixins/click-action-support, it sends 2 actions when it is clicked, one for each click event.

Since we're ultimately concerned with radio buttons changing, they should sendAction on change instead of click.The change event is fully supported in IE9+, and all other browsers.

maintaining this and ember-cli-materialize?

Hey @mike-north - saw that you currently have projects to support MDL and MaterializeCSS. Was just curious if you planned on maintaining both going forward or were committing to one vs the other? I started off with Ember Paper, but it seems to be dying, and unfortunately, my project is using bootstrap, so MaterializeCSS isn't a good fit. MDL seems to fit the bill, but just wanted to understand your plans with this project before I jumped into it.

Thanks!

Allow to use local fonts

When Ember is used as offline application , this addon is having problem because Fonts are from CDN.

[Report Only] Refused to load the stylesheet 'http://fonts.googleapis.com/icon?family=Material+Icons' because it violates the following Content Security Policy directive: "style-src 'self'".

ember.debug.js:5165 DEBUG: -------------------------------
ember.debug.js:5165 DEBUG: Ember      : 2.0.0
ember.debug.js:5165 DEBUG: Ember Data : 2.0.0
ember.debug.js:5165 DEBUG: jQuery     : 1.11.3
ember.debug.js:5165 DEBUG: -------------------------------
jquery.js:3609 [Report Only] Refused to load the font 'http://fonts.gstatic.com/s/materialicons/v7/2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2' because it violates the following Content Security Policy directive: "font-src 'self'".
(anonymous function) @ jquery.js:3609
localhost/:1 [Report Only] Refused to load the font 'http://fonts.gstatic.com/s/materialicons/v7/2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2' because it violates the following Content Security Policy directive: "font-src 'self'".

ember.debug.js:5165 DEBUG: For more advanced debugging, install the Ember Inspector from https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi
ember.debug.js:47537 Uncaught Error: There is no route named tabs
localhost/:1 [Report Only] Refused to load the stylesheet 'http://fonts.googleapis.com/icon?family=Material+Icons' because it violates the following Content Security Policy directive: "style-src 'self'".

mdl nav collapsible/multiple nesting items

Is there a way to get nested items in the mdl-nav? (even if it is at least one level with some sort of accordion).

I want to use the drawer as a menu, but would like to be able to group links instead of just having a plain list.

Or even just getting any random content in there

pass name attribute onto input fields

Suggestion

Consider an excerpt from the template at: https://github.com/mike-north/ember-material-lite/blob/master/addon/templates/components/mdl-textfield.hbs

<div class="mdl-textfield__expandable-holder">
    {{input class="mdl-textfield__input" type=type pattern=pattern id=_inputId disabled=disabled value=value}}

Please consider also passing the name attribute to the ember input helper:

<div class="mdl-textfield__expandable-holder">
    {{input class="mdl-textfield__input" type=type name=name pattern=pattern id=_inputId disabled=disabled value=value}}

Motivation

Reason 1: input names are pretty standard on form inputs, so it should be at least possible to specify them through mdl input fields

Reason 2: in acceptance / integration tests, the most convenient way to refer various input elements is via their names:

fillIn("input[name=username]", "foxnewsnetwork");
fillIn("input[name=password]", "password123");

Reason 3: users who request server-rendered ember sites (via fastboot or some static build process) often are stuck on awful devices with awful javascript engines that don't handle ember correctly (e.g. literally every tablet / phone that uses the default internet app). Names on input fields allow forms to serialize and submit themselves without js, and are often the only way these users can interact with one's ember app.

I can do a pr if this is what we want to do.

Fails on install

For some reason, I am unable to install this as an addon.
On Ubuntu 14.04; io.js v0.12.6; ember-cli 1.13; npm 1.12.1

I get the following:

home/dj/code/projects/1-13/tito/client/node_modules/ember-material-lite/blueprints/ember-material-lite/index.js:6
  beforeInstall: function (options) {
  ^^^^^^^^^^^^^
Unexpected identifier
/home/dj/code/projects/1-13/tito/client/node_modules/ember-material-lite/blueprints/ember-material-lite/index.js:6
  beforeInstall: function (options) {
  ^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Function.Blueprint.load (/home/dj/code/projects/1-13/tito/client/node_modules/ember-cli/lib/models/blueprint.js:1239:25)
    at Function.Blueprint.lookup (/home/dj/code/projects/1-13/tito/client/node_modules/ember-cli/lib/models/blueprint.js:1214:24)
    at Class.module.exports.Task.extend.lookupBlueprint (/home/dj/code/projects/1-13/tito/client/node_modules/ember-cli/lib/tasks/generate-from-blueprint.js:91:22)

Thanks for the efforts.
DJ

CSS imported twice when changing colors

When I import the color definitions into my app.scss, change the primary and accent color, and import the material-design-lite styles after that (like described in the README.md) I end up having two nearly exact copies of all styles available in my Ember.js app. First, the original ones in vendor.css, and second the ones with changed colors in app.css. Is it possible to have the material-design-lite styles with changed colors in the vendor.css file only?

Creating route links on table rows

Ember recommends the use of link-to for route links. Creating clickable links is easy enough when using vanilla HTMLbars (see example) but would be really helpful is possible with Ember Material Lite.

Thanks for this great package!

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.