text input QOL improvements
This commit is contained in:
parent
72478d68d2
commit
37ab51a6dc
12
dist/main-bundle.js
vendored
12
dist/main-bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -3,12 +3,14 @@ import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { IIndividualValues, IndividualValueKey } from 'app/components/PokemonExplorer/types';
|
||||
import { CaptureSource } from 'app/models/Pokemon';
|
||||
|
||||
import * as styles from 'app/components/PokemonExplorer/styles/IvForm.scss';
|
||||
|
||||
export interface IIvFormProps {
|
||||
ivs : IIndividualValues;
|
||||
placeholder : IIndividualValues;
|
||||
captureSource : CaptureSource;
|
||||
|
||||
handleChangeIndividualValue : (stat : IndividualValueKey, value : number | null) => void;
|
||||
handleMaximizeLevel : () => void;
|
||||
@ -49,6 +51,7 @@ export class IvForm extends React.Component<IIvFormProps, IState> {
|
||||
const {
|
||||
ivs,
|
||||
placeholder,
|
||||
captureSource,
|
||||
} = this.props;
|
||||
|
||||
const idIvLevelInput = 'iv-level-input';
|
||||
@ -91,9 +94,10 @@ export class IvForm extends React.Component<IIvFormProps, IState> {
|
||||
type="number"
|
||||
id={ idIvHpInput }
|
||||
className={ inputTextCss }
|
||||
min={ this.MIN_IV }
|
||||
min={ Math.max(this.MIN_IV, captureSource) }
|
||||
max={ this.MAX_IV }
|
||||
maxLength={ 2 }
|
||||
onFocus={ this.handleFocusField }
|
||||
onChange={ this.handleChangeHp }
|
||||
value={ ivs.ivHp !== null ? ivs.ivHp : '' }
|
||||
placeholder={ showPlaceholder ? '' + placeholder.ivHp : '' }
|
||||
@ -104,9 +108,10 @@ export class IvForm extends React.Component<IIvFormProps, IState> {
|
||||
type="number"
|
||||
id={ idIvAtkInput }
|
||||
className={ inputTextCss }
|
||||
min={ this.MIN_IV }
|
||||
min={ Math.max(this.MIN_IV, captureSource) }
|
||||
max={ this.MAX_IV }
|
||||
maxLength={ 2 }
|
||||
onFocus={ this.handleFocusField }
|
||||
onChange={ this.handleChangeAtk }
|
||||
value={ ivs.ivAtk !== null ? ivs.ivAtk : '' }
|
||||
placeholder={ showPlaceholder ? '' + placeholder.ivAtk : '' }
|
||||
@ -117,9 +122,10 @@ export class IvForm extends React.Component<IIvFormProps, IState> {
|
||||
type="number"
|
||||
id={ idIvDefInput }
|
||||
className={ inputTextCss }
|
||||
min={ this.MIN_IV }
|
||||
min={ Math.max(this.MIN_IV, captureSource) }
|
||||
max={ this.MAX_IV }
|
||||
maxLength={ 2 }
|
||||
onFocus={ this.handleFocusField }
|
||||
onChange={ this.handleChangeDef }
|
||||
value={ ivs.ivDef !== null ? ivs.ivDef : '' }
|
||||
placeholder={ showPlaceholder ? '' + placeholder.ivDef : '' }
|
||||
@ -137,6 +143,7 @@ export class IvForm extends React.Component<IIvFormProps, IState> {
|
||||
min={ this.MIN_LEVEL }
|
||||
max={ this.MAX_LEVEL }
|
||||
step={ 0.5 }
|
||||
onFocus={ this.handleFocusField }
|
||||
onChange={ this.handleChangeLevel }
|
||||
value={ ivLevel !== null ? ivLevel : '' }
|
||||
placeholder={ showPlaceholder ? '' + placeholder.level : '' }
|
||||
@ -154,6 +161,10 @@ export class IvForm extends React.Component<IIvFormProps, IState> {
|
||||
)];
|
||||
}
|
||||
|
||||
private readonly handleFocusField = (event : React.FocusEvent<HTMLInputElement>) => {
|
||||
event.target.select();
|
||||
}
|
||||
|
||||
private readonly handleChangeLevel = (event : React.ChangeEvent<HTMLInputElement>) => {
|
||||
const raw = event.currentTarget.value;
|
||||
const value = parseFloat(raw);
|
||||
|
||||
@ -230,6 +230,7 @@ export class LeagueIvExplorer extends React.Component<ILeagueIvExplorerProps, IS
|
||||
<IvForm
|
||||
ivs={ individualValues }
|
||||
placeholder={ leaguePokemon.pvp[activeLeague][captureSource][0] }
|
||||
captureSource={ captureSource }
|
||||
handleChangeIndividualValue={ handleChangeIndividualValue }
|
||||
handleMaximizeLevel={ handleMaximizeLevel }
|
||||
/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user