Skip to content

Commit

Permalink
Merge pull request #2 from Vlsarro/dev
Browse files Browse the repository at this point in the history
Fix invalid springs selection position
  • Loading branch information
Vlsarro authored May 3, 2021
2 parents 21b4e24 + 004689e commit 9a347e5
Show file tree
Hide file tree
Showing 26 changed files with 312 additions and 279 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Other
package-lock.json
36 changes: 29 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
{
"name": "vicegripper",
"version": "0.9.9",
"private": true,
"version": "1.0.0",
"private": false,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"lodash": "^4.17.4",
"prop-types": "^15.7.2",
"rc-slider": "^8.3.1",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-scripts": "1.0.11",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"react-toggle": "^4.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"test": "react-scripts test",
"eject": "react-scripts eject",
"deploy": "npm run build&&gh-pages -d build"
"deploy": "npm run build && gh-pages -d build"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"homepage": "https://vlsarro.github.io/vicegripper",
"devDependencies": {
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
25 changes: 14 additions & 11 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<!doctype html>
<!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">
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="App which shows pressure of hand gripper"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand All @@ -22,9 +27,7 @@
<title>Vice Gripper</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
Expand Down
Binary file added public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 13 additions & 3 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
"icons": [
{
"src": "favicon.ico",
"sizes": "192x192",
"type": "image/png"
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "./index.html",
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
Expand Down
30 changes: 30 additions & 0 deletions src/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import PropTypes from 'prop-types';

const Button = ({className, name, disabled, onClick}) => {
const baseInputClassName = 'resistance-btn';
const inputClassName = className ? `${baseInputClassName} ${className}` : baseInputClassName;

const onClickHandler = () => {
onClick(name);
}

return (
<input className={inputClassName} name={name} type='button' onClick={onClickHandler} value={name}
disabled={disabled}/>
)
}

Button.propTypes = {
className: PropTypes.string,
name: PropTypes.string.isRequired,
disabled: PropTypes.bool,
onClick: PropTypes.func.isRequired
}

Button.defaultProps = {
disabled: false,
className: ''
}

export default Button;
27 changes: 27 additions & 0 deletions src/components/GripToggle.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import Toggle from 'react-toggle'
import PropTypes from 'prop-types';
import 'react-toggle/style.css'

const GripToggle = ({onChange}) => {

const onChangeHandler = (e) => {
onChange(e.target.checked)
}

return (
<div className="toggle-wrapper">
<label>
<span className="grip" title="Inner grip">I</span>
<Toggle icons={false} onChange={onChangeHandler} />
<span className="grip" title="Outer grip">O</span>
</label>
</div>
)
}

GripToggle.propTypes = {
onChange: PropTypes.func.isRequired
}

export default GripToggle
43 changes: 43 additions & 0 deletions src/components/ResistanceInput.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import Button from './Button'
import PropTypes from 'prop-types';

const ResistanceInput = ({onChange, onButtonClick, weightUnit, inputClass, invalidMsg, calcBtnClass, disabled}) => {
const placeholder = `Enter resistance (in ${weightUnit})`
const baseTextInputClass = 'res-input'
const textInputClass = inputClass ? `${baseTextInputClass} ${inputClass}` : baseTextInputClass

const onChangeHandler = (e) => {
onChange(e.target.value)
}

return (
<div className="res-input-comp-wrapper">
<div className="res-input-wrapper">
<input data-tip data-for='resistanceToolTip' className={textInputClass} type="text"
onChange={onChangeHandler} placeholder={placeholder} />
{inputClass === 'invalid' &&
<small className={inputClass}>{invalidMsg}</small>
}
</div>
<Button className={calcBtnClass} name={'CALC'} disabled={disabled}
onClick={onButtonClick} />
</div>
)
}

ResistanceInput.propTypes = {
onChange: PropTypes.func.isRequired,
onButtonClick: PropTypes.func.isRequired,
weightUnit: PropTypes.string.isRequired,
inputClass: PropTypes.string,
invalidMsg: PropTypes.string.isRequired,
calcBtnClass: PropTypes.string,
disabled: PropTypes.bool
}

ResistanceInput.defaultProps = {
disabled: false
}

export default ResistanceInput;
29 changes: 29 additions & 0 deletions src/components/ResistanceRange.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import Slider from 'rc-slider';
import PropTypes from 'prop-types';
import 'rc-slider/assets/index.css';

const createSliderWithTooltip = Slider.createSliderWithTooltip;
const Range = createSliderWithTooltip(Slider.Range);

const ResistanceRange = ({onAfterChange, sliderKey, resistance, weightUnit, defaultValue, springNumber}) => {
return (
<div className="slider-wrapper" key={sliderKey}>
<Range dots step={1} max={11} onAfterChange={onAfterChange}
defaultValue={defaultValue} count={springNumber} pushable
tipFormatter={value => value + 1}/>
<p className="res-result">{`Resistance: ${resistance.toPrecision(3)} ${weightUnit}, positions: ${defaultValue.map((x) => {return x + 1})}`}</p>
</div>
)
}

ResistanceRange.propTypes = {
onAfterChange: PropTypes.func.isRequired,
sliderKey: PropTypes.string.isRequired,
resistance: PropTypes.number.isRequired,
weightUnit: PropTypes.string.isRequired,
defaultValue: PropTypes.arrayOf(PropTypes.number).isRequired,
springNumber: PropTypes.number.isRequired
}

export default ResistanceRange;
35 changes: 35 additions & 0 deletions src/components/SpringNumberSelect.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from "react"
import uniqueId from "lodash/uniqueId"
import PropTypes from "prop-types"

const SpringNumberSelect = ({onChange, springNumber}) => {
const id = uniqueId('prefix-')
const labelStyle = {
padding: '5px',
verticalAlign: 'middle',
fontWeight: 'normal',
marginBottom: '0'
};

const onChangeHandler = (e) => {
onChange(e.target.value)
}

return (
<div className="spring-select-wrapper">
<label className="spring-label" style={labelStyle} htmlFor={id}>Number of springs</label>
<select className="spring-select" id={id} onChange={onChangeHandler} value={springNumber}>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
)
}

SpringNumberSelect.propTypes = {
springNumber: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired
}

export default SpringNumberSelect;
25 changes: 0 additions & 25 deletions src/components/button.jsx

This file was deleted.

31 changes: 0 additions & 31 deletions src/components/griptoggle.jsx

This file was deleted.

45 changes: 0 additions & 45 deletions src/components/resistanceinput.jsx

This file was deleted.

Loading

0 comments on commit 9a347e5

Please sign in to comment.