Giter Site home page Giter Site logo

anubra266 / choc-paginator Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 4.0 37.41 MB

πŸ“Ÿ The Complete Pagination Library for Chakra UI

Home Page: https://choc-ui.tech/docs/packages/pagination

License: MIT License

HTML 1.42% TypeScript 98.58%
choc-ui chakra-ui react javascript choc-paginator

choc-paginator's Introduction

choc-paginator's People

Contributors

allcontributors[bot] avatar amaslakov avatar anubra266 avatar dependabot[bot] avatar f-laino avatar yicru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

choc-paginator's Issues

Allow href attribute (for SEO)

Can you add an optional attribute for href, also with an optional base path string (or the ability to customize its behavior with a function, as like as itemRender).
Example:

<Flex
      w="full"
      bg={useColorModeValue("gray.400", "gray.600")}
      p={50}
      alignItems="center"
      justifyContent="center"
    >
      <Pagination
        defaultCurrent={2}
        total={50}
        paginationProps={{ display: "flex", mb: 4 }}
        forwardHref={true}
        basePath="https://localhost/"
      />
</Flex>

Empty span before pagination buttons

<span> that's intended to hold the total number of items, when showTotal is set, stays even when showTotal is NOT set. This makes it hard to left align the pagination component.
image

'backward' in itemRender will not display correctly

If itemRender is defined and backward is specified, it will not be displayed correctly.
The rightRender is passed in src/components/pagination.tsx:L153, but I think it should be leftRender.

The example below will appear as shown in the picture.

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2021-10-08 18 44 06

import { Button, forwardRef } from "@chakra-ui/react"
import ChocPaginator from "@choc-ui/paginator"
import React, { ComponentProps } from "react"

type ItemRenderFn = ComponentProps<typeof ChocPaginator>["itemRender"]

const PrevButton = forwardRef((props, ref) => (
  <Button ref={ref} {...props}>
    Prev
  </Button>
))

const NextButton = forwardRef((props, ref) => (
  <Button ref={ref} {...props}>
    Next
  </Button>
))

const BackwardButton = forwardRef((props, ref) => (
  <Button ref={ref} {...props}>
    Backward
  </Button>
))

const ForwardButton = forwardRef((props, ref) => (
  <Button ref={ref} {...props}>
    Forward
  </Button>
))

export const Pagination: React.FC = () => {
  const itemRender: ItemRenderFn = (_, type) => {
    if (type === "prev") return PrevButton
    if (type === "next") return NextButton
    // This will not be rendered.
    if (type === "backward") return BackwardButton
    if (type === "forward") return ForwardButton
  }

  return (
    <ChocPaginator
      colorScheme="blue"
      defaultCurrent={5}
      itemRender={itemRender}
      pageSize={10}
      paginationProps={{
        display: "flex",
      }}
      total={500}
    />
  )
}

I tried to fix it, but gave up because it fails to test on the master branch.
Would be great to see this fixed.

PaginationComp calling hooks in different orders on each render, causing Chakra-UI toast issues.

Whenever this Pagination component is rendered within my app, the following error is logged to the console:

Warning: React has detected a change in the order of Hooks called by PaginationComp. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks.

For some reason, this is interfering with the ability to use chakra-ui's Toast component, to the point that the toast is not shown at all.

The following error is reported when attempting (and failing) to show toast:

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.

Is this a known issue? Would be great to see this fixed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.