GithubHelp home page GithubHelp logo

fsxc's Introduction

xcomponent demo

A forkable demo repo for xcomponent to help you get started.

xcomponent is a cross-domain component library which helps you render iframes and popups, pass down props, accept callbacks, and much more. This repo sets you up with the best possible starting point for building an xcomponent, including:

  • Predefined webpack, babel, karma etc. configs for working with xcomponent
  • Predefined test-setup, including a mock component frame
  • Predefined demo pages for both iframe and popup components

Useful starting points

Quick Start

Getting Started

  • Fork the module
  • Install: npm install
  • Start editing code in ./src and writing tests in ./tests
  • Build: npm run build

Building

npm run build

Running Demo Server

npm run demo

Deploying

  • Host your bundled xcomponent script somewhere, e.g. https://mysite.com/fsxc.wizard.js
  • Set up a public url for your component, e.g. https://mysite.com/fsxc
  • Make sure the fsxc.wizard.js is included in the login page, and using window.xprops

Now other sites can include https://mysite.com/fsxc.wizard.js on their pages, and render your component!

Tests

  • Edit tests in ./test/tests

  • Run the tests:

    npm run test

Testing with different/multiple browsers

npm run karma -- --browser=PhantomJS
npm run karma -- --browser=Chrome
npm run karma -- --browser=Safari
npm run karma -- --browser=Firefox
npm run karma -- --browser=PhantomJS,Chrome,Safari,Firefox

Keeping the browser open after tests

npm run karma -- --keep-open

Publishing

Before you publish for the first time:
  • Remove the example code in ./src, ./test/tests and ./demo
  • Edit the module name in package.json
  • Edit README.md and CONTRIBUTING.md
Then:
  • Publish your code: npm run release to build and publish a patch version
  • Or npm run release:patch, npm run release:minor, npm run release:major

Notes

  • webpack.config.js is set up to build both iframe and popup versions of your component. Normally this will be overkill and you'll just want to pick one. The reason there's an example of both is, the popup rendering code adds more to the bundle size, so cutting this out can streamline your bundle if you only need iframe support.

  • The karma tests use a mock for the component window (i.e. everything displayed in the popup window or iframe window). This can be seen here. When writing tests which need to consume window.xprops and call callbacks like window.xprops.onLogin(), you'll need to do that here.

  • This module imports from xcomponent/src rather than xcomponent/dist, allowing your build to take advantage of tree-shaking, flow-types, etc. from xcomponent and all of its dependencies. That means that various babel plugins etc. that are required by xcomponent and its dependencies are included in this module. If this isn't to your liking, you're free to switch to xcomponent/dist, but be warned that you will lose out on some benefits this way. It will reduce the build time though.

  • This module is forked from xcomponent-demo, which gives a solid (but opinionated) default setup for front-end javascript libraries, including webpack, karma, babel, flowtype, etc. You're free to switch out any of these technologies, but the existing setup is likely to give the best compatibility especially given the previous note around importing from xcomponent/src.

fsxc's People

Contributors

bluepnume avatar steveoliver avatar

Watchers

 avatar James Cloos avatar

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.