Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: create FieldWarnings component and update FieldErrors #2686

Merged
merged 9 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slow-carrots-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-uikit/field-warnings': major
---

Create field warnings component
4 changes: 2 additions & 2 deletions packages/components/field-errors/docs/usage-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Example = () => (
renderError={(key) => {
switch (key) {
case 'duplicate':
return 'This thing is already in use. It must be unique.';
return 'This is already in use. It must be unique.';
default:
// When null is returned then the default error handling from
// renderDefaultError will kick in for that error.
Expand All @@ -24,7 +24,7 @@ const Example = () => (
renderDefaultError={(key) => {
switch (key) {
case 'minLength':
return 'This thing is too short.';
return 'This is too short.';
default:
// When null is returned then the error handling defined in
// FieldError itself will kick in
Expand Down
49 changes: 49 additions & 0 deletions packages/components/field-errors/src/field-errors.story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { storiesOf } from '@storybook/react';
import { withKnobs, boolean, text, object } from '@storybook/addon-knobs/react';
import Section from '../../../../docs/.storybook/decorators/section';
import Readme from '../README.md';
import FieldErrors from './field-errors';

storiesOf('Components|FieldError', module)
.addDecorator(withKnobs)
.addParameters({
readme: {
// Show readme at the addons panel
sidebar: Readme,
},
})
.add('FieldError', () => {
return (
<Section>
<FieldErrors
id={text('id', 'error-id')}
errors={object('errors', {
missing: true,
duplicate: true,
minLength: true,
})}
renderError={(key) => {
switch (key) {
case 'duplicate':
return 'This thing is already in use. It must be unique.';
default:
// When null is returned then the default error handling from
// renderDefaultError will kick in for that error.
return null;
}
}}
renderDefaultError={(key) => {
switch (key) {
case 'minLength':
return 'This thing is too short.';
default:
// When null is returned then the error handling defined in
// FieldError itself will kick in
return null;
}
}}
isVisible={boolean('isVisible', true)}
/>
</Section>
);
});
Loading
Loading