-
Notifications
You must be signed in to change notification settings - Fork 17
Migrating to V1
Subdirectory imports are now supported. Hence it is advised to use it for importing instead.
import { Button } from "@lifesg/react-design-system/button";Types are also now exported along with the same component folder as opposed to the types file
// v6
import { ButtonProps } from "react-lifesg-design-system/types";
// New
import { ButtonProps } from "@lifesg/react-design-system/button";// v6
import { Color, MediaQuery, TextStyleHelper } from "react-lifesg-design-system";
// New
import { Color } from "@lifesg/react-design-system/color";
import { MediaQuery } from "@lifesg/react-design-system/media";
import { TextStyleHelper } from "@lifesg/react-design-system/text";- Accordion
- Alert
- ErrorDisplay
- Footer
- Form
- Icon
- InputGroup
- Layout
- LinkList
- Modal
- Navbar
- NotificationBanner
- ToggleButton
-
Accordion.Basehas been replaced with justAccordion -
Accordion.Itemstill remains
You may refer to the storybook documentation for more details.
-
AlertBoxhas been renamed asAlertin terms of terminology -
AlertBox.Basehas been renamed toAlert -
AlertBox.Descriptionhas been deprecated to have the style applied to<p>instead
You may refer to the storybook documentation for more details.
- The components now takes in
imgso you can configure all image attributes instead of justimgSrc - [v1.0.0-alpha.24] The default titles and descriptions have been replaced with placeholders. Specify the props based on your use case. Otherwise, if you were using the default messages in previous versions, refer to this commit for the original copy.
- The footer props have been amended for clarity
-
addonhas been deprecated and replaced withshowDownloadAddon - Introduced
copyrightInfoandlogoSrcto allow customisation of the copyright text and logo respectively -
optionsinFooterLinkPropshas been replaced withdata-options -
lastUpdatedhas been made optional. Defaults to today's date if it is not specified
-
Refer to the storybook documentation for more details
-
Form.Fieldhas been replaced toForm.Inputto be more in sync with the base component -
Form.FieldGrouphas been replaced toForm.InputGroupto be more in sync with the base component -
Form.ErrorMessagehas been removed; to render error messages, pass in theerrorMessageprop
The corresponding type names have also been changed.
| component | old | new |
|---|---|---|
Field |
FormFieldProps |
FormInputProps |
FieldGroup |
FormFieldGroupProps |
FormInputGroupProps |
- Icons have been moved to @lifesg/react-icons and each icon is now a named export
// Old
import { Icon } from "@lifesg/icon";
<Icon type="cross" />;
// New
import { CrossIcon } from "@lifesg/react-icons/cross";
<CrossIcon />;- Use height and width with
styled(Icon)to resize icons;font-sizeis no longer needed
-
InputGroupProps.addonhas been amended for clarity
// Old
export interface AddonProps<T> extends DropdownListProps<T> {
type?: InputGroupAddonType;
value?: T;
children?: JSX.Element;
position?: "left" | "right";
placeholder?: string;
displayValueExtractor?: (item: T) => any; // format function to derive display value upon selected
onShowOptions?: () => void;
onHideOptions?: () => void;
selectorTestId?: string;
}
// New
export interface AddonProps<T, V> {
type?: InputGroupAddonType | undefined;
attributes: ListAddon<T, V> | LabelAddon | CustomAddon;
position?: "left" | "right" | undefined;
}
// Refer to the storybook docs for the full list of new props-
Layout.GridContenthas been deprecated and merged withLayout.Content. You can switch to use flex or grid using thetypeprop -
Layout.GridContainerhas been deprecated and merged withLayout.Container. You can switch to use flex or grid using thetypeprop
-
onDefaultClickHandlerhas been deprecated and replaced byonItemClick. PreviouslyonItemClickdid not return theeventobject in its params. It now does.
-
Modal.Basehas been renamed to justModalfor simplicity -
Modal.Boxstill remains the same
- All Navbar prop types have been renamed to remove their prefix
Here is the full list of changes
| Previous | New |
|---|---|
INavItem |
NavItemProps |
INavbarItems |
NavItemsProps |
INavResources |
NavbarResourcesProps |
INavbarButtonComponentProps |
NavbarButtonComponentProps |
INavbarActionButtons |
NavbarActionButtonsProps |
INavbarButton |
NavbarButtonProps |
TDrawerDismissalMethod |
DrawerDismissalMethod |
INavbarProps |
NavbarProps |
-
blockDrawerDismissalMethodsinNavbarPropshas been renamed todrawerDismissalExclusionsfor clarity
You can refer to the Storybook documentation for the amended names of the types
- The
resourcesprop has been amended to support customisation of additional assets. You may specify the main brand logo viaresources.primary.
-
NotificationBanner.Basehas been simplified to be justNotificationBanner -
NotificationBanner.Labelhas been deprecated and the style has been integrated into the main component. You may just specify the content plainly
-
ToggleButtonhas been deprecated in favour ofToggle - The states of a
Togglehas also been simplified to either checked or not checked as opposed to the previous where there was a non selected default state
You may encounter the following when developing with NextJS:
- Hydration error in the console
Warning: Prop `className` did not match. - CSS changes applied to
styled(DSComponent)are not reflected on Fast Refresh. A manual refresh in the browser is required
So far these issues have been observed only in dev mode. You can choose to live with them.
Otherwise, a workaround is to add the following webpack config in next.config.js. However note that this may affect other libraries that rely on specific module resolution.
module.exports = {
webpack: (config, { isServer }) => {
return {
...config,
resolve: {
...config.resolve,
mainFields: isServer
? ["main", "module"]
: ["browser", "main", "module"],
},
};
},
// rest of your config
};
The root cause is webpack resolving the component's entry point from CJS on the server and from ESM on the browser. This affects the load order of
styled-componentsgenerated styles. For more details, see this NextJS issue.