Skip to content

Commit

Permalink
style: use spaces for md files fp-50 (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
what1s1ove authored Dec 3, 2023
1 parent 972f948 commit 2f649a6
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8

[*.yml]
[*.{yml,md}]
indent_style = space
indent_size = 2
152 changes: 76 additions & 76 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ npm install form-payload
```html
<!-- index.html -->
<form name="general">
<label>
Name
<input type="text" name="name" value="Jon" />
</label>
<label>
Birthday
<input type="date" name="birthday" value="2021-03-27" />
</label>
<label>
Friends Count
<input type="number" name="friendsCount" value="1" />
</label>
<fieldset name="friend">
<legend>Friend</legend>
<label>
Friend Name
<input type="test" name="friendName" value="Kate" />
</label>
</fieldset>
<button type="submit">Submit</button>
<label>
Name
<input type="text" name="name" value="Jon" />
</label>
<label>
Birthday
<input type="date" name="birthday" value="2021-03-27" />
</label>
<label>
Friends Count
<input type="number" name="friendsCount" value="1" />
</label>
<fieldset name="friend">
<legend>Friend</legend>
<label>
Friend Name
<input type="test" name="friendName" value="Kate" />
</label>
</fieldset>
<button type="submit">Submit</button>
</form>

...

<form name="mailing">
<label>
Mailing
<input type="email" name="mail" name="[email protected]" />
</label>
<label>
Mailing
<input type="email" name="mail" name="[email protected]" />
</label>
</form>
```

Expand All @@ -56,22 +56,22 @@ import { getFormValues, getControlValue } from 'form-payload';
const { general: generalFormNode, mailing: mailingFormNode } = document.forms;

generalFormNode.addEventListener('submit', (evt) => {
evt.preventDefault();

console.log(getFormValues(generalFormNode));
// {
// name: 'Jon',
// birthday: Sat Mar 27 2021 18:06:42 GMT+0200 (Eastern European Standard Time),
// friendsCount: 1,
// friend: {
// friendName: 'Kate',
// },
// }
evt.preventDefault();

console.log(getFormValues(generalFormNode));
// {
// name: 'Jon',
// birthday: Sat Mar 27 2021 18:06:42 GMT+0200 (Eastern European Standard Time),
// friendsCount: 1,
// friend: {
// friendName: 'Kate',
// },
// }
});

mailingFormNode.addEventListener('change', (evt) => {
console.log(getControlValue(evt.target));
// '[email protected]'
console.log(getControlValue(evt.target));
// '[email protected]'
});
```

Expand All @@ -85,45 +85,45 @@ _It doesn't matter which framework you use, you just need to pass the valid [HTM
import { getFormValues, getControlValue, ControlType } from 'form-payload';

const SimpleForm = () => {
const handleSubmit = (evt: React.FormEvent<HTMLFormElement>) => {
evt.preventDefault();

console.log(getFormValues(evt.target as HTMLFormElement));
// {
// name: 'Jon',
// birthday: Sat Mar 27 2021 18:06:42 GMT+0200 (Eastern European Standard Time),
// }
};

const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
console.log(getControlValue(evt.target));
// '[email protected]'
};

return (
<>
<form onSubmit={handleSubmit}>
<label>
Name
<input name="name" type={ControlType.TEXT} defaultValue="Jon" />
</label>
<label>
Date
<input name="birthday" type={ControlType.DATE} defaultValue="2021-03-27" />
</label>
<button type="submit">Submit</button>
</form>

...

<form>
<label>
Mailing
<input name="mail" type={ControlType.EMAIL} onChange={handleChange} />
</label>
</form>
</>
);
const handleSubmit = (evt: React.FormEvent<HTMLFormElement>) => {
evt.preventDefault();

console.log(getFormValues(evt.target as HTMLFormElement));
// {
// name: 'Jon',
// birthday: Sat Mar 27 2021 18:06:42 GMT+0200 (Eastern European Standard Time),
// }
};

const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
console.log(getControlValue(evt.target));
// '[email protected]'
};

return (
<>
<form onSubmit={handleSubmit}>
<label>
Name
<input name="name" type={ControlType.TEXT} defaultValue="Jon" />
</label>
<label>
Date
<input name="birthday" type={ControlType.DATE} defaultValue="2021-03-27" />
</label>
<button type="submit">Submit</button>
</form>

...

<form>
<label>
Mailing
<input name="mail" type={ControlType.EMAIL} onChange={handleChange} />
</label>
</form>
</>
);
};
```

Expand Down

0 comments on commit 2f649a6

Please sign in to comment.