diff --git a/react/example/package.json b/react/example/package.json index 29a7fdb5ff..c1033de5be 100644 --- a/react/example/package.json +++ b/react/example/package.json @@ -10,7 +10,7 @@ "build": "webpack --mode production" }, "dependencies": { - "@egovernments/digit-ui-components": "0.0.1-beta.21", + "@egovernments/digit-ui-components": "0.0.1-beta.22", "@egovernments/digit-ui-libraries": "1.8.2-beta.1", "@egovernments/digit-ui-module-common": "1.7.10", "@egovernments/digit-ui-module-core": "1.8.1-beta.6", diff --git a/react/modules/Project/package.json b/react/modules/Project/package.json index 54ee8fe4a2..04e772137f 100644 --- a/react/modules/Project/package.json +++ b/react/modules/Project/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@egovernments/digit-ui-react-components": "1.8.1-beta.4", - "@egovernments/digit-ui-components": "0.0.1-beta.21", + "@egovernments/digit-ui-components": "0.0.1-beta.22", "lodash": "^4.17.21", "react": "17.0.2", "react-date-range": "^1.4.0", diff --git a/react/modules/core/package.json b/react/modules/core/package.json index f532edf058..fbc6ea67b9 100644 --- a/react/modules/core/package.json +++ b/react/modules/core/package.json @@ -14,7 +14,7 @@ "prepublish": "yarn build" }, "dependencies": { - "@egovernments/digit-ui-components": "0.0.1-beta.21", + "@egovernments/digit-ui-components": "0.0.1-beta.22", "@egovernments/digit-ui-react-components": "1.8.1-beta.4", "react": "17.0.2", "react-dom": "17.0.2", diff --git a/react/modules/sample/package.json b/react/modules/sample/package.json index d7d96e857b..ee511854fc 100644 --- a/react/modules/sample/package.json +++ b/react/modules/sample/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@egovernments/digit-ui-react-components": "1.8.1-beta.4", - "@egovernments/digit-ui-components": "0.0.1-beta.21", + "@egovernments/digit-ui-components": "0.0.1-beta.22", "react": "17.0.2", "react-date-range": "^1.4.0", "react-dom": "17.0.2", diff --git a/react/package.json b/react/package.json index c5bdbffdbd..e828167821 100644 --- a/react/package.json +++ b/react/package.json @@ -77,7 +77,7 @@ "@egovernments/digit-ui-module-sample": "0.0.1", "@egovernments/digit-ui-react-components": "1.7.10", "@egovernments/digit-ui-svg-components": "1.0.4", - "@egovernments/digit-ui-components": "0.0.1-beta.21", + "@egovernments/digit-ui-components": "0.0.1-beta.22", "babel-loader": "8.1.0", "clean-webpack-plugin": "4.0.0", "css-loader": "5.2.6", diff --git a/react/ui-components/README.md b/react/ui-components/README.md index 6bca3f1954..36edec27c1 100644 --- a/react/ui-components/README.md +++ b/react/ui-components/README.md @@ -58,6 +58,7 @@ yarn storybook # Changelog ```bash +0.0.1-beta.22 From this version of ui-components the Toast component will have a new prop named type, replacing the seperate props for info,warning and error 0.0.1-beta.21 Added categorySelectAllState in the nestedmultiselect variant of multiselectdropdown 0.0.1-beta.20 updated multiselectdropdown categoryselectall functionality and added key navigation for dropdown options 0.0.1-beta.19 making CheckBox more customizable and adding custom color for Button @@ -80,6 +81,26 @@ yarn storybook 0.0.1 base version ``` +## [0.0.1-beta.22] - 2024-05-20 + +### Breaking Changes + +- Toast Component: From this version of `ui-components`, the `Toast` component has a new prop named `type`, replacing the separate props for `info`, `warning`, and `error`. + - Old Usage: + ```jsx + + + + ``` + - New Usage: + ```jsx + + + + + ``` + + ## Published from DIGIT Core Digit Core Repo (https://github.com/egovernments/Core-Platform/tree/digit-ui-core) diff --git a/react/ui-components/package.json b/react/ui-components/package.json index d41b8d7a88..b2f8b8d0ef 100644 --- a/react/ui-components/package.json +++ b/react/ui-components/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-components", - "version": "0.0.1-beta.21", + "version": "0.0.1-beta.22", "license": "MIT", "main": "dist/index.js", "module": "dist/index.modern.js", diff --git a/react/ui-components/src/atoms/Toast.js b/react/ui-components/src/atoms/Toast.js index e1cb4880af..1fe6328eb5 100644 --- a/react/ui-components/src/atoms/Toast.js +++ b/react/ui-components/src/atoms/Toast.js @@ -5,6 +5,7 @@ import Button from "./Button"; import StringManipulator from "./StringManipulator"; const Toast = (props) => { + const [isVisible, setIsVisible] = useState(true); const [isAnimating, setIsAnimating] = useState(false); @@ -32,15 +33,25 @@ const Toast = (props) => { setIsVisible(false); }; - const variant = props?.error - ? "digit-error" - : props?.warning - ? "digit-warning" - : props?.info - ? "digit-info" - : props?.variant - ? props?.variant - : ""; + let variant; + switch (props?.type) { + case "success": + variant = "digit-success"; + break; + case "error": + variant = "digit-error"; + break; + case "warning": + variant = "digit-warning"; + break; + case "info": + variant = "digit-info"; + break; + default: + variant = props?.variant || ""; + break; + } + const isWarningButtons = props?.isWarningButtons ? "digit-warning-buttons" : ""; @@ -51,52 +62,13 @@ const Toast = (props) => { return null; } - if (props.error) { - return ( -
- -
- {sentenceCaseLabel} -
- -
- ); - } - - if (props.info) { - return ( -
- -
- {sentenceCaseLabel} -
- -
- ); - } - - - if (props.warning) { + if (props?.type === "warning") { return (
{!props?.isWarningButtons ? ( @@ -139,9 +111,23 @@ const Toast = (props) => { ); } - return ( -
+ const icon = + props?.type === "error" ? ( + + ) : props?.type === "info" ? ( + + ) : ( + ); + + return ( +
+ {icon}
{sentenceCaseLabel}
@@ -160,6 +146,7 @@ Toast.propTypes = { onClose: PropTypes.func, isDleteBtn: PropTypes.bool, transitionTime: PropTypes.number, + type: PropTypes.string, }; Toast.defaultProps = { diff --git a/react/ui-components/src/hoc/FormComposerV2.js b/react/ui-components/src/hoc/FormComposerV2.js index 8b0a4d0fb6..655aae5088 100644 --- a/react/ui-components/src/hoc/FormComposerV2.js +++ b/react/ui-components/src/hoc/FormComposerV2.js @@ -415,7 +415,7 @@ export const FormComposer = (props) => { {props.onSkip && props.showSkip && } )} - {showErrorToast && } + {showErrorToast && } ); }; diff --git a/react/ui-components/src/hoc/stories/Toast.stories.js b/react/ui-components/src/hoc/stories/Toast.stories.js index bf70b95fa5..73118a3191 100644 --- a/react/ui-components/src/hoc/stories/Toast.stories.js +++ b/react/ui-components/src/hoc/stories/Toast.stories.js @@ -7,7 +7,10 @@ export default { argTypes: { populators: { control: "object" }, label: { control: "text" }, - error: { control: "boolean" }, + type: { + control: "select", + options: ["success", "warning", "error", "info"], + } }, }; @@ -18,42 +21,42 @@ const commonArgs = { name: "toast", }, label: "", - error: false, - warning: "", - info: false, + type:"success", }; export const SuccessToast = Template.bind({}); SuccessToast.args = { ...commonArgs, label: "Success Toast Message", + type:"success", }; export const WarningToast = Template.bind({}); WarningToast.args = { ...commonArgs, label: "Warning Toast Message", - warning: "warning", + type:"warning", }; export const ErrorToast = Template.bind({}); ErrorToast.args = { ...commonArgs, label: "Error Toast Message", - error: true, + type:"error", }; export const InfoToast = Template.bind({}); InfoToast.args = { ...commonArgs, label: "Info Toast Message", - info: true, + type:"info", }; export const SuccessToastWithTransitionTime = Template.bind({}); SuccessToastWithTransitionTime.args = { ...commonArgs, label: "Success Toast Message", + type:"success", transitionTime: 600000, }; @@ -61,7 +64,7 @@ export const WarningToastWithTransitionTime = Template.bind({}); WarningToastWithTransitionTime.args = { ...commonArgs, label: "Warning Toast Message", - warning: "warning", + type:"warning", transitionTime: 600000, }; @@ -69,7 +72,7 @@ export const ErrorToastWithTrnasitionTime = Template.bind({}); ErrorToastWithTrnasitionTime.args = { ...commonArgs, label: "Error Toast Message", - error: true, + type:"error", transitionTime: 600000, }; @@ -77,6 +80,6 @@ export const InfoToastWithTrnasitionTime = Template.bind({}); InfoToastWithTrnasitionTime.args = { ...commonArgs, label: "Info Toast Message", - info: true, + type:"info", transitionTime: 600000, }; diff --git a/react/ui-components/yarn-error.log b/react/ui-components/yarn-error.log index 8f4f4b5a69..cbadf418b8 100644 --- a/react/ui-components/yarn-error.log +++ b/react/ui-components/yarn-error.log @@ -29,7 +29,7 @@ Trace: npm manifest: { "name": "@egovernments/digit-ui-components", - "version": "0.0.1-beta.21", + "version": "0.0.1-beta.22", "license": "MIT", "main": "dist/index.js", "module": "dist/index.modern.js", diff --git a/react/yarn-error.log b/react/yarn-error.log index 871c9649cf..b35294b497 100644 --- a/react/yarn-error.log +++ b/react/yarn-error.log @@ -91,7 +91,7 @@ npm manifest: "dependencies": { "lodash": "4.17.21", "microbundle-crl": "0.13.11", - "@egovernments/digit-ui-components": "0.0.1-beta.21", + "@egovernments/digit-ui-components": "0.0.1-beta.22", "babel-loader": "8.1.0", "clean-webpack-plugin": "4.0.0", "react": "17.0.2",