refactor(Nav): improve toggle animation, refactor to TS (#755)

* style(Nav): match transition effect of official site

* fix(Pages): fix bug when searchResults pageSize is < prev PageSize causes currentPage to be impossible value

* refactor/fix(Nav): fix width transition animation and refactor to TS
This commit is contained in:
Danny Avila 2023-08-04 16:51:23 -04:00 committed by GitHub
parent d6dbd56e33
commit c7b586ba4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 34 deletions

View file

@ -1,10 +1,22 @@
import React from 'react';
import { PagesProps } from 'librechat-data-provider';
export default function Pages({ pageNumber, pages, nextPage, previousPage }) {
const clickHandler = (func) => async (e) => {
e.preventDefault();
await func();
};
export default function Pages({
pageNumber,
pages,
nextPage,
previousPage,
setPageNumber,
}: PagesProps) {
const clickHandler =
(func: () => Promise<void>) => async (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
await func();
};
if (pageNumber > pages) {
setPageNumber(pages);
}
return pageNumber == 1 && pages == 1 ? null : (
<div className="m-auto mb-2 mt-4 flex items-center justify-center gap-2">