diff --git a/Parts/DropDown.js b/Parts/DropDown.js index 0fa96fc..e109d23 100644 --- a/Parts/DropDown.js +++ b/Parts/DropDown.js @@ -40,11 +40,21 @@ let Dropdown = React.forwardRef(({ children, dropdownCss, onValueChanged, button await update(); } - onValueChanged && onValueChanged(true); + try { + if (onValueChanged) + onValueChanged(true); + } catch (e) { + console.error(e); + } }; const closeDropdownPopover = () => { setDropdownPopoverShow(false); - onValueChanged && onValueChanged(false); + try { + if (onValueChanged) + onValueChanged(false); + } catch (e) { + console.error(e); + } }; function handleOutsideClick(event) { diff --git a/Parts/Modal.js b/Parts/Modal.js index 429e562..8cd60dd 100644 --- a/Parts/Modal.js +++ b/Parts/Modal.js @@ -1,5 +1,5 @@ import React from "react" -import { Third } from "./Layout" +import { Half, Third } from "./Layout" import tw, { styled } from "twin.macro" import "styled-components/macro" @@ -7,9 +7,9 @@ import "styled-components/macro" function Modal({ isOpen, onBackdropClick, ...props }) { if (isOpen) { return
- e.stopPropagation()}> + e.stopPropagation()}> {props.children} - +
} return null; diff --git a/Parts/Pagination.js b/Parts/Pagination.js index 1e111f6..43ac140 100644 --- a/Parts/Pagination.js +++ b/Parts/Pagination.js @@ -1,56 +1,116 @@ import Button from "./Button"; -import tw, { styled } from "twin.macro" -import "styled-components/macro" +import tw, { styled } from "twin.macro"; +import "styled-components/macro"; -function CustomBtn({children, setPage, currentPage, page, css, ...props}){ - console.log(css) - return +const Btn = styled(Button)(({ active }) => [tw`rounded-none mx-0`, active && tw`bg-accent`]); + +function CustomBtn({ children, setPage, currentPage, page, ...props }) { + return ( + setPage(page)} active={page == currentPage} {...props}> + {children} + + ); } export default function Pagination({ currentPage, maxPages, setPage, ...props }) { - function RenderButtons() { switch (maxPages) { case 1: - return 1; + return ( + + 1 + + ); case 2: - return <> - 1 - 2 - + return ( + <> + + 1 + + + 2 + + + ); case 3: - return <> - 1 - 2 - 3 - + return ( + <> + + 1 + + + 2 + + + 3 + + + ); case 4: - return <> - 1 - 2 - 3 - 4 - + return ( + <> + + 1 + + + 2 + + + 3 + + + 4 + + + ); case 5: - return <> - 1 - 2 - 3 - 4 - 5 - + return ( + <> + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + ); default: { - return <> - {currentPage > 3 && <} - {Math.max(currentPage-2,1)} - {Math.max(currentPage-2,1)+1} - {Math.max(currentPage-2,1)+2} - {(maxPages - currentPage) >= 1 && {Math.max(currentPage-2,1)+3}} - {(maxPages - currentPage) >= 2 && {Math.max(currentPage-2,1)+4}} - {(maxPages - currentPage) >= 3 && >} - - } + let firstItem = Math.min(Math.max(currentPage - 2, 1), maxPages - 4); + let secondItem = Math.min(Math.max(currentPage - 1, 2), maxPages - 3); + let thirdItem = Math.min(Math.max(currentPage, 3), maxPages - 2); + let fourthItem = Math.min(Math.max(currentPage + 1, 4), maxPages - 1); + let fifthItem = Math.min(Math.max(currentPage + 2, 5), maxPages); + return ( + <> + + {firstItem != 1 ? <>< : firstItem} + + + + {secondItem} + + + {thirdItem} + + + {fourthItem} + + + {fifthItem != maxPages ? <>> : fifthItem} + + + ); + } } } @@ -58,5 +118,5 @@ export default function Pagination({ currentPage, maxPages, setPage, ...props })
- ) -} \ No newline at end of file + ); +} diff --git a/globalStyle.js b/globalStyle.js index 3d65f85..1fe9851 100644 --- a/globalStyle.js +++ b/globalStyle.js @@ -68,7 +68,7 @@ body { const GlobalStyles = () => { return <> - + {/* */} }