Skip to content

Commit

Permalink
AC-2492::Missing visual text label for buttons (#3952)
Browse files Browse the repository at this point in the history
* AC-2492::Missing visual text label for buttons

* AC-2492::Missing visual text label for buttons

* AC-2492::added lint and preetier command feedabck

* AC-2492::made changes according to thr PR comment

* AC-2492::run yarn prettier on swatch.spec.js

* AC-2492::run yarn prettier on swatch.spec.js

* AC-2492::run yarn prettier on swatch.spec.js

Co-authored-by: James Calcaben <jcalcaben@users.noreply.github.com>
Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 11, 2022
1 parent 170e66c commit 42b6d91
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`appends "_focused" to className if hasFocus is true 1`] = `
<button
aria-label="Color's option red"
className="root_focused"
onClick={[Function]}
style={
Expand Down Expand Up @@ -37,6 +38,7 @@ exports[`appends "_focused" to className if hasFocus is true 1`] = `

exports[`appends "_outOfStock" to className if isEverythingOutOfStock is true 1`] = `
<button
aria-label="Color's option red"
className="root_outOfStock"
disabled={true}
onClick={[Function]}
Expand Down Expand Up @@ -73,6 +75,7 @@ exports[`appends "_outOfStock" to className if isEverythingOutOfStock is true 1`

exports[`appends "_outOfStock" to className if isOptionOutOfStock is true 1`] = `
<button
aria-label="Color's option red"
className="root_outOfStock"
disabled={true}
onClick={[Function]}
Expand All @@ -88,6 +91,7 @@ exports[`appends "_outOfStock" to className if isOptionOutOfStock is true 1`] =

exports[`appends "_selected" to className if isSelected is true 1`] = `
<button
aria-label="Color's Selected option red"
className="root_selected"
onClick={[Function]}
style={
Expand Down Expand Up @@ -123,6 +127,7 @@ exports[`appends "_selected" to className if isSelected is true 1`] = `

exports[`renders a Swatch correctly 1`] = `
<button
aria-label="Color's option red"
className="root"
onClick={[Function]}
style={
Expand Down Expand Up @@ -158,6 +163,7 @@ exports[`renders a Swatch correctly 1`] = `

exports[`renders an icon if isSelected is true 1`] = `
<button
aria-label="Color's Selected option red"
className="root_selected"
onClick={[Function]}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`renders SwatchList component correctly 1`] = `
className="root"
>
<button
aria-label="undefined's option foo"
className="root"
onClick={[Function]}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const defaultProps = {
swatch_data: {
value: '#123123'
}
}
},
attributeLabel: 'Color'
};

test('renders a Swatch correctly', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/venia-ui/lib/components/ProductOptions/option.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const Option = props => {
onSelectionChange={handleSelectionChange}
isEverythingOutOfStock={isEverythingOutOfStock}
outOfStockVariants={outOfStockVariants}
attributeLabel={label}
/>
<dl className={classes.selection}>
<dt
Expand Down
7 changes: 5 additions & 2 deletions packages/venia-ui/lib/components/ProductOptions/swatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const Swatch = props => {
onClick,
style,
isEverythingOutOfStock,
isOptionOutOfStock
isOptionOutOfStock,
attributeLabel
} = props;

const talonProps = useSwatch({
Expand Down Expand Up @@ -83,7 +84,8 @@ const Swatch = props => {
'--venia-swatch-bg': swatchValue
});
}

const selectedText = isSelected ? 'Selected' : '';
const ariaLabel = `${attributeLabel}'s ${selectedText} option ${label}`;
const className =
classes[
getClassName(
Expand All @@ -104,6 +106,7 @@ const Swatch = props => {
type="button"
data-cy="Swatch-root"
disabled={isEverythingOutOfStock || isOptionOutOfStock}
aria-label={ariaLabel}
>
{!isOptionOutOfStock && (
<Icon classes={{ root: checkStyle }} src={CheckIcon} />
Expand Down
7 changes: 5 additions & 2 deletions packages/venia-ui/lib/components/ProductOptions/swatchList.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const SwatchList = props => {
items,
onSelectionChange,
isEverythingOutOfStock,
outOfStockVariants
outOfStockVariants,
attributeLabel
} = props;

const classes = useStyle(defaultClasses, props.classes);
Expand All @@ -35,6 +36,7 @@ const SwatchList = props => {
onClick={onSelectionChange}
isEverythingOutOfStock={isEverythingOutOfStock}
isOptionOutOfStock={isOptionOutOfStock}
attributeLabel={attributeLabel}
/>
);
}),
Expand All @@ -44,7 +46,8 @@ const SwatchList = props => {
items,
onSelectionChange,
isEverythingOutOfStock,
outOfStockVariants
outOfStockVariants,
attributeLabel
]
);

Expand Down

0 comments on commit 42b6d91

Please sign in to comment.