With npm installed just run:
npm install
To run:
npm start
To run tests:
npm test
- This project was bootstrapped with Create React App.
- Some files have not been touched in the implementation.
- The following external modules have been used:
lodash:- A bit overkill just to get the
groupByfunction.
- A bit overkill just to get the
react-numeric-input:NumericInputcomponent (not sure I would have used this in a real app).
- The components have been put in the
componentsfolder:ErrorMsg: Displays an error message.TriangleInfo: Displays info about a triangle.- No real tests as I have no real experience testing React components (also quite fleeting how/what to test when it comes to UI tests).
- The triangle calculations are in the
modelsfolder:- In a real app there would probably be a lot more operations on triangles so a class would be a better solution.
- A function
isTriangleto test if the sides make up a triangle and that all input lengths are valid. - A function
triangleTypethat returns the type of the triangle. - An enum
TriangleTypeto avoid fragile comparisons. - Basic unit tests. Valid for current triangle definition but
Number.MAX_VALUEis not useful for more general triangle operations.
- The
App:- Combines the different sub components.
- The UI is currently limited to integers but this could be easily changed by modifying the propertis on
NumericInput. - The table solution is not a nice one as it does not scale wit different window sizes:
- Should probably look into
bootstrap.cssor build a more general React component for the layout.
- Should probably look into
- There is a warning regarding old
PropTypesuse in this file (maybe due toNumericInput).