Skip to content

Commit

Permalink
feat(pagination): fix pagination select
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasaarcoverde committed Nov 24, 2023
1 parent a3dc543 commit 5985424
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 4 additions & 5 deletions packages/components/src/pagination/pagination-select.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentPropsWithoutRef, ReactNode } from 'react'
import type { ReactNode } from 'react'
import React, { forwardRef } from 'react'

import { Action } from '../action'
Expand All @@ -23,8 +23,6 @@ export const PaginationSelect = forwardRef<
} = props

if (loading) {
console.log({ loading })

return (
<div data-sl-pagination-select data-loading={loading}>
<Skeleton />
Expand All @@ -48,7 +46,7 @@ export const PaginationSelect = forwardRef<
</Select>
<Bleed>
<SelectPopover data-sl-pagination-select-popover>
{children}
{options.map((option) => children(option))}
</SelectPopover>
</Bleed>
</SelectProvider>
Expand All @@ -57,10 +55,11 @@ export const PaginationSelect = forwardRef<
)
})

export interface PaginationSelectProps extends ComponentPropsWithoutRef<'div'> {
export interface PaginationSelectProps {
onValueChange?: (value: number) => void
value: number
options: number[]
children: (option: number) => ReactNode
loading?: boolean
label: ReactNode
disabled?: boolean
Expand Down
9 changes: 4 additions & 5 deletions packages/components/src/pagination/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import './pagination.css'
import { SelectOption } from '../select'
import { Skeleton } from '../skeleton'
import { PaginationSelect } from './pagination-select'

/**
* Pagination triggers allow merchants to view the size of a list and navigate between pages.
*
Expand Down Expand Up @@ -58,11 +57,11 @@ export const Pagination = forwardRef<HTMLDivElement, PaginationProps>(
label={`Show ${size}`}
disabled={loading}
>
{sizeOptions.map((option) => (
{(option) => (
<SelectOption value={String(option)}>
Show {option}
</SelectOption>
))}
)}
</PaginationSelect>
)}

Expand Down Expand Up @@ -91,9 +90,9 @@ export const Pagination = forwardRef<HTMLDivElement, PaginationProps>(
loading={loading}
label={`${page} of ${pageOptions.length}`}
>
{pageOptions.map((option) => (
{(option) => (
<SelectOption value={String(option)}>{option}</SelectOption>
))}
)}
</PaginationSelect>

<Action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ describe('pagination', () => {
expect(
container.querySelector('[data-sl-pagination-actions]')
).toBeInTheDocument()
expect(
container.querySelector('[data-sl-pagination-page-select]')
).toBeInTheDocument()
expect(
container.querySelector('[data-sl-pagination-total-label]')
).toBeInTheDocument()
Expand Down

0 comments on commit 5985424

Please sign in to comment.