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.

On this page

Back to All Codemods

Carousel Transform

Converts a v6 Carousel component to a v7 Carousel component.

Automatic Changes

  • Renames the navigationPagination prop to navigationStyle. If navigationPagination is true, then navigationStyle="text". Otherwise navigationStyle="dots".
  • Renames the type prop to isSlideFullWidth. If type is "small", then isSlideFullWidth={false}. Otherwise isSlideFullWidth={true}.
  • Renames the heading prop to labelOverrides['aria-label'].
  • Removes the animate prop, which has been deprecated.
  • Removes the headingLevel prop, which has been deprecated.
  • Renames the autoplay prop to shouldAutoPlay.
  • Renames the onChange prop to onSlideChange.
  • Renames the nextButtonLabel prop to labelOverrides.nextButtonScreenReaderLabel.
  • Renames the previousButtonLabel prop to labelOverrides.previousButtonScreenReaderLabel.
  • Renames the playLabel prop to labelOverrides.playButtonScreenReaderLabel.
  • Renames the pauseLabel prop to labelOverrides.pauseButtonScreenReaderLabel.
  • Renames the getSlideButtonLabel prop to labelOverrides.getDotNavigationScreenReaderLabel.
  • Renames the getPaginationText prop to labelOverrides.getTextNavigationLabel.
  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.

For example:

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

export default function Page() {

return (

<Carousel

navigationPagination={true}

type="small"

animate={animate}

heading="Carousel"

headingLevel={headingLevel}

autoplay={autoplay}

onChange={onChange}

nextButtonLabel="Go to next offer"

previousButtonLabel="Go to previous offer"

playLabel="Play carousel"

pauseLabel="Pause carousel"

getSlideButtonLabel={(slideNumber) => `Offer ${slideNumber}`}

getPaginationText={(current, total) => `Offer ${current} of ${total}`}

theme={{ color: 'red' }}

{...otherProps}

>

{/** Children */}

</Carousel>

);

}

Transforms into:

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

export default function Page() {

return (

<Carousel

navigationStyle="text"

isSlideFullWidth={false}

shouldAutoPlay={autoplay}

onSlideChange={onChange}

{...otherProps}

labelOverrides={{

'aria-label': 'Carousel',

nextButtonScreenReaderLabel: 'Go to next offer',

previousButtonScreenReaderLabel: 'Go to previous offer',

playButtonScreenReaderLabel: 'Play carousel',

pauseButtonScreenReaderLabel: 'Pause carousel',

getDotNavigationScreenReaderLabel: (slideNumber) =>

`Offer ${slideNumber}`,

getTextNavigationLabel: (current, total) =>

`Offer ${current} of ${total}`,

}}

>

{/** Children */}

</Carousel>

);

}

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.