-
Notifications
You must be signed in to change notification settings - Fork 13
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.Base
has been replaced with justAccordion
-
Accordion.Item
still remains
You may refer to the storybook documentation for more details.
-
AlertBox
has been renamed asAlert
in terms of terminology -
AlertBox.Base
has been renamed toAlert
-
AlertBox.Description
has 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
img
so 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
-
addon
has been deprecated and replaced withshowDownloadAddon
- Introduced
copyrightInfo
andlogoSrc
to allow customisation of the copyright text and logo respectively -
options
inFooterLinkProps
has been replaced withdata-options
-
lastUpdated
has been made optional. Defaults to today's date if it is not specified
-
Refer to the storybook documentation for more details
-
Form.Field
has been replaced toForm.Input
to be more in sync with the base component -
Form.FieldGroup
has been replaced toForm.InputGroup
to be more in sync with the base component -
Form.ErrorMessage
has been removed; to render error messages, pass in theerrorMessage
prop
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-size
is no longer needed
-
InputGroupProps.addon
has 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.GridContent
has been deprecated and merged withLayout.Content
. You can switch to use flex or grid using thetype
prop -
Layout.GridContainer
has been deprecated and merged withLayout.Container
. You can switch to use flex or grid using thetype
prop
-
onDefaultClickHandler
has been deprecated and replaced byonItemClick
. PreviouslyonItemClick
did not return theevent
object in its params. It now does.
-
Modal.Base
has been renamed to justModal
for simplicity -
Modal.Box
still 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 |
-
blockDrawerDismissalMethods
inNavbarProps
has been renamed todrawerDismissalExclusions
for clarity
You can refer to the Storybook documentation for the amended names of the types
- The
resources
prop has been amended to support customisation of additional assets. You may specify the main brand logo viaresources.primary
.
-
NotificationBanner.Base
has been simplified to be justNotificationBanner
-
NotificationBanner.Label
has been deprecated and the style has been integrated into the main component. You may just specify the content plainly
-
ToggleButton
has been deprecated in favour ofToggle
- The states of a
Toggle
has 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-components
generated styles. For more details, see this NextJS issue.