Skip to content

Suggestion: Use JSImport annotations instead of requiring user to configure an 'mui' or similar variables #92

Open
@tgiddings

Description

@tgiddings

Currently, the raw components for material-ui are contained in the Mui Scala object, which pulls its definition from an mui Javascript object which the library user must configure, e.g., as

var mui = require("material-ui");
mui.Styles = require("material-ui/styles");
mui.SvgIcons = require('material-ui/svg-icons/index');

window.mui = mui;

However, depending on the tool chain used to manage Javascript dependencies, getting such an object into the global namespace may be inconvenient and/or finicky, and it is also not obvious that it needs to be done to begin with.

Scala.js has an @JSImport annotation which is designed for this use case, that of importing definitions from modules. @JSName("mui") can be replaced with @JSImport("material-ui",Namespace) It has the same semantics as the original Mui object, so the facade classes don't need to be changed. It also works out of the box with sbt plugins like scalajs-bundler that manage NPM dependencies. Making such a tool chain work with scalajs-react-components' current method of getting component definitions is something I haven't managed to do yet.

(the above also applies to the other libraries this library provides facades for).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions