index.jsx 1.1 KB
Newer Older
J
Jason Park 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
import React from 'react';
import { classes } from '/common/util';
import { DescriptionViewer, RendererContainer, TabBar, WikiViewer } from '/components';
import styles from './stylesheet.scss';

class ViewerSection extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      tabIndex: 0,
    };
  }

  setTabIndex(tabIndex) {
    this.setState({ tabIndex });
  }

  render() {
    const { className, style } = this.props;
    const { tabIndex } = this.state;

J
Jason Park 已提交
23 24 25 26 27 28 29
    const tabs = ['Visualization', 'Description', 'Tracer API'].map((title, i) => ({
      title,
      props: {
        onClick: () => this.setTabIndex(i)
      },
    }));

J
Jason Park 已提交
30 31
    return (
      <section className={classes(styles.viewer_section, className)} style={style}>
J
Jason Park 已提交
32
        <TabBar tabs={tabs} tabIndex={tabIndex} />
J
Jason Park 已提交
33 34 35 36 37 38 39 40 41 42 43 44
        <div className={styles.content} data-tab_index={tabIndex}>
          <RendererContainer className={styles.tab} />
          <DescriptionViewer className={styles.tab} />
          <WikiViewer className={styles.tab} />
        </div>
      </section>
    );
  }
}

export default ViewerSection;