diff --git a/plugins/woocommerce-admin/client/customize-store/intro/color-palettes.tsx b/plugins/woocommerce-admin/client/customize-store/intro/color-palettes.tsx
index 94e45e9dd47..cce1a21b986 100644
--- a/plugins/woocommerce-admin/client/customize-store/intro/color-palettes.tsx
+++ b/plugins/woocommerce-admin/client/customize-store/intro/color-palettes.tsx
@@ -1,8 +1,16 @@
+/**
+ * External dependencies
+ */
+import { useInstanceId } from '@wordpress/compose';
+import { __, sprintf } from '@wordpress/i18n';
+
/**
* Internal dependencies
*/
import { ColorPalette } from './types';
+const MAX_COLOR_PALETTES = 4;
+
export const ColorPalettes = ( {
colorPalettes,
totalPalettes,
@@ -10,33 +18,71 @@ export const ColorPalettes = ( {
colorPalettes: ColorPalette[];
totalPalettes: number;
} ) => {
- let extra = null;
+ const canFit = totalPalettes <= MAX_COLOR_PALETTES;
- if ( totalPalettes > 4 ) {
- extra =
+{ totalPalettes - 4 };
+ const descriptionId = useInstanceId(
+ ColorPalettes,
+ 'color-palettes-description'
+ ) as string;
+
+ function renderMore() {
+ if ( canFit ) return null;
+ return (
+
+ +{ totalPalettes - 4 }
+
+ );
+ }
+
+ function renderDescription() {
+ if ( canFit ) return null;
+ return (
+
+ { sprintf(
+ /* translators: $d is the total amount of color palettes */
+ __(
+ 'There are a total of %d color palettes',
+ 'woocommerce'
+ ),
+ totalPalettes
+ ) }
+
+ );
}
return (
-
- { colorPalettes.map( ( colorPalette ) => (
-
- ) ) }
- { extra }
-
+ <>
+
+ { colorPalettes.map( ( colorPalette ) => (
+
+ ) ) }
+ { renderMore() }
+
+
+ { renderDescription() }
+ >
);
};
diff --git a/plugins/woocommerce-admin/client/customize-store/intro/intro.scss b/plugins/woocommerce-admin/client/customize-store/intro/intro.scss
index cd47827cdea..144ca7e8b6d 100644
--- a/plugins/woocommerce-admin/client/customize-store/intro/intro.scss
+++ b/plugins/woocommerce-admin/client/customize-store/intro/intro.scss
@@ -314,6 +314,10 @@
text-align: center;
}
}
+
+ &-description {
+ @include visually-hidden();
+ }
}
.theme-card__free {
diff --git a/plugins/woocommerce/changelog/add-51574 b/plugins/woocommerce/changelog/add-51574
new file mode 100644
index 00000000000..cb98b7ee856
--- /dev/null
+++ b/plugins/woocommerce/changelog/add-51574
@@ -0,0 +1,4 @@
+Significance: patch
+Type: add
+
+Add a11y to the color swatches