Skip to content

Commit

Permalink
fix(datepicker): pass error prop to Form.Field (#708)
Browse files Browse the repository at this point in the history
* chore: revert eslint-plugin-prettier to v3

* chore: add error knob to Storybook

* fix(datepicker): pass error prop to Form.Field
  • Loading branch information
arthurdenner committed Jan 13, 2022
1 parent f0c1707 commit 5603059
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -56,7 +56,7 @@
"babel-jest": "27.4.5",
"babel-loader": "8.2.3",
"cssnano": "4.1.11",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-prettier": "3.4.1",
"husky": "7.0.4",
"jest-transform-css": "3.0.0",
"prettier": "2.5.1",
Expand Down
4 changes: 3 additions & 1 deletion src/components/input.tsx
Expand Up @@ -16,6 +16,7 @@ const inputData = {
const CustomInput = React.forwardRef<Input, InputProps>((props, ref) => {
const {
clearIcon,
error,
icon,
isClearIconVisible,
label,
Expand All @@ -27,11 +28,12 @@ const CustomInput = React.forwardRef<Input, InputProps>((props, ref) => {
} = props;

return (
<Form.Field required={required}>
<Form.Field error={error} required={required}>
{label && <label htmlFor={rest.id as string | undefined}>{label}</label>}
<Input
{...rest}
ref={ref}
error={error}
required={required}
icon={
<CustomIcon
Expand Down
44 changes: 25 additions & 19 deletions stories/index.stories.tsx
Expand Up @@ -109,25 +109,31 @@ export const withCustomIcons = () => {
);
};

export const usageWithForm = () => (
<Content>
<Form>
<Form.Group width="equals">
<SemanticDatepicker
label="Initial date"
id="initialDate"
onChange={onChange}
required
/>
<SemanticDatepicker
label="Final date"
id="finalDate"
onChange={onChange}
/>
</Form.Group>
</Form>
</Content>
);
export const usageWithForm = () => {
const error = boolean('Error state', false);

return (
<Content>
<Form>
<Form.Group width="equals">
<SemanticDatepicker
error={error}
label="Initial date"
id="initialDate"
onChange={onChange}
required
/>
<SemanticDatepicker
error={error}
label="Final date"
id="finalDate"
onChange={onChange}
/>
</Form.Group>
</Form>
</Content>
);
};

export const inverted = () => {
const type = select('Type', typeMap, typeMap.basic);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -5946,10 +5946,10 @@ eslint-plugin-jsx-a11y@^6.2.3:
has "^1.0.3"
jsx-ast-utils "^2.2.1"

eslint-plugin-prettier@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz#8b99d1e4b8b24a762472b4567992023619cb98e0"
integrity sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==
eslint-plugin-prettier@3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.4.1.tgz#e9ddb200efb6f3d05ffe83b1665a716af4a387e5"
integrity sha512-htg25EUYUeIhKHXjOinK4BgCcDwtLHjqaxCDsMy5nbnUMkKFvIhMVCp+5GFUXQ4Nr8lBsPqtGAqBenbpFqAA2g==
dependencies:
prettier-linter-helpers "^1.0.0"

Expand Down

1 comment on commit 5603059

@vercel
Copy link

@vercel vercel bot commented on 5603059 Jan 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.