forked from johreh/gloomycompanion
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ModifierCardCounter.jsx
29 lines (24 loc) · 1.01 KB
/
ModifierCardCounter.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import PropTypes from 'prop-types';
import React from 'react';
import ButtonDiv from './ButtonDiv';
import ModifierDeckState from './ModifierDeckState';
import * as css from './style/ModifierDeck.scss';
export default function ModifierCardCounter(props) {
function count() {
return props.deckState.num_special[props.modifierType];
}
return (
<div className={css.counterIcon}>
<div className={`${css.background} ${css[props.modifierType]}`} />
<ButtonDiv className={`${css.decrement} ${css.button}`} onClick={() => props.removeSpecial(props.modifierType)}>-</ButtonDiv>
<div className={css.iconText}>{count()}</div>
<ButtonDiv className={`${css.increment} ${css.button}`} onClick={() => props.addSpecial(props.modifierType)}>+</ButtonDiv>
</div>
);
}
ModifierCardCounter.propTypes = {
modifierType: PropTypes.string.isRequired,
deckState: PropTypes.instanceOf(ModifierDeckState).isRequired,
addSpecial: PropTypes.func.isRequired,
removeSpecial: PropTypes.func.isRequired,
};