Merged in feat/BOOK-119-accessibility-replace-radiogroup (pull request #3081)
feat(BOOK-119): replace radio group on select rate with buttons and make them accessible * feat(BOOK-119): replace radio group on select rate with buttons and make them accessible * feat(BOOK-119): update roomNR * feat(BOOK-119): update onpress and buttonOverlay name change Approved-by: Erik Tiekstra
This commit is contained in:
@@ -6,10 +6,12 @@ import { Typography } from '../../Typography'
|
||||
import Modal from '../Modal'
|
||||
import styles from '../rate-card.module.css'
|
||||
import { variants } from '../variants'
|
||||
import { Button as ButtonRAC } from 'react-aria-components'
|
||||
import { cx } from 'class-variance-authority'
|
||||
import { useIntl } from 'react-intl'
|
||||
|
||||
interface CodeRateCardProps {
|
||||
name: string
|
||||
value: string
|
||||
id: string
|
||||
isSelected: boolean
|
||||
rateTitle: string
|
||||
paymentTerm: string
|
||||
@@ -24,8 +26,7 @@ interface CodeRateCardProps {
|
||||
}
|
||||
|
||||
export default function CodeRateCard({
|
||||
name,
|
||||
value,
|
||||
id,
|
||||
isSelected,
|
||||
rateTitle,
|
||||
paymentTerm,
|
||||
@@ -40,119 +41,131 @@ export default function CodeRateCard({
|
||||
const classNames = variants({
|
||||
variant: 'Code',
|
||||
})
|
||||
const intl = useIntl()
|
||||
|
||||
return (
|
||||
<label>
|
||||
<input
|
||||
className={styles.radio}
|
||||
type="radio"
|
||||
name={name}
|
||||
value={value}
|
||||
checked={isSelected}
|
||||
onChange={handleChange}
|
||||
<div
|
||||
className={cx(classNames, {
|
||||
[styles.selected]: isSelected,
|
||||
})}
|
||||
>
|
||||
<ButtonRAC
|
||||
onPress={handleChange}
|
||||
className={styles.buttonOverlay}
|
||||
aria-pressed={isSelected}
|
||||
aria-labelledby={`${id}-title`}
|
||||
aria-describedby={`${id}-details`}
|
||||
/>
|
||||
<div className={classNames}>
|
||||
<Typography variant="Label/xsBold">
|
||||
<p className={styles.banner}>{bannerText}</p>
|
||||
</Typography>
|
||||
<div className={styles.container}>
|
||||
<header>
|
||||
<Typography variant="Tag/sm">
|
||||
<h3 className={styles.title}>
|
||||
<Modal
|
||||
title={rateTitle}
|
||||
subtitle={paymentTerm}
|
||||
trigger={
|
||||
<IconButton theme="Black" style="Muted" wrapping>
|
||||
<MaterialIcon
|
||||
icon="info"
|
||||
size={20}
|
||||
color="Icon/Default"
|
||||
/>
|
||||
</IconButton>
|
||||
}
|
||||
<Typography variant="Label/xsBold">
|
||||
<p className={styles.banner}>{bannerText}</p>
|
||||
</Typography>
|
||||
<div className={styles.container}>
|
||||
<Typography variant="Tag/sm">
|
||||
<h3 className={styles.title}>
|
||||
<Modal
|
||||
title={rateTitle}
|
||||
subtitle={paymentTerm}
|
||||
trigger={
|
||||
<IconButton
|
||||
theme="Black"
|
||||
style="Muted"
|
||||
wrapping
|
||||
className={styles.triggerButton}
|
||||
aria-label={intl.formatMessage({
|
||||
id: 'selectRate.rateCard.openReservationPolicy',
|
||||
defaultMessage: 'Open reservation policy',
|
||||
})}
|
||||
>
|
||||
{rateTermDetails.map((termGroup) => (
|
||||
<div key={termGroup.title} className={styles.terms}>
|
||||
<Typography variant={'Body/Paragraph/mdBold'}>
|
||||
<p>{termGroup.title}</p>
|
||||
</Typography>
|
||||
{termGroup.terms.map((term) => (
|
||||
<Typography key={term}>
|
||||
<p className={styles.term}>
|
||||
<MaterialIcon
|
||||
icon="check"
|
||||
color="Icon/Feedback/Success"
|
||||
size={20}
|
||||
className={styles.termsIcon}
|
||||
/>
|
||||
{term}
|
||||
</p>
|
||||
</Typography>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</Modal>
|
||||
{rateTitle}
|
||||
<span className={styles.textSecondary}>
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
{` / ${paymentTerm}`}
|
||||
</span>
|
||||
</h3>
|
||||
</Typography>
|
||||
<div className={styles.checkIcon}>
|
||||
<MaterialIcon icon="check" size={22} color="Icon/Inverted" />
|
||||
</div>
|
||||
</header>
|
||||
<div className={styles.content}>
|
||||
<div
|
||||
className={`${styles.rateRow} ${isHighlightedRate ? styles.highlightedRate : ''}`}
|
||||
<MaterialIcon icon="info" size={20} color="Icon/Default" />
|
||||
</IconButton>
|
||||
}
|
||||
>
|
||||
<Typography variant="Body/Supporting text (caption)/smBold">
|
||||
<p>{rate.label}</p>
|
||||
</Typography>
|
||||
{rateTermDetails.map((termGroup) => (
|
||||
<div key={termGroup.title} className={styles.terms}>
|
||||
<Typography variant={'Body/Paragraph/mdBold'}>
|
||||
<p>{termGroup.title}</p>
|
||||
</Typography>
|
||||
{termGroup.terms.map((term) => (
|
||||
<Typography key={term}>
|
||||
<p className={styles.term}>
|
||||
<MaterialIcon
|
||||
icon="check"
|
||||
color="Icon/Feedback/Success"
|
||||
size={20}
|
||||
className={styles.termsIcon}
|
||||
/>
|
||||
{term}
|
||||
</p>
|
||||
</Typography>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</Modal>
|
||||
<span id={`${id}-title`}>
|
||||
{rateTitle}
|
||||
<span className={styles.textSecondary}>
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
{` / ${paymentTerm}`}
|
||||
</span>
|
||||
</span>
|
||||
</h3>
|
||||
</Typography>
|
||||
<div className={styles.content} id={`${id}-details`}>
|
||||
<div
|
||||
className={`${styles.rateRow} ${isHighlightedRate ? styles.highlightedRate : ''}`}
|
||||
>
|
||||
<Typography variant="Body/Supporting text (caption)/smBold">
|
||||
<p>{rate.label}</p>
|
||||
</Typography>
|
||||
<Typography variant="Title/Subtitle/md">
|
||||
<p>
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
{`${rate.price} `}
|
||||
<Typography variant="Body/Supporting text (caption)/smBold">
|
||||
<span>{rate.unit}</span>
|
||||
</Typography>
|
||||
</p>
|
||||
</Typography>
|
||||
</div>
|
||||
{comparisonRate ? (
|
||||
<div className={`${styles.rateRow} ${styles.comparisonRate}`}>
|
||||
<Typography variant="Title/Subtitle/md">
|
||||
<p>
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
{`${rate.price} `}
|
||||
<span className={styles.strikethrough}>
|
||||
{comparisonRate.price}
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
</span>{' '}
|
||||
<Typography variant="Body/Supporting text (caption)/smBold">
|
||||
<span>{rate.unit}</span>
|
||||
<span className={styles.strikethrough}>
|
||||
{comparisonRate.unit}
|
||||
</span>
|
||||
</Typography>
|
||||
</p>
|
||||
</Typography>
|
||||
</div>
|
||||
{comparisonRate ? (
|
||||
<div className={`${styles.rateRow} ${styles.comparisonRate}`}>
|
||||
<Typography variant="Title/Subtitle/md">
|
||||
<p>
|
||||
<span className={styles.strikethrough}>
|
||||
{comparisonRate.price}
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
</span>{' '}
|
||||
<Typography variant="Body/Supporting text (caption)/smBold">
|
||||
<span className={styles.strikethrough}>
|
||||
{comparisonRate.unit}
|
||||
</span>
|
||||
</Typography>
|
||||
</p>
|
||||
</Typography>
|
||||
</div>
|
||||
) : null}
|
||||
{approximateRate ? (
|
||||
<div className={`${styles.rateRow} ${styles.approximateRate}`}>
|
||||
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||
<p>{approximateRate.label}</p>
|
||||
</Typography>
|
||||
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||
<p>
|
||||
{approximateRate.price} {approximateRate.unit}
|
||||
</p>
|
||||
</Typography>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
{approximateRate ? (
|
||||
<div className={`${styles.rateRow} ${styles.approximateRate}`}>
|
||||
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||
<p>{approximateRate.label}</p>
|
||||
</Typography>
|
||||
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||
<p>
|
||||
{approximateRate.price} {approximateRate.unit}
|
||||
</p>
|
||||
</Typography>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
{isSelected && (
|
||||
<MaterialIcon
|
||||
icon="check"
|
||||
size={22}
|
||||
color="Icon/Inverted"
|
||||
className={styles.checkIcon}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user