Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ui-pagination/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@instructure/ui-themes": "workspace:*",
"@instructure/ui-tooltip": "workspace:*",
"@instructure/ui-utils": "workspace:*",
"@instructure/ui-text": "workspace:*",
"@instructure/ui-view": "workspace:*",
"@instructure/uid": "workspace:*"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class PaginationArrowButton extends Component<PaginationNavigationProps> {
renderIcon() {
const icon = this.Icon
if (!icon) return null
return renderIconWithProps(icon, 'md', 'baseColor')
return renderIconWithProps(icon, 'md', 'actionTertiaryBaseColor')
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import { Component } from 'react'

import { withStyle } from '@instructure/emotion'
import { Text } from '@instructure/ui-text/latest'
import { NumberInput } from '@instructure/ui-number-input/latest'
import { ScreenReaderContent } from '@instructure/ui-a11y-content'

Expand Down Expand Up @@ -191,7 +192,9 @@ class PaginationPageInput extends Component<
const { label, numberOfPages, styles } = this.props

return typeof label === 'function' && label(numberOfPages) ? (
<span css={styles?.inputLabel}>{label(numberOfPages)}</span>
<Text variant="content">
<span css={styles?.inputLabel}>{label(numberOfPages)}</span>
</Text>
) : null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import type { PaginationPageInputStyle } from './props'
* ---
* Generates the style object from the theme and provided additional information
* @param {Object} componentTheme The theme variable object.
* @param {Object} props the props of the component, the style is applied to
* @param {Object} sharedTokens Shared token object that stores common values for the theme.
* @param {Object} state the state of the component, the style is applied to
* @return {Object} The final style object, which will be used in the component
*/
const generateStyle = (
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,17 @@ describe('<Pagination />', () => {
const pagination = screen.getByRole('navigation')
const allButtons = screen.queryAllByRole('button')
const paginationButtons = screen.getAllByRole('button', { name: /^#\d$/ })
const ellipses = screen.getAllByText('…', {
selector: '[aria-hidden="true"]'
})
const ellipses = document.querySelectorAll('li[aria-hidden="true"]')

expect(pagination).toBeInTheDocument()
expect(pagination).toHaveTextContent('Prev#0…#2#3#4#5#6…#8Next')

expect(allButtons.length).toEqual(9)
expect(paginationButtons.length).toEqual(7)
expect(ellipses.length).toEqual(2)
expect(Array.from(ellipses).every((el) => el.textContent === '…')).toBe(
true
)
})

it('should truncate start', async () => {
Expand All @@ -241,16 +242,17 @@ describe('<Pagination />', () => {
const pagination = screen.getByRole('navigation')
const allButtons = screen.queryAllByRole('button')
const paginationButtons = screen.getAllByRole('button', { name: /^#\d$/ })
const ellipses = screen.getAllByText('…', {
selector: '[aria-hidden="true"]'
})
const ellipses = document.querySelectorAll('li[aria-hidden="true"]')

expect(pagination).toBeInTheDocument()
expect(pagination).toHaveTextContent('Prev#0…#5#6#7#8')

expect(allButtons.length).toEqual(6)
expect(paginationButtons.length).toEqual(5)
expect(ellipses.length).toEqual(1)
expect(Array.from(ellipses).every((el) => el.textContent === '…')).toBe(
true
)
})

it('should truncate end', async () => {
Expand All @@ -263,16 +265,17 @@ describe('<Pagination />', () => {
const pagination = screen.getByRole('navigation')
const allButtons = screen.queryAllByRole('button')
const paginationButtons = screen.getAllByRole('button', { name: /^#\d$/ })
const ellipses = screen.getAllByText('…', {
selector: '[aria-hidden="true"]'
})
const ellipses = document.querySelectorAll('li[aria-hidden="true"]')

expect(pagination).toBeInTheDocument()
expect(pagination).toHaveTextContent('#0#1#2#3…#5Next')

expect(allButtons.length).toEqual(6)
expect(paginationButtons.length).toEqual(5)
expect(ellipses.length).toEqual(1)
expect(Array.from(ellipses).every((el) => el.textContent === '…')).toBe(
true
)
})

it('should omit ellipses when bounds included in context', async () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/ui-pagination/src/Pagination/v2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
ReactNode
} from 'react'

import { Text } from '@instructure/ui-text/latest'
import { View } from '@instructure/ui-view/latest'
import { omitProps, withDeterministicId } from '@instructure/ui-react-utils'
import { hasVisibleChildren } from '@instructure/ui-a11y-utils'
Expand Down Expand Up @@ -258,12 +259,11 @@ class Pagination extends Component<PaginationProps> {

return (
<View
as="span"
padding={visibleLabel ? 'small' : '0'}
display={visibleLabel ? display : 'auto'}
id={this._labelId}
>
{this.props.label}
<Text variant="content">{this.props.label}</Text>
</View>
)
}
Expand Down Expand Up @@ -375,7 +375,7 @@ class Pagination extends Component<PaginationProps> {
pages.push(this.renderPagesInInterval(1, boundaryCount!, currentPage!))
pages.push(
<li key="ellipsis1" style={{ all: 'unset' }}>
{ellipsis}
<Text>{ellipsis}</Text>
</li>
)
if (
Expand Down Expand Up @@ -418,7 +418,7 @@ class Pagination extends Component<PaginationProps> {
)
pages.push(
<li key="ellipsis2" style={{ all: 'unset' }}>
{ellipsis}
<Text>{ellipsis}</Text>
</li>
)
pages.push(
Expand Down Expand Up @@ -463,14 +463,14 @@ class Pagination extends Component<PaginationProps> {
if (sliceStart - firstIndex > 1)
visiblePages.unshift(
<li style={{ all: 'unset' }} key="first" aria-hidden="true">
{this.props.ellipsis}
<Text>{this.props.ellipsis}</Text>
</li>
)
if (sliceStart - firstIndex > 0) visiblePages.unshift(firstPage)
if (lastIndex - sliceEnd + 1 > 1)
visiblePages.push(
<li style={{ all: 'unset' }} key="last" aria-hidden="true">
{this.props.ellipsis}
<Text>{this.props.ellipsis}</Text>
</li>
)
if (lastIndex - sliceEnd + 1 > 0) visiblePages.push(lastPage)
Expand Down
11 changes: 5 additions & 6 deletions packages/ui-pagination/src/Pagination/v2/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* SOFTWARE.
*/

import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
import type { PaginationStyle, PaginationProps } from './props'
import type { NewComponentTypes } from '@instructure/ui-themes'
import type { PaginationStyle } from './props'

/**
* ---
Expand All @@ -37,9 +37,7 @@ import type { PaginationStyle, PaginationProps } from './props'
* @return {Object} The final style object, which will be used in the component
*/
const generateStyle = (
componentTheme: NewComponentTypes['Pagination'],
_props: PaginationProps,
_sharedTokens: SharedTokens
componentTheme: NewComponentTypes['Pagination']
): PaginationStyle => {
return {
pageIndicatorList: {
Expand All @@ -57,7 +55,8 @@ const generateStyle = (
pages: {
label: 'pagination__pages',
display: 'inline-flex',
alignItems: 'center'
alignItems: 'center',
gap: componentTheme.pageIndicatorGap
}
}
}
Expand Down
45 changes: 0 additions & 45 deletions packages/ui-pagination/src/Pagination/v2/theme.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/ui-pagination/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{ "path": "../ui-icons/tsconfig.build.json" },
{ "path": "../ui-portal/tsconfig.build.json" },
{ "path": "../ui-react-utils/tsconfig.build.json" },
{ "path": "../ui-text/tsconfig.build.json" },
{ "path": "../ui-themes/tsconfig.build.json" },
{ "path": "../ui-tooltip/tsconfig.build.json" },
{ "path": "../ui-utils/tsconfig.build.json" },
Expand Down
7 changes: 5 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading