Skip to content

Commit

Permalink
feat(DnInput): add name prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jkusa committed Jan 31, 2022
1 parent b45e190 commit 4dcae71
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/DnInput/DnInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const DnInput = ({
frontIconComponent,
backIconComponent,
id,
name,
...rest
}: DnInputProps): JSX.Element => {
return (
Expand All @@ -39,7 +40,7 @@ export const DnInput = ({
{...rest}
>
{frontIconComponent}
<input id={id} type={type} placeholder={placeholderText} disabled={isDisabled} />
<input id={id} name={name} type={type} placeholder={placeholderText} disabled={isDisabled} />
{backIconComponent}
{isError && <p className="message">{errorMessage}</p>}
</div>
Expand Down Expand Up @@ -72,6 +73,7 @@ export interface DnInputProps {
frontIconComponent?: React.ReactNode;
backIconComponent?: React.ReactNode;
id?: string;
name?: string;
}

DnInput.defaultProps = {
Expand All @@ -86,4 +88,5 @@ DnInput.defaultProps = {
frontIconComponent: null,
backIconComponent: null,
id: undefined,
name: undefined,
};
6 changes: 6 additions & 0 deletions src/DnInput/__stories__/index.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const getPlaceholderText = (value) => text('placeholderText', value, propsGroupI

const getId = (value) => text('id', value, propsGroupId);

const getName = (value) => text('name', value, propsGroupId);

export default {
title: 'Components/DnInput',
decorators: [withKnobs],
Expand All @@ -51,6 +53,7 @@ export const playground = () => {
<div className={getThemeClassName()}>
<DnInput
id={getId('someId')}
name={getName('someName')}
size={getSize()}
type={getType()}
isActive={getIsActive()}
Expand All @@ -68,6 +71,7 @@ export const fieldWithIconAtFront = () => {
return (
<DnInput
id={getId('someId')}
name={getName('someName')}
size={getSize()}
type={getType()}
isActive={getIsActive()}
Expand All @@ -87,6 +91,7 @@ export const fieldWithIconAtBack = () => {
return (
<DnInput
id={getId('someId')}
name={getName('someName')}
size={getSize()}
type={getType()}
isActive={getIsActive()}
Expand All @@ -105,6 +110,7 @@ export const fieldWithButton = () => {
<DnInputGroup hasButton>
<DnInput
id={getId('someId')}
name={getName('someName')}
size={getSize()}
type={getType()}
isActive={getIsActive()}
Expand Down
1 change: 1 addition & 0 deletions src/DnInput/__tests__/__snapshots__/index.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ exports[`DnInput Tests should render correctly with custom props 1`] = `
<input
disabled=""
id="someId"
name="myInput"
placeholder="Just an input field"
type="text"
/>
Expand Down
1 change: 1 addition & 0 deletions src/DnInput/__tests__/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ describe('DnInput Tests', () => {
isInverse
errorMessage="Error"
placeholderText="Just an input field"
name="myInput"
/>
</div>,
);
Expand Down

0 comments on commit 4dcae71

Please sign in to comment.