File tree 3 files changed +29
-20
lines changed
src/design-system/asset-input 3 files changed +29
-20
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
1
3
export interface Asset {
2
4
id : string ;
3
5
ticker : string ;
4
6
balance : string ;
5
7
amount : string ;
6
- icon ?: string ;
8
+ icon ?: string | React . ReactNode ;
7
9
}
8
10
9
11
export interface AssetWithFiat extends Asset {
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
1
3
import cardanoImage from '../../assets/images/cardano-blue-bg.png' ;
4
+ import { Image } from '../profile-picture' ;
2
5
3
6
import type { AssetWithFiat , AssetState } from './asset-input.data' ;
4
7
@@ -7,7 +10,7 @@ export const asset: AssetWithFiat = {
7
10
amount : '' ,
8
11
id : '' ,
9
12
ticker : 'Token' ,
10
- icon : cardanoImage ,
13
+ icon : < Image imageSrc = { cardanoImage } /> ,
11
14
fiat : {
12
15
value : '0' ,
13
16
ticker : 'USD' ,
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import * as cx from './ticker-button.css';
11
11
interface Props {
12
12
name : string ;
13
13
id : string ;
14
- icon ?: string ;
14
+ icon ?: string | React . ReactNode ;
15
15
onClick ?: ( ) => void ;
16
16
}
17
17
@@ -20,20 +20,24 @@ export const TickerButton = ({
20
20
id,
21
21
icon,
22
22
onClick,
23
- } : Readonly < Props > ) : JSX . Element => (
24
- < button
25
- className = { cx . button }
26
- onClick = { onClick }
27
- data-testid = { `asset-input-ticker-button-${ id } ` }
28
- >
29
- < Flex alignItems = "center" gap = "$16" >
30
- { icon && < Image imageSrc = { icon } alt = "Token" /> }
31
- < Text . SubHeading weight = "$bold" >
32
- < Flex justifyContent = "center" alignItems = "center" >
33
- < span > { name } </ span >
34
- < ChevronRight className = { cx . chevronIcon } />
35
- </ Flex >
36
- </ Text . SubHeading >
37
- </ Flex >
38
- </ button >
39
- ) ;
23
+ } : Readonly < Props > ) : JSX . Element => {
24
+ const isIconString = typeof icon === 'string' ;
25
+
26
+ return (
27
+ < button
28
+ className = { cx . button }
29
+ onClick = { onClick }
30
+ data-testid = { `asset-input-ticker-button-${ id } ` }
31
+ >
32
+ < Flex alignItems = "center" gap = "$16" >
33
+ { isIconString ? < Image imageSrc = { icon } alt = "Token" /> : icon }
34
+ < Text . SubHeading weight = "$bold" >
35
+ < Flex justifyContent = "center" alignItems = "center" >
36
+ < span > { name } </ span >
37
+ < ChevronRight className = { cx . chevronIcon } />
38
+ </ Flex >
39
+ </ Text . SubHeading >
40
+ </ Flex >
41
+ </ button >
42
+ ) ;
43
+ } ;
You can’t perform that action at this time.
0 commit comments