Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

separate interface for pagination #28

Open
GamerGirlandCo opened this issue Nov 7, 2023 · 3 comments
Open

separate interface for pagination #28

GamerGirlandCo opened this issue Nov 7, 2023 · 3 comments

Comments

@GamerGirlandCo
Copy link
Contributor

all the views currently implemented (List and Table) have pagination props:

/**
* If a boolean, enables/disables paging with the default configuration. If a number, paging will be
* enabled with the given number of entries per page.
*/
paging?: number | boolean;
/** The initial page of the table. */
initialPage?: number;
/** Controlled prop for setting the page of the table. */
page?: number;

i was thinking, maybe we could move these to a separate interface, and have TableProps and ListState extend said interface, to avoid repitition.

what do you think?

@GamerGirlandCo GamerGirlandCo changed the title pagination props separate interface for pagination Nov 7, 2023
@GamerGirlandCo
Copy link
Contributor Author

something like

export interface Pagination {
     /** 
      * If a boolean, enables/disables paging with the default configuration. If a number, paging will be 
      * enabled with the given number of entries per page. 
      */ 
     paging?: number | boolean; 
  
     /** The initial page of the table. */ 
     initialPage?: number; 
     /** Controlled prop for setting the page of the table. */ 
     page?: number;
}

which could then be extended like this

export interface TableProps<T> extends Pagination {
// ...
}

@blacksmithgu
Copy link
Owner

It saves some typing, but the main benefit of extracting is if we can actually write generic code that just needs Pagination; is there anywhere where we would benefit doing this?

@GamerGirlandCo
Copy link
Contributor Author

It saves some typing, but the main benefit of extracting is if we can actually write generic code that just needs Pagination; is there anywhere where we would benefit doing this?

i'm experimenting with creating a generic usePagination hook. as of right now, the only place where it doesn't work is the table component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants