Material Design Web Components
Go to file
2019-07-31 22:34:45 +01:00
.vscode create a benchmark cli 2019-07-24 17:08:53 -07:00
demos Merge pull request #144 from eskan/patch-2 2019-07-20 13:02:47 -07:00
packages update eslint plugins 2019-07-31 22:34:45 +01:00
scripts Update dependencies 2019-04-04 15:36:55 -07:00
test fix raf impl 2019-07-26 15:10:52 -07:00
.eslintignore update eslint config 2019-07-31 12:12:40 -07:00
.eslintrc.yaml update eslint plugins 2019-07-31 22:34:45 +01:00
.gitignore create a benchmark cli 2019-07-24 17:08:53 -07:00
.travis.yml Fix typescript building 2019-02-01 15:39:47 -08:00
CHANGELOG.md CHANGELOG entry for removed auto icon font loading 2019-07-29 11:34:07 -07:00
CONTRIBUTING.md Fix broken link in contribution docs. Closes #84 2018-12-18 12:06:46 +01:00
karma.conf.js add icon-button test 2019-04-11 15:07:35 -07:00
lerna.json v0.6.0 2019-06-05 15:19:56 -07:00
LICENSE [first commit] lots of wip elements 2018-04-25 19:20:55 -07:00
package-lock.json update eslint plugins 2019-07-31 22:34:45 +01:00
package.json update eslint plugins 2019-07-31 22:34:45 +01:00
polymer.json add demo build polymer.json 2018-05-02 11:23:40 -07:00
README.md create a benchmark cli 2019-07-24 17:08:53 -07:00
sass-template.tmpl Minimize direct imports of lit-html and lit-element 2019-01-30 13:06:06 -08:00
tsconfig.json Fix typescript building 2019-02-01 15:39:47 -08:00

Material Web Components

⚠️ These components are a work in progress. They are pre-release and should be considered experimental, as they may undergo major changes before release. We are experimenting with alternate architectures and approaches with the goal of allowing us to bring the most correct and optimal implementation of Material components to the widest possible audiences. Visible progress may be slow, as this research is across teams and repositories so is not consistently reflected in commits to this codebase. ⚠️

Material Web Components helps developers execute Material Design using web components.

Built on top of the Material Components Web project and LitElement, the Material Web Components enable a reliable development workflow to build beautiful and functional web projects.

Web Components can be seamlessly incorporated into a wide range of usage contexts. Whether you're already heavily invested in another framework or not, it's easy to incorporate Material Web Components into your site in a lightweight, idiomatic fashion.

Demos

Quick start

Note: This guide assumes you have npm installed locally.

The easiest way to try out the Material Web Components is to use one of these online tools:

Or you can also copy this HTML file into a local file and run it in any browser that supports JavaScript Modules.

When you're ready to use the Material Web Components in your web application:

  1. Ensure the webcomponents polyfills are included in your HTML page

    • Install webcomponents polyfills

      npm i @webcomponents/webcomponentsjs

    • Add webcomponents polyfills to your HTML page

      <script src="@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>

  2. Add one of the MWC elements to your project, for example for icon:

    npm i @material/mwc-icon

  3. Import the element definition into your HTML page:

    <script type="module" src="@material/mwc-icon/mwc-icon.js"></script>

    Or into your module script:

    import {Icon} from "@material/mwc-icon"

  4. Create an instance of element in your HTML page, or via any framework that supports rendering Custom Elements:

    <mwc-icon>sentiment_very_satisfied</mwc-icon>

  5. Install the Polymer CLI:

    npm i -g polymer-cli

  6. Run the development server and open a browser pointing to its URL:

    polymer serve

The Material Web Components are published on npm using JavaScript Modules. This means it can take advantage of the standard native JavaScript module loader available in all current major browsers.

However, since the Material Web Components use npm convention to reference dependencies by name, a light transform to rewrite specifiers to URLs is required to get it to run in the browser. The polymer-cli's development server polymer serve automatically handles this transform.

Tools like WebPack and Rollup can also be used to serve and/or bundle.

Contributing guide

Below are instructions for setting up project development.

  1. Clone this repo with git clone.
  2. Install dependencies by running npm run bootstrap
  3. Run a development server with npm run dev
    • View the demos by accessing <dev server url>/demos/index.html
    • This will also build the project.
  4. Build the project with npm run build
  5. Run tests with npm run test
  6. Run benchmarks with npm run build:tests && npm run test:bench

Developing Components

Components are written in Typescript, and compiled to Javascript Modules.

The output Javascript Modules can be used in every modern browser directly, and are supported a wide variety of popular bundler and build tools.

The components render output structure, handle styling, and manage data flow with lit-html while integrating with Material Design's common logic library for each component.

Styling Components

Components define their styling using SASS.

The SASS output is built into a javascript module which exports the component's styling as a lit-html template.

Component styling is compiled with both npm run build and npm run watch.

To compile the component SASS manually, use npm run build-styling

Browser Support

We officially support the last two versions of every major browser. Specifically, we test on the following browsers:

  • Chrome
  • Safari
  • Firefox
  • IE 11/Edge
  • Opera
  • Mobile Safari
  • Chrome on Android