Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add migration guidance for icons #5443

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/little-radios-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type StringSuggestions } from '~components/types/StringSuggestions'
// `undefined` means the icon has no usage, thus is not available in the new icon set
type NewIconProps = { name: IconNames; isFilled?: boolean } | undefined

const iconMap = new Map<keyof typeof OLD_ICONS, NewIconProps>([
export const iconMap = new Map<keyof typeof OLD_ICONS, NewIconProps>([
['AcademyIcon', { name: 'school' }],
['ActionOffIcon', undefined],
['ActionOffWhiteIcon', undefined],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Canvas, Meta, Controls, Story } from '@storybook/blocks'
import { ResourceLinks, KAIOInstallation, LinkTo } from '~storybook/components'
import * as IconStories from './Icon.docs.stories'

<Meta title="Components/Icon/Icon (Future)/Migration Guide" />

# Icon Migration Guide

This is a short guide to assist in migration from the old to new Icon component.

## Codemod

To assist in migration we have created the `upgradeiconv1` codemod. This will loop through the given directory and update all instances of Icon to the latest implementation. You can refer to this [README](https://github.com/cultureamp/kaizen-design-system/blob/main/packages/components/codemods/README.md#upgradeiconv1) on how to run this within your repository.

For more information on the changes to the API, we recommend referring the <LinkTo pageId="components-icon-icon-future-api-specification--docs">API Specification</LinkTo>.

## Changes to Icon exportNames

The following table outlines the changes to the Icons names and whether the new `isFilled` prop is required. This can be used if you are manually migrating components.

Where `N/A` is shown, this indicates that an equivalent icon does not exist or has been made redundant by the new API, ie:

- `ActionOffIcon` is not needed as the new `ActionOnIcon` (`flash_on`) can be used with the `isFilled` to handle the toggled states.
- `ActionOffIconActionOffWhiteIcon` is not needed as the API allows for color to be set via `className` or inherited via it's parent element.

You will need to discuss alternative with your design team or reach out in the #help_design_system channel if an equivalent icon does not exist.

<Story of={IconStories.IconTableComparison} />
38 changes: 38 additions & 0 deletions packages/components/src/__rc__/Icon/_docs/Icon.docs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ToggleSwitchField } from '~components/ToggleSwitch'
import { Button } from '~components/__rc__/Button'
import { Tag } from '~components/__rc__/Tag'
import { StickerSheet } from '~storybook/components/StickerSheet'
import { iconMap } from '../../../../codemods/upgradeIconV1/getNewIconPropsFromOldIconName'
import { iconDefaultSet } from '../constants'
import { Icon } from '../index'
import imgInterfaceDont from './assets/interface-dont.png'
Expand Down Expand Up @@ -476,3 +477,40 @@ export const TooltipDont: Story = {
/>
),
}

export const IconTableComparison: Story = {
render: () => {
return (
<TableContainer>
<TableHeader>
<TableRow>
<TableHeaderRowCell width={4 / 12} labelText="Old name" />
<TableHeaderRowCell width={4 / 12} labelText="New name" />
<TableHeaderRowCell width={4 / 12} labelText="isFilled" />
</TableRow>
</TableHeader>
{Array.from(iconMap).map(([key, value]) => (
<TableCard key={key}>
<TableRow>
<TableRowCell width={4 / 12}>
<Text tag="div" variant="body">
{key}
</Text>
</TableRowCell>
<TableRowCell width={4 / 12}>
<Text tag="div" variant="body">
{value?.name ?? 'N/A'}
</Text>
</TableRowCell>
<TableRowCell width={4 / 12}>
<Text tag="div" variant="body">
{value?.isFilled ? 'true' : value?.name ? 'false' : 'N/A'}
</Text>
</TableRowCell>
</TableRow>
</TableCard>
))}
</TableContainer>
)
},
}
Loading