mirror of
https://github.com/seigler/bl3skills.com
synced 2025-07-27 09:46:10 +00:00
show invested amount
This commit is contained in:
parent
b233594643
commit
d0b516e662
4 changed files with 152 additions and 106 deletions
40
src/components/Skill/index.js
Normal file
40
src/components/Skill/index.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
// import { useState } from 'preact/hooks';
|
||||
import SKILLS from '@constants/skills';
|
||||
import style from './index.css';
|
||||
|
||||
function getInitials (string) {
|
||||
const initials = string.match(/\b\w/g) || [];
|
||||
return ((initials.shift() || '') + (initials.pop() || '')).toUpperCase();
|
||||
}
|
||||
|
||||
export default function VaultHunter ({
|
||||
name = '?',
|
||||
text = 'Long description',
|
||||
ranks = 0,
|
||||
invested = 0,
|
||||
effect = rank => `Rank ${rank} effect`,
|
||||
type = null,
|
||||
enabled = true,
|
||||
}) {
|
||||
const isAugment = [
|
||||
SKILLS.AUGMENT_CHEVRON,
|
||||
SKILLS.AUGMENT_DIAMOND,
|
||||
SKILLS.ACTION_SKILL,
|
||||
].includes(type);
|
||||
let shapeStyle = null;
|
||||
if (type === SKILLS.AUGMENT_CHEVRON) { shapeStyle = style.chevron; }
|
||||
if (type === SKILLS.AUGMENT_DIAMOND) { shapeStyle = style.diamond; }
|
||||
if (type === SKILLS.ACTION_SKILL) { shapeStyle = style.actionSkill; }
|
||||
return (
|
||||
<div class={[
|
||||
style.skill,
|
||||
isAugment ? style.augment : '',
|
||||
shapeStyle,
|
||||
enabled ? style.enabled : '',
|
||||
enabled && (ranks === 0 || invested > 0) ? style.usable : '',
|
||||
].join(' ')}>
|
||||
{ getInitials(name) }
|
||||
{ enabled && ranks > 0 && <div class={style.ranks}>{invested}/{ranks}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue