Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @mscharley/bs-material-ui-icons with all npm packages installed. Try it out:

require("@material-ui/core/package.json"); // @material-ui/core is a peer dependency. require("@material-ui/icons/package.json"); // @material-ui/icons is a peer dependency. require("reason-react/package.json"); // reason-react is a peer dependency. var bsMaterialUiIcons = require("@mscharley/bs-material-ui-icons")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@mscharley/bs-material-ui-icons v1.0.3

Reason bindings for material-ui-icons

Reason bindings for Material-UI-Icons

npm Greenkeeper badge

Reason bindings for material-ui-icons.

Status

🚧 This is a WIP, not everything is supported yet but we're getting close. 🚧

Feel free to create an issue or PR if you find anything missing.

Installation

yarn add @mscharley/bs-material-ui-icons
yarn add @material-ui/core
yarn add @material-ui/icons

Then add @mscharley/bs-material-ui-icons to bs-dependencies in your bsconfig.json:

{
  // ...
  "bs-dependencies": ["@mscharley/bs-material-ui-icons"]
}

Usage

let component = ReasonReact.statelessComponent("Example");

let make = (_children) => {
  ...component,
  render: (_self) => <MscharleyBsMaterialUiIcons.Delete.Filled />
};

You can find a list of available icons here. The icons are exposed as <IconName.Theme /> from this library, which is slightly different to ReactJS which uses <IconNameTheme /> or <IconName /> for the filled theme.

Help! The icon I want to use isn't available

Maybe this library hasn't been updated yet to include the new icon. No problems! Just open an issue and let us know we're msising something. We'll get things updated as soon as possible.

Design decisions

Why does this module take so long to build?

There are an awful lot of icons available in @material-ui/icons; as of writing, around 5000 of them. Initially, this project exported all of these icons from one module file. This was very fast to build! However due to interactions with the way the bsb builds files and the way it writes imports this led to very big deployment packages, even with tree shaking. Using a single icon caused builds to increase in size by 3MB (~7x in my small project!) because all the icons were always being included.

This module now exports each group of icons into it's own file. This leads to a slightly different usage pattern to ReactJS, namely <Delete.Filled /> instead of <Delete /> or <Delete.Outlined /> instead of <DeleteOutlined />. This isn't that big a deal, really. It also lets packagers only include the icons you're using. Unfortunately, it means that the BSB build is a little bit longer.

Gotchas

Why can't I include MscharleyBsMaterialUiIcons?

MscharleyBsMaterialUiIcons.js is compiled in script mode while its dependent is not

Related to the build question above, this package uses the namespace option in BuckleScript. This means that MscharleyBsMaterialUiIcons is purely synthetic and there isn't actually a script to include and re-export. Even if this did work it would be discouraged because you would end up at square one with code elimination as highlighted in the design decision above.

The current recommended way to alias this library is as follows:

/* Icons.re */
open MscharleyBsMaterialUiIcons;

module PowerSettingsNew = PowerSettingsNew.Filled;
module ReportProblem = ReportProblem.Filled;
module Help = Help.Outlined;
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free