-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refactor/token-input' into refactor/theme
- Loading branch information
Showing
7 changed files
with
56 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,22 @@ | ||
import { useMemo } from 'react'; | ||
|
||
import { CoinIcon } from '../CoinIcon'; | ||
import { FlexProps } from '../Flex'; | ||
|
||
import { StyledTicker, StyledTokenAdornment } from './TokenInput.style'; | ||
|
||
type SingleToken = string; | ||
|
||
type MultiToken = { text: string; icons: string[] }; | ||
|
||
type TokenTicker = SingleToken | MultiToken; | ||
import { StyledTicker, StyledTokenAdornment, StyledTokenImg } from './TokenInput.style'; | ||
|
||
type Props = { | ||
ticker?: TokenTicker; | ||
ticker: string; | ||
logoUrl: string; | ||
}; | ||
|
||
type NativeAttrs = Omit<FlexProps, keyof Props>; | ||
|
||
type TokenAdornmentProps = Props & NativeAttrs; | ||
|
||
const TokenAdornment = ({ ticker = '', ...props }: TokenAdornmentProps): JSX.Element => { | ||
const { tickerText, tickers } = useMemo(() => { | ||
if (typeof ticker === 'object') { | ||
return { | ||
tickerText: ticker.text, | ||
tickers: ticker.icons | ||
}; | ||
} | ||
|
||
return { | ||
tickerText: ticker, | ||
tickers: undefined | ||
}; | ||
}, [ticker]); | ||
|
||
return ( | ||
<StyledTokenAdornment {...props} alignItems='center' gap='spacing1' justifyContent='space-evenly'> | ||
<CoinIcon ticker={tickerText} tickers={tickers} /> | ||
<StyledTicker>{tickerText}</StyledTicker> | ||
</StyledTokenAdornment> | ||
); | ||
}; | ||
const TokenAdornment = ({ ticker, logoUrl, ...props }: TokenAdornmentProps): JSX.Element => ( | ||
<StyledTokenAdornment {...props} alignItems='center' gap='spacing1' justifyContent='space-evenly'> | ||
<StyledTokenImg alt={ticker} src={logoUrl} /> | ||
<StyledTicker>{ticker}</StyledTicker> | ||
</StyledTokenAdornment> | ||
); | ||
|
||
export { TokenAdornment }; | ||
export type { TokenAdornmentProps, TokenTicker }; | ||
export type { TokenAdornmentProps }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters