-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated ErrorMessage component to have new props named showIcon,truncateMessage and maxLength * updated Fieldv1 * updated ui-components and css versions
- Loading branch information
1 parent
6ae3652
commit 8c9ff1c
Showing
17 changed files
with
163 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@egovernments/digit-ui-css", | ||
"version": "1.8.2-coreui.14", | ||
"version": "1.8.2-coreui.15", | ||
"license": "MIT", | ||
"main": "dist/index.css", | ||
"author": "Jagankumar <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
@import url("../index.scss"); | ||
@import url("../typography.scss"); | ||
|
||
.digit-error-message { | ||
@extend .alert-error; | ||
@extend .typography.text-body-s; | ||
@apply block mb-md; | ||
} | ||
.digit-error-icon-message-wrap { | ||
@apply flex w-full whitespace-pre-wrap break-words; | ||
gap: theme(digitv2.spacers.spacer1); | ||
|
||
.digit-employee-card { | ||
.digit-error-icon{ | ||
@apply flex items-center; | ||
width: theme(digitv2.spacers.spacer4); | ||
height: theme(digitv2.lineHeight.lineheight2); | ||
} | ||
.digit-error-message { | ||
@extend .typography.text-body-s; | ||
font-size: 12px; | ||
margin-top: -21px; | ||
@extend .typography.body-s; | ||
@apply w-full; | ||
margin: theme(digitv2.spacers.spacer0); | ||
color: theme(digitv2.lightTheme.alert-error) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
rel='stylesheet' type='text/css'> | ||
<link | ||
rel="stylesheet" | ||
href="https://unpkg.com/@egovernments/[email protected].14/dist/index.css" | ||
href="https://unpkg.com/@egovernments/[email protected].15/dist/index.css" | ||
/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#00bcd1" /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,51 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { SVG } from "./SVG"; | ||
import StringManipulator from "./StringManipulator"; | ||
|
||
const ErrorMessage = ({ message, className = "", style = {} }) => { | ||
const ErrorMessage = ({ | ||
wrapperClassName = "", | ||
wrapperStyles = {}, | ||
showIcon, | ||
iconStyles = {}, | ||
message, | ||
className = "", | ||
style = {}, | ||
truncateMessage, | ||
maxLength, | ||
}) => { | ||
return ( | ||
<React.Fragment> | ||
<h2 className={`digit-error-message ${className}`} style={style}> | ||
{message} | ||
</h2> | ||
</React.Fragment> | ||
<div | ||
className={`digit-error-icon-message-wrap ${ | ||
wrapperClassName ? wrapperClassName : "" | ||
}`} | ||
style={wrapperStyles} | ||
> | ||
{showIcon && ( | ||
<div className="digit-error-icon" style={iconStyles}> | ||
<SVG.Info width="1rem" height="1rem" fill="#B91900" /> | ||
</div> | ||
)} | ||
<div className={`digit-error-message ${className}`} style={style}> | ||
{truncateMessage | ||
? StringManipulator( | ||
"TOSENTENCECASE", | ||
StringManipulator("TRUNCATESTRING", message, { | ||
maxLength: maxLength || 256, | ||
}) | ||
) | ||
: StringManipulator("TOSENTENCECASE", message)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
ErrorMessage.propTypes = { | ||
className: PropTypes.string, | ||
style: PropTypes.object, | ||
message: PropTypes.string, | ||
showIcon: PropTypes.bool, | ||
truncateMessage: PropTypes.bool, | ||
}; | ||
|
||
export default ErrorMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
react/ui-components/src/hoc/stories/ErrorMessage.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React, { Children } from "react"; | ||
import { ErrorMessage } from "../../atoms"; | ||
import { truncate } from "lodash"; | ||
|
||
export default { | ||
title: "Atom-Groups/ErrorMessage", | ||
component: ErrorMessage, | ||
argTypes: { | ||
wrapperClassName: { | ||
control: "text", | ||
}, | ||
wrapperStyles: { | ||
control: { type: "object" }, | ||
}, | ||
showIcon: { | ||
control: "boolean", | ||
}, | ||
iconStyles: { | ||
control: { type: "object" }, | ||
}, | ||
message: { | ||
control: "text", | ||
}, | ||
className: { | ||
control: "text", | ||
}, | ||
style: { | ||
control: { type: "object" }, | ||
}, | ||
truncateMessage: { | ||
control: "boolean", | ||
}, | ||
maxLength:{ | ||
control:"text" | ||
} | ||
}, | ||
}; | ||
|
||
const Template = (args) => <ErrorMessage {...args} />; | ||
|
||
const commonArgs = { | ||
wrapperClassName: "", | ||
wrapperStyles: {}, | ||
showIcon: false, | ||
iconStyles: {}, | ||
message: "", | ||
className: "", | ||
style: {}, | ||
truncateMessage:false, | ||
maxLength:"" | ||
}; | ||
|
||
// Default ErrorMessage | ||
export const Default = Template.bind({}); | ||
Default.args = { | ||
...commonArgs, | ||
message: "Error Message", | ||
}; | ||
|
||
// ErrorMessage with icon | ||
export const WithIcon = Template.bind({}); | ||
WithIcon.args = { | ||
...commonArgs, | ||
message: "Error Message With Icon", | ||
showIcon: true, | ||
}; | ||
|
||
// ErrorMessage with icon | ||
export const WithTruncateMessage = Template.bind({}); | ||
WithTruncateMessage.args = { | ||
...commonArgs, | ||
message: "Error with truncateMessage as true", | ||
showIcon: true, | ||
truncateMessage:true, | ||
maxLength:10 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.