Skip to content

Commit

Permalink
feat(react/pagination): apply default props
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Sep 16, 2024
1 parent c817ff1 commit 819c3cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions packages/react/src/pagination/Pagination.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { Fragment, forwardRef } from 'react';
import { Box } from '../box';
import { useDefaultProps } from '../default-props';
import { usePaginationStyle } from './styles';
import PaginationItem from './PaginationItem';
import usePagination from './usePagination';

const Pagination = forwardRef((
{
const Pagination = forwardRef((inProps, ref) => {
const {
boundaryCount = 1,
count = 1,
defaultPage = 1,
Expand All @@ -16,9 +17,7 @@ const Pagination = forwardRef((
siblingCount = 1,
slot,
...rest
},
ref,
) => {
} = useDefaultProps({ props: inProps, name: 'Pagination' });
const { items } = usePagination({
boundaryCount,
count,
Expand Down
9 changes: 4 additions & 5 deletions packages/react/src/pagination/PaginationItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { ariaAttr } from '@tonic-ui/utils';
import React, { forwardRef } from 'react';
import { Button } from '../button';
import { useDefaultProps } from '../default-props';
import {
usePaginationItemStyle,
} from './styles';
Expand All @@ -34,8 +35,8 @@ const getAriaLabel = ({ type, page, selected }) => {
return `Go to ${type} page`;
};

const PaginationItem = forwardRef((
{
const PaginationItem = forwardRef((inProps, ref) => {
const {
'aria-label': ariaLabel,
disabled = false,
type = 'page',
Expand All @@ -44,9 +45,7 @@ const PaginationItem = forwardRef((
slot: slotProp,
variant = 'ghost',
...rest
},
ref,
) => {
} = useDefaultProps({ props: inProps, name: 'PaginationItem' });
const slot = {
...defaultSlot,
...slotProp,
Expand Down

0 comments on commit 819c3cf

Please sign in to comment.