Skip to content

Commit

Permalink
feat: init release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
iremlopsum committed Feb 17, 2022
0 parents commit 1040758
Show file tree
Hide file tree
Showing 21 changed files with 24,922 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# builds
build
dist
.rpt2_cache

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
bracketSpacing: true,
jsxBracketSameLine: true,
semi: false,
singleQuote: true,
trailingComma: 'all',
printWidth: 120,
}
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- 8
env:
- SKIP_PREFLIGHT_CHECK=true
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# @colorfy-software/use-form

>
[![NPM](https://img.shields.io/npm/v/@colorfy-software/use-form.svg)](https://www.npmjs.com/package/@colorfy-software/use-form) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save @colorfy-software/use-form
```

## Usage

```tsx
import * as React from "react";

import { useMyHook } from "@colorfy-software/use-form";

const Example = () => {
const example = useMyHook();
return <div>{example}</div>;
};
```

## License

MIT © [colorfy-software](https://github.com/colorfy-software)
2,026 changes: 2,026 additions & 0 deletions example/README.md

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@colorfy-software/use-form-example",
"homepage": "https://colorfy-software.github.io/@colorfy-software/use-form",
"version": "0.0.0",
"license": "MIT",
"private": true,
"dependencies": {
"react": "link:../node_modules/react",
"react-dom": "^16.9.0",
"react-scripts": "^3.0.1",
"@colorfy-software/use-form": "link:.."
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
20 changes: 20 additions & 0 deletions example/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">

<link rel="manifest" href="%PUBLIC_URL%/manifest.json">

<title>@colorfy-software/use-form</title>
</head>

<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>

<div id="root"></div>
</body>
</html>
8 changes: 8 additions & 0 deletions example/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"short_name": "@colorfy-software/use-form",
"name": "@colorfy-software/use-form",
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
49 changes: 49 additions & 0 deletions example/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react'

import useForm, { hasLengthyError, hasEmailError } from '@colorfy-software/use-form'

const FORM_SCHEMA = {
email: '',
password: '',
}

const FORM_VALIDATION = {
email: {
validatorFn: (value) => hasLengthyError(value) || hasEmailError(value),
},
password: {
validatorFn: (value) => hasLengthyError(value),
},
}

const App = () => {
const onSubmitForm = async ({ email, password }) => {
console.log('onSubmitForm', { email, password })
}

const { state, onHandleChange, onHandleSubmit, errors } = useForm(FORM_SCHEMA, FORM_VALIDATION, onSubmitForm)

return (
<div>
<h1>useForm</h1>
{errors.email && <p>{errors.email}</p>}
<input
type="email"
name="email"
placeholder="email"
value={state.email}
onChange={(e) => onHandleChange('email', e.target.value)}
/>
{errors.password && <p>{errors.password}</p>}
<input
type="password"
name="password"
placeholder="password"
value={state.password}
onChange={(e) => onHandleChange('password', e.target.value)}
/>
<button onClick={onHandleSubmit}>Submit</button>
</div>
)
}
export default App
5 changes: 5 additions & 0 deletions example/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* body {
margin: 0;
padding: 0;
font-family: sans-serif;
} */
7 changes: 7 additions & 0 deletions example/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'
import ReactDOM from 'react-dom'

import './index.css'
import App from './App'

ReactDOM.render(<App />, document.getElementById('root'))
Loading

0 comments on commit 1040758

Please sign in to comment.