{"size": 2846, "ext": "js", "max_stars_repo_path": "src/components/PaginationControls/PaginationControls.stories.js", "max_stars_repo_name": "hcodyd/insidesales-components", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/PaginationControls/PaginationControls.stories.js", "max_issues_repo_name": "hcodyd/insidesales-components", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/PaginationControls/PaginationControls.stories.js", "max_forks_repo_name": "hcodyd/insidesales-components", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 34.7073170732, "max_line_length": 77, "alphanum_fraction": 0.3517217147}
import React from 'react';
import {
  storiesOf,
  action,
} from '@storybook/react';

import PaginationControls from './PaginationControls';

storiesOf('Components', module)
  .addWithChapters(
    'PaginationControls',
    {
      info: `
        Usage

        ~~~
        import React from 'react';
        import {PaginationControls} from 'insidesales-components';
        ~~~
      `,
      chapters: [
        {
          sections: [
            {
              title: 'Basic PaginationControls',
              sectionFn: () => {
                    const StatefulWrapper = class extends React.Component {
                        constructor() {
                            super();
                            this.state = {page: 1}
                        }
                        render = () => {
                        console.log(this.state.page)
                        return (<PaginationControls
                            currentPage={this.state.page}
                            totalPages={100}
                            advanceAPage={(e) => {
                                this.setState({page: this.state.page + 1})
                                action('advanceAPage')(e);
                            }}
                            goBackAPage={(e) => {
                                this.setState({page: this.state.page - 1})
                                action('goBackAPage')(e)
                            }}
                            isRequestPageValid={(e) => {
                                action('isRequestPageValid')(e)
                                return true;
                            }}
                            requestPage={(page) => {
                                this.setState({page})
                                action('requestPage')(page)
                            }}
                        />)}
                    }
                    return (
                    <div style={{background: 'black', padding: '10px'}}>
                        <StatefulWrapper/>
                    </div>
                )
                }
            },
            {
              title: 'PaginationControls with one page',
              sectionFn: () => {
                    return (
                        <div style={{background: 'black', padding: '10px'}}>
                            <PaginationControls
                            currentPage={1}
                            totalPages={1}
                            advanceAPage={action('advanceAPage')}
                            goBackAPage={action('goBackAPage')}
                            isRequestPageValid={action('isRequestPageValid')}
                            requestPage={action('requestPage')} />
                        </div>
                )
                }
            },
        ]}
      ]
    }
  );
