All Projects → jscissr → React Polymer

jscissr / React Polymer

Licence: mit
Use Polymer elements in React

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Polymer

Redux Store Element
A custom element allowing a more declarative use of Redux.
Stars: ✭ 83 (-39.42%)
Mutual labels:  polymer
Gulp Vulcanize
Concatenate a set of Web Components into one file
Stars: ✭ 101 (-26.28%)
Mutual labels:  polymer
Hot Table
Handsontable - Best Data Grid Web Component with Spreadsheet Look and Feel.
Stars: ✭ 114 (-16.79%)
Mutual labels:  polymer
Geo Location
Web component element for the Geolocation API
Stars: ✭ 86 (-37.23%)
Mutual labels:  polymer
Frontend
🍭 Frontend for Home Assistant
Stars: ✭ 1,366 (+897.08%)
Mutual labels:  polymer
Polymer Build
Moved to Polymer/tools monorepo
Stars: ✭ 107 (-21.9%)
Mutual labels:  polymer
Flip Clock
A flip clock, timer and countdown made with Polymer
Stars: ✭ 69 (-49.64%)
Mutual labels:  polymer
The Grid
Grid layout custom element with drag and drop capabilities
Stars: ✭ 122 (-10.95%)
Mutual labels:  polymer
Wc Loader
🚽 Webcomponents webpack loader.
Stars: ✭ 101 (-26.28%)
Mutual labels:  polymer
Hq
Lightning fast, zero configuration, web application development server
Stars: ✭ 114 (-16.79%)
Mutual labels:  polymer
Vaadin Upload
The Web Component for uploading multiple files with progress indication. Part of the Vaadin components.
Stars: ✭ 87 (-36.5%)
Mutual labels:  polymer
Highcharts Chart
Polymer Element wrapper for highcharts library. Seamlessly create various types of charts from one element.
Stars: ✭ 97 (-29.2%)
Mutual labels:  polymer
Create Lit App
Create LitHTML apps with no build configuration. (LitHTML/Redux/Webpack/Express)
Stars: ✭ 108 (-21.17%)
Mutual labels:  polymer
Lit Loader
LitElement Single File Component loader for Webpack.
Stars: ✭ 84 (-38.69%)
Mutual labels:  polymer
Polydev
Automatic web components profiling in chrome devtools
Stars: ✭ 118 (-13.87%)
Mutual labels:  polymer
Polymer Bundler
Moved to Polymer/tools monorepo
Stars: ✭ 1,206 (+780.29%)
Mutual labels:  polymer
Todo List Fabricv1
A todo list application using Hyperledger Fabric V1 as a data source
Stars: ✭ 103 (-24.82%)
Mutual labels:  polymer
Elements
⚛⚗ A desktop App which displays the periodic table
Stars: ✭ 131 (-4.38%)
Mutual labels:  polymer
Webdash
🔥 Orchestrate your web project with Webdash the customizable web dashboard
Stars: ✭ 1,528 (+1015.33%)
Mutual labels:  polymer
Vaadin Combo Box
The Web Component for displaying a list of items with filtering. Part of the Vaadin components.
Stars: ✭ 113 (-17.52%)
Mutual labels:  polymer

react-polymer travis npm downloads

Use Polymer elements in React

react-polymer now supports Polymer 2.0! If you need to use Polymer 1.0 please use v3

Since this change you can put Polymer elements into React components and at first glance it just works:

<paper-button raised>click me</paper-button>

However, when you then start using custom attributes and events, it doesn't work anymore.

Now you need react-polymer:

import reactPolymer from 'react-polymer' // Must be imported before React
import React from 'react'

reactPolymer.registerAttribute('drawer') // Note: this is only needed for custom attributes on standard elements like div
reactPolymer.registerAttribute('main')
reactPolymer.registerEvent('color-picker-selected', 'onColorPickerSelected')


<paper-drawer-panel>
  <div drawer> Drawer panel... </div>
  <div main> Main panel... </div>
</paper-drawer-panel>
<paper-swatch-picker onColorPickerSelected={this.colorChange} />

Also, all the form elements don't work like the native ones. That's because React internally has wrappers to make controlled components. We have our own wrapper for the Polymer form elements:

import reactPolymer from 'react-polymer'
import React from 'react'
import {
  PaperCheckbox,
  PaperToggleButton,
  PaperInput,
  PaperTextarea,
  IronAutogrowTextarea,
  PaperSlider,
  PaperMenu,
  PaperListbox,
  PaperRadioGroup,
  PaperTabs,
  IronSelector
} from 'react-polymer/input'


<PaperInput value={this.state.value} onChange={this.valueChanged} />
<PaperToggleButton checked={this.state.checked} onChange={this.checkedChange} />

Another problem that is solved automatically by react-polymer is that className doesn't work on Polymer elements.

See more examples.

ES6

This module uses some ES6 features, so you should run it through a transpiler like babel. If you use browserify, you don't need to do anything. If you use webpack, you have to enable transpiling, but replace the default exclude config with exclude: s => /node_modules/.test(s) && !/react-polymer/.test(s). (If you know how to make webpack do this automatically like it works with browserify, please tell me!)

Testing

npm install
bower install
npm run test-local

Caveats

gold-* elements are not yet supported.

Polymer elements can have properties with notify attribute, which trigger {property}-changed events. However these events don't bubble, so you have to manually call addEventListener yourself.

This module does a lot of monkey patching on internal APIs of react-dom, so it only works with React 15. It is recommended to pin React to a fixed version, and always test new versions before updating. There is no guarantee that it will still work, even after patch-level updates of React.

Notes

A React issue that might simplify this once solved:

Similar Libraries

For mixing Polymer and React, there is Maple, which doesn't seem to be maintained anymore. However, if all you are looking for is a way to incorporate pre-built Material Design components into React, there are also Material-UI and React-Materialize.

License

MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].