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

Search Transform

Converts a v6 Search component to a v7 Search or v7 DefaultSearch component.

Automatic Changes

  • Renames loading to isLoading
  • Renames labelText to label
  • Renames buttonSearch to showSearchButton
  • Renames disabled to aria-disabled
  • Renames searchButtonLabel to labelOverrides.searchButtonScreenReaderLabel
  • Renames clearButtonLabel to labelOverrides.clearButtonScreenReaderLabel
  • Deletes the showLabelText prop. There must always be visible label text.
  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.
  • Deletes the SearchResults component. SearchResult components should now be direct children of the Search component.
  • If Search has no children, renames component to DefaultSearch.

For example:

import {

Search,

SearchResults,

SearchResult,

} from '@americanexpress/dls-react6';

export default function Page() {

return (

<Search

loading={loading}

labelText={labelText}

buttonSearch={buttonSearch}

disabled={disabled}

searchButtonLabel="Search"

clearButtonLabel="Clear Search"

showLabelText={showLabelText}

theme={{ color: 'red' }}

{...otherProps}

>

<SearchResults>

<SearchResult key="1" id="result-1" {...otherProps} />

<SearchResult key="2" id="result-2" {...otherProps} />

<SearchResult key="3" id="result-3" {...otherProps} />

</SearchResults>

</Search>

);

}

Transforms into:

import { Search, SearchResult } from '@americanexpress/dls-react';

export default function Page() {

return (

<Search

isLoading={loading}

label={labelText}

showSearchButton={buttonSearch}

aria-disabled={disabled}

labelOverrides={{

searchButtonScreenReaderLabel: 'Search',

clearButtonScreenReaderLabel: 'Clear Search',

}}

{...otherProps}

>

<SearchResult key="1" id="result-1" {...otherProps} />

<SearchResult key="2" id="result-2" {...otherProps} />

<SearchResult key="3" id="result-3" {...otherProps} />

</Search>

);

}

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.