Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/2343.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove MUI themes from search results
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
isOnMainnet,
} from '../../../types/network'
import { HideMoreResults, ShowMoreResults } from './ShowMoreResults'
import { getThemeForScope } from '../../../styles/theme'
import { orderByLayer } from '../../../types/layers'
import { useRedirectIfSingleResult } from './useRedirectIfSingleResult'
import { SearchParams } from '../../components/Search/search-utils'
Expand Down Expand Up @@ -47,7 +46,6 @@ export const GlobalSearchResultsView: FC<{
}

const otherNetworks = RouteUtils.getEnabledNetworks().filter(isNotMainnet)
const notificationTheme = getThemeForScope('testnet')
const mainnetResults = searchResults.filter(isOnMainnet).sort(orderByLayer)
const otherResults = searchResults.filter(isNotOnMainnet).sort(orderByLayer)

Expand All @@ -66,7 +64,7 @@ export const GlobalSearchResultsView: FC<{
{otherResults.length !== 0 &&
(othersOpen ? (
<>
<HideMoreResults theme={notificationTheme} onHide={() => setOthersOpen(false)} />
<HideMoreResults onHide={() => setOthersOpen(false)} />
{otherNetworks.map(net => (
<SearchResultsList
key={net}
Expand All @@ -79,7 +77,6 @@ export const GlobalSearchResultsView: FC<{
</>
) : (
<ShowMoreResults
theme={notificationTheme}
hasWantedResults={!!mainnetResults.length}
otherResultsCount={otherResults.length}
onShow={() => setOthersOpen(true)}
Expand Down
50 changes: 25 additions & 25 deletions src/app/pages/SearchResultsPage/ResultListFrame.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { styled, useTheme } from '@mui/material/styles'
import useMediaQuery from '@mui/material/useMediaQuery'
import { COLORS } from '../../../styles/theme/colors'
import { FC } from 'react'
import { cn } from '@oasisprotocol/ui-library/src/lib/utils'
import { useScreenSize } from '../../hooks/useScreensize'
import { useScopeParam } from 'app/hooks/useScopeParam'

export const ResultListFrame = styled('div')(({ theme: wantedTheme }) => {
const currentTheme = useTheme()
const isMobile = useMediaQuery(wantedTheme.breakpoints.down('sm'))
return isMobile
? {
[`&& > div > [data-slot="card"]`]:
currentTheme.palette.layout.border !== wantedTheme.palette.layout.networkBubbleBorder &&
wantedTheme.palette.layout.main !== wantedTheme.palette.layout.networkBubbleBorder
? {
borderRadius: 0,
border: `solid ${wantedTheme.palette.layout.networkBubbleBorder}`,
borderWidth: '10px 1px',
}
: {},
}
: {
marginBottom: 20,
border: `solid 15px ${wantedTheme.palette.layout.networkBubbleBorder}`,
background: COLORS.white,
borderRadius: 6,
}
})
export const ResultListFrame: FC<{ children: React.ReactNode; networkForTheme: string }> = ({
children,
networkForTheme,
}) => {
const { isMobile } = useScreenSize()
const scope = useScopeParam()
const fallbackTheme = 'mainnet'
const expectedTheme = scope?.network ?? fallbackTheme

return (
<div
className={cn(
!isMobile && 'mb-5 border-[15px] border-solid border-theme-layout-accent bg-white rounded-md',
isMobile && expectedTheme !== networkForTheme && 'mobile-card-border-override',
networkForTheme,
)}
>
{children}
</div>
)
}
7 changes: 2 additions & 5 deletions src/app/pages/SearchResultsPage/ScopedSearchResultsView.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { FC, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { getFilterForNetwork, getNetworkNames, isOnMainnet } from '../../../types/network'
import { getFilterForNetwork, getNetworkNames } from '../../../types/network'
import {
getFilterForScope,
getNameForScope,
getInverseFilterForScope,
SearchScope,
} from '../../../types/searchScope'
import { getThemeForScope } from '../../../styles/theme'
import { RouteUtils } from '../../utils/route-utils'
import { SearchResults } from './hooks'
import { SearchResultsList } from './SearchResultsList'
Expand All @@ -31,7 +30,6 @@ export const ScopedSearchResultsView: FC<{
const isNotInWantedScope = getInverseFilterForScope(wantedScope)
const wantedResults = searchResults.filter(isInWantedScope)
const otherResults = searchResults.filter(isNotInWantedScope)
const notificationTheme = getThemeForScope(otherResults.some(isOnMainnet) ? 'mainnet' : 'testnet')

useRedirectIfSingleResult(wantedScope, searchParams, searchResults)

Expand All @@ -49,7 +47,7 @@ export const ScopedSearchResultsView: FC<{
)}
{othersOpen ? (
<>
<HideMoreResults theme={notificationTheme} onHide={() => setOthersOpen(false)} />
<HideMoreResults onHide={() => setOthersOpen(false)} />
{RouteUtils.getEnabledNetworks()
.filter(net => net !== wantedScope.network)
.map(net => (
Expand All @@ -65,7 +63,6 @@ export const ScopedSearchResultsView: FC<{
) : (
!!otherResults.length && (
<ShowMoreResults
theme={notificationTheme}
onShow={() => setOthersOpen(true)}
hasWantedResults={!!wantedResults.length}
otherResultsCount={otherResults.length}
Expand Down
4 changes: 1 addition & 3 deletions src/app/pages/SearchResultsPage/SearchResultsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
isConsensusBlock,
isConsensusTransaction,
} from './hooks'
import { getThemeForScope } from '../../../styles/theme'
import { Network } from '../../../types/network'
import { SubPageCard } from '../../components/SubPageCard'
import { AllTokenPrices } from '../../../coin-gecko/api'
Expand Down Expand Up @@ -50,10 +49,9 @@ export const SearchResultsList: FC<{
if (!numberOfResults) {
return null
}
const theme = getThemeForScope(networkForTheme)

return (
<ResultListFrame theme={theme}>
<ResultListFrame networkForTheme={networkForTheme}>
<SubPageCard
title={title}
featured
Expand Down
3 changes: 1 addition & 2 deletions src/app/pages/SearchResultsPage/ShowMoreResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ZoomOut from '@mui/icons-material/ZoomOut'
import { Trans, useTranslation } from 'react-i18next'
import ZoomIn from '@mui/icons-material/ZoomIn'

export const HideMoreResults: FC<{ theme: Theme; onHide: () => void }> = ({ onHide }) => {
export const HideMoreResults: FC<{ onHide: () => void }> = ({ onHide }) => {
return (
<div
className="w-[90%] mx-auto md:w-full flex justify-center items-center gap-1 p-4 leading-tight my-8 rounded-md box-border bg-[#F4F4F5] hover:bg-[#DDDDDE] cursor-pointer"
Expand All @@ -19,7 +19,6 @@ export const HideMoreResults: FC<{ theme: Theme; onHide: () => void }> = ({ onHi
}

export const ShowMoreResults: FC<{
theme: Theme
onShow: () => void
hasWantedResults: boolean
otherResultsCount: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SearchResultsList } from '../SearchResultsList'
import { Ticker } from '../../../../types/ticker'

vi.mock('../../../hooks/useAccountMetadata')
vi.mock('../../../hooks/useScopeParam')

describe('SearchResultsView', () => {
beforeEach(() => {
Expand Down
4 changes: 4 additions & 0 deletions src/styles/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
--color-theme-contrast-main: #000062;
}

.mobile-card-border-override > div > [data-slot='card'] {
@apply rounded-none border-solid border-theme-layout-accent border-y-[10px] border-x;
}

/* Specific fixes needed during migration to Oasis UI Library */

/* Override MUI styles that are applied globally */
Expand Down
2 changes: 0 additions & 2 deletions src/styles/theme/defaultTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ declare module '@mui/material/styles' {
secondary?: string
primaryBackground?: string
secondaryBackground?: string
networkBubbleBorder?: string
graphZoomOutText?: string
helpScreenIconColor?: string
}
Expand Down Expand Up @@ -75,7 +74,6 @@ export const defaultTheme = createTheme({
secondary: COLORS.white,
primaryBackground: COLORS.brandExtraDark,
secondaryBackground: COLORS.iconBackground,
networkBubbleBorder: COLORS.white,
graphZoomOutText: COLORS.white,
helpScreenIconColor: COLORS.aqua,
},
Expand Down
1 change: 0 additions & 1 deletion src/styles/theme/localnet/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const localnetTheme = createTheme(
secondary: COLORS.localnet,
primaryBackground: COLORS.localnetLight,
secondaryBackground: COLORS.white,
networkBubbleBorder: COLORS.localnet,
graphZoomOutText: COLORS.brandDark,
helpScreenIconColor: COLORS.brandExtraDark,
},
Expand Down
1 change: 0 additions & 1 deletion src/styles/theme/testnet/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const testnetTheme = createTheme(
secondary: COLORS.testnet,
primaryBackground: COLORS.testnetLight,
secondaryBackground: COLORS.white,
networkBubbleBorder: COLORS.testnet,
graphZoomOutText: COLORS.brandDark,
helpScreenIconColor: COLORS.brandExtraDark,
},
Expand Down
Loading