league functionality, stats list layout
This commit is contained in:
parent
f16da85933
commit
58a17849a4
@ -123,11 +123,20 @@ export class LeagueStatsList extends React.Component<ILeagueStatsListProps, ISta
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private padString(value : string, length : number) {
|
||||||
|
let output = value;
|
||||||
|
for (let i = value.length - length - 1; i >= 0; i--) {
|
||||||
|
output += String.fromCharCode(160);
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
private rowFactory({ index, style } : IRowFactory) {
|
private rowFactory({ index, style } : IRowFactory) {
|
||||||
const activeIvs = this.props.activeIndividualValues;
|
const activeIvs = this.props.activeIndividualValues;
|
||||||
const stats = this.props.leagueStatsList[index];
|
const stats = this.props.leagueStatsList[index];
|
||||||
const css = classNames(
|
const css = classNames(
|
||||||
'list-item',
|
'list-item', // global style
|
||||||
|
styles.listItem,
|
||||||
{
|
{
|
||||||
active: activeIvs.level === stats.level &&
|
active: activeIvs.level === stats.level &&
|
||||||
activeIvs.hp === stats.ivHp &&
|
activeIvs.hp === stats.ivHp &&
|
||||||
@ -140,6 +149,7 @@ export class LeagueStatsList extends React.Component<ILeagueStatsListProps, ISta
|
|||||||
this.props.handleActivateLeagueStats(stats);
|
this.props.handleActivateLeagueStats(stats);
|
||||||
this.setState({ activeIndex: index });
|
this.setState({ activeIndex: index });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
key={ index }
|
key={ index }
|
||||||
@ -147,7 +157,12 @@ export class LeagueStatsList extends React.Component<ILeagueStatsListProps, ISta
|
|||||||
className={ css }
|
className={ css }
|
||||||
onClick={ onClick }
|
onClick={ onClick }
|
||||||
>
|
>
|
||||||
{ `${ Grade[stats.speciesGrade] } ${ stats.cp } ${ stats.level } ${ stats.ivHp } ${ stats.ivAtk } ${ stats.ivDef }` }
|
<span>{ Grade[stats.speciesGrade] }</span>
|
||||||
|
<span>{ this.padString(stats.cp.toString(), 4) }</span>
|
||||||
|
<span>{ this.padString(stats.level.toString(), 4) }</span>
|
||||||
|
<span>{ this.padString(stats.ivHp.toString(), 2) }</span>
|
||||||
|
<span>{ this.padString(stats.ivAtk.toString(), 2) }</span>
|
||||||
|
<span>{ this.padString(stats.ivDef.toString(), 2) }</span>
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,6 @@ export class PokemonExplorer extends React.Component<IPokemonExplorerProps, ISta
|
|||||||
individualValues,
|
individualValues,
|
||||||
leaguePokemon
|
leaguePokemon
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const league = 'great'; // TODO: this should be a prop
|
|
||||||
|
|
||||||
let rankedPokemon : IStats | null = null;
|
let rankedPokemon : IStats | null = null;
|
||||||
let placeholderLevel = '';
|
let placeholderLevel = '';
|
||||||
@ -79,7 +78,7 @@ export class PokemonExplorer extends React.Component<IPokemonExplorerProps, ISta
|
|||||||
individualValues.atk === null &&
|
individualValues.atk === null &&
|
||||||
individualValues.def === null
|
individualValues.def === null
|
||||||
) {
|
) {
|
||||||
rankedPokemon = leaguePokemon.pvp[league][0];
|
rankedPokemon = leaguePokemon.pvp[activeLeague][0];
|
||||||
placeholderLevel = '' + rankedPokemon.level;
|
placeholderLevel = '' + rankedPokemon.level;
|
||||||
placeholderHp = '' + rankedPokemon.ivHp;
|
placeholderHp = '' + rankedPokemon.ivHp;
|
||||||
placeholderAtk = '' + rankedPokemon.ivAtk;
|
placeholderAtk = '' + rankedPokemon.ivAtk;
|
||||||
@ -91,7 +90,7 @@ export class PokemonExplorer extends React.Component<IPokemonExplorerProps, ISta
|
|||||||
individualValues.atk !== null &&
|
individualValues.atk !== null &&
|
||||||
individualValues.def !== null
|
individualValues.def !== null
|
||||||
) {
|
) {
|
||||||
leaguePokemon.pvp[league].some((stats) => {
|
leaguePokemon.pvp[activeLeague].some((stats) => {
|
||||||
if (individualValueLevel === stats.level &&
|
if (individualValueLevel === stats.level &&
|
||||||
individualValues.hp === stats.ivHp &&
|
individualValues.hp === stats.ivHp &&
|
||||||
individualValues.atk === stats.ivAtk &&
|
individualValues.atk === stats.ivAtk &&
|
||||||
@ -134,63 +133,63 @@ export class PokemonExplorer extends React.Component<IPokemonExplorerProps, ISta
|
|||||||
const idIvDefInput = 'iv-def-input';
|
const idIvDefInput = 'iv-def-input';
|
||||||
const containerCss = classNames(
|
const containerCss = classNames(
|
||||||
'nes-container',
|
'nes-container',
|
||||||
'with-title'
|
'with-title',
|
||||||
);
|
);
|
||||||
const containerRoundCss = classNames(
|
const containerRoundCss = classNames(
|
||||||
containerCss,
|
containerCss,
|
||||||
'is-rounded'
|
'is-rounded',
|
||||||
);
|
);
|
||||||
const pokemonType = classNames(
|
const pokemonType = classNames(
|
||||||
containerRoundCss,
|
containerRoundCss,
|
||||||
styles.pokemonType
|
styles.pokemonType,
|
||||||
);
|
);
|
||||||
const containerTitleCss = classNames(
|
const containerTitleCss = classNames(
|
||||||
'title'
|
'title',
|
||||||
);
|
);
|
||||||
const baseStatsCss = classNames(
|
const baseStatsCss = classNames(
|
||||||
styles.pokemonBaseStats,
|
styles.pokemonBaseStats,
|
||||||
containerCss
|
containerCss,
|
||||||
);
|
);
|
||||||
const formContainerCss = classNames(
|
const formContainerCss = classNames(
|
||||||
containerCss,
|
containerCss,
|
||||||
'form'
|
'form',
|
||||||
);
|
);
|
||||||
const fieldCss = classNames(
|
const fieldCss = classNames(
|
||||||
'nes-field'
|
'nes-field',
|
||||||
);
|
);
|
||||||
const inlineFieldCss = classNames(
|
const inlineFieldCss = classNames(
|
||||||
fieldCss,
|
fieldCss,
|
||||||
'is-inline',
|
'is-inline',
|
||||||
styles.fieldRow
|
styles.fieldRow,
|
||||||
);
|
);
|
||||||
const inputTextCss = classNames(
|
const inputTextCss = classNames(
|
||||||
'nes-input',
|
'nes-input',
|
||||||
styles.ivInput
|
styles.ivInput,
|
||||||
);
|
);
|
||||||
const inputTextLevelCss = classNames(
|
const inputTextLevelCss = classNames(
|
||||||
inputTextCss,
|
inputTextCss,
|
||||||
styles.levelInput
|
styles.levelInput,
|
||||||
);
|
);
|
||||||
const leaugeRankCss = classNames(
|
const leaugeRankCss = classNames(
|
||||||
styles.leaguePokemonRank,
|
styles.leaguePokemonRank,
|
||||||
containerCss,
|
containerCss,
|
||||||
{
|
{
|
||||||
'with-title': false
|
'with-title': false
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
const maxButtonCss = classNames(
|
const maxButtonCss = classNames(
|
||||||
'nes-btn',
|
'nes-btn',
|
||||||
{
|
{
|
||||||
'is-primary': individualValues.hp !== null && individualValues.atk !== null && individualValues.def !== null,
|
'is-primary': individualValues.hp !== null && individualValues.atk !== null && individualValues.def !== null,
|
||||||
'is-disabled': individualValues.hp === null || individualValues.atk === null || individualValues.def === null,
|
'is-disabled': individualValues.hp === null || individualValues.atk === null || individualValues.def === null,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const pokemonIconCss = classNames(
|
const pokemonIconCss = classNames(
|
||||||
`pokemon-${dex}`,
|
`pokemon-${dex}`,
|
||||||
{
|
{
|
||||||
alola: leaguePokemon.form === 'ALOLA'
|
alola: leaguePokemon.form === 'ALOLA'
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let type1 : JSX.Element | null = null;
|
let type1 : JSX.Element | null = null;
|
||||||
@ -307,6 +306,7 @@ export class PokemonExplorer extends React.Component<IPokemonExplorerProps, ISta
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={ maxButtonCss }
|
className={ maxButtonCss }
|
||||||
|
disabled={ individualValues.hp === null || individualValues.atk === null || individualValues.def === null }
|
||||||
onClick={ this.handleClickMaximizeLevel }
|
onClick={ this.handleClickMaximizeLevel }
|
||||||
>
|
>
|
||||||
MAX LEAGUE Lv
|
MAX LEAGUE Lv
|
||||||
@ -343,7 +343,7 @@ export class PokemonExplorer extends React.Component<IPokemonExplorerProps, ISta
|
|||||||
<LeagueStatsList
|
<LeagueStatsList
|
||||||
activePokemonId={ leaguePokemon.id }
|
activePokemonId={ leaguePokemon.id }
|
||||||
activeIndividualValues={ individualValues }
|
activeIndividualValues={ individualValues }
|
||||||
leagueStatsList={ leaguePokemon.pvp[league] }
|
leagueStatsList={ leaguePokemon.pvp[activeLeague] }
|
||||||
handleActivateLeagueStats={ this.handleActivateLeagueStats }
|
handleActivateLeagueStats={ this.handleActivateLeagueStats }
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -10,3 +10,19 @@
|
|||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.listItem {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
|
||||||
|
&:global(.list-item) {
|
||||||
|
&:global(.active),
|
||||||
|
&:hover {
|
||||||
|
&::before {
|
||||||
|
top: 8px;
|
||||||
|
left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
// This file is automatically generated.
|
// This file is automatically generated.
|
||||||
// Please do not change this file!
|
// Please do not change this file!
|
||||||
|
export const listItem: string;
|
||||||
export const selectList: string;
|
export const selectList: string;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user