Allow user to set uncap level
doesn't save to server yet
This commit is contained in:
parent
7c96b5c836
commit
3a1ef5d685
3 changed files with 26 additions and 4 deletions
|
|
@ -15,6 +15,8 @@ interface Props {
|
||||||
const UncapIndicator = (props: Props) => {
|
const UncapIndicator = (props: Props) => {
|
||||||
let numStars
|
let numStars
|
||||||
|
|
||||||
|
const [uncap, setUncap] = useState(props.uncapLevel)
|
||||||
|
|
||||||
if (props.type === 'character') {
|
if (props.type === 'character') {
|
||||||
if (props.flb) {
|
if (props.flb) {
|
||||||
numStars = 5
|
numStars = 5
|
||||||
|
|
@ -31,18 +33,25 @@ const UncapIndicator = (props: Props) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleStar(index: number, empty: boolean) {
|
||||||
|
if (empty)
|
||||||
|
setUncap(index + 1)
|
||||||
|
else
|
||||||
|
setUncap(index)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul className="UncapIndicator">
|
<ul className="UncapIndicator">
|
||||||
{
|
{
|
||||||
Array.from(Array(numStars)).map((x, i) => {
|
Array.from(Array(numStars)).map((x, i) => {
|
||||||
if (props.type === 'character' && i > 4) {
|
if (props.type === 'character' && i > 4) {
|
||||||
return <UncapStar ulb={true} key={`star_${i}`} />
|
return <UncapStar ulb={true} empty={i >= uncap} key={`star_${i}`} index={i} onClick={toggleStar} />
|
||||||
} else if (
|
} else if (
|
||||||
props.type === 'character' && i == 4 ||
|
props.type === 'character' && i == 4 ||
|
||||||
props.type !== 'character' && i > 2) {
|
props.type !== 'character' && i > 2) {
|
||||||
return <UncapStar flb={true} key={`star_${i}`} />
|
return <UncapStar flb={true} empty={i >= uncap} key={`star_${i}`} index={i} onClick={toggleStar} />
|
||||||
} else {
|
} else {
|
||||||
return <UncapStar key={`star_${i}`} />
|
return <UncapStar empty={i >= uncap} key={`star_${i}`} index={i} onClick={toggleStar} />
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,11 @@
|
||||||
transform: scale(1.2);
|
transform: scale(1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.empty {
|
&.empty,
|
||||||
|
&.empty.mlb,
|
||||||
|
&.empty.flb,
|
||||||
|
&.empty.ulb,
|
||||||
|
&.empty.special {
|
||||||
background: url('/icons/uncap/empty.svg');
|
background: url('/icons/uncap/empty.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,18 @@ import classnames from 'classnames'
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
empty: boolean
|
||||||
special: boolean
|
special: boolean
|
||||||
flb: boolean
|
flb: boolean
|
||||||
ulb: boolean
|
ulb: boolean
|
||||||
|
index: number
|
||||||
|
onClick: (index: number, empty: boolean) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const UncapStar = (props: Props) => {
|
const UncapStar = (props: Props) => {
|
||||||
const classes = classnames({
|
const classes = classnames({
|
||||||
UncapStar: true,
|
UncapStar: true,
|
||||||
|
'empty': props.empty,
|
||||||
'special': props.special,
|
'special': props.special,
|
||||||
'mlb': !props.special,
|
'mlb': !props.special,
|
||||||
'flb': props.flb,
|
'flb': props.flb,
|
||||||
|
|
@ -19,12 +23,17 @@ const UncapStar = (props: Props) => {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function clicked() {
|
||||||
|
props.onClick(props.index, props.empty)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className={classes}><img alt="" src="/icons/star.svg" /></li>
|
<li className={classes}><img alt="" src="/icons/star.svg" /></li>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
UncapStar.defaultProps = {
|
UncapStar.defaultProps = {
|
||||||
|
empty: false,
|
||||||
special: false,
|
special: false,
|
||||||
flb: false,
|
flb: false,
|
||||||
ulb: false
|
ulb: false
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue