Codemods

The American Express Design System provides a unified language for designing American Express websites and experiences. The design system provides design resources that match our coded components and are aligned with the American Express brand. Included are colors, components, icons and glyphs, type styles, and graphic assets to get you up and running quickly.

Back to All Codemods

Pagination Transform

Converts a v6 Pagination component to a v7 Pagination component.

Automatic Changes

  • Adds id prop if not present. The id prop is now required. Update prop value to an appropriate value.
  • Renames the selected prop to selectedPage.
  • Renames the skipFirstText prop to labelOverrides.skipToFirstScreenReaderLabel.
  • Renames the previousText prop to labelOverrides.previousScreenReaderLabel.
  • Renames the nextText prop to labelOverrides.nextScreenReaderLabel.
  • Renames the skipLastText prop to labelOverrides.skipToLastScreenReaderLabel.
  • Removes the getLinkUrl prop, which has been deprecated.
  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.

For example:

import { Pagination } from '@americanexpress/dls-react6';

export default function Page() {

return (

<Pagination

selected={selectedPage}

total={100}

onChange={setSelectedPage}

skipFirstText="Custom skip first text"

previousText="Custom previous text"

nextText="Custom next text"

skipLastText="Custom skip last text"

getSelectedPageLabel={(selected, total) =>

`Custom selected page label: ${page} of ${total}`

}

getLinkUrl={(page) => `https://www.example.com/page/${page}`}

theme={{ color: 'red' }}

{...otherProps}

/>

);

}

Transforms into:

import { Pagination } from '@americanexpress/dls-react';

export default function Page() {

return (

<Pagination

id="unique-id-for-pagination"

selectedPage={selectedPage}

total={100} // needs manual change

onChange={setSelectedPage}

getSelectedPageLabel={(selected, total) =>

`Custom selected page label: ${page} of ${total}`

}

{...otherProps}

labelOverrides={{

skipToFirstScreenReaderLabel: 'Custom skip first text',

previousScreenReaderLabel: 'Custom previous text',

nextScreenReaderLabel: 'Custom next text',

skipToLastScreenReaderLabel: 'Custom skip last text',

}}

/>

);

}

Manual Changes

The Pagination component now includes “Results Per Page” functionality by default. This significantly changes the behavior of the component. See the component documentation for more info on the “Results Per Page” functionality and other new props.

The total prop has been deprecated in favor of totalResults. The total prop was for the total number of pages, whereas the totalResults prop is for the total number of results.

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.