All Projects → krakenjs → Zoid

krakenjs / Zoid

Licence: other
Cross domain components

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Zoid

Paypal Checkout Components
Javascript Integration for PayPal Button and PayPal Checkout
Stars: ✭ 938 (-43.9%)
Mutual labels:  hacktoberfest, popup, iframe
Sentry Javascript
Official Sentry SDKs for JavaScript. We're hiring https://grnh.se/ca81c1701us
Stars: ✭ 6,012 (+259.57%)
Mutual labels:  hacktoberfest, ember
React Accessible Accordion
Accessible Accordion component for React
Stars: ✭ 610 (-63.52%)
Mutual labels:  hacktoberfest, component
Ember Inspector
Adds an Ember tab to the browser's Developer Tools that allows you to inspect Ember objects in your application.
Stars: ✭ 936 (-44.02%)
Mutual labels:  hacktoberfest, ember
Vue Plyr
A Vue component for the plyr (https://github.com/sampotts/plyr) video & audio player.
Stars: ✭ 531 (-68.24%)
Mutual labels:  hacktoberfest, component
Ngx Ui
🚀 Style and Component Library for Angular
Stars: ✭ 534 (-68.06%)
Mutual labels:  hacktoberfest, component
Orbit
React components of open-source Orbit design system by Kiwi.com
Stars: ✭ 774 (-53.71%)
Mutual labels:  hacktoberfest, component
Ember Intl
Localization library for any Ember Application or Addon
Stars: ✭ 412 (-75.36%)
Mutual labels:  hacktoberfest, ember
Ember Octane Vs Classic Cheat Sheet
A cheat sheet for converting classic Ember app to Octane
Stars: ✭ 48 (-97.13%)
Mutual labels:  hacktoberfest, ember
Ember Api Docs
Ember API Docs viewer
Stars: ✭ 55 (-96.71%)
Mutual labels:  hacktoberfest, ember
React Frame Component
Render your React app to an iFrame
Stars: ✭ 1,163 (-30.44%)
Mutual labels:  component, iframe
Ember Power Select
The extensible select component built for ember.
Stars: ✭ 521 (-68.84%)
Mutual labels:  component, ember
Ember Bootstrap
Ember-cli addon for using Bootstrap as native Ember components.
Stars: ✭ 475 (-71.59%)
Mutual labels:  hacktoberfest, ember
Ember.js
Ember.js - A JavaScript framework for creating ambitious web applications
Stars: ✭ 22,092 (+1221.29%)
Mutual labels:  hacktoberfest, ember
Pdfvuer
A PDF viewer for Vue using Mozilla's PDF.js
Stars: ✭ 443 (-73.5%)
Mutual labels:  hacktoberfest, component
Post Robot
Cross domain post-messaging on the client side using a simple listener/client pattern.
Stars: ✭ 619 (-62.98%)
Mutual labels:  hacktoberfest, popup
Vc Popup
一个行为标准的vue popup组件集
Stars: ✭ 289 (-82.72%)
Mutual labels:  component, popup
React Countdown
A customizable countdown component for React.
Stars: ✭ 402 (-75.96%)
Mutual labels:  hacktoberfest, component
Vueup
Simple, lightweight and super fast global notification popup for Vue.js
Stars: ✭ 104 (-93.78%)
Mutual labels:  component, popup
Ember Styleguide
This is a UI addon that intends to help standardize the Ember family of websites and make it easier to make the Ember website an Ember app.
Stars: ✭ 69 (-95.87%)
Mutual labels:  hacktoberfest, ember

zoid


build status code coverage npm version

A cross-domain component toolkit, supporting:

  • Render an iframe or popup on a different domain, and pass down props, including objects and functions
  • Call callbacks natively from the child window without worrying about post-messaging or cross-domain restrictions
  • Create and expose components to share functionality from your site to others!
  • Render your component directly as a React, Vue or Angular component!

It's 'data-down, actions up' style components, but 100% cross-domain using iframes and popups!


API Docs

Public options and methods supported by zoid

Demos

Working demos of different zoid patterns

Demo App

Forkable demo app with build, test, publishing and demos pre-configured.

Example

A full example of a cross-domain component using zoid


Quick example

Define a component to be put on both the parent and child pages:

var MyLoginComponent = zoid.create({

    tag: 'my-login-component',
    url: 'http://www.my-site.com/my-login-component'
});

Render the component on the parent page:

<div id="container"></div>

<script src="script-where-my-login-component-is-defined.js"></script>
<script>
    MyLoginComponent({

        prefilledEmail: '[email protected]',

        onLogin: function(email) {
            console.log('User logged in with email:', email);
        }

    }).render('#container');
</script>

Implement the component in the iframe:

<input type="text" id="email" />
<input type="password" id="password" />
<button id="login">Log In</button>

<script src="script-where-my-login-component-is-defined.js"></script>
<script>
    var email = document.querySelector('#email');
    var password = document.querySelector('#password');
    var button = document.querySelector('#login');

    email.value = window.xprops.prefilledEmail;

    function validUser (email, password) {
      return email && password;
    }

    button.addEventListener('click', function() {
        if (validUser(email.value, password.value)) {
            window.xprops.onLogin(email.value);
        }
    });
</script>

Useful Links

Framework Specific

Rationale

Writing cross domain components is tricky.

Consider this: I own foo.com, you own bar.com, and I have some functionality I want to share on your page. I could just give you some javascript to load in your page. But then:

  • What if I've written a component in React, but you're using some other framework?
  • What if I have secure form fields, or secure data I don't want your site to spy on?
  • What if I need to make secure calls to my back-end, without resorting to CORS?

What about an iframe?

You could just use a vanilla iframe for all of this. But:

  • You have to pass data down in the url, or with a post-message.
  • You need to set up post-message listeners to get events back up from the child.
  • You need to deal with error cases, like if your iframe fails to load or doesn't respond to a post-message.
  • You need to think carefully about how to expose all this functionality behind a simple, clear interface.

zoid solves all of these problems.

  • You pass data and callbacks down as a javascript object
  • zoid renders the component and passes down the data
  • The child calls your callbacks when it's ready

It will even automatically generate React and Angular bindings, so people can drop-in your component anywhere and not worry about iframes or post-messages.

FAQ

  • Do I need to use a particular framework like React to use zoid?

    No, zoid is framework agnostic. You can:

    • Use it with vanilla javascript.
    • Use it with any framework of your choice.
    • Use it with React or Angular and take advantage of the automatic bindings on the parent page
  • Why write another ui / component library?

    This isn't designed to replace libraries like React, which are responsible for rendering same-domain components. In fact, the only real rendering zoid does is iframes and popups; the rest is up to you! You can build your components using any framework, library or pattern you want, then use zoid to expose your components cross-domain. It should play nicely with any other framework!

  • Aren't iframes really slow?

    Yes, but there are a few things to bear in mind here:

    • zoid isn't designed for building components for your own site. For that you should use native component libraries like React, which render quickly onto your page. Use zoid to share functionality with other sites, that you can't share native-javascript components with

    • zoid also provides mechanisms for pre-rendering html and css into iframes and popups, so you can at least render a loading spinner, or maybe something more advanced, while the new window loads its content.

  • I don't want to bother with popups, can I get zoid with just the iframe support?

    You can indeed. There's an zoid.frame.js and zoid.frame.min.js in the dist/ folder. There's a lot of magic that's needed to make popups work with IE, and that's all trimmed out.

  • Can I contribute?

    By all means! But please raise an issue first if it's more than a small change, to discuss the feasibility.

  • Is this different to react-frame-component?

    Yes. react-frame-component allows you to render html into a sandboxed iframe on the same domain. zoid is geared around sharing functionality from one domain to another, in a cross-domain iframe.

Browser Support

  • Internet Explorer 9+
  • Chrome 27+
  • Firefox 30+
  • Safari 5.1+
  • Opera 23+
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].