Skip to content

Commit

Permalink
Continue the work on cross-site / cross-paratime search
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed May 27, 2023
1 parent 103c7d2 commit 696ed38
Show file tree
Hide file tree
Showing 18 changed files with 421 additions and 373 deletions.
2 changes: 2 additions & 0 deletions src/app/components/StyledDescriptionList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const StyledDescriptionList = styled(InlineDescriptionList, {
'dt, dd': {
display: 'flex',
alignItems: 'center',
// TODO do we want to use this here? Discuss with Don
// boxShadow: `0px 1px 0px ${theme.palette.layout.descriptionListSeparator}`,
boxShadow: `0px 1px 0px ${COLORS.grayLight}`,
':last-of-type': {
boxShadow: 'none',
Expand Down
30 changes: 30 additions & 0 deletions src/app/pages/SearchResultsPage/GlobalSearchResultsView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { FC } from 'react'
import { useTranslation } from 'react-i18next'

import { getFilterForScope, getKeyForScope, getNameForScope } from '../../../types/searchScope'
import { RouteUtils } from '../../utils/route-utils'
import { SearchResults } from './hooks'
import { NoResults } from './NoResults'
import { SearchResultsFiltered } from './SearchResultsFiltered'
import { useGetRosePrice } from '../../../coin-gecko/api'

export const GlobalSearchResultsView: FC<{ searchResults: SearchResults }> = ({ searchResults }) => {
const { t } = useTranslation()
const roseFiatValue = useGetRosePrice().data
return searchResults.allResults.length === 0 ? (
<NoResults />
) : (
<>
{RouteUtils.getEnabledSearchScopes().map(scope => (
<SearchResultsFiltered
key={getKeyForScope(scope)}
title={getNameForScope(t, scope)}
filter={getFilterForScope(scope)}
searchResults={searchResults}
networkForTheme={scope.network}
roseFiatValue={roseFiatValue}
/>
))}
</>
)
}
5 changes: 2 additions & 3 deletions src/app/pages/SearchResultsPage/NoResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import Link from '@mui/material/Link'
import { SearchSuggestionsLinks } from '../../components/Search/SearchSuggestionsLinks'
import { OptionalBreak } from '../../components/OptionalBreak'
import { useTheme } from '@mui/material/styles'
import { getNetworkNames } from '../../../types/network'
import { SearchScope } from '../../../types/searchScope'
import { getNameForScope, SearchScope } from '../../../types/searchScope'

export const NoResults: FC<{ scope?: SearchScope }> = ({ scope }) => {
const { t } = useTranslation()
const theme = useTheme()
const title = !scope
? t('search.noResults.header')
: t('search.noResults.scopeHeader', { scope: getNetworkNames(t)[scope.network] })
: t('search.noResults.scopeHeader', { scope: getNameForScope(t, scope) })

return (
<EmptyState
Expand Down
116 changes: 0 additions & 116 deletions src/app/pages/SearchResultsPage/ResultsElsewhere.tsx

This file was deleted.

112 changes: 0 additions & 112 deletions src/app/pages/SearchResultsPage/ResultsFilteredThemed.tsx

This file was deleted.

26 changes: 14 additions & 12 deletions src/app/pages/SearchResultsPage/ResultsGroupByType.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react'
import { Link as RouterLink } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import Button from '@mui/material/Button'
import Box from '@mui/material/Box'
import Divider from '@mui/material/Divider'
import { styled } from '@mui/material/styles'
import { SubPageCard } from '../../components/SubPageCard'
import Typography from '@mui/material/Typography'

interface Props<T> {
title: string
Expand All @@ -31,20 +30,23 @@ export const ViewResultButton = (() => {
* It doesn't actually run a search query, but uses existing results.
*/
export function ResultsGroupByType<T>({ title, results, resultComponent, link, linkLabel }: Props<T>) {
const { t } = useTranslation()

if (!results || results.length <= 0) {
return <></>
}

return (
<SubPageCard
featured
title={title}
subheader={t('search.results.count', {
count: results.length,
})}
>
<>
<Box sx={{ mb: 5 }}>
<Typography
variant="h4"
component="h4"
sx={{
display: 'inline',
}}
>
{title}
</Typography>
</Box>
{results.map((item, i) => (
<div key={i}>
{resultComponent(item)}
Expand All @@ -56,6 +58,6 @@ export function ResultsGroupByType<T>({ title, results, resultComponent, link, l
{i < results.length - 1 && <Divider variant="card" />}
</div>
))}
</SubPageCard>
</>
)
}

0 comments on commit 696ed38

Please sign in to comment.