diff --git a/packages/ui-pagination/package.json b/packages/ui-pagination/package.json index e4f19e1300..ebf7451290 100644 --- a/packages/ui-pagination/package.json +++ b/packages/ui-pagination/package.json @@ -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:*" }, diff --git a/packages/ui-pagination/src/Pagination/v2/PaginationArrowButton/index.tsx b/packages/ui-pagination/src/Pagination/v2/PaginationArrowButton/index.tsx index bbfb0dfd27..c1eaead4f7 100644 --- a/packages/ui-pagination/src/Pagination/v2/PaginationArrowButton/index.tsx +++ b/packages/ui-pagination/src/Pagination/v2/PaginationArrowButton/index.tsx @@ -86,7 +86,7 @@ class PaginationArrowButton extends Component { renderIcon() { const icon = this.Icon if (!icon) return null - return renderIconWithProps(icon, 'md', 'baseColor') + return renderIconWithProps(icon, 'md', 'actionTertiaryBaseColor') } render() { diff --git a/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/index.tsx b/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/index.tsx index 6d3f230637..48dfe7bcaa 100644 --- a/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/index.tsx +++ b/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/index.tsx @@ -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' @@ -191,7 +192,9 @@ class PaginationPageInput extends Component< const { label, numberOfPages, styles } = this.props return typeof label === 'function' && label(numberOfPages) ? ( - {label(numberOfPages)} + + {label(numberOfPages)} + ) : null } diff --git a/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/styles.ts b/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/styles.ts index 1ca3fbba30..d06b864592 100644 --- a/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/styles.ts +++ b/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/styles.ts @@ -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 = ( diff --git a/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/theme.ts b/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/theme.ts deleted file mode 100644 index ca21bce47a..0000000000 --- a/packages/ui-pagination/src/Pagination/v2/PaginationPageInput/theme.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 - present Instructure, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import type { Theme } from '@instructure/ui-themes' -import type { PaginationPageInputTheme } from '@instructure/shared-types' - -/** - * Generates the theme object for the component from the theme and provided additional information - * @param {Object} theme The actual theme object. - * @return {Object} The final theme object with the overrides and component variables - */ -const generateComponentTheme = (theme: Theme): PaginationPageInputTheme => { - const { spacing, colors } = theme - - const componentVariables: PaginationPageInputTheme = { - inputSpacing: spacing.xSmall, - inputWidth: '4.5rem', - labelColor: colors?.contrasts?.grey125125 - } - - return { - ...componentVariables - } -} - -export default generateComponentTheme diff --git a/packages/ui-pagination/src/Pagination/v2/__tests__/Pagination.test.tsx b/packages/ui-pagination/src/Pagination/v2/__tests__/Pagination.test.tsx index e14c6ad56e..5bc4725530 100644 --- a/packages/ui-pagination/src/Pagination/v2/__tests__/Pagination.test.tsx +++ b/packages/ui-pagination/src/Pagination/v2/__tests__/Pagination.test.tsx @@ -219,9 +219,7 @@ describe('', () => { 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') @@ -229,6 +227,9 @@ describe('', () => { 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 () => { @@ -241,9 +242,7 @@ describe('', () => { 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') @@ -251,6 +250,9 @@ describe('', () => { 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 () => { @@ -263,9 +265,7 @@ describe('', () => { 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') @@ -273,6 +273,9 @@ describe('', () => { 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 () => { diff --git a/packages/ui-pagination/src/Pagination/v2/index.tsx b/packages/ui-pagination/src/Pagination/v2/index.tsx index f5105dc7dd..e65dac7ec8 100644 --- a/packages/ui-pagination/src/Pagination/v2/index.tsx +++ b/packages/ui-pagination/src/Pagination/v2/index.tsx @@ -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' @@ -258,12 +259,11 @@ class Pagination extends Component { return ( - {this.props.label} + {this.props.label} ) } @@ -375,7 +375,7 @@ class Pagination extends Component { pages.push(this.renderPagesInInterval(1, boundaryCount!, currentPage!)) pages.push(
  • - {ellipsis} + {ellipsis}
  • ) if ( @@ -418,7 +418,7 @@ class Pagination extends Component { ) pages.push(
  • - {ellipsis} + {ellipsis}
  • ) pages.push( @@ -463,14 +463,14 @@ class Pagination extends Component { if (sliceStart - firstIndex > 1) visiblePages.unshift( ) if (sliceStart - firstIndex > 0) visiblePages.unshift(firstPage) if (lastIndex - sliceEnd + 1 > 1) visiblePages.push( ) if (lastIndex - sliceEnd + 1 > 0) visiblePages.push(lastPage) diff --git a/packages/ui-pagination/src/Pagination/v2/styles.ts b/packages/ui-pagination/src/Pagination/v2/styles.ts index 47991204f6..d172d299af 100644 --- a/packages/ui-pagination/src/Pagination/v2/styles.ts +++ b/packages/ui-pagination/src/Pagination/v2/styles.ts @@ -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' /** * --- @@ -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: { @@ -57,7 +55,8 @@ const generateStyle = ( pages: { label: 'pagination__pages', display: 'inline-flex', - alignItems: 'center' + alignItems: 'center', + gap: componentTheme.pageIndicatorGap } } } diff --git a/packages/ui-pagination/src/Pagination/v2/theme.ts b/packages/ui-pagination/src/Pagination/v2/theme.ts deleted file mode 100644 index e91ee9f7d1..0000000000 --- a/packages/ui-pagination/src/Pagination/v2/theme.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 - present Instructure, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import type { Theme } from '@instructure/ui-themes' -import { PaginationTheme } from '@instructure/shared-types' - -/** - * Generates the theme object for the component from the theme and provided additional information - * @param {Object} theme The actual theme object. - * @return {Object} The final theme object with the overrides and component variables - */ -const generateComponentTheme = (theme: Theme): PaginationTheme => { - const { spacing } = theme - - const componentVariables: PaginationTheme = { - pageIndicatorGap: spacing.xSmall - } - - return { - ...componentVariables - } -} - -export default generateComponentTheme diff --git a/packages/ui-pagination/tsconfig.build.json b/packages/ui-pagination/tsconfig.build.json index f443f20090..8ec8405937 100644 --- a/packages/ui-pagination/tsconfig.build.json +++ b/packages/ui-pagination/tsconfig.build.json @@ -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" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 72733c873f..b094aa4ed3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3219,6 +3219,9 @@ importers: '@instructure/ui-react-utils': specifier: workspace:* version: link:../ui-react-utils + '@instructure/ui-text': + specifier: workspace:* + version: link:../ui-text '@instructure/ui-themes': specifier: workspace:* version: link:../ui-themes @@ -9387,12 +9390,12 @@ packages: glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} - deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me + deprecated: Glob versions prior to v9 are no longer supported glob@8.1.0: resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} engines: {node: '>=12'} - deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me + deprecated: Glob versions prior to v9 are no longer supported glob@9.3.5: resolution: {integrity: sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==}