-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Vlsarro/dev
Fix invalid springs selection position
- Loading branch information
Showing
26 changed files
with
312 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,6 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Other | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.