mirror of
https://github.com/vercel/commerce.git
synced 2025-06-18 21:21:21 +00:00
add roles and aria-selected to the product page's swatches
Currently for a user with a screen reader it would be near impossible to use this page. This change will read clearly what the swatch is and for what group it belongs.
This commit is contained in:
parent
936f149fcc
commit
1c3bd853fb
@ -104,7 +104,7 @@ const ProductView: FC<Props> = ({ product }) => {
|
|||||||
{product.options?.map((opt) => (
|
{product.options?.map((opt) => (
|
||||||
<div className="pb-4" key={opt.displayName}>
|
<div className="pb-4" key={opt.displayName}>
|
||||||
<h2 className="uppercase font-medium">{opt.displayName}</h2>
|
<h2 className="uppercase font-medium">{opt.displayName}</h2>
|
||||||
<div className="flex flex-row py-4">
|
<div role="listbox" className="flex flex-row py-4">
|
||||||
{opt.values.map((v, i: number) => {
|
{opt.values.map((v, i: number) => {
|
||||||
const active = (choices as any)[
|
const active = (choices as any)[
|
||||||
opt.displayName.toLowerCase()
|
opt.displayName.toLowerCase()
|
||||||
|
@ -39,7 +39,9 @@ const Swatch: FC<Omit<ButtonProps, 'variant'> & Props> = ({
|
|||||||
<Button
|
<Button
|
||||||
className={rootClassName}
|
className={rootClassName}
|
||||||
style={color ? { backgroundColor: color } : {}}
|
style={color ? { backgroundColor: color } : {}}
|
||||||
aria-label="Variant Swatch"
|
role="option"
|
||||||
|
aria-label={`${variant} ${label}`}
|
||||||
|
aria-selected={active}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{variant === 'color' && active && (
|
{variant === 'color' && active && (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user