Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Robertson committed Jun 29, 2020
1 parent 9299aab commit bfd1c7e
Show file tree
Hide file tree
Showing 7 changed files with 614 additions and 41 deletions.
17 changes: 3 additions & 14 deletions x-pack/plugins/canvas/public/components/paginate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,16 @@

import React, { useState, useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { Paginate as Component } from './paginate';
import { Paginate as Component, PaginateProps, PaginateChildProps } from './paginate';

interface InPaginateProps {
export { PaginateProps, PaginateChildProps };
export interface InPaginateProps {
perPage?: number;
startPage?: number;
rows: any[];
children: (props: PaginateChildProps) => React.ReactNode;
}

export type PaginateProps = Omit<InPaginateProps, 'startPage'> & {
pageNumber: number;
totalPages: number;
nextPageEnabled: boolean;
prevPageEnabled: boolean;
setPage: (num: number) => void;
nextPage: () => void;
prevPage: () => void;
};

export type PaginateChildProps = Omit<PaginateProps, 'children'>;

export const Paginate: React.FunctionComponent<InPaginateProps> = ({
perPage = 10,
startPage = 0,
Expand Down
35 changes: 18 additions & 17 deletions x-pack/plugins/canvas/public/components/paginate/paginate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@

import React from 'react';
import PropTypes from 'prop-types';
import { PaginateProps } from './';
import { InPaginateProps } from './';

export const Paginate: React.FunctionComponent<PaginateProps> = (props) => {
return (
<React.Fragment>
{props.children({
rows: props.rows,
perPage: props.perPage,
pageNumber: props.pageNumber,
totalPages: props.totalPages,
nextPageEnabled: props.nextPageEnabled,
prevPageEnabled: props.prevPageEnabled,
setPage: props.setPage,
nextPage: props.nextPage,
prevPage: props.prevPage,
})}
</React.Fragment>
);
export type PaginateProps = Omit<InPaginateProps, 'startPage'> & {
pageNumber: number;
totalPages: number;
nextPageEnabled: boolean;
prevPageEnabled: boolean;
setPage: (num: number) => void;
nextPage: () => void;
prevPage: () => void;
};

export type PaginateChildProps = Omit<PaginateProps, 'children'>;

export const Paginate: React.FunctionComponent<PaginateProps> = ({
children,
...childrenProps
}) => {
return <React.Fragment>{children(childrenProps)}</React.Fragment>;
};

Paginate.propTypes = {
Expand Down
Loading

0 comments on commit bfd1c7e

Please sign in to comment.