@@ -28,13 +28,20 @@ const StyledTypography = styled(Typography)<{ selected: boolean }>(({ theme, sel
2828 color : selected ? theme . palette . primary . main : theme . palette . grey [ 500 ] ,
2929} ) )
3030
31+ const StyledCaption = styled ( Typography ) < { selected : boolean } > ( ( { theme, selected } ) => ( {
32+ fontSize : 10 ,
33+ textTransform : 'none' ,
34+ color : selected ? theme . palette . primary . main : theme . palette . grey [ 500 ] ,
35+ marginLeft : '1px' ,
36+ } ) )
37+
3138interface ImgButtonGroupProps {
3239 title ?: string
3340 description ?: string
3441 name : string
3542 control : any
3643 value : string
37- options : { value : string ; label : string ; imgSrc : string } [ ]
44+ options : { value : string ; label : string ; imgSrc ?: string ; caption ? : string } [ ]
3845 onChange ?: ( value : string ) => void
3946 disabled ?: boolean
4047}
@@ -75,18 +82,29 @@ function ImgButtonGroup({
7582 } }
7683 selected = { field . value === option . value }
7784 >
78- < img
79- style = { { width : 20 , height : 20 } }
80- src = { option . imgSrc }
81- onError = { ( { currentTarget } ) => {
82- // eslint-disable-next-line no-param-reassign
83- currentTarget . onerror = null // prevents looping
84- // eslint-disable-next-line no-param-reassign
85- currentTarget . src = `${ option . imgSrc } `
85+ { option . imgSrc && (
86+ < img
87+ style = { { width : 20 , height : 20 } }
88+ src = { option . imgSrc }
89+ onError = { ( { currentTarget } ) => {
90+ // eslint-disable-next-line no-param-reassign
91+ currentTarget . onerror = null // prevents looping
92+ // eslint-disable-next-line no-param-reassign
93+ currentTarget . src = `${ option . imgSrc } `
94+ } }
95+ alt = { `Logo for ${ option . imgSrc } ` }
96+ />
97+ ) }
98+ < Box
99+ sx = { {
100+ display : 'flex' ,
101+ flexDirection : 'column' ,
102+ alignItems : 'flex-start' ,
86103 } }
87- alt = { `Logo for ${ option . imgSrc } ` }
88- />
89- < StyledTypography selected = { field . value === option . value } > { option . label } </ StyledTypography >
104+ >
105+ < StyledTypography selected = { field . value === option . value } > { option . label } </ StyledTypography >
106+ < StyledCaption selected = { field . value === option . value } > { option . caption } </ StyledCaption >
107+ </ Box >
90108 </ StyledButton >
91109 ) ) }
92110 </ Box >
0 commit comments