Socket
Socket
Sign inDemoInstall

api-playground

Package Overview
Dependencies
34
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    api-playground

Components to create playgrounds for APIs easily.


Version published
Weekly downloads
4
Maintainers
1
Install size
7.44 MB
Created
Weekly downloads
 

Readme

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

Last updated on 18 May 2016

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc