|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
import React, { useContext } from 'react'; |
|
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
|
import classNames from 'classnames'; |
|
|
|
|
import { I18nContext } from '../../../contexts/i18n'; |
|
|
|
|
import Typography from '../typography/typography'; |
|
|
|
|
import { |
|
|
|
@ -11,13 +12,22 @@ import { |
|
|
|
|
export default function RadioGroup({ options, name, selectedValue, onChange }) { |
|
|
|
|
const t = useContext(I18nContext); |
|
|
|
|
|
|
|
|
|
const hasRecommendation = Boolean( |
|
|
|
|
options.find((option) => option.recommended), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div className="radio-group"> |
|
|
|
|
<div |
|
|
|
|
className={classNames('radio-group', { |
|
|
|
|
'radio-group--has-recommendation': hasRecommendation, |
|
|
|
|
})} |
|
|
|
|
> |
|
|
|
|
{options.map((option) => { |
|
|
|
|
const checked = option.value === selectedValue; |
|
|
|
|
return ( |
|
|
|
|
<div className="radio-group__column" key={`${name}-${option.value}`}> |
|
|
|
|
<label> |
|
|
|
|
{hasRecommendation && ( |
|
|
|
|
<Typography |
|
|
|
|
color={COLORS.SUCCESS3} |
|
|
|
|
className="radio-group__column-recommended" |
|
|
|
@ -25,7 +35,7 @@ export default function RadioGroup({ options, name, selectedValue, onChange }) { |
|
|
|
|
> |
|
|
|
|
{option.recommended ? t('recommendedGasLabel') : ''} |
|
|
|
|
</Typography> |
|
|
|
|
|
|
|
|
|
)} |
|
|
|
|
<div className="radio-group__column-radio"> |
|
|
|
|
<input |
|
|
|
|
type="radio" |
|
|
|
|