npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mithril-mdl

v1.1.0

Published

Material Design Lite components via mithril.js

Downloads

1

Readme

Material Design Lite components via mithril.js

This module provides mithril components which construct html to be used with the Material Design Lite framework. It provides a simple way to apply the needed classes to create MDL components. It spits out normal html elements, and calls componentHandler.upgradeDom() after each render pass. It is designed to work nicely with JSX (via babel or similar). Not nearly all components are supported right now. I will continue adding them when the need comes up. Your are welcome to submit pull requests :)

Basics

Some attributes will be used by all components.

The following attributes will be carried over to the topmost resulting element:

  • id
  • class
  • config
  • disabled
  • all attributes beginning with on (onclick, onchange, etc.)

And these attributes all apply some classes:

  • large: applies mdl-layout--large-screen-only
  • ripple: applies mdl-js-ripple-effect
  • active: applies is-active
  • primary: applies mdl-color--primary
  • primaryDark: applies mdl-color--primary-dark

Components

The following components can be imported from the module directly.

ES5

var Button = require('mithril-mdl').Button;

ES6

import {Button} from 'mithril-mdl';

You may then use them like so:

ES5

m.render(document.body, m(Button, {ripple: true, accent: true, raised: true}, 'I am a button!'));

JSX

m.render(document.body, <Button ripple accent raised>I am a button!</Button>);

Fab

Tag: button

Class: mdl-button mdl-js-button mdl-button--fab

Attributes:

  • mini: Switches mdl-button--fab to mdl-button--mini-fab
  • color: Sets mdl-button--colored
  • accent: Sets mdl-button--accent
  • raised: Sets mdl-shadow--4dp
  • primary: Sets mdl-button--primary

Button

Tag: button

Class: mdl-button mdl-js-button

Attributes:

  • color: Sets mdl-button--colored
  • accent: Sets mdl-button--accent
  • raised: Sets mdl-button--raised
  • primary: Sets mdl-button--primary

Icon

Tag: i

Class: material-icons

Spacer

Tag: div

Class: mdl-layout__spacer

ProgressBar

Tag: div

Class: mdl-progress mdl-js-progress mdl-progress__indeterminate

Attributes:

  • progress: A number which will be passed to MaterialProgress.setProgress(). If set also removes mdl-progress__indeterminate
  • buffer: A number which will be passed to MaterialProgress.setBuffer().

WARNING: The JavaScript portion of this is not tested across redraws and might break.

TextInput

Tag: div wrapping input, label and optionally span

Class: mdl-textfield mdl-js-textfield, mdl-textfield__label and mdl-textfield__error

Attributes: All default attributes (class, id etc.) are assigned to the input element. id has to be passed to allow for a label.

  • value: sets value of the input
  • label: sets text content of the label
  • error: if this and pattern is set, adds a span, with this text set as its text content.
  • pattern: sets pattern property of the input
  • floating: sets mdl-textfield--floating-label on the div
  • outerClass: additional classes to apply to the div (should be a string)

Grid

Tag: div

Class: mdl-grid

Cell

Tag: div

Class: mdl-cell

Attributes:

  • align: sets mdl-cell--${align}. Should be top, stretch or bottom
  • width: sets mdl-cell--${width}-col. Basically the number of columns for this cell
  • phone: sets mdl-cell--${phone}-col-phone
  • tablet: sets mdl-cell--${tablet}-col-tablet
  • desktop: sets mdl-cell--${desktop}-col-desktop
  • nophone: sets mdl-cell--hide-phone
  • notablet: sets mdl-cell--hide-tablet
  • nodesktop: sets mdl-cell--hide-desktop

Tabs

Tag: div

Class: mdl-layout__tab-bar

Tab

Tag: a

Class: mdl-layout__tab

Attributes:

  • href: Transferred over

Layout

Tag: header

Class: mdl-layout__header

Attributes:

  • scroll: Sets mdl-layout__header--scroll
  • waterfall: Sets mdl-layout__header--waterfall
  • transparent: Sets mdl-layout__header--transparent

Title

Tag: span

Class: mdl-layout-title

Header

Tag: div

Class: mdl-layout mdl-js-layout

Attributes:

  • drawer: If this or fixedDrawer is provided, sets mdl-layout--overlay-drawer-button
  • fixedDrawer: Sets mdl-layout--fixed-drawer
  • fixedHeader: Sets mdl-layout--fixed-header
  • fixedTabs: Sets mdl-layout--fixed-tabs

HeaderRow

Tag: div

Class: mdl-layout__header-row

Navigation

Tag: div

Class: mdl-navigation

NavLink

Tag: a

Class: mdl-navigation__link

Attributes:

  • href: Transferred over

Drawer

Tag: div

Class: mdl-layout__drawer

Content

Tag: main

Class: mdl-layout__content

Problems

  • Not really reliable for partial redraws (still works, just flickering etc.), due to mdls js adding elements all over the place (or maybe me being an idiot, not sure)