Skip to content

Commit

Permalink
feat: Add ErrorMessage text component (#1310)
Browse files Browse the repository at this point in the history
feat: Add ErrorMessage text component
  • Loading branch information
drazik authored Dec 16, 2019
2 parents 32f3df5 + 2e70dcc commit 3f6d11e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions react/Text/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ import { Caption } from 'cozy-ui/transpiled/react/Text';
<Caption>This a caption text</Caption>
```

#### ErrorMessage text

```
import { ErrorMessage } from 'cozy-ui/transpiled/react/Text';
<ErrorMessage>This an error message text</ErrorMessage>
```
12 changes: 12 additions & 0 deletions react/Text/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import cx from 'classnames'
import PropTypes from 'prop-types'
import styles from './styles.styl'

export const BaseText = props => {
const { className, children, tag, ellipsis, ...restProps } = props
Expand Down Expand Up @@ -42,6 +43,10 @@ export const Caption = ({ className, ...restProps }) => (
<BaseText className={cx('u-caption', className)} {...restProps} />
)

export const ErrorMessage = ({ className, ...restProps }) => (
<BaseText className={cx(styles.ErrorMessage, className)} {...restProps} />
)

// Props
const commonProps = {
children: PropTypes.node,
Expand Down Expand Up @@ -71,6 +76,9 @@ Caption.propTypes = {
Uppercase.propTypes = {
...commonProps
}
ErrorMessage.propTypes = {
...commonProps
}

// Default Props
const commonDefaultProps = {
Expand Down Expand Up @@ -101,4 +109,8 @@ Uppercase.defaultProps = {
...commonDefaultProps
}

ErrorMessage.defaultProps = {
...commonDefaultProps
}

export default Text
2 changes: 2 additions & 0 deletions react/Text/styles.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.ErrorMessage
color var(--pomegranate)
6 changes: 6 additions & 0 deletions react/__snapshots__/examples.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5870,6 +5870,12 @@ exports[`Text should render examples: Text 7`] = `
</div>"
`;

exports[`Text should render examples: Text 8`] = `
"<div>
<div class=\\"styles__ErrorMessage___PWDaA\\">This an error message text</div>
</div>"
`;

exports[`Textarea should render examples: Textarea 1`] = `"<div><textarea placeholder=\\"Once upon a time…\\" class=\\"styles__c-textarea___D7EEH\\"></textarea></div>"`;

exports[`Textarea should render examples: Textarea 2`] = `"<div><textarea placeholder=\\"Once upon a time, there was an error…\\" class=\\"styles__c-textarea___D7EEH styles__is-error___1kGLj\\"></textarea></div>"`;
Expand Down

0 comments on commit 3f6d11e

Please sign in to comment.