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

TooltipButton Transform

Converts a v6 TooltipButton component to an equivalent v7 component.

Automatic Changes

  • Removes the alternateIconProps prop, which has been deprecated (see Manual Changes)
  • Removes the handleTooltipToggle prop, which has been deprecated (see Manual Changes)
  • Removes the active prop, which has been deprecated (see Manual Changes)
  • Removes the info prop, which has been deprecated. InfoTooltips will be automatically converted to the new API (see sections below).
  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.
  • Migrates the title prop on the icon supplied in the icon prop to the screenReaderLabel prop on the new components (see sections below).

When
iconIconInfoGlyphInfo

  • Renames TooltipButton to InfoTooltipButton
  • Removes the icon prop, which has been deprecated since an info icon is rendered already

For example:

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

export default function Page() {

return (

<TooltipButton

info={anyValue}

alternateIconProps={anyValue}

handleTooltipToggle={anyValue}

active={anyValue}

icon={<IconInfo title="More Info" />}

someOtherProp={anyValue}

{...otherProps}

/>

);

}

Transforms into:

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

export default function Page() {

return (

<InfoTooltipButton

screenReaderLabel="More Info"

someOtherProp={anyValue}

{...otherProps}

/>

);

}

When the
icon

  • Renames TooltipButton to IconButton
  • Migrates the contents of the icon prop as children of the IconButton

For example:

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

export default function Page() {

return (

<TooltipButton

info={anyValue}

alternateIconProps={anyValue}

handleTooltipToggle={anyValue}

active={anyValue}

icon={<IconAccount title="Additional Account Information" />}

someOtherProp={anyValue}

{...otherProps}

/>

);

}

Transforms into:

import { TooltipTrigger, IconButton } from '@americanexpress/dls-react';

export default function Page() {

return (

<IconButton

screenReaderLabel="Additional Account Information"

someOtherProp={anyValue}

{...otherProps}

>

<IconAccount />

</IconButton>

);

}

Manual Changes

alternateIconProps has been deprecated

Previously, this prop allowed additional props to be added to the icon when active. In v7, we’ve reworked the state management of the Tooltip component to be consistent with the rest of our system. If you’re using the tooltip as an info tooltip, we’d recommend throwing away this prop entirely. We’ve rebuilt the trigger for an info tooltip into it’s own dedicated component, so that it can be consistent across all products at Amex. If you’re not using the tooltip as an info tooltip, we’d recommend controlling the state of the v7 Tooltip component, and then conditionally applying props to the icon you’ve chosen. See the documentation for the v7 Tooltip component for more information.

State management props
handleTooltipToggleactive

In v7, we’ve reworked the state management of the Tooltip component to be consistent with the rest of our system. The API for handling the open/closed states of the tooltip have been migrated to a wrapper component. As a result, these props are no longer supported.

The following is an example of controlling the open state of the v6 Tooltip using active and handleTooltipToggle:

() => {

const [isOpen, setIsOpen] = useState(false);

const handleTooltipToggle = (event) => {

setIsOpen(!isOpen);

};

return (

<Tooltip

id="tooltip"

open={isOpen}

info={true}

triggerElement={

<TooltipButton

handleTooltipToggle={handleTooltipToggle}

active={isOpen}

>

<GlyphInfo />

</TooltipButton>

}

>

Some Content

</Tooltip>

);

};

The equivalent v7 code should look like the following:

() => {

const [isOpen, setIsOpen] = useState(false);

const handleTooltipToggle = (newOpen) => {

setIsOpen(newOpen);

};

return (

<Tooltip id="tooltip" isOpen={isOpen} onIsOpenChange={handleTooltipToggle}>

<TooltipTrigger>

<InfoTooltipButton />

</TooltipTrigger>

<TooltipContent>Some Content</TooltipContent>

</Tooltip>

);

};

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.