Skip to content

Commit 7f11bf6

Browse files
author
Dustyn Blackmore
committed
Updated CONTRIBUTING and README
Minor additions, including some more information on the component (validation)
1 parent 0ecb364 commit 7f11bf6

2 files changed

Lines changed: 94 additions & 3 deletions

File tree

CONTRIBUTING.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@ Please update the README with any API changes, the code and docs should
2727
always be in sync.
2828

2929
### Development
30+
Note: Personally: I have been using yarn due to inconsistent, or unreliable,
31+
behavior with NPM.
3032

3133
- `npm start` runs the dev server to run/develop examples
34+
- `yarn start`
3235
- `npm test` will run the tests.
33-
- `scripts/test` same as `npm test` but keeps karma running and watches
34-
for changes
36+
- `yarn test`
3537

3638
### Build
3739

3840
Please do not include the output of `scripts/build` in your commits, we
3941
only do this when we release. (Also, you probably don't need to build
4042
anyway unless you are fixing something around our global build.)
43+
44+
### Coding Requirements / Standards
45+
46+
I'm working on finalizing / ensuring these are part of the actual local build/
47+
test phase - to which I am not even entirely compliant.
48+
49+
For now; there is a built in lint, which appears to conform to semistandard.

README.md

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ An input component to serve the common good.
1010
* [Installation](#installation)
1111
* [Usage](#usage)
1212
* [Styles](#styles)
13+
* [FAQ](#FAQ)
1314
* [Examples](#examples)
1415

1516
## Installation
@@ -69,6 +70,32 @@ A basic example may be;
6970
}
7071
```
7172

73+
## FAQ
74+
(Mostly asked by myself, to myself)
75+
76+
* Why does this component even exist?
77+
Initially developing an application heavily dependent on HTML 'Input' elements,
78+
I was quickly overwhelmed with the vast options of options available on NPM.
79+
These options, whilst not opinionated, often didn't quite meet my requirements,
80+
which I felt really were 'core' and 'key' features of an input.
81+
82+
In working on this app, I developed my own (app specific) child component, made
83+
it rather hard to conveniently include in other projects. Work invested in copy
84+
/ paste quickly became tedious (And the wrong way to manage things anyway).
85+
86+
Thus; react-component_input.js was born
87+
88+
* Goals of this Project
89+
The goal of this project is to provide a 'core'/'key' feature functional input
90+
component that performs nothing outside of that scope. These should also provide
91+
appropriate functionality that is exposed by React (Otherwise; what would be the
92+
point of making this a react component, right?)
93+
94+
Overall; this is one of the reasons styles are completely abstract from the
95+
project.
96+
97+
Yes.. Yes. It's not perfect.. :( See... [Validation](#Validation)
98+
7299
## Examples
73100

74101
Inside an app:
@@ -107,4 +134,59 @@ class App extends Component {
107134
}
108135

109136
export default App;
110-
```
137+
```
138+
139+
## Validation
140+
Oh gosh; how I wanted to/will eventually leave this out of the component. In its
141+
current state; this is an inbuilt and entirely custom to component feature.
142+
Validation, in it's pure form; isn't really built into HTML Inputs, nor should
143+
it ever be purely depended on for any form of 'backend' processing.
144+
145+
For now; the behavior was included to provide exposure to the validation
146+
error.
147+
148+
See; https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
149+
150+
So.. for now, against my personal preference, and the project goals; it's
151+
included.
152+
153+
This is how it works;
154+
155+
Validation is a, or an array of, objects which contain a 'callback', and
156+
validation error message. This object is provided to the component via the
157+
'validation' prop.
158+
159+
The callback functions are passed the value of the triggered input, as
160+
provided by the (React Event)[https://reactjs.org/docs/handling-events.html].
161+
The return of the function, true or false, is used to determine the state of the
162+
component. If false; the validation error is rendered. If an array of validation
163+
is provided, and one fails - the component fails validation, however; only the
164+
failing validation object error message is shown.
165+
166+
An example validation object may be;
167+
168+
```js
169+
let validMinLength = (length = 0) => ({
170+
errorMessage:
171+
'The length of your input must be more than ' + parseInt(length),
172+
callback: value => value.length >= parseInt(length)
173+
});
174+
```
175+
and
176+
```js
177+
let validMinLength = (length = 0) => ({
178+
errorMessage:
179+
'The length of your input must be more than ' + parseInt(length),
180+
callback: value => value.length >= parseInt(length)
181+
});
182+
```
183+
184+
This is then passed to the component via the validation property.
185+
```jsx
186+
validation={validMinLength(10)}
187+
```
188+
189+
As stated, as an array;
190+
```jsx
191+
validation={[validMaxLength(32), validMinLength(10)]}
192+
```

0 commit comments

Comments
 (0)