Input Componentization
During my time as a software developer I’ve faced several issues that I found annoying, the most annoying being the need to replicate both behaviour and design changes in projects with lots of inputs. That can be partially solved with good pratices, however this repository makes it even easier as you can create inputs with predefined behaviours with a simple line.
What is the objective of the project?
Create an input component that receive values such as type, placeholder and initialValue, creates an input field based on those parameters and then return the value and errors whenever there is a change on the field.
Why should I use this concept?
-
Maintainability and reuse
Since all the code regarding inputs is in the same place it’s much easier to maintain and edit your code. One change affects the whole code. This way it is much easier to fix bugs and you ensure that once a bug is fixed the same bug won’t pop out elsewhere(if you repeat the type of an input a lot it’s pretty common to forget to fix the bug somewhere). -
Low coupling
As long as you always return the value of the input and which errors it contain, doesn’t matter how you implement it. Suppose you are using Ionic w/ Angular and you want to change from ion-input to mat-input, if you are using this concept you only need to make a single change.
When should I use this concept?
- Big projects;
- Medium/small project with a high number of inputs.
When should I not use this concept?
- Medium/small project with a low number of inputs.
How to see a demo of this project?
- Clone the repository;
- Go to the folder cloned;
- Open either the ‘angular’ or the ‘ionic’ folder;
- Run ‘npm install’.
If you selected ‘angular’
- Run ‘ng serve’;
- Open ‘localhost:4200’ at your browser.
If you selected ‘ionic’
- Run ‘ionic serve’;
- Open ‘localhost:8100’ at your browser.