2021-07-15 00:09:42 +02:00
|
|
|
import React from 'react';
|
|
|
|
// import { Arrow } from './Arrow';
|
|
|
|
import './NumberSelector.css'
|
|
|
|
|
|
|
|
// setType: (txt: string) => void
|
|
|
|
// choices: { label: string, value: string }[]
|
|
|
|
// selected: string
|
|
|
|
export function NumberSelector({ setType, choices, selected }) {
|
2021-07-15 21:04:47 +02:00
|
|
|
|
|
|
|
choices.forEach(choice => {
|
|
|
|
if(choice.percentage > 3) choice.percentage = Math.max(20, choice.percentage < 90 ? choice.percentage : 100)
|
|
|
|
})
|
|
|
|
|
2021-07-15 00:09:42 +02:00
|
|
|
return (
|
|
|
|
<div className="numberSelector">
|
|
|
|
{choices.map(v=>(
|
|
|
|
<div key={v.value} className="choiceWrapper">
|
2021-07-15 21:04:47 +02:00
|
|
|
<div className={`choice ${selected&&selected===v.value?'selected':''}`} onClick={() => setType(v.value)}>
|
2021-07-15 00:09:42 +02:00
|
|
|
{v.label}
|
2021-07-15 21:04:47 +02:00
|
|
|
{v.percentage > 0 ? (
|
|
|
|
<div class="progressBar">
|
|
|
|
<div class="progressBarInner" style={{width: `${v.percentage}%`}}></div>
|
|
|
|
</div>
|
|
|
|
) : ''}
|
2021-07-15 00:09:42 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|