1
1
import React , { useCallback } from 'react' ;
2
2
import styled from 'styled-components' ;
3
3
import { colors } from '../../../config.json' ;
4
+ import { messages } from '../../../shared/gettext' ;
5
+ import { AriaDescribed , AriaDescription , AriaDescriptionGroup } from '../AriaGroup' ;
4
6
import ImageView from '../ImageView' ;
5
7
import * as Cell from '.' ;
6
8
@@ -40,6 +42,22 @@ export default function CellList<T>(props: ICellListProps<T>) {
40
42
) ;
41
43
}
42
44
45
+ const StyledContainer = styled ( Cell . Container ) ( {
46
+ display : 'flex' ,
47
+ marginBottom : '1px' ,
48
+ backgroundColor : colors . blue40 ,
49
+ } ) ;
50
+
51
+ const StyledButton = styled . button ( {
52
+ display : 'flex' ,
53
+ alignItems : 'center' ,
54
+ flex : 1 ,
55
+ border : 'none' ,
56
+ background : 'transparent' ,
57
+ padding : 0 ,
58
+ margin : 0 ,
59
+ } ) ;
60
+
43
61
const StyledLabel = styled ( Cell . Label ) ( { } , ( props : { paddingLeft : number } ) => ( {
44
62
fontFamily : 'Open Sans' ,
45
63
fontWeight : 'normal' ,
@@ -51,6 +69,18 @@ const StyledLabel = styled(Cell.Label)({}, (props: { paddingLeft: number }) => (
51
69
marginRight : '25px' ,
52
70
} ) ) ;
53
71
72
+ const StyledRemoveButton = styled . button ( {
73
+ background : 'transparent' ,
74
+ border : 'none' ,
75
+ padding : 0 ,
76
+ } ) ;
77
+
78
+ const StyledRemoveIcon = styled ( ImageView ) ( {
79
+ [ StyledRemoveButton + ':hover &' ] : {
80
+ backgroundColor : colors . white80 ,
81
+ } ,
82
+ } ) ;
83
+
54
84
interface ICellListItemProps < T > {
55
85
value : T ;
56
86
onSelect ?: ( application : T ) => void ;
@@ -64,18 +94,30 @@ function CellListItem<T>(props: ICellListItemProps<T>) {
64
94
const onRemove = useCallback ( ( ) => props . onRemove ?.( props . value ) , [ props . onRemove , props . value ] ) ;
65
95
66
96
return (
67
- < Cell . CellButton onClick = { props . onSelect ? onSelect : undefined } >
68
- < StyledLabel paddingLeft = { props . paddingLeft } > { props . children } </ StyledLabel >
69
- { props . onRemove && (
70
- < ImageView
71
- source = "icon-close"
72
- width = { 22 }
73
- height = { 22 }
74
- onClick = { onRemove }
75
- tintColor = { colors . white60 }
76
- tintHoverColor = { colors . white80 }
77
- />
78
- ) }
79
- </ Cell . CellButton >
97
+ < AriaDescriptionGroup >
98
+ < StyledContainer >
99
+ < StyledButton
100
+ onClick = { props . onSelect ? onSelect : undefined }
101
+ as = { props . onSelect ? 'button' : 'span' } >
102
+ < AriaDescription >
103
+ < StyledLabel paddingLeft = { props . paddingLeft } > { props . children } </ StyledLabel >
104
+ </ AriaDescription >
105
+ </ StyledButton >
106
+ { props . onRemove && (
107
+ < AriaDescribed >
108
+ < StyledRemoveButton
109
+ onClick = { onRemove }
110
+ aria-label = { messages . pgettext ( 'accessibility' , 'Remove item' ) } >
111
+ < StyledRemoveIcon
112
+ source = "icon-close"
113
+ width = { 22 }
114
+ height = { 22 }
115
+ tintColor = { colors . white60 }
116
+ />
117
+ </ StyledRemoveButton >
118
+ </ AriaDescribed >
119
+ ) }
120
+ </ StyledContainer >
121
+ </ AriaDescriptionGroup >
80
122
) ;
81
123
}
0 commit comments