-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
630 additions
and
280 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { FC, ReactNode } from 'react' | ||
import { Network } from '../../../types/network' | ||
import { ThemeProvider } from '@mui/material/styles' | ||
import { getThemesForNetworks } from '../../../styles/theme' | ||
import CssBaseline from '@mui/material/CssBaseline' | ||
|
||
export const ThemeByNetwork: FC<{ network: Network; children: React.ReactNode }> = ({ | ||
network, | ||
children, | ||
}) => ( | ||
<ThemeProvider theme={getThemesForNetworks()[network]}> | ||
<CssBaseline /> | ||
{children} | ||
</ThemeProvider> | ||
) | ||
|
||
export const withDefaultTheme = (node: ReactNode) => ( | ||
<ThemeByNetwork network={Network.mainnet}>{node}</ThemeByNetwork> | ||
) |
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
116 changes: 116 additions & 0 deletions
116
src/app/pages/SearchResultsPage/ResultsOnForeignNetworkThemed.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,116 @@ | ||
import { FC, useState } from 'react' | ||
import { getNetworkNames, Network } from '../../../types/network' | ||
import { Trans, useTranslation } from 'react-i18next' | ||
import { styled, useTheme } from '@mui/material/styles' | ||
import { getThemesForNetworks } from '../../../styles/theme' | ||
import useMediaQuery from '@mui/material/useMediaQuery' | ||
import Box from '@mui/material/Box' | ||
import { ResultsOnNetwork } from './ResultsOnNetwork' | ||
import { SearchQueries } from './hooks' | ||
import { COLORS } from '../../../styles/theme/colors' | ||
import ZoomIn from '@mui/icons-material/ZoomIn' | ||
import Warning from '@mui/icons-material/Warning' | ||
|
||
const NotificationBox = styled(Box)(({ theme }) => ({ | ||
// TODO: this is probably not fully correct. | ||
marginTop: 10, | ||
marginBottom: 20, | ||
fontSize: 14, | ||
|
||
boxSizing: 'border-box', | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
padding: '5px 10px', | ||
gap: 10, | ||
|
||
height: 50, | ||
|
||
background: theme.palette.background.default, | ||
border: `2px solid ${theme.palette.layout.border}`, | ||
color: theme.palette.layout.main, | ||
|
||
borderRadius: 50, | ||
})) | ||
|
||
/** | ||
* Component for selectively displaying a subset of search results that belongs to a specific foreign network, | ||
* with appropriate theming and collapse/open functionality. | ||
* | ||
* It doesn't actually run a search query, but uses existing results. | ||
* Except the theming and the collapse functionality, it relies on ResultsOnNetwork. | ||
*/ | ||
export const ResultsOnForeignNetworkThemed: FC<{ | ||
network: Network | ||
alsoHasLocalResults: boolean | ||
openByDefault?: boolean | ||
searchQueries: SearchQueries | ||
numberOfResults: number | ||
roseFiatValue: number | undefined | ||
}> = ({ | ||
network, | ||
searchQueries, | ||
numberOfResults, | ||
roseFiatValue, | ||
openByDefault = false, | ||
alsoHasLocalResults, | ||
}) => { | ||
const [open, setOpen] = useState(openByDefault) | ||
const { t } = useTranslation() | ||
const theme = useTheme() | ||
const isMobile = useMediaQuery(theme.breakpoints.down('sm')) | ||
const networkName = getNetworkNames(t)[network] | ||
if (!numberOfResults) { | ||
return null | ||
} | ||
const otherTheme = getThemesForNetworks()[network] | ||
|
||
if (!open) { | ||
return ( | ||
<NotificationBox theme={otherTheme} onClick={() => setOpen(true)}> | ||
<ZoomIn /> | ||
<span> | ||
<Trans | ||
t={t} | ||
i18nKey={ | ||
alsoHasLocalResults | ||
? 'search.otherResults.clickToShowMore' | ||
: 'search.otherResults.clickToShowThem' | ||
} | ||
values={{ | ||
countLabel: t(alsoHasLocalResults ? 'search.results.moreCount' : 'search.results.count', { | ||
count: numberOfResults, | ||
}), | ||
networkName, | ||
}} | ||
/> | ||
</span> | ||
</NotificationBox> | ||
) | ||
} | ||
return ( | ||
<Box | ||
sx={{ | ||
marginTop: 50, | ||
pt: 4, | ||
px: isMobile ? 0 : '4%', | ||
border: isMobile ? 'none' : `solid 15px ${otherTheme.palette.layout.border}`, | ||
background: otherTheme.palette.background.default, | ||
}} | ||
> | ||
<NotificationBox | ||
sx={{ | ||
background: COLORS.white, // TODO should come from theme | ||
color: COLORS.grayDark, // TODO should come from theme | ||
border: `2px solid ${otherTheme.palette.layout.border}`, | ||
}} | ||
onClick={() => setOpen(false)} | ||
> | ||
<Warning /> | ||
{t('search.otherResults.clickToHide', { networkName })} | ||
</NotificationBox> | ||
<ResultsOnNetwork network={network} searchQueries={searchQueries} roseFiatValue={roseFiatValue} /> | ||
</Box> | ||
) | ||
} |
Oops, something went wrong.