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

Collapsible Transform

Converts a v6 CollapsibleHeading to a v7 AccordionText component.

Automatic Changes

  • Renames the import and usages of CollapsibleHeading to AccordionText.
  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.
  • Deletes the forId prop. Use the id prop instead.
  • Renames the labels.collapsed prop to labelOverrides.collapsedLabel.
  • Renames the labels.expanded prop to labelOverrides.expandedLabel.
  • Renames defaultBtn to shouldUseUnstyledButton.
  • Removes children if shouldUseUnstyledButton is false.
  • Removes labelOverrides if shouldUseUnstyledButton is true.

For example:

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

export default function Page() {

return (

<CollapsibleHeading

forId="panel-1"

labels={{

expanded: 'Hide Details',

collapsed: 'Show Details',

}}

{...otherProps}

>

Show Details

</CollapsibleHeading>

);

}

Transforms into:

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

export default function Page() {

return (

<AccordionText

id="panel-1"

labelOverrides={{

expandedLabel: 'Hide Details',

collapsedLabel: 'Show Details',

}}

{...otherProps}

/>

);

}

And:

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

export default function Page() {

return (

<CollapsibleHeading

forId="panel-1"

labels={{

expanded: 'Hide Details',

collapsed: 'Show Details',

}}

defaultBtn={true}

{...otherProps}

>

Show Details

</CollapsibleHeading>

);

}

Transforms into:

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

export default function Page() {

return (

<AccordionText

id="panel-1"

labels={{

expanded: 'Hide Details',

collapsed: 'Show Details',

}}

isDefaultBtn={true}

{...otherProps}

>

Show Details

</AccordionText>

);

}

Manual Changes

Heading

The text or content that is displayed above the trigger element can be passed to the AccordionText using the heading prop.

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.