@@ -250,40 +250,48 @@ class ColorPreset extends Component<ColorPresetProps, ColorPresetState> {
250250 : this . renderIndicatorTooltip ( indicatorBase , color )
251251 }
252252
253- renderIndicatorBase = ( color : string , selectOnClick ?: boolean ) => (
254- < View
255- disabled = { this . props . disabled }
256- position = "relative"
257- width = "2.375rem"
258- height = "2.375rem"
259- background = "transparent"
260- margin = "xx-small"
261- display = "inline-block"
262- borderRadius = "medium"
263- borderWidth = "0"
264- padding = "0"
265- cursor = { this . props . disabled ? 'not-allowed' : 'auto' }
266- as = "button"
267- { ...( selectOnClick ? { onClick : ( ) => this . props . onSelect ( color ) } : { } ) }
268- { ...{
269- 'aria-label' : `${ color } ${
270- this . isSelectedColor ( color ) ? ' selected' : ''
271- } `
272- } }
273- >
274- < div >
275- < ColorIndicator color = { color } shape = "rectangle" role = "presentation" />
276- { this . isSelectedColor ( color ) && (
277- < div css = { this . props ?. styles ?. selectedIndicator } >
278- < IconCheckDarkSolid
279- themeOverride = { { sizeXSmall : '0.8rem' } }
280- size = "x-small"
281- />
282- </ div >
283- ) }
284- </ div >
285- </ View >
286- )
253+ renderIndicatorBase = ( color : string , selectOnClick ?: boolean ) => {
254+ const hexCode = color
255+ const isSelected = this . isSelectedColor ( color )
256+
257+ const screenReaderLabel =
258+ typeof this . props . colorScreenReaderLabel === 'function'
259+ ? this . props . colorScreenReaderLabel ( hexCode , isSelected )
260+ : hexCode
261+
262+ return (
263+ < View
264+ disabled = { this . props . disabled }
265+ position = "relative"
266+ width = "2.375rem"
267+ height = "2.375rem"
268+ background = "transparent"
269+ margin = "xx-small"
270+ display = "inline-block"
271+ borderRadius = "medium"
272+ borderWidth = "0"
273+ padding = "0"
274+ cursor = { this . props . disabled ? 'not-allowed' : 'auto' }
275+ as = "button"
276+ aria-label = { screenReaderLabel }
277+ { ...( selectOnClick
278+ ? { onClick : ( ) => this . props . onSelect ( color ) }
279+ : { } ) }
280+ >
281+ < div >
282+ < ColorIndicator color = { color } shape = "rectangle" role = "presentation" />
283+ { this . isSelectedColor ( color ) && (
284+ < div css = { this . props ?. styles ?. selectedIndicator } >
285+ < IconCheckDarkSolid
286+ themeOverride = { { sizeXSmall : '0.8rem' } }
287+ size = "x-small"
288+ />
289+ </ div >
290+ ) }
291+ </ div >
292+ </ View >
293+ )
294+ }
287295
288296 renderIndicatorTooltip = ( child : React . ReactElement , color : string ) => {
289297 return (
0 commit comments