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-material-forms

v4.9.0

Published

Basic input form elements as mithril components

Downloads

111

Readme

mithril-material-forms

Lightweight input form components using mithril. Requires material-icon font to work correctly (checkbox, select).

  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  // pick requried styles
  @import "mithril-material-forms/styles/layout";
  @import "mithril-material-forms/styles/typography";
  // maybe add additional themes
  @import "mithril-material-forms/styles/theme-material";
  @import "mithril-material-forms/styles/theme-solid";
  // and choose a default theme
  @import "mithril-material-forms/styles/theme-solid-as-default";

Use with

  import m from "mithril";
  import { Switch, SwitchAttrs } from "mithril-material-forms";
  m.render(document.body, 
    m(Switch, <SwitchAttrs>{ requiredAttributes })
  );

For attribute details check each component implementation in index.js. For a list of example build checkout the examples page in /docs/index.html or goto mithril-material-forms docs

Change default theme, by including styles and setting the theme through attributes

  import m from "mithril";
  import "mithril-material-forms/styles/theme-solid";
  import { Switch, SwitchAttrs } from "mithril-material-forms";
  m.render(document.body, 
    m(Switch, <SwitchAttrs>{ theme: "the-solid" })
  );

Usage

  • per convention, an attribute onchange(value): void is used to register to change events

Breaking Changes

v4

  • mithril is now written in typescript and uses no babel transpilation. There may be a need for polyfills
  • components are exported separately

v3

  • required mithril-dependency >= v2
  • all callbacks have mithil-lowercase names onchange instead of onChange
    • this was inconsistent in button, checkbox and input

Adding a new component

A set of instructions for creating and adding a new mithril material component.

  1. Add a new folder to ./components/<component-name>
  2. In this folder, create following files:
    • Component code: ./components/<component-name>/index.ts
    • General style: ./components/<component-name>/layout.scss
    • [Optional] Style for material theme: ./components/<component-name>/<component-name>-material.scss
    • [Optional] Style for solid theme: ./components/<component-name>/<component-name>-solid.scss
  3. Register your component in ./index.ts
  4. Add your layout file (./components/<component-name>/layout.scss) to ./styles/layout.scss
  5. To add your new to component to the demo page, in ./app/index.ts...
    • Add it to the template object, in all possible variations (e.g. disabled, with(out) icon, etc.)
    • Add it to the last render function