From ae69037a26a617bba95c2039eac86113313685f1 Mon Sep 17 00:00:00 2001 From: jwc780 Date: Thu, 25 Jun 2020 14:15:29 -0400 Subject: [PATCH] fix: fixed various parameterform bugs --- src/components/App.css | 1 + .../SettingsBar/SettingsBarInternal.tsx | 31 ++++++---- .../UtilityComponents/ParameterForm.tsx | 56 ++++++++++++------- 3 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/components/App.css b/src/components/App.css index e1f23b0..381125d 100644 --- a/src/components/App.css +++ b/src/components/App.css @@ -81,6 +81,7 @@ body{ .switch-toggle{ width: 80%! important; + margin-bottom: .5rem! important; } /* Tooltip Styles */ diff --git a/src/components/SettingsBar/SettingsBarInternal.tsx b/src/components/SettingsBar/SettingsBarInternal.tsx index f061988..a085cfd 100644 --- a/src/components/SettingsBar/SettingsBarInternal.tsx +++ b/src/components/SettingsBar/SettingsBarInternal.tsx @@ -61,6 +61,13 @@ export class SettingsBarInternal extends React.PureComponent{ ['Light', [['lightMin', 'Min'], ['lightMax', 'Max']]], ] } + private defaultFormStyle = { + formLabel: {display: "inline-block", marginRight: ".1rem", minWidth:"6rem"}, + formControl: {minWidth: '6rem', maxWidth: '9rem', display: "inline-flex"}, + inputGroup: {display: "inline-flex"}, + inputGroupAppend: {display: "inline-block"}, + formGroup: {display: "block ruby", marginBottom: ".5rem" }, + } //Graphs private handleGraphChange = (value: string, id: string) => { var numValue : number | undefined; @@ -69,7 +76,6 @@ export class SettingsBarInternal extends React.PureComponent{ this.props.settings.distance[id] = numValue; } private generateGraphForm = () => { - const rangeAxisFormStyle = {formLabel: {paddingTop: 0, paddingBottom: 0}, formGroup: {marginBottom: ".5rem"}}; return this.forms.graphs.distance.map((value, i) => { return( { handleValueChange={this.handleGraphChange} newValue={String(this.props.settings.distance[value[0]])} append="m" - labelWidth={3} style={rangeAxisFormStyle} ariaLabel={value[1]}> + labelWidth={3} ariaLabel={value[1]} + style={this.defaultFormStyle}> {value[1]} ); @@ -92,18 +99,22 @@ export class SettingsBarInternal extends React.PureComponent{ } private generateLaunchAngleForm = () => { const forms = this.forms, calculationSettings = this.props.settings.calculationSettings; - return forms.calculations.launchAngle.map((value, i) => { + const run = () : JSX.Element[] => {return forms.calculations.launchAngle.map((value, i) => { const initialValue = calculationSettings.launchAngle[value[0]]; return( + - {value[1]} - + labelWidth={3} append={value[2]} ariaLabel={value[1]} + style={this.defaultFormStyle}>{value[1]} + ); - }); + })} + return( + <>{run()} + ) } private handleNumericalMethodChange = (value: string, id: string) : void | string => { const calculationSettings = this.props.settings.calculationSettings; @@ -121,7 +132,7 @@ export class SettingsBarInternal extends React.PureComponent{ const initialValue = calculationSettings[value[0]]; return( + type="number" handleValueChange={this.handleNumericalMethodChange} labelWidth={3} append={value[2]} style={this.defaultFormStyle}> {value[1]} ); @@ -229,8 +240,8 @@ export class SettingsBarInternal extends React.PureComponent{ controlId="rounding" ariaLabel="Tooltip Rounding" type="number" newValue={String(format.rounding)} handleValueChange={this.handleRoundingChange} - labelWidth={3} append="dp"> - Tooltip Rounding + labelWidth={3} append="dp" style={this.defaultFormStyle}> + Rounding

Color Generation

{this.generateColorForms()} diff --git a/src/components/UtilityComponents/ParameterForm.tsx b/src/components/UtilityComponents/ParameterForm.tsx index 9126ab8..e1c71c3 100644 --- a/src/components/UtilityComponents/ParameterForm.tsx +++ b/src/components/UtilityComponents/ParameterForm.tsx @@ -19,12 +19,6 @@ export class ParameterForm extends React.Component { - if(this.props.append !== ""){ - return ({this.props.append}); - }else{return (<>);} - }; - this.appendText = makeAppend(); } handleChange = (event) => { const errorCode = this.props.handleValueChange(event.target.value, this.props.controlId); @@ -33,23 +27,43 @@ export class ParameterForm extends React.Component { this.setState((state) => {return {value: newValue, invalid: false};}); - } + } + private makeAppend = () => { + if(this.props.append !== ""){ + return ({this.props.append}); + }else{return false;} + }; render(){ const props = this.props, state = this.state, style = props.style; - return ( - - {props.children} - - - - {this.appendText} - - - - ); + const appendText = this.makeAppend(); + if(appendText !== false){ + return ( + + {props.children} + + + + {appendText} + + + + ); + }else{ + return ( + + {props.children} + + + + + ); + } } }