Socket
Book a DemoInstallSign in
Socket

api-playground

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-playground

Components to create playgrounds for APIs easily.

0.1.2
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

API Playground

Components to create playgrounds for APIs easily.

Example Playground

import React  from 'react';
import ReactDOM from 'react-dom';
import { compose, applyMiddleware, createStore } from 'redux';
import { logger, Playground } from 'api-playground';
import MyComponentExample from './myComponentExample';

let reduxStore = createStore(e => e, {}, compose(
  applyMiddleware(logger)
));

let config = { example: 'hello' };

ReactDOM.render((
  <Playground
    store={reduxStore}
    getConfig={config}
    changeConfig={(key, value) => config[key] = value}
  >
    <MyComponentExample/>
  </Playground>
), document.getElementById('main'));

Example Component

import React, { PropTypes, Component } from 'react';
import { PlaygroundComponent, View, Section, Ui } from 'api-playground';

@PlaygroundComponent
class MyComponentExample extends Component {
  static contextTypes = {
    store: PropTypes.object
  };

  static subscribe = 'reduxStateKey';

  addItem = (value) => {
    this.refs.modal.setState({ isOpen: false });
  };

  removeItem = (index) => {
  };

  actions = {
    addItem: this.addItem,
    removeItem: this.removeItem
  };

  render() {
    return (
      <View>
        <Section.Items
          showTotals={['quantity']}
          items={this.state}
          removeItem={this.removeItem}
        />
        <Section>
          <Section.Param name="Quantity" value={this.state.length}/>
        </Section>
        <Section>
          <Section.Request ref="request"/>
        </Section>
        <Ui.Modal ref="modal">
          <Section.Form
            name="Item"
            defaults={{ item: 'defaultValue' }}
            action={this.addItem}
          />
        </Ui.Modal>
      </View>
    );
  }
}

export default MyComponentExample;

FAQs

Package last updated on 18 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.