Material Design Web Components
Go to file
Elliott Marquez 6f841a09e8
Changes to Textfield, line-ripple, and floating-label to build (#458)
* make it build internally!

* specify foundations and expand interface

* add explainers and fix typo

* update changelog

* fix changelog typo

* make dev deps deps

* update changelog to only public

* clear up things from clog (internal not external)

* undo all changelog notes
2019-09-05 20:17:51 -07:00
.github Fix formatting for checklist in issue template 2019-08-19 10:41:25 -07:00
demos Remove short Top App Bar variant (#422) 2019-08-26 17:00:41 -07:00
packages Changes to Textfield, line-ripple, and floating-label to build (#458) 2019-09-05 20:17:51 -07:00
scripts Some small items before release (#431) 2019-08-27 14:15:27 -07:00
test remove console log and fix format 2019-08-28 02:09:41 -07:00
.clang-format introduce clang-format 2019-07-31 20:15:16 +01:00
.eslintignore make proxy more in-line with lit-element 2019-08-23 17:22:59 -07:00
.eslintrc.yaml Extends ESLint from @typescript-eslint (#371) 2019-08-15 14:51:43 -07:00
.gitignore move tests to src folder 2019-08-23 17:22:58 -07:00
.travis.yml Add saucelabs environment variables 2019-08-23 17:34:48 -07:00
CHANGELOG.md Changes to Textfield, line-ripple, and floating-label to build (#458) 2019-09-05 20:17:51 -07:00
CONTRIBUTING.md Remove CHANGELOGS from subpackages 2019-08-13 15:38:26 -07:00
karma.conf.js actually enable sauce launcher 2019-08-23 17:58:11 -07:00
karma.proxy.js make proxy more in-line with lit-element 2019-08-23 17:22:59 -07:00
lerna.json v0.8.0 2019-09-03 17:03:26 -07:00
LICENSE [first commit] lots of wip elements 2018-04-25 19:20:55 -07:00
package-lock.json Prepare to release 0.8.0 (#453) 2019-09-03 16:41:30 -07:00
package.json make sure to build tests before testing 2019-08-28 02:09:41 -07:00
polymer.json add demo build polymer.json 2018-05-02 11:23:40 -07:00
README.md add some readme documentation 2019-08-28 02:09:41 -07:00
sass-template.tmpl Minimize direct imports of lit-html and lit-element 2019-01-30 13:06:06 -08:00
tsconfig.json Import TypeScript helpers from tslib, instead of inlining. (#439) 2019-08-28 11:47:31 -07: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 install
  3. Build the project with npm run build
  4. 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.
  5. Run tests with npm run test
  6. Run benchmarks with npm run test:bench
    • Specify packages to run wih the -p flag. e.g. npm run test:bench -- -p icon ripple textfield
    • The benchmarker will use tachometer to compare all the benchmarks in a given package directory.
      • e.g. npm run test:bench -- -p my-package will benchmark each file in test/lib/benchmark/my-package
    • See the help information of the benchmarker cli with npm run test:bench -- --help

Note: You can debug specific tests by running:

npm run test:debug -- --packages mwc-button,mwc-fab

or you may use wildcards such as:

npm run test:debug -- --packages mwc-icon-button*

Additionally, you can run specific browsers with the --browsers flag. e.g.

npm run test:debug -- --browsers Firefox or npm run test -- --browsers ChromeHeadless.

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