Migration Guide
Introducing version 2 of the spirit-web-react package.
Please follow these steps to safely upgrade to Spirit Design System v2 components.
âšī¸ Don't forget to check the migration guide of the spirit-web package for general changes in available feature flags, CSS, and other changes that might affect your project.
Overview
- General Changes
- Component Changes
- Alert: danger Icon
- Alert: role="alert"
- Collapse: id Prop
- Dropdown: New Structure
- Dropdown: id Prop
- Dropdown: Placement Control
- FileUploader: FileUploaderAttachment buttonLabel and editButtonLabel Props
- Grid: Breakpoint Props
- Grid: GridSpan Component
- Header: HeaderDesktopActions isAtEnd prop
- Modal: ModalDialog isExpandedOnMobile Prop
- Modal: ModalDialog isScrollable Prop
- Modal: ModalDialog Custom Height
- Modal: ModalDialog Uniform Appearance
- Tabs: TabItem and TabPane Props
- TextField: label Prop
- Tooltip: off Placement
- Tooltip: New Structure
- Tooltip: Placement Control
- TooltipModern
General Changes
Dropped Support for Node.js 16
The Node.js v16 is no longer supported. The minimum required Node.js version is 18.
Required id Prop in Form Components
The id prop is now consistently required by all form components.
Affected components:
- Checkbox
- FieldGroup
- FileUploader
- Radio
- Select
- TextArea
- TextField
Migration Guide
Add the id prop to the listed form components.
Placement in Dropdown and Tooltip
The Dropdown and Tooltip components now support only flow-relative cross-axis placements.
New placement naming:
- The main placement axis (top, right, bottom, left) remains the same.
- The cross axis (formerly also top, right, bottom, left) is now relative to the main axis: start, end.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/dropdown-tooltip-flow-placement
đ See Codemods documentation for more details.
đ§ Or check Dropdown: Placement Control and Tooltip: Placement Control for manual migration steps.
Component Changes
Alert: danger Icon
The danger icon for danger color in the Alert component is now required.
Migration Guide
Either install newer version of the spirit-icons package, or add an icon named danger to your project's icons.
Alert: role="alert"
The role="alert" was removed from the default setting of the component.
As explained in the ARIA: alert role documentation:
The alert role is used to communicate an important and usually time-sensitive message to the user. When this role is added to an element, the browser will send out an accessible alert event to assistive technology products which can then notify the user. The alert role should only be used for information that requires the user's immediate attention, which is typically content that is dynamically displayed (such as form validation message etc.), not for content that appears on page load. It should not be used on HTML that the user hasn't interacted with.
Migration Guide
In case you need to use the component as an information that requires the user's immediate attention, you can use role="alert" as an additional attribute.
Collapse: id Prop
The id prop is now required by the Collapse component.
Migration Guide
Add the id prop to the Collapse component.
Dropdown: New Structure
The Dropdown component was refactored and new structure and API were introduced.
Migration Guide
The new Dropdown has a different API.
Instead of:
<Dropdown id="DropdownExample" renderTrigger={({ trigger }) => <Button {...trigger}>Trigger</Button>}>
âĻ
</Dropdown>
Use:
const [isOpen, setIsOpen] = React.useState(false);
const onToggle = () => setIsOpen(!isOpen);
<Dropdown id="DropdownExample" isOpen={isOpen} onToggle={onToggle}>
<DropdownTrigger elementType={Button}>Trigger button</DropdownTrigger>
<DropdownPopover>âĻ</DropdownPopover>
</Dropdown>;
đ See Dropdown documentation for more details and examples.
đĒ If you are still using the DropdownModern component instead of Dropdown, you can use codemod to automatically update your code base:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/dropdownmodern-component-name
đ See Codemods documentation for more details.
Dropdown: id Prop
The id prop is now required by the Dropdown component.
Migration Guide
Add the id prop to the Dropdown component.
Dropdown: Placement Control
The Dropdown component now supports only flow-relative cross-axis placements.
Migration Guide
đĒ Use codemod described in Placement in Dropdown and Tooltip to automatically update your codebase.
đ§ Manual Migration Steps
Manually update cross-axis names in the placement prop:
- <Dropdown placement="top-left" âĻ /> â <Dropdown placement="top-start" âĻ />
- <Dropdown placement="top-right" âĻ /> â <Dropdown placement="top-end" âĻ />
- <Dropdown placement="right-top" âĻ /> â <Dropdown placement="right-start" âĻ />
- <Dropdown placement="right-bottom" âĻ /> â <Dropdown placement="right-end" âĻ />
- <Dropdown placement="bottom-left" âĻ /> â <Dropdown placement="bottom-start" âĻ />
- <Dropdown placement="bottom-right" âĻ /> â <Dropdown placement="bottom-end" âĻ />
- <Dropdown placement="left-top" âĻ /> â <Dropdown placement="left-start" âĻ />
- <Dropdown placement="left-bottom" âĻ /> â <Dropdown placement="left-end" âĻ />
FileUploader: FileUploaderAttachment buttonLabel and editButtonLabel Props
The buttonLabel and editButtonLabel props were removed from the FileUploaderAttachment component. Use removeText and editText props instead.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/fileuploader-prop-names
đ See Codemods documentation for more details.
đ§ Manual Migration Steps
Manually replace the props in your project:
- <FileUploaderAttachment buttonLabel="Remove this attachment" âĻ /> â <FileUploaderAttachment removeText="Remove this attachment" âĻ />
- <FileUploaderAttachment editButtonLabel="Edit this attachment" âĻ /> â <FileUploaderAttachment editText="Edit this attachment" âĻ />
Grid: Breakpoint Props
The cols prop in the Grid now supports object values for different breakpoints. The tablet and desktop props were removed.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/grid-breakpoint-props
đ See Codemods documentation for more details.
đ§ Manual Migration Steps
Manually replace tablet and desktop props with the cols object prop.
- <Grid cols="2" tablet="3" âĻ /> â <Grid cols={{ mobile: 2, tablet: 3 }} âĻ />
- <Grid desktop="3" âĻ /> â <Grid cols={{ desktop: 3 }} âĻ />
- <Grid cols="1" tablet="2" desktop="3" âĻ /> â <Grid cols={{ mobile: 1, tablet: 2, desktop: 3 }} âĻ />
Grid: GridSpan Component
The GridSpan component was removed. Instead, you can use the more powerful GridItem component that allows you to define the start and end columns for each breakpoint.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/grid-gridspan
đ See Codemods documentation for more details.
đ§ Manual Migration Steps
The hardest part in the migration is to get the columnStart value. The equation is 1 + (columns - over) / 2, where columns is the number of columns in the grid and over is the value from the GridSpan component. The default number of columns is 12, so the equation is 1 + (12 - over) / 2 most of the time.
- Replace GridSpan with GridItem.
- Calculate and set the columnStart value as 1 + (columns - over) / 2. In our 12-column grid, the equation is 1 + (12 - over) / 2, where over is the value from the GridSpan component.
- Set the columnEnd value to span over or use columnStart + over.
- If you use responsive props, calculate the values for each breakpoint and pass them to the GridItem component columnStart and columnEnd props as an object.
- Remove the over prop.
Examples
- Centered grid item over 4 columns:
-<GridSpan over="4">âĻ</GridSpan>
+<GridItem columnStart="5" columnEnd="span 4">âĻ</GridItem>
columnStart = 1 + (12 - 4) / 2 = 5
- Centered grid item over 6 columns:
-<GridSpan over="6">âĻ</GridSpan>
+<GridItem columnStart="4" columnEnd="span 6">âĻ</GridItem>
columnStart = 1 + (12 - 6) / 2 = 4
- Responsive grid item centered over 8 columns on mobile, 6 columns on tablet, and 4 columns on desktop:
-<GridSpan over="8" tablet="6" desktop="4">âĻ</GridSpan>
+<GridItem
+ columnStart={{ mobile: 3, tablet: 4, desktop: 5 }}
+ columnEnd={{ mobile: 'span 8', tablet: 'span 6', desktop: 'span 4' }}
+>âĻ</GridItem>
- columnStart = 1 + (12 - 8) / 2 = 3
- columnStart = 1 + (12 - 6) / 2 = 4
- columnStart = 1 + (12 - 4) / 2 = 5
Header: HeaderDesktopActions isAtEnd prop
The HeaderDesktopActions component slots were simplified and the second slot alignment is now available by using the isAtEnd prop.
The HeaderDesktopActions color prop was removed.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/header-headerdesktopactions-isatend
đ See Codemods documentation for more details.
đ§ Manual Migration Steps
Use the HeaderDesktopActions component with the isAtEnd prop instead of the color="secondary" prop. Remove the color prop from the HeaderDesktopActions component.
- <HeaderDesktopActions color="secondary" âĻ /> â <HeaderDesktopActions isAtEnd âĻ />
- <HeaderDesktopActions color="primary" âĻ /> â <HeaderDesktopActions âĻ />
Modal: ModalDialog isExpandedOnMobile Prop
The default value of the isExpandedOnMobile prop is now set to true and the ModalDialog is expanded on mobile by default. It is possible to re-collapse the inside by setting the isExpandedOnMobile prop to false.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/modal-isexpandedonmobile-prop
đ See Codemods documentation for more details.
đ§ Manual Migration Steps
Manually add isExpandedOnMobile={false} prop to the ModalDialog component to keep the current behavior.
Modal: ModalDialog isScrollable Prop
The default value of the isScrollable prop is now set to false and the ModalDialog is non-scrollable by default. It is possible to re-enable the inside scrolling by adding the isScrollable prop.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/modal-iscrollable-prop
đ See Codemods documentation for more details.
đ§ Manual Migration Steps
Manually add the isScrollable prop to the ModalDialog component.
If you use ScrollView for scrolling the content of your modal, you must also make the ModalDialog scrollable by setting the isScrollable prop.
Modal: ModalDialog Custom Height
The preferredHeightOnMobile and preferredHeightFromTabletUp props were removed and replaced with a single height prop which accepts either a single value or object with breakpoint keys and values.
Also, the prop maxHeightFromTabletUp was removed and replaced with the maxHeight prop, which also accepts either a single value or an object with breakpoint keys and values.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/modal-custom-height
đ See Codemods documentation for more details.
đ§ Manual Migration Steps
Manually update the preferredHeightOnMobile and preferredHeightFromTabletUp props to the new height prop:
- <ModalDialog preferredHeightOnMobile="333px" âĻ /> â <ModalDialog height="333px" âĻ />
- <ModalDialog preferredHeightFromTabletUp="444px" âĻ /> â <ModalDialog height={{ tablet: '444px' }} âĻ />
- <ModalDialog preferredHeightOnMobile="333px" preferredHeightFromTabletUp="444px" âĻ /> â <ModalDialog height={{ mobile: '333px', tablet: '444px' }} âĻ />
Update the maxHeightFromTabletUp prop to the new maxHeight prop:
- <ModalDialog maxHeightFromTabletUp="555px" âĻ /> â <ModalDialog maxHeight={{ tablet: '555px' }} âĻ />
Modal: ModalDialog Uniform Appearance
The uniform ModalDialog appearance replaced the current behavior. Current mobile appearance remains accessible via the isDockedOnMobile property.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/modal-isdockeonmobile-prop
đ See Codemods documentation for more details.
đ§ Manual Migration Steps
Manually add the isDockedOnMobile prop to the ModalDialog component.
Tabs: TabItem and TabPane Props
TabItem forTab prop was renamed to forTabPane. TabPane tabId prop was renamed to id.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/tabs-tabitem-tabpane-props
đ See Codemods documentation for more details.
đ§ Manual Migration Steps
Manually replace the props in your project.
- <TabItem forTab="TabPane1" âĻ /> â <TabItem forTabPane="TabPane1" âĻ />
- <TabPane tabId="TabPane1" âĻ /> â <TabPane id="TabPane1" âĻ />
TextField: label Prop
The label prop is now required by the TextField component.
Migration Guide
Please ensure that label is added to all instances of the TextField component. If you need to hide the label, you can use the isLabelHidden prop.
Tooltip: off Placement
The off placement was removed.
Migration Guide
Please use the new refactored Tooltip component.
Tooltip: New Structure
The Tooltip component structure changed and Tooltip (formerly the optional TooltipWrapper) is now a mandatory wrapping component. Similarly, Tooltip (the tip itself) was renamed to TooltipPopover.
Migration Guide
đ See Tooltip documentation for more details and examples.
Tooltip now has a different API and uses the Floating UI library. That's because we found out that most users want the advanced positioning options anyway.
Instead of:
<TooltipWrapper>
<Button UNSAFE_className="TooltipTarget">I have a tooltip!</Button>
<Tooltip>Hello there!</Tooltip>
</TooltipWrapper>
Use:
<Tooltip
id="Tooltip"
// âĻ
>
<TooltipTrigger elementType={Button}>I have a tooltip!</TooltipTrigger>
<TooltipPopover>Hello there!</TooltipPopover>
</Tooltip>
Tooltip: Placement Control
The Tooltip component now supports only flow-relative cross-axis placements.
Migration Guide
đĒ Use codemod described in Placement in Dropdown and Tooltip to automatically update your codebase.
đ§ Manual Migration Steps
Manually update cross-axis names in the placement prop:
- <Tooltip placement="top-left" âĻ /> â <Tooltip placement="top-start" âĻ />
- <Tooltip placement="top-right" âĻ /> â <Tooltip placement="top-end" âĻ />
- <Tooltip placement="right-top" âĻ /> â <Tooltip placement="right-start" âĻ />
- <Tooltip placement="right-bottom" âĻ /> â <Tooltip placement="right-end" âĻ />
- <Tooltip placement="bottom-left" âĻ /> â <Tooltip placement="bottom-start" âĻ />
- <Tooltip placement="bottom-right" âĻ /> â <Tooltip placement="bottom-end" âĻ />
- <Tooltip placement="left-top" âĻ /> â <Tooltip placement="left-start" âĻ />
- <Tooltip placement="left-bottom" âĻ /> â <Tooltip placement="left-end" âĻ />
TooltipModern
The TooltipModern component was renamed to Tooltip.
Migration Guide
đĒ Use codemod to automatically update your codebase:
npx @lmc-eu/spirit-codemods -p <path> -t v2/web-react/tooltipmodern-component-name
đ See Codemods documentation for more details.
đ§ Manual Migration Steps
Manually rename TooltipModern to Tooltip.
Please refer back to these instructions or reach out to our team if you encounter any issues during migration.