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