-
-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(coinmarket): add crypto picker for buy/exchange
- Loading branch information
1 parent
36c867d
commit 01c60f3
Showing
16 changed files
with
1,752 additions
and
167 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
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
72 changes: 72 additions & 0 deletions
72
packages/product-components/src/components/SelectAssetModal/AssetItemNotFound.tsx
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Column, Paragraph, Text } from '@trezor/components'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { SelectAssetNetworkProps, SelectAssetSearchCategoryType } from './SelectAssetModal'; | ||
import { spacings } from '@trezor/theme'; | ||
|
||
interface AssetItemNotFoundProps { | ||
searchCategory: SelectAssetSearchCategoryType; | ||
networkCategories: SelectAssetNetworkProps[]; | ||
listHeight: string; | ||
listMinHeight: number; | ||
} | ||
|
||
export const AssetItemNotFound = ({ | ||
searchCategory, | ||
networkCategories, | ||
listHeight, | ||
listMinHeight, | ||
}: AssetItemNotFoundProps) => { | ||
// TODO: resolve messages sharing https://github.com/trezor/trezor-suite/issues/5325 | ||
const translations = searchCategory | ||
? { | ||
heading: { | ||
id: 'TR_TOKEN_NOT_FOUND_ON_NETWORK', | ||
defaultMessage: 'Token not found on the {networkName} network', | ||
values: { | ||
networkName: networkCategories.find( | ||
category => category.coingeckoId === searchCategory.coingeckoId, | ||
)?.name, | ||
}, | ||
}, | ||
paragraph: { | ||
id: 'TR_TOKEN_TRY_DIFFERENT_SEARCH_OR_SWITCH', | ||
defaultMessage: 'Please try a different search or switch to another network.', | ||
}, | ||
} | ||
: { | ||
heading: { | ||
id: 'TR_TOKEN_NOT_FOUND', | ||
defaultMessage: 'Token not found', | ||
}, | ||
paragraph: { | ||
id: 'TR_TOKEN_TRY_DIFFERENT_SEARCH', | ||
defaultMessage: 'Please try a different search.', | ||
}, | ||
}; | ||
|
||
return ( | ||
<Column | ||
alignItems="center" | ||
justifyContent="center" | ||
height={listHeight} | ||
minHeight={listMinHeight} | ||
> | ||
<Text typographyStyle="body"> | ||
<FormattedMessage {...translations.heading} /> | ||
</Text> | ||
<Paragraph | ||
align="center" | ||
maxWidth={280} | ||
margin={{ | ||
top: spacings.xxxs, | ||
left: 'auto', | ||
right: 'auto', | ||
}} | ||
> | ||
<Text variant="tertiary" typographyStyle="hint"> | ||
<FormattedMessage {...translations.paragraph} /> | ||
</Text> | ||
</Paragraph> | ||
</Column> | ||
); | ||
}; |
60 changes: 60 additions & 0 deletions
60
packages/product-components/src/components/SelectAssetModal/CheckableTag.tsx
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { UIVariant } from '@trezor/components/src/config/types'; | ||
import { | ||
borders, | ||
Elevation, | ||
mapElevationToBackground, | ||
mapElevationToBorder, | ||
spacingsPx, | ||
typography, | ||
} from '@trezor/theme'; | ||
import styled, { DefaultTheme } from 'styled-components'; | ||
|
||
export const tagVariants = ['primary', 'tertiary'] as const; | ||
export type TagVariant = Extract<UIVariant, (typeof tagVariants)[number]>; | ||
|
||
interface CheckableTagProps { | ||
$variant: 'primary' | 'tertiary'; | ||
$elevation: Elevation; | ||
} | ||
|
||
const getCheckableTagStyles = ( | ||
$elevation: Elevation, | ||
theme: DefaultTheme, | ||
type: CheckableTagProps['$variant'] | 'hover', | ||
) => { | ||
switch (type) { | ||
case 'primary': | ||
return ` | ||
background: ${theme.backgroundPrimarySubtleOnElevation1}; | ||
color: ${theme.textPrimaryDefault}; | ||
border: 1px solid ${theme.borderSecondary}; | ||
`; | ||
case 'hover': | ||
return ` | ||
background: ${mapElevationToBackground({ $elevation, theme })}; | ||
color: ${theme.textDefault}; | ||
border: 1px solid ${mapElevationToBorder({ $elevation, theme })}; | ||
`; | ||
default: | ||
return ` | ||
background: ${mapElevationToBackground({ $elevation, theme })}; | ||
color: ${theme.textSubdued}; | ||
border: 1px solid ${mapElevationToBackground({ $elevation, theme })}; | ||
`; | ||
} | ||
}; | ||
|
||
export const CheckableTag = styled.button<CheckableTagProps>` | ||
cursor: pointer; | ||
border: 0; | ||
${typography.hint}; | ||
padding: ${spacingsPx.xxs} ${spacingsPx.sm}; | ||
border-radius: ${borders.radii.full}; | ||
${({ $elevation, theme, $variant }) => getCheckableTagStyles($elevation, theme, $variant)} | ||
&:hover { | ||
${({ $elevation, theme, $variant }) => | ||
getCheckableTagStyles($elevation, theme, $variant === 'primary' ? 'primary' : 'hover')} | ||
} | ||
`; |
Oops, something went wrong.