GithubHelp home page GithubHelp logo

reactnativecn / react-native-web-player Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dabbott/javascript-playgrounds

2.0 5.0 1.0 568 KB

Build and run react native apps in your browser!

Home Page: http://dabbott.github.io/react-native-web-player/

License: Other

Makefile 0.84% JavaScript 90.68% HTML 1.49% CSS 6.99%

react-native-web-player's Introduction

React Native Web Player

Run react native apps in your browser!

Try it out!

Upgrade Instructions

Versions below 1.2.4 were hosted via unpkg.com (aka npmcdn.com). This host no longer supports serving static files. Please update your iframe url to point to //cdn.rawgit.com/dabbott/react-native-web-player/gh-v1.2.4/index.html.

Instructions

Include the web player in an iframe.

<iframe width="880" height="425" frameborder="0" src="//cdn.rawgit.com/dabbott/react-native-web-player/gh-v1.2.4/index.html"></iframe>

The iframe accepts the following parameters after the hash in the url:

  • code - The code to show/run in the player. Defaults to the sample app.
  • title - An optional title for the player. By default, there is no title.
  • width - The width of the device. Defaults to 210.
  • scale - Zoom the device screen. Defaults to 1.
  • platform - One of ios or android. Defaults to ios. Currently this changes the phone image, but may also have an effect on how the code is executed in the future.
  • assetRoot - Specifies the root url for asset requires. E.g. to require http://localhost:8080/images/hello.png, you could set assetRoot=http%3A%2F%2Flocalhost%3A8080%2F and write require('./images/hello.png') in your code.
  • vendorComponents - JSON encoded array of 3rd party components to make available to the sandbox. The format is an array of a 3-element arrays. The first element is the require() name, the second element is the global namespace location (e.g. window.moment), and the third element is the source url. E.g. to load moment.js: set vendorComponents to the url-encoded value encodeURIComponent([["moment", "moment", "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"]])

The easiest way to set the code parameter is to edit the code in the web player and copy and paste the url when you're done (the url updates automatically as you type).

Alternately, you can manually url-encode the parameters. You can do so via the JavaScript console.

encodeURIComponent('Hello World')
# => "Hello%20World"

Hosting

This project contains static assets that run standalone in the browser. You don't need a server, unless you want to host the assets yourself.

MaxCDN

The recommended host is rawgit + MaxCDN. MaxCDN is highly performant and serves over http and https. The examples in this readme all point to:

<iframe width="880" height="425" frameborder="0" src="//cdn.rawgit.com/dabbott/react-native-web-player/v1.2.4/index.html"></iframe>
gh-pages

If you prefer, you may access the gh-pages branch directly. This has the advantage of always serving you the latest version, but the drawback of potentially failing on major API changes (along with slower download speeds for the assets).

<iframe width="880" height="425" frameborder="0" src="//dabbott.github.io/react-native-web-player/"></iframe>

Examples

Development

Run

npm install
npm run start
=> localhost:8080

Build

npm run build

Publish

First publish to npm.

npm version (major|minor|patch)
npm publish

Then publish to gh-pages and make a special tagged release for hosting via CDN.

# Point to the latest release
make TAG=v1.2.4

License

BSD

react-native-web-player's People

Contributors

dabbott avatar nbclark avatar npmcdn-to-unpkg-bot avatar sunnylqm avatar thedgbrt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

ishida83

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.