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

SlideStepper Transform

Converts a v6 SlideStepper component to a v7 Slider component.

Automatic Changes

  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.
  • Renames the import and usages of SlideStepper to Slider.
  • Renames the onChange prop to onSliderValueChange, but does not update to the new function signature (see Manual Changes section for more details).
  • Removes the intervalDelay prop, which has been deprecated.
  • Removes the children, which has been deprecated. The current value of the slider will be displayed in a DataTip by default. If you want to display a different value, use the getDataTipValue prop (see Manual Changes section for more details).
  • The label prop will display a visible label for the entire component, which is also the accessible label read by screen readers.
  • The min prop will display a visible label for the minimum value, which is also an accessible description read by screen readers.
  • The max prop will display a visible label for the maximum value, which is also an accessible description read by screen readers.

For example:

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

export default function Page() {

return (

<SlideStepper

id="slider"

label="Label"

min={0}

max={100}

step={1}

value={50}

onChange={() => {}}

intervalDelay={10}

theme={{ color: 'red' }}

{...otherProps}

>

{/** Children */}

</SlideStepper>

);

}

Transforms into:

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

export default function Page() {

return (

<Slider

id="slider"

label="Label"

min={0}

max={100}

step={1}

value={50}

onChange={() => {}}

{...otherProps}

/>

);

}

Manual Changes

onChange has been renamed to onSliderValueChange with a different signature

We’ve renamed the prop to onSliderValueChange to be more descriptive, by specifing what exactly has changed. Previously, the signature included the event as the first parameter and the newValue in an object with the key value as the second parameter:

onChange(event, { value: newValue });

Now, the signature includes only the newValue as the first parameter:

onSliderValueChange(newValue);

Please update the function signature and verify the expected functionality works.

children has been removed, use getDataTipValue instead to mimic the same behavior

In v6, a Tooltip displayed the slider value, which came from the children prop. In v7, a DataTip displays the slider value by default, so children can safely be removed if the slider value and displayed value are the same.

If you want to display a different value, (e.g. prepend a $ to the value), use the getDataTipValue prop. The getDataTipValue prop is a function that takes the slider value and percent and returns a user-friendly string to be displayed in the DataTip.

For example:

getDataTipValue={(value, percent) => `$${value}`}

Use
minLabelmaxLabel

By default, the min and max props are displayed as a label for the minimum and maximum values, respectively. If you want a different label, use the minLabel and maxLabel props. The label will be a visible label and an accessible description read by screen readers.

Use the
label

If you were previously using a Label component, that can be removed in favor of the label prop.

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.