Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
f5cdbc78
Commit
f5cdbc78
authored
Jan 16, 2025
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix SearchBar component
parent
8fa2e6ea
Changes
24
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
207 additions
and
158 deletions
+207
-158
eslint.config.mjs
eslint.config.mjs
+1
-1
image.tsx
toolkit/chakra/image.tsx
+5
-3
popover.tsx
toolkit/chakra/popover.tsx
+2
-0
ClearButton.tsx
ui/shared/ClearButton.tsx
+11
-9
TokenLogoPlaceholder.tsx
ui/shared/TokenLogoPlaceholder.tsx
+3
-6
CoinzillaTextAd.tsx
ui/shared/ad/CoinzillaTextAd.tsx
+10
-4
TokenEntity.tsx
ui/shared/entities/token/TokenEntity.tsx
+12
-7
Layout.tsx
ui/shared/layout/Layout.tsx
+1
-1
NetworkMenuContentDesktop.tsx
ui/snippets/networkMenu/NetworkMenuContentDesktop.tsx
+2
-1
SearchBar.tsx
ui/snippets/searchBar/SearchBar.tsx
+57
-63
SearchBarBackdrop.tsx
ui/snippets/searchBar/SearchBarBackdrop.tsx
+2
-4
SearchBarInput.tsx
ui/snippets/searchBar/SearchBarInput.tsx
+32
-9
SearchBarRecentKeywords.tsx
ui/snippets/searchBar/SearchBarRecentKeywords.tsx
+3
-4
SearchBarSuggest.tsx
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggest.tsx
+40
-23
SearchBarSuggestAddress.tsx
...ts/searchBar/SearchBarSuggest/SearchBarSuggestAddress.tsx
+1
-1
SearchBarSuggestApp.tsx
...ippets/searchBar/SearchBarSuggest/SearchBarSuggestApp.tsx
+5
-3
SearchBarSuggestBlock.tsx
...pets/searchBar/SearchBarSuggest/SearchBarSuggestBlock.tsx
+6
-5
SearchBarSuggestDomain.tsx
...ets/searchBar/SearchBarSuggest/SearchBarSuggestDomain.tsx
+2
-2
SearchBarSuggestItemLink.tsx
...s/searchBar/SearchBarSuggest/SearchBarSuggestItemLink.tsx
+6
-5
SearchBarSuggestLabel.tsx
...pets/searchBar/SearchBarSuggest/SearchBarSuggestLabel.tsx
+1
-1
SearchBarSuggestToken.tsx
...pets/searchBar/SearchBarSuggest/SearchBarSuggestToken.tsx
+1
-1
SearchBarSuggestTx.tsx
...nippets/searchBar/SearchBarSuggest/SearchBarSuggestTx.tsx
+2
-2
SearchBarSuggestUserOp.tsx
...ets/searchBar/SearchBarSuggest/SearchBarSuggestUserOp.tsx
+2
-2
Settings.tsx
ui/snippets/topBar/settings/Settings.tsx
+0
-1
No files found.
eslint.config.mjs
View file @
f5cdbc78
...
@@ -29,7 +29,7 @@ const RESTRICTED_MODULES = {
...
@@ -29,7 +29,7 @@ const RESTRICTED_MODULES = {
name
:
'
@chakra-ui/react
'
,
name
:
'
@chakra-ui/react
'
,
importNames
:
[
importNames
:
[
'
Menu
'
,
'
useToast
'
,
'
useDisclosure
'
,
'
useClipboard
'
,
'
Tooltip
'
,
'
Skeleton
'
,
'
IconButton
'
,
'
Button
'
,
'
Menu
'
,
'
useToast
'
,
'
useDisclosure
'
,
'
useClipboard
'
,
'
Tooltip
'
,
'
Skeleton
'
,
'
IconButton
'
,
'
Button
'
,
'
Image
'
,
'
Image
'
,
'
Popover
'
,
'
PopoverTrigger
'
,
'
PopoverContent
'
,
'
PopoverBody
'
,
'
PopoverFooter
'
,
],
],
message
:
'
Please use corresponding component or hook from ui/shared/chakra component instead
'
,
message
:
'
Please use corresponding component or hook from ui/shared/chakra component instead
'
,
},
},
...
...
toolkit/chakra/image.tsx
View file @
f5cdbc78
import
type
{
ImageProps
as
ChakraImageProps
}
from
'
@chakra-ui/react
'
;
/* eslint-disable no-restricted-imports */
import
type
{
BoxProps
,
ImageProps
as
ChakraImageProps
}
from
'
@chakra-ui/react
'
;
import
{
Image
as
ChakraImage
}
from
'
@chakra-ui/react
'
;
import
{
Image
as
ChakraImage
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -6,11 +7,12 @@ import { Skeleton } from './skeleton';
...
@@ -6,11 +7,12 @@ import { Skeleton } from './skeleton';
export
interface
ImageProps
extends
ChakraImageProps
{
export
interface
ImageProps
extends
ChakraImageProps
{
fallback
?:
React
.
ReactNode
;
fallback
?:
React
.
ReactNode
;
containerProps
?:
BoxProps
;
}
}
export
const
Image
=
React
.
forwardRef
<
HTMLImageElement
,
ImageProps
>
(
export
const
Image
=
React
.
forwardRef
<
HTMLImageElement
,
ImageProps
>
(
function
Image
(
props
,
ref
)
{
function
Image
(
props
,
ref
)
{
const
{
fallback
,
src
,
...
rest
}
=
props
;
const
{
fallback
,
src
,
containerProps
,
...
rest
}
=
props
;
const
[
loading
,
setLoading
]
=
React
.
useState
(
true
);
const
[
loading
,
setLoading
]
=
React
.
useState
(
true
);
const
[
error
,
setError
]
=
React
.
useState
(
false
);
const
[
error
,
setError
]
=
React
.
useState
(
false
);
...
@@ -33,7 +35,7 @@ export const Image = React.forwardRef<HTMLImageElement, ImageProps>(
...
@@ -33,7 +35,7 @@ export const Image = React.forwardRef<HTMLImageElement, ImageProps>(
}
}
return
(
return
(
<
Skeleton
loading=
{
loading
}
>
<
Skeleton
loading=
{
loading
}
{
...
containerProps
}
>
<
ChakraImage
<
ChakraImage
ref=
{
ref
}
ref=
{
ref
}
src=
{
src
}
src=
{
src
}
...
...
toolkit/chakra/popover.tsx
View file @
f5cdbc78
/* eslint-disable no-restricted-imports */
import
{
Popover
as
ChakraPopover
,
Portal
}
from
'
@chakra-ui/react
'
;
import
{
Popover
as
ChakraPopover
,
Portal
}
from
'
@chakra-ui/react
'
;
import
*
as
React
from
'
react
'
;
import
*
as
React
from
'
react
'
;
...
@@ -53,6 +54,7 @@ export const PopoverCloseTrigger = React.forwardRef<
...
@@ -53,6 +54,7 @@ export const PopoverCloseTrigger = React.forwardRef<
export
const
PopoverRoot
=
(
props
:
ChakraPopover
.
RootProps
)
=>
{
export
const
PopoverRoot
=
(
props
:
ChakraPopover
.
RootProps
)
=>
{
const
positioning
=
{
const
positioning
=
{
placement
:
'
bottom-start
'
as
const
,
...
props
.
positioning
,
...
props
.
positioning
,
offset
:
{
offset
:
{
mainAxis
:
4
,
mainAxis
:
4
,
...
...
ui/shared/ClearButton.tsx
View file @
f5cdbc78
import
{
chakra
,
IconButton
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
chakra
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
IconButton
}
from
'
toolkit/chakra/icon-button
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
interface
Props
{
interface
Props
{
...
@@ -10,21 +11,22 @@ interface Props {
...
@@ -10,21 +11,22 @@ interface Props {
}
}
const
ClearButton
=
({
onClick
,
isDisabled
,
className
}:
Props
)
=>
{
const
ClearButton
=
({
onClick
,
isDisabled
,
className
}:
Props
)
=>
{
const
iconColor
=
useColorModeValue
(
'
gray.300
'
,
'
gray.600
'
);
const
iconColorHover
=
useColorModeValue
(
'
gray.200
'
,
'
gray.500
'
);
return
(
return
(
<
IconButton
<
IconButton
isD
isabled=
{
isDisabled
}
d
isabled=
{
isDisabled
}
className=
{
className
}
className=
{
className
}
colorScheme=
"none"
aria
-
label=
"Clear input"
aria
-
label=
"Clear input"
title=
"Clear input"
title=
"Clear input"
boxSize=
{
6
}
icon=
{
<
IconSvg
name=
"status/error"
boxSize=
{
3
}
color=
{
iconColor
}
_hover=
{
{
color
:
iconColorHover
}
}
/>
}
size=
"sm"
size=
"sm"
onClick=
{
onClick
}
onClick=
{
onClick
}
>
<
IconSvg
name=
"status/error"
boxSize=
{
3
}
color=
{
{
_light
:
'
gray.300
'
,
_dark
:
'
gray.600
'
}
}
_hover=
{
{
color
:
{
_light
:
'
gray.200
'
,
_dark
:
'
gray.500
'
}
}
}
/>
/>
</
IconButton
>
);
);
};
};
...
...
ui/shared/TokenLogoPlaceholder.tsx
View file @
f5cdbc78
import
{
chakra
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
chakra
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
const
TokenLogoPlaceholder
=
({
className
}:
{
className
?:
string
})
=>
{
const
TokenLogoPlaceholder
=
({
className
}:
{
className
?:
string
})
=>
{
const
bgColor
=
useColorModeValue
(
'
gray.200
'
,
'
gray.600
'
);
const
color
=
useColorModeValue
(
'
gray.400
'
,
'
gray.200
'
);
return
(
return
(
<
IconSvg
<
IconSvg
className=
{
className
}
className=
{
className
}
fontWeight=
{
600
}
fontWeight=
{
600
}
bgColor=
{
bgColor
}
bgColor=
{
{
_light
:
'
gray.200
'
,
_dark
:
'
gray.600
'
}
}
color=
{
color
}
color=
{
{
_light
:
'
gray.400
'
,
_dark
:
'
gray.200
'
}
}
borderRadius=
"base"
borderRadius=
"base"
name=
"token-placeholder"
name=
"token-placeholder"
transitionProperty=
"background-color,color"
transitionProperty=
"background-color,color"
...
...
ui/shared/ad/CoinzillaTextAd.tsx
View file @
f5cdbc78
import
{
Box
,
Image
,
Link
,
Text
,
chakra
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Link
,
Text
,
chakra
}
from
'
@chakra-ui/react
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
{
ndash
}
from
'
lib/html-entities
'
;
import
{
ndash
}
from
'
lib/html-entities
'
;
import
isBrowser
from
'
lib/isBrowser
'
;
import
isBrowser
from
'
lib/isBrowser
'
;
import
{
Image
}
from
'
toolkit/chakra/image
'
;
import
{
Skeleton
}
from
'
toolkit/chakra/skeleton
'
;
type
AdData
=
{
type
AdData
=
{
ad
:
{
ad
:
{
...
@@ -78,9 +80,13 @@ const CoinzillaTextAd = ({ className }: { className?: string }) => {
...
@@ -78,9 +80,13 @@ const CoinzillaTextAd = ({ className }: { className?: string }) => {
Ads:
Ads:
</
Text
>
</
Text
>
{
urlObject
.
hostname
===
'
nifty.ink
'
?
{
urlObject
.
hostname
===
'
nifty.ink
'
?
<
Text
as=
"span"
mr=
{
1
}
>
🎨
</
Text
>
:
<
Text
as=
"span"
mr=
{
1
}
>
🎨
</
Text
>
:
(
<
Image
src=
{
adData
.
ad
.
thumbnail
}
width=
"20px"
height=
"20px"
mb=
"-4px"
mr=
{
1
}
display=
"inline"
alt=
""
/>
<
Image
}
src=
{
adData
.
ad
.
thumbnail
}
containerProps=
{
{
width
:
'
20px
'
,
height
:
'
20px
'
,
mb
:
'
-4px
'
,
mr
:
1
,
display
:
'
inline-block
'
}
}
alt=
""
/>
)
}
<
Text
as=
"span"
whiteSpace=
"pre-wrap"
>
{
`${ adData.ad.name } ${ ndash } ${ adData.ad.description_short } `
}
</
Text
>
<
Text
as=
"span"
whiteSpace=
"pre-wrap"
>
{
`${ adData.ad.name } ${ ndash } ${ adData.ad.description_short } `
}
</
Text
>
<
Link
href=
{
adData
.
ad
.
url
}
>
{
adData
.
ad
.
cta_button
}
</
Link
>
<
Link
href=
{
adData
.
ad
.
url
}
>
{
adData
.
ad
.
cta_button
}
</
Link
>
</
Box
>
</
Box
>
...
...
ui/shared/entities/token/TokenEntity.tsx
View file @
f5cdbc78
import
type
{
As
}
from
'
@chakra-ui/react
'
;
import
{
chakra
}
from
'
@chakra-ui/react
'
;
import
{
Image
,
Skeleton
,
chakra
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
TokenInfo
}
from
'
types/api/token
'
;
import
type
{
TokenInfo
}
from
'
types/api/token
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
{
Image
}
from
'
toolkit/chakra/image
'
;
import
{
Skeleton
}
from
'
toolkit/chakra/skeleton
'
;
import
*
as
EntityBase
from
'
ui/shared/entities/base/components
'
;
import
*
as
EntityBase
from
'
ui/shared/entities/base/components
'
;
import
TokenLogoPlaceholder
from
'
ui/shared/TokenLogoPlaceholder
'
;
import
TokenLogoPlaceholder
from
'
ui/shared/TokenLogoPlaceholder
'
;
import
TruncatedTextTooltip
from
'
ui/shared/TruncatedTextTooltip
'
;
import
TruncatedTextTooltip
from
'
ui/shared/TruncatedTextTooltip
'
;
...
@@ -48,11 +49,15 @@ const Icon = (props: IconProps) => {
...
@@ -48,11 +49,15 @@ const Icon = (props: IconProps) => {
return
(
return
(
<
Image
<
Image
{
...
styles
}
{
...
styles
}
className=
{
props
.
className
}
containerProps=
{
{
className
:
props
.
className
,
...
styles
,
}
}
src=
{
props
.
token
.
icon_url
??
undefined
}
src=
{
props
.
token
.
icon_url
??
undefined
}
alt=
{
`${ props.token.name || 'token' } logo`
}
alt=
{
`${ props.token.name || 'token' } logo`
}
fallback=
{
<
TokenLogoPlaceholder
{
...
styles
}
/>
}
fallback=
{
<
TokenLogoPlaceholder
{
...
styles
}
/>
}
fallbackStrategy=
{
props
.
token
.
icon_url
?
'
onError
'
:
'
beforeLoadOrError
'
}
// TODO @tom2drum implement fallbackStrategy in Image component
// fallbackStrategy={ props.token.icon_url ? 'onError' : 'beforeLoadOrError' }
/>
/>
);
);
};
};
...
@@ -69,7 +74,7 @@ const Content = chakra((props: ContentProps) => {
...
@@ -69,7 +74,7 @@ const Content = chakra((props: ContentProps) => {
return
(
return
(
<
TruncatedTextTooltip
label=
{
nameString
}
>
<
TruncatedTextTooltip
label=
{
nameString
}
>
<
Skeleton
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
loading=
{
props
.
isLoading
}
display=
"inline-block"
display=
"inline-block"
whiteSpace=
"nowrap"
whiteSpace=
"nowrap"
overflow=
"hidden"
overflow=
"hidden"
...
@@ -93,7 +98,7 @@ const Symbol = (props: SymbolProps) => {
...
@@ -93,7 +98,7 @@ const Symbol = (props: SymbolProps) => {
return
(
return
(
<
Skeleton
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
loading=
{
props
.
isLoading
}
display=
"inline-flex"
display=
"inline-flex"
alignItems=
"center"
alignItems=
"center"
maxW=
"20%"
maxW=
"20%"
...
@@ -152,7 +157,7 @@ const TokenEntity = (props: EntityProps) => {
...
@@ -152,7 +157,7 @@ const TokenEntity = (props: EntityProps) => {
);
);
};
};
export
default
React
.
memo
(
chakra
<
As
,
EntityProps
>
(
TokenEntity
));
export
default
React
.
memo
(
chakra
(
TokenEntity
));
export
{
export
{
Container
,
Container
,
...
...
ui/shared/layout/Layout.tsx
View file @
f5cdbc78
...
@@ -20,7 +20,7 @@ const LayoutDefault = ({ children }: Props) => {
...
@@ -20,7 +20,7 @@ const LayoutDefault = ({ children }: Props) => {
<
Layout
.
SideBar
/>
<
Layout
.
SideBar
/>
<
Layout
.
MainColumn
>
<
Layout
.
MainColumn
>
<
HeaderAlert
/>
<
HeaderAlert
/>
{
/* <HeaderDesktop/> */
}
<
HeaderDesktop
/>
<
AppErrorBoundary
>
<
AppErrorBoundary
>
<
Layout
.
Content
>
<
Layout
.
Content
>
{
children
}
{
children
}
...
...
ui/snippets/networkMenu/NetworkMenuContentDesktop.tsx
View file @
f5cdbc78
import
{
Tabs
,
VStack
,
Skeleton
,
Flex
,
Box
}
from
'
@chakra-ui/react
'
;
import
{
Tabs
,
VStack
,
Flex
,
Box
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
FeaturedNetwork
,
NetworkGroup
}
from
'
types/networks
'
;
import
type
{
FeaturedNetwork
,
NetworkGroup
}
from
'
types/networks
'
;
import
{
PopoverBody
,
PopoverContent
}
from
'
toolkit/chakra/popover
'
;
import
{
PopoverBody
,
PopoverContent
}
from
'
toolkit/chakra/popover
'
;
import
{
Skeleton
}
from
'
toolkit/chakra/skeleton
'
;
import
NetworkMenuLink
from
'
./NetworkMenuLink
'
;
import
NetworkMenuLink
from
'
./NetworkMenuLink
'
;
...
...
ui/snippets/searchBar/SearchBar.tsx
View file @
f5cdbc78
import
{
import
{
Box
}
from
'
@chakra-ui/react
'
;
Box
,
import
{
useClickAway
}
from
'
@uidotdev/usehooks
'
;
Portal
,
PopoverTrigger
,
PopoverContent
,
PopoverBody
,
PopoverFooter
,
useDisclosure
,
useOutsideClick
,
}
from
'
@chakra-ui/react
'
;
import
_debounce
from
'
lodash/debounce
'
;
import
_debounce
from
'
lodash/debounce
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
type
{
FormEvent
}
from
'
react
'
;
import
type
{
FormEvent
}
from
'
react
'
;
...
@@ -20,7 +12,8 @@ import { route } from 'nextjs-routes';
...
@@ -20,7 +12,8 @@ import { route } from 'nextjs-routes';
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
{
getRecentSearchKeywords
,
saveToRecentKeywords
}
from
'
lib/recentSearchKeywords
'
;
import
{
getRecentSearchKeywords
,
saveToRecentKeywords
}
from
'
lib/recentSearchKeywords
'
;
import
Popover
from
'
ui/shared/chakra/Popover
'
;
import
{
PopoverBody
,
PopoverContent
,
PopoverFooter
,
PopoverRoot
,
PopoverTrigger
}
from
'
toolkit/chakra/popover
'
;
import
{
useDisclosure
}
from
'
toolkit/hooks/useDisclosure
'
;
import
LinkInternal
from
'
ui/shared/links/LinkInternal
'
;
import
LinkInternal
from
'
ui/shared/links/LinkInternal
'
;
import
SearchBarBackdrop
from
'
./SearchBarBackdrop
'
;
import
SearchBarBackdrop
from
'
./SearchBarBackdrop
'
;
...
@@ -36,9 +29,8 @@ type Props = {
...
@@ -36,9 +29,8 @@ type Props = {
const
SCROLL_CONTAINER_ID
=
'
search_bar_popover_content
'
;
const
SCROLL_CONTAINER_ID
=
'
search_bar_popover_content
'
;
const
SearchBar
=
({
isHomepage
}:
Props
)
=>
{
const
SearchBar
=
({
isHomepage
}:
Props
)
=>
{
const
{
isO
pen
,
onClose
,
onOpen
}
=
useDisclosure
();
const
{
o
pen
,
onClose
,
onOpen
}
=
useDisclosure
();
const
inputRef
=
React
.
useRef
<
HTMLFormElement
>
(
null
);
const
inputRef
=
React
.
useRef
<
HTMLFormElement
>
(
null
);
const
menuRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
scrollRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
scrollRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
menuWidth
=
React
.
useRef
<
number
>
(
0
);
const
menuWidth
=
React
.
useRef
<
number
>
(
0
);
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
...
@@ -80,7 +72,11 @@ const SearchBar = ({ isHomepage }: Props) => {
...
@@ -80,7 +72,11 @@ const SearchBar = ({ isHomepage }: Props) => {
}
}
},
[
handelHide
]);
},
[
handelHide
]);
useOutsideClick
({
ref
:
menuRef
,
handler
:
handleOutsideClick
});
const
menuRef
=
useClickAway
<
HTMLDivElement
>
(
handleOutsideClick
);
const
handleOpenChange
=
React
.
useCallback
(({
open
}:
{
open
:
boolean
})
=>
{
open
&&
onOpen
();
},
[
onOpen
]);
const
handleClear
=
React
.
useCallback
(()
=>
{
const
handleClear
=
React
.
useCallback
(()
=>
{
handleSearchTermChange
(
''
);
handleSearchTermChange
(
''
);
...
@@ -126,13 +122,13 @@ const SearchBar = ({ isHomepage }: Props) => {
...
@@ -126,13 +122,13 @@ const SearchBar = ({ isHomepage }: Props) => {
return
(
return
(
<>
<>
<
Popover
<
Popover
Root
isOpen=
{
isO
pen
&&
(
searchTerm
.
trim
().
length
>
0
||
recentSearchKeywords
.
length
>
0
)
}
open=
{
o
pen
&&
(
searchTerm
.
trim
().
length
>
0
||
recentSearchKeywords
.
length
>
0
)
}
autoFocus=
{
false
}
autoFocus=
{
false
}
on
Close=
{
onClos
e
}
on
OpenChange=
{
handleOpenChang
e
}
p
lacement=
"bottom-start"
p
ositioning=
{
{
offset
:
isMobile
&&
!
isHomepage
?
{
mainAxis
:
-
4
,
crossAxis
:
12
}
:
{
mainAxis
:
8
,
crossAxis
:
0
}
}
}
offset=
{
isMobile
&&
!
isHomepage
?
[
12
,
-
4
]
:
[
0
,
8
]
}
lazyMount
isLazy
closeOnInteractOutside=
{
false
}
>
>
<
PopoverTrigger
>
<
PopoverTrigger
>
<
SearchBarInput
<
SearchBarInput
...
@@ -144,10 +140,9 @@ const SearchBar = ({ isHomepage }: Props) => {
...
@@ -144,10 +140,9 @@ const SearchBar = ({ isHomepage }: Props) => {
onClear=
{
handleClear
}
onClear=
{
handleClear
}
isHomepage=
{
isHomepage
}
isHomepage=
{
isHomepage
}
value=
{
searchTerm
}
value=
{
searchTerm
}
isSuggestOpen=
{
isO
pen
}
isSuggestOpen=
{
o
pen
}
/>
/>
</
PopoverTrigger
>
</
PopoverTrigger
>
<
Portal
>
<
PopoverContent
<
PopoverContent
w=
{
`${ menuWidth.current }px`
}
w=
{
`${ menuWidth.current }px`
}
ref=
{
menuRef
}
ref=
{
menuRef
}
...
@@ -189,9 +184,8 @@ const SearchBar = ({ isHomepage }: Props) => {
...
@@ -189,9 +184,8 @@ const SearchBar = ({ isHomepage }: Props) => {
</
PopoverFooter
>
</
PopoverFooter
>
)
}
)
}
</
PopoverContent
>
</
PopoverContent
>
</
Portal
>
</
PopoverRoot
>
</
Popover
>
<
SearchBarBackdrop
isOpen=
{
open
}
/>
<
SearchBarBackdrop
isOpen=
{
isOpen
}
/>
</>
</>
);
);
};
};
...
...
ui/snippets/searchBar/SearchBarBackdrop.tsx
View file @
f5cdbc78
import
{
Box
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Box
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
interface
Props
{
interface
Props
{
...
@@ -6,8 +6,6 @@ interface Props {
...
@@ -6,8 +6,6 @@ interface Props {
}
}
const
SearchBarBackdrop
=
({
isOpen
}:
Props
)
=>
{
const
SearchBarBackdrop
=
({
isOpen
}:
Props
)
=>
{
const
backdropBgColor
=
useColorModeValue
(
'
blackAlpha.400
'
,
'
blackAlpha.600
'
);
return
(
return
(
<
Box
<
Box
position=
"fixed"
position=
"fixed"
...
@@ -15,7 +13,7 @@ const SearchBarBackdrop = ({ isOpen }: Props) => {
...
@@ -15,7 +13,7 @@ const SearchBarBackdrop = ({ isOpen }: Props) => {
left=
{
0
}
left=
{
0
}
w=
"100vw"
w=
"100vw"
h=
"100vh"
h=
"100vh"
bgColor=
{
backdropBgColor
}
bgColor=
{
{
_light
:
'
blackAlpha.400
'
,
_dark
:
'
blackAlpha.600
'
}
}
zIndex=
"overlay"
zIndex=
"overlay"
display=
{
{
base
:
'
none
'
,
lg
:
isOpen
?
'
block
'
:
'
none
'
}
}
display=
{
{
base
:
'
none
'
,
lg
:
isOpen
?
'
block
'
:
'
none
'
}
}
/>
/>
...
...
ui/snippets/searchBar/SearchBarInput.tsx
View file @
f5cdbc78
import
{
InputGroup
,
Input
,
InputLeftElement
,
chakra
,
InputRightElement
,
Center
}
from
'
@chakra-ui/react
'
;
import
{
chakra
,
Center
}
from
'
@chakra-ui/react
'
;
import
throttle
from
'
lodash/throttle
'
;
import
throttle
from
'
lodash/throttle
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
ChangeEvent
,
FormEvent
,
FocusEvent
}
from
'
react
'
;
import
type
{
ChangeEvent
,
FormEvent
,
FocusEvent
}
from
'
react
'
;
import
{
useColorModeValue
}
from
'
toolkit/chakra/color-mode
'
;
import
{
useScrollDirection
}
from
'
lib/contexts/scrollDirection
'
;
import
{
useScrollDirection
}
from
'
lib/contexts/scrollDirection
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
{
Input
}
from
'
toolkit/chakra/input
'
;
import
{
InputGroup
}
from
'
toolkit/chakra/input-group
'
;
import
ClearButton
from
'
ui/shared/ClearButton
'
;
import
ClearButton
from
'
ui/shared/ClearButton
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
interface
Props
{
interface
Props
{
onChange
:
(
value
:
string
)
=>
void
;
onChange
:
(
value
:
string
)
=>
void
;
onSubmit
:
(
event
:
FormEvent
<
HTMLFormElement
>
)
=>
void
;
onSubmit
:
(
event
:
FormEvent
<
HTMLFormElement
>
)
=>
void
;
...
@@ -98,10 +98,17 @@ const SearchBarInput = (
...
@@ -98,10 +98,17 @@ const SearchBarInput = (
};
};
},
[
handleKeyPress
]);
},
[
handleKeyPress
]);
const
bgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
transformMobile
=
scrollDirection
!==
'
down
'
?
'
translateY(0)
'
:
'
translateY(-100%)
'
;
const
transformMobile
=
scrollDirection
!==
'
down
'
?
'
translateY(0)
'
:
'
translateY(-100%)
'
;
const
rightElement
=
(()
=>
{
const
startElement
=
(
<
IconSvg
name=
"search"
boxSize=
{
{
base
:
isHomepage
?
6
:
4
,
lg
:
6
}
}
color=
{
{
_light
:
'
blackAlpha.600
'
,
_dark
:
'
whiteAlpha.600
'
}
}
/>
);
const
endElement
=
(()
=>
{
if
(
value
)
{
if
(
value
)
{
return
<
ClearButton
onClick=
{
onClear
}
/>;
return
<
ClearButton
onClick=
{
onClear
}
/>;
}
}
...
@@ -132,9 +139,8 @@ const SearchBarInput = (
...
@@ -132,9 +139,8 @@ const SearchBarInput = (
noValidate
noValidate
onSubmit=
{
onSubmit
}
onSubmit=
{
onSubmit
}
onBlur=
{
onBlur
}
onBlur=
{
onBlur
}
onFocus=
{
onFocus
}
w=
"100%"
w=
"100%"
backgroundColor=
{
bgColor
}
backgroundColor=
{
{
_light
:
'
white
'
,
_dark
:
'
black
'
}
}
borderRadius=
{
{
base
:
isHomepage
?
'
base
'
:
'
none
'
,
lg
:
'
base
'
}
}
borderRadius=
{
{
base
:
isHomepage
?
'
base
'
:
'
none
'
,
lg
:
'
base
'
}
}
position=
{
{
base
:
isHomepage
?
'
static
'
:
'
absolute
'
,
lg
:
'
relative
'
}
}
position=
{
{
base
:
isHomepage
?
'
static
'
:
'
absolute
'
,
lg
:
'
relative
'
}
}
top=
{
{
base
:
isHomepage
?
0
:
55
,
lg
:
0
}
}
top=
{
{
base
:
isHomepage
?
0
:
55
,
lg
:
0
}
}
...
@@ -149,7 +155,24 @@ const SearchBarInput = (
...
@@ -149,7 +155,24 @@ const SearchBarInput = (
transitionDuration=
"normal"
transitionDuration=
"normal"
transitionTimingFunction=
"ease"
transitionTimingFunction=
"ease"
>
>
<
InputGroup
size=
{
{
base
:
'
sm
'
,
lg
:
isHomepage
?
'
sm_md
'
:
'
sm
'
}
}
>
<
InputGroup
startElement=
{
startElement
}
startOffset=
{
{
base
:
isHomepage
?
'
50px
'
:
'
38px
'
,
lg
:
'
50px
'
}
}
endElement=
{
endElement
}
>
<
Input
placeholder=
{
isMobile
?
'
Search by address / ...
'
:
'
Search by address / txn hash / block / token...
'
}
value=
{
value
}
onChange=
{
handleChange
}
border=
{
isHomepage
?
'
none
'
:
'
2px solid
'
}
borderColor=
{
{
_light
:
'
blackAlpha.100
'
,
_dark
:
'
whiteAlpha.200
'
}
}
color=
{
{
_light
:
'
black
'
,
_dark
:
'
white
'
}
}
_hover=
{
{
borderColor
:
'
input.border.hover
'
}
}
_focusWithin=
{
{
_placeholder
:
{
color
:
'
gray.300
'
},
borderColor
:
'
input.border.focus
'
,
_hover
:
{
borderColor
:
'
input.border.focus
'
}
}
}
/>
</
InputGroup
>
{
/* TODO @tom2drum migrate icon styles */
}
{
/* <InputGroup size={{ base: 'sm', lg: isHomepage ? 'sm_md' : 'sm' }}>
<InputLeftElement w={{ base: isHomepage ? 6 : 4, lg: 6 }} ml={{ base: isHomepage ? 4 : 3, lg: 4 }} h="100%">
<InputLeftElement w={{ base: isHomepage ? 6 : 4, lg: 6 }} ml={{ base: isHomepage ? 4 : 3, lg: 4 }} h="100%">
<IconSvg name="search" boxSize={{ base: isHomepage ? 6 : 4, lg: 6 }} color={ useColorModeValue('blackAlpha.600', 'whiteAlpha.600') }/>
<IconSvg name="search" boxSize={{ base: isHomepage ? 6 : 4, lg: 6 }} color={ useColorModeValue('blackAlpha.600', 'whiteAlpha.600') }/>
</InputLeftElement>
</InputLeftElement>
...
@@ -175,7 +198,7 @@ const SearchBarInput = (
...
@@ -175,7 +198,7 @@ const SearchBarInput = (
<InputRightElement top={{ base: 2, lg: isHomepage ? 3 : 2 }} right={ 2 }>
<InputRightElement top={{ base: 2, lg: isHomepage ? 3 : 2 }} right={ 2 }>
{ rightElement }
{ rightElement }
</InputRightElement>
</InputRightElement>
</
InputGroup
>
</InputGroup>
*/
}
</
chakra
.
form
>
</
chakra
.
form
>
);
);
};
};
...
...
ui/snippets/searchBar/SearchBarRecentKeywords.tsx
View file @
f5cdbc78
import
{
Box
,
Flex
,
Link
,
Text
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Flex
,
Link
,
Text
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
...
@@ -14,7 +14,6 @@ type Props = {
...
@@ -14,7 +14,6 @@ type Props = {
const
SearchBarSuggest
=
({
onClick
,
onClear
}:
Props
)
=>
{
const
SearchBarSuggest
=
({
onClick
,
onClear
}:
Props
)
=>
{
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
bgHoverColor
=
useColorModeValue
(
'
blue.50
'
,
'
gray.800
'
);
const
[
keywords
,
setKeywords
]
=
React
.
useState
<
Array
<
string
>>
(
getRecentSearchKeywords
());
const
[
keywords
,
setKeywords
]
=
React
.
useState
<
Array
<
string
>>
(
getRecentSearchKeywords
());
...
@@ -49,7 +48,7 @@ const SearchBarSuggest = ({ onClick, onClear }: Props) => {
...
@@ -49,7 +48,7 @@ const SearchBarSuggest = ({ onClick, onClear }: Props) => {
</
Box
>
</
Box
>
)
}
)
}
<
Flex
mb=
{
3
}
justifyContent=
"space-between"
fontSize=
"sm"
>
<
Flex
mb=
{
3
}
justifyContent=
"space-between"
fontSize=
"sm"
>
<
Text
fontWeight=
{
600
}
variant=
"
secondary"
>
Recent
</
Text
>
<
Text
fontWeight=
{
600
}
color=
"text.
secondary"
>
Recent
</
Text
>
<
Link
onClick=
{
clearKeywords
}
>
Clear all
</
Link
>
<
Link
onClick=
{
clearKeywords
}
>
Clear all
</
Link
>
</
Flex
>
</
Flex
>
{
keywords
.
map
(
kw
=>
(
{
keywords
.
map
(
kw
=>
(
...
@@ -63,7 +62,7 @@ const SearchBarSuggest = ({ onClick, onClear }: Props) => {
...
@@ -63,7 +62,7 @@ const SearchBarSuggest = ({ onClick, onClear }: Props) => {
borderBottomWidth
:
'
0
'
,
borderBottomWidth
:
'
0
'
,
}
}
}
}
_hover=
{
{
_hover=
{
{
bgColor
:
bgHoverColor
,
bgColor
:
{
_light
:
'
blue.50
'
,
_dark
:
'
gray.800
'
}
,
}
}
}
}
fontSize=
"sm"
fontSize=
"sm"
_first=
{
{
_first=
{
{
...
...
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggest.tsx
View file @
f5cdbc78
import
{
Box
,
T
ab
,
TabList
,
Tabs
,
Text
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
T
ext
,
Tabs
}
from
'
@chakra-ui/react
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
throttle
from
'
lodash/throttle
'
;
import
throttle
from
'
lodash/throttle
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -13,7 +13,7 @@ import * as regexp from 'lib/regexp';
...
@@ -13,7 +13,7 @@ import * as regexp from 'lib/regexp';
import
useMarketplaceApps
from
'
ui/marketplace/useMarketplaceApps
'
;
import
useMarketplaceApps
from
'
ui/marketplace/useMarketplaceApps
'
;
import
TextAd
from
'
ui/shared/ad/TextAd
'
;
import
TextAd
from
'
ui/shared/ad/TextAd
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
type
{
ApiCategory
,
ItemsCategoriesMap
}
from
'
ui/shared/search/utils
'
;
import
type
{
ApiCategory
,
Category
,
ItemsCategoriesMap
}
from
'
ui/shared/search/utils
'
;
import
{
getItemCategory
,
searchCategories
}
from
'
ui/shared/search/utils
'
;
import
{
getItemCategory
,
searchCategories
}
from
'
ui/shared/search/utils
'
;
import
SearchBarSuggestApp
from
'
./SearchBarSuggestApp
'
;
import
SearchBarSuggestApp
from
'
./SearchBarSuggestApp
'
;
...
@@ -36,7 +36,7 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
...
@@ -36,7 +36,7 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
const
categoriesRefs
=
React
.
useRef
<
Array
<
HTMLParagraphElement
>>
([]);
const
categoriesRefs
=
React
.
useRef
<
Array
<
HTMLParagraphElement
>>
([]);
const
tabsRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
tabsRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
[
tabIndex
,
setTabIndex
]
=
React
.
useState
(
0
);
const
[
currentTab
,
setCurrentTab
]
=
React
.
useState
<
Category
|
undefined
>
(
undefined
);
const
handleScroll
=
React
.
useCallback
(()
=>
{
const
handleScroll
=
React
.
useCallback
(()
=>
{
const
container
=
document
.
getElementById
(
containerId
);
const
container
=
document
.
getElementById
(
containerId
);
...
@@ -45,12 +45,20 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
...
@@ -45,12 +45,20 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
}
}
const
topLimit
=
container
.
getBoundingClientRect
().
y
+
(
tabsRef
.
current
?.
clientHeight
||
0
)
+
24
;
const
topLimit
=
container
.
getBoundingClientRect
().
y
+
(
tabsRef
.
current
?.
clientHeight
||
0
)
+
24
;
if
(
categoriesRefs
.
current
[
categoriesRefs
.
current
.
length
-
1
].
getBoundingClientRect
().
y
<=
topLimit
)
{
if
(
categoriesRefs
.
current
[
categoriesRefs
.
current
.
length
-
1
].
getBoundingClientRect
().
y
<=
topLimit
)
{
setTabIndex
(
categoriesRefs
.
current
.
length
-
1
);
const
lastCategory
=
categoriesRefs
.
current
[
categoriesRefs
.
current
.
length
-
1
];
const
lastCategoryId
=
lastCategory
.
getAttribute
(
'
data-id
'
);
if
(
lastCategoryId
)
{
setCurrentTab
(
lastCategoryId
as
Category
);
}
return
;
return
;
}
}
for
(
let
i
=
0
;
i
<
categoriesRefs
.
current
.
length
-
1
;
i
++
)
{
for
(
let
i
=
0
;
i
<
categoriesRefs
.
current
.
length
-
1
;
i
++
)
{
if
(
categoriesRefs
.
current
[
i
].
getBoundingClientRect
().
y
<=
topLimit
&&
categoriesRefs
.
current
[
i
+
1
].
getBoundingClientRect
().
y
>
topLimit
)
{
if
(
categoriesRefs
.
current
[
i
].
getBoundingClientRect
().
y
<=
topLimit
&&
categoriesRefs
.
current
[
i
+
1
].
getBoundingClientRect
().
y
>
topLimit
)
{
setTabIndex
(
i
);
const
currentCategory
=
categoriesRefs
.
current
[
i
];
const
currentCategoryId
=
currentCategory
.
getAttribute
(
'
data-id
'
);
if
(
currentCategoryId
)
{
setCurrentTab
(
currentCategoryId
as
Category
);
}
break
;
break
;
}
}
}
}
...
@@ -106,11 +114,13 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
...
@@ -106,11 +114,13 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
categoriesRefs
.
current
=
Array
(
Object
.
keys
(
itemsGroups
).
length
).
fill
(
''
).
map
((
_
,
i
)
=>
categoriesRefs
.
current
[
i
]
||
React
.
createRef
());
categoriesRefs
.
current
=
Array
(
Object
.
keys
(
itemsGroups
).
length
).
fill
(
''
).
map
((
_
,
i
)
=>
categoriesRefs
.
current
[
i
]
||
React
.
createRef
());
const
resultCategories
=
searchCategories
.
filter
(
cat
=>
itemsGroups
[
cat
.
id
]);
setCurrentTab
(
resultCategories
[
0
]?.
id
);
},
[
itemsGroups
]);
},
[
itemsGroups
]);
const
scrollToCategory
=
React
.
useCallback
((
index
:
number
)
=>
(
)
=>
{
const
handleTabsValueChange
=
React
.
useCallback
(({
value
}:
{
value
:
string
}
)
=>
{
set
TabIndex
(
index
);
set
CurrentTab
(
value
as
Category
);
scroller
.
scrollTo
(
`cat_
${
index
}
`
,
{
scroller
.
scrollTo
(
`cat_
${
value
}
`
,
{
duration
:
250
,
duration
:
250
,
smooth
:
true
,
smooth
:
true
,
offset
:
-
(
tabsRef
.
current
?.
clientHeight
||
0
),
offset
:
-
(
tabsRef
.
current
?.
clientHeight
||
0
),
...
@@ -118,8 +128,6 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
...
@@ -118,8 +128,6 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
});
});
},
[
containerId
]);
},
[
containerId
]);
const
bgColor
=
useColorModeValue
(
'
white
'
,
'
gray.900
'
);
const
content
=
(()
=>
{
const
content
=
(()
=>
{
if
(
query
.
isPending
||
marketplaceApps
.
isPlaceholderData
)
{
if
(
query
.
isPending
||
marketplaceApps
.
isPlaceholderData
)
{
return
<
ContentLoader
text=
"We are searching, please wait... "
fontSize=
"sm"
/>;
return
<
ContentLoader
text=
"We are searching, please wait... "
fontSize=
"sm"
/>;
...
@@ -142,30 +150,39 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
...
@@ -142,30 +150,39 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
return
(
return
(
<>
<>
{
resultCategories
.
length
>
1
&&
(
{
resultCategories
.
length
>
1
&&
(
<
Box
position=
"sticky"
top=
"0"
width=
"100%"
background=
{
bgColor
}
py=
{
5
}
my=
{
-
5
}
ref=
{
tabsRef
}
>
<
Box
position=
"sticky"
top=
"0"
width=
"100%"
background=
{
{
_light
:
'
white
'
,
_dark
:
'
gray.900
'
}
}
py=
{
5
}
my=
{
-
5
}
ref=
{
tabsRef
}
>
<
Tabs
variant=
"outline"
colorScheme=
"gray"
size=
"sm"
index=
{
tabIndex
}
>
<
Tabs
.
Root
<
TabList
columnGap=
{
3
}
rowGap=
{
2
}
flexWrap=
"wrap"
>
variant=
"secondary"
{
resultCategories
.
map
((
cat
,
index
)
=>
(
size=
"sm"
<
Tab
key=
{
cat
.
id
}
onClick=
{
scrollToCategory
(
index
)
}
{
...
(
tabIndex
===
index
?
{
'
data
-
selected
':
'
true
'
}
:
{})
}
>
value=
{
currentTab
}
onValueChange=
{
handleTabsValueChange
}
>
<
Tabs
.
List
columnGap=
{
3
}
rowGap=
{
2
}
flexWrap=
"wrap"
>
{
resultCategories
.
map
((
cat
)
=>
(
<
Tabs
.
Trigger
key=
{
cat
.
id
}
value=
{
cat
.
id
}
>
{
cat
.
title
}
{
cat
.
title
}
</
Tab
>
</
Tab
s
.
Trigger
>
))
}
))
}
</
TabList
>
</
Tab
s
.
List
>
</
Tabs
>
</
Tabs
.
Root
>
</
Box
>
</
Box
>
)
}
)
}
{
resultCategories
.
map
((
cat
,
indx
)
=>
{
{
resultCategories
.
map
((
cat
,
ind
e
x
)
=>
{
return
(
return
(
<
Element
name=
{
`cat_${
indx
}`
}
key=
{
cat
.
id
}
>
<
Element
name=
{
`cat_${
cat.id
}`
}
key=
{
cat
.
id
}
>
<
Text
<
Text
fontSiz
e=
"sm"
textStyl
e=
"sm"
fontWeight=
{
600
}
fontWeight=
{
600
}
variant=
"
secondary"
color=
"text.
secondary"
mt=
{
6
}
mt=
{
6
}
mb=
{
3
}
mb=
{
3
}
ref=
{
(
el
:
HTMLParagraphElement
)
=>
{
ref=
{
(
el
:
HTMLParagraphElement
)
=>
{
categoriesRefs
.
current
[
indx
]
=
el
;
categoriesRefs
.
current
[
ind
e
x
]
=
el
;
}
}
}
}
data
-
id=
{
cat
.
id
}
>
>
{
cat
.
title
}
{
cat
.
title
}
</
Text
>
</
Text
>
...
...
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestAddress.tsx
View file @
f5cdbc78
...
@@ -34,7 +34,7 @@ const SearchBarSuggestAddress = ({ data, isMobile, searchTerm, addressFormat }:
...
@@ -34,7 +34,7 @@ const SearchBarSuggestAddress = ({ data, isMobile, searchTerm, addressFormat }:
const
nameEl
=
addressName
&&
(
const
nameEl
=
addressName
&&
(
<
Flex
alignItems=
"center"
>
<
Flex
alignItems=
"center"
>
<
Text
<
Text
variant=
"
secondary"
color=
"text.
secondary"
overflow=
"hidden"
overflow=
"hidden"
whiteSpace=
"nowrap"
whiteSpace=
"nowrap"
textOverflow=
"ellipsis"
textOverflow=
"ellipsis"
...
...
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestApp.tsx
View file @
f5cdbc78
import
{
Image
,
Flex
,
Text
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Flex
,
Text
}
from
'
@chakra-ui/react
'
;
import
NextLink
from
'
next/link
'
;
import
NextLink
from
'
next/link
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
MarketplaceAppOverview
}
from
'
types/client/marketplace
'
;
import
type
{
MarketplaceAppOverview
}
from
'
types/client/marketplace
'
;
import
highlightText
from
'
lib/highlightText
'
;
import
highlightText
from
'
lib/highlightText
'
;
import
{
useColorModeValue
}
from
'
toolkit/chakra/color-mode
'
;
import
{
Image
}
from
'
toolkit/chakra/image
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
SearchBarSuggestItemLink
from
'
./SearchBarSuggestItemLink
'
;
import
SearchBarSuggestItemLink
from
'
./SearchBarSuggestItemLink
'
;
...
@@ -45,7 +47,7 @@ const SearchBarSuggestApp = ({ data, isMobile, searchTerm, onClick }: Props) =>
...
@@ -45,7 +47,7 @@ const SearchBarSuggestApp = ({ data, isMobile, searchTerm, onClick }: Props) =>
{
data
.
external
&&
<
IconSvg
name=
"link_external"
color=
"icon_link_external"
boxSize=
{
3
}
verticalAlign=
"middle"
flexShrink=
{
0
}
/>
}
{
data
.
external
&&
<
IconSvg
name=
"link_external"
color=
"icon_link_external"
boxSize=
{
3
}
verticalAlign=
"middle"
flexShrink=
{
0
}
/>
}
</
Flex
>
</
Flex
>
<
Text
<
Text
variant=
"
secondary"
color=
"text.
secondary"
overflow=
"hidden"
overflow=
"hidden"
textOverflow=
"ellipsis"
textOverflow=
"ellipsis"
style=
{
{
style=
{
{
...
@@ -73,7 +75,7 @@ const SearchBarSuggestApp = ({ data, isMobile, searchTerm, onClick }: Props) =>
...
@@ -73,7 +75,7 @@ const SearchBarSuggestApp = ({ data, isMobile, searchTerm, onClick }: Props) =>
<
span
dangerouslySetInnerHTML=
{
{
__html
:
highlightText
(
data
.
title
,
searchTerm
)
}
}
/>
<
span
dangerouslySetInnerHTML=
{
{
__html
:
highlightText
(
data
.
title
,
searchTerm
)
}
}
/>
</
Text
>
</
Text
>
<
Text
<
Text
variant=
"
secondary"
color=
"text.
secondary"
overflow=
"hidden"
overflow=
"hidden"
whiteSpace=
"nowrap"
whiteSpace=
"nowrap"
textOverflow=
"ellipsis"
textOverflow=
"ellipsis"
...
...
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestBlock.tsx
View file @
f5cdbc78
import
{
Text
,
Flex
,
Grid
,
Tag
}
from
'
@chakra-ui/react
'
;
import
{
Text
,
Flex
,
Grid
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
ItemsProps
}
from
'
./types
'
;
import
type
{
ItemsProps
}
from
'
./types
'
;
...
@@ -6,6 +6,7 @@ import type { SearchResultBlock } from 'types/client/search';
...
@@ -6,6 +6,7 @@ import type { SearchResultBlock } from 'types/client/search';
import
dayjs
from
'
lib/date/dayjs
'
;
import
dayjs
from
'
lib/date/dayjs
'
;
import
highlightText
from
'
lib/highlightText
'
;
import
highlightText
from
'
lib/highlightText
'
;
import
{
Tag
}
from
'
toolkit/chakra/tag
'
;
import
*
as
BlockEntity
from
'
ui/shared/entities/block/BlockEntity
'
;
import
*
as
BlockEntity
from
'
ui/shared/entities/block/BlockEntity
'
;
import
HashStringShortenDynamic
from
'
ui/shared/HashStringShortenDynamic
'
;
import
HashStringShortenDynamic
from
'
ui/shared/HashStringShortenDynamic
'
;
...
@@ -26,7 +27,7 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: ItemsProps<Search
...
@@ -26,7 +27,7 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: ItemsProps<Search
);
);
const
hash
=
!
isFutureBlock
?
(
const
hash
=
!
isFutureBlock
?
(
<
Text
<
Text
variant=
"
secondary"
color=
"text.
secondary"
overflow=
"hidden"
overflow=
"hidden"
whiteSpace=
"nowrap"
whiteSpace=
"nowrap"
as=
{
shouldHighlightHash
?
'
mark
'
:
'
span
'
}
as=
{
shouldHighlightHash
?
'
mark
'
:
'
span
'
}
...
@@ -36,7 +37,7 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: ItemsProps<Search
...
@@ -36,7 +37,7 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: ItemsProps<Search
</
Text
>
</
Text
>
)
:
null
;
)
:
null
;
const
date
=
!
isFutureBlock
?
dayjs
(
data
.
timestamp
).
format
(
'
llll
'
)
:
undefined
;
const
date
=
!
isFutureBlock
?
dayjs
(
data
.
timestamp
).
format
(
'
llll
'
)
:
undefined
;
const
futureBlockText
=
<
Text
variant=
"
secondary"
>
Learn estimated time for this block to be created.
</
Text
>;
const
futureBlockText
=
<
Text
color=
"text.
secondary"
>
Learn estimated time for this block to be created.
</
Text
>;
if
(
isMobile
)
{
if
(
isMobile
)
{
return
(
return
(
...
@@ -48,7 +49,7 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: ItemsProps<Search
...
@@ -48,7 +49,7 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: ItemsProps<Search
{
data
.
block_type
===
'
uncle
'
&&
<
Tag
ml=
"auto"
>
Uncle
</
Tag
>
}
{
data
.
block_type
===
'
uncle
'
&&
<
Tag
ml=
"auto"
>
Uncle
</
Tag
>
}
</
Flex
>
</
Flex
>
{
hash
}
{
hash
}
{
isFutureBlock
?
futureBlockText
:
<
Text
variant=
"
secondary"
>
{
date
}
</
Text
>
}
{
isFutureBlock
?
futureBlockText
:
<
Text
color=
"text.
secondary"
>
{
date
}
</
Text
>
}
</>
</>
);
);
}
}
...
@@ -64,7 +65,7 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: ItemsProps<Search
...
@@ -64,7 +65,7 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: ItemsProps<Search
{
data
.
block_type
===
'
uncle
'
&&
<
Tag
flexShrink=
{
0
}
>
Uncle
</
Tag
>
}
{
data
.
block_type
===
'
uncle
'
&&
<
Tag
flexShrink=
{
0
}
>
Uncle
</
Tag
>
}
{
isFutureBlock
?
futureBlockText
:
hash
}
{
isFutureBlock
?
futureBlockText
:
hash
}
</
Flex
>
</
Flex
>
{
date
&&
<
Text
variant=
"
secondary"
textAlign=
"end"
>
{
date
}
</
Text
>
}
{
date
&&
<
Text
color=
"text.
secondary"
textAlign=
"end"
>
{
date
}
</
Text
>
}
</
Grid
>
</
Grid
>
);
);
};
};
...
...
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestDomain.tsx
View file @
f5cdbc78
...
@@ -29,7 +29,7 @@ const SearchBarSuggestDomain = ({ data, isMobile, searchTerm, addressFormat }: I
...
@@ -29,7 +29,7 @@ const SearchBarSuggestDomain = ({ data, isMobile, searchTerm, addressFormat }: I
<
Text
<
Text
overflow=
"hidden"
overflow=
"hidden"
whiteSpace=
"nowrap"
whiteSpace=
"nowrap"
variant=
"
secondary"
color=
"text.
secondary"
>
>
<
HashStringShortenDynamic
hash=
{
hash
}
isTooltipDisabled
/>
<
HashStringShortenDynamic
hash=
{
hash
}
isTooltipDisabled
/>
</
Text
>
</
Text
>
...
@@ -40,7 +40,7 @@ const SearchBarSuggestDomain = ({ data, isMobile, searchTerm, addressFormat }: I
...
@@ -40,7 +40,7 @@ const SearchBarSuggestDomain = ({ data, isMobile, searchTerm, addressFormat }: I
const
expiresText
=
data
.
ens_info
?.
expiry_date
?
` expires
${
dayjs
(
data
.
ens_info
.
expiry_date
).
fromNow
()
}
`
:
''
;
const
expiresText
=
data
.
ens_info
?.
expiry_date
?
` expires
${
dayjs
(
data
.
ens_info
.
expiry_date
).
fromNow
()
}
`
:
''
;
const
ensNamesCount
=
data
?.
ens_info
.
names_count
>
39
?
'
40+
'
:
`+
${
data
.
ens_info
.
names_count
-
1
}
`
;
const
ensNamesCount
=
data
?.
ens_info
.
names_count
>
39
?
'
40+
'
:
`+
${
data
.
ens_info
.
names_count
-
1
}
`
;
const
additionalInfo
=
(
const
additionalInfo
=
(
<
Text
variant=
"
secondary"
textAlign=
{
isMobile
?
'
start
'
:
'
end
'
}
>
<
Text
color=
"text.
secondary"
textAlign=
{
isMobile
?
'
start
'
:
'
end
'
}
>
{
data
?.
ens_info
.
names_count
>
1
?
ensNamesCount
:
expiresText
}
{
data
?.
ens_info
.
names_count
>
1
?
ensNamesCount
:
expiresText
}
</
Text
>
</
Text
>
);
);
...
...
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestItemLink.tsx
View file @
f5cdbc78
import
{
chakra
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
chakra
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
type
Props
=
{
type
Props
=
{
...
@@ -8,9 +8,10 @@ type Props = {
...
@@ -8,9 +8,10 @@ type Props = {
children
:
React
.
ReactNode
;
children
:
React
.
ReactNode
;
};
};
const
SearchBarSuggestItemLink
=
({
onClick
,
href
,
target
,
children
}:
Props
)
=>
{
const
SearchBarSuggestItemLink
=
React
.
forwardRef
<
HTMLAnchorElement
,
Props
>
(({
onClick
,
href
,
target
,
children
},
ref
)
=>
{
return
(
return
(
<
chakra
.
a
<
chakra
.
a
ref=
{
ref
}
py=
{
3
}
py=
{
3
}
px=
{
1
}
px=
{
1
}
display=
"flex"
display=
"flex"
...
@@ -22,9 +23,9 @@ const SearchBarSuggestItemLink = ({ onClick, href, target, children }: Props) =>
...
@@ -22,9 +23,9 @@ const SearchBarSuggestItemLink = ({ onClick, href, target, children }: Props) =>
borderBottomWidth
:
'
0
'
,
borderBottomWidth
:
'
0
'
,
}
}
}
}
_hover=
{
{
_hover=
{
{
bgColor
:
useColorModeValue
(
'
blue.50
'
,
'
gray.800
'
)
,
bgColor
:
{
_light
:
'
blue.50
'
,
_dark
:
'
gray.800
'
}
,
}
}
}
}
fontSiz
e=
"sm"
textStyl
e=
"sm"
_first=
{
{
_first=
{
{
mt
:
2
,
mt
:
2
,
}
}
}
}
...
@@ -35,6 +36,6 @@ const SearchBarSuggestItemLink = ({ onClick, href, target, children }: Props) =>
...
@@ -35,6 +36,6 @@ const SearchBarSuggestItemLink = ({ onClick, href, target, children }: Props) =>
{
children
}
{
children
}
</
chakra
.
a
>
</
chakra
.
a
>
);
);
};
}
)
;
export
default
SearchBarSuggestItemLink
;
export
default
SearchBarSuggestItemLink
;
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestLabel.tsx
View file @
f5cdbc78
...
@@ -28,7 +28,7 @@ const SearchBarSuggestLabel = ({ data, isMobile, searchTerm, addressFormat }: It
...
@@ -28,7 +28,7 @@ const SearchBarSuggestLabel = ({ data, isMobile, searchTerm, addressFormat }: It
<
Text
<
Text
overflow=
"hidden"
overflow=
"hidden"
whiteSpace=
"nowrap"
whiteSpace=
"nowrap"
variant=
"
secondary"
color=
"text.
secondary"
>
>
<
HashStringShortenDynamic
hash=
{
hash
}
isTooltipDisabled
/>
<
HashStringShortenDynamic
hash=
{
hash
}
isTooltipDisabled
/>
</
Text
>
</
Text
>
...
...
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestToken.tsx
View file @
f5cdbc78
...
@@ -29,7 +29,7 @@ const SearchBarSuggestToken = ({ data, isMobile, searchTerm, addressFormat }: It
...
@@ -29,7 +29,7 @@ const SearchBarSuggestToken = ({ data, isMobile, searchTerm, addressFormat }: It
);
);
const
address
=
(
const
address
=
(
<
Text
variant=
"
secondary"
whiteSpace=
"nowrap"
overflow=
"hidden"
>
<
Text
color=
"text.
secondary"
whiteSpace=
"nowrap"
overflow=
"hidden"
>
<
HashStringShortenDynamic
hash=
{
hash
}
isTooltipDisabled
/>
<
HashStringShortenDynamic
hash=
{
hash
}
isTooltipDisabled
/>
</
Text
>
</
Text
>
);
);
...
...
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestTx.tsx
View file @
f5cdbc78
...
@@ -24,7 +24,7 @@ const SearchBarSuggestTx = ({ data, isMobile }: ItemsProps<SearchResultTx>) => {
...
@@ -24,7 +24,7 @@ const SearchBarSuggestTx = ({ data, isMobile }: ItemsProps<SearchResultTx>) => {
{
icon
}
{
icon
}
{
hash
}
{
hash
}
</
Flex
>
</
Flex
>
<
Text
variant=
"
secondary"
>
{
date
}
</
Text
>
<
Text
color=
"text.
secondary"
>
{
date
}
</
Text
>
</>
</>
);
);
}
}
...
@@ -35,7 +35,7 @@ const SearchBarSuggestTx = ({ data, isMobile }: ItemsProps<SearchResultTx>) => {
...
@@ -35,7 +35,7 @@ const SearchBarSuggestTx = ({ data, isMobile }: ItemsProps<SearchResultTx>) => {
{
icon
}
{
icon
}
{
hash
}
{
hash
}
</
Flex
>
</
Flex
>
<
Text
variant=
"
secondary"
textAlign=
"end"
flexShrink=
{
0
}
ml=
"auto"
>
{
date
}
</
Text
>
<
Text
color=
"text.
secondary"
textAlign=
"end"
flexShrink=
{
0
}
ml=
"auto"
>
{
date
}
</
Text
>
</
Flex
>
</
Flex
>
);
);
};
};
...
...
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestUserOp.tsx
View file @
f5cdbc78
...
@@ -24,7 +24,7 @@ const SearchBarSuggestUserOp = ({ data, isMobile }: ItemsProps<SearchResultUserO
...
@@ -24,7 +24,7 @@ const SearchBarSuggestUserOp = ({ data, isMobile }: ItemsProps<SearchResultUserO
{
icon
}
{
icon
}
{
hash
}
{
hash
}
</
Flex
>
</
Flex
>
<
Text
variant=
"
secondary"
>
{
date
}
</
Text
>
<
Text
color=
"text.
secondary"
>
{
date
}
</
Text
>
</>
</>
);
);
}
}
...
@@ -35,7 +35,7 @@ const SearchBarSuggestUserOp = ({ data, isMobile }: ItemsProps<SearchResultUserO
...
@@ -35,7 +35,7 @@ const SearchBarSuggestUserOp = ({ data, isMobile }: ItemsProps<SearchResultUserO
{
icon
}
{
icon
}
{
hash
}
{
hash
}
</
Flex
>
</
Flex
>
<
Text
variant=
"
secondary"
textAlign=
"end"
flexShrink=
{
0
}
ml=
"auto"
>
{
date
}
</
Text
>
<
Text
color=
"text.
secondary"
textAlign=
"end"
flexShrink=
{
0
}
ml=
"auto"
>
{
date
}
</
Text
>
</
Flex
>
</
Flex
>
);
);
};
};
...
...
ui/snippets/topBar/settings/Settings.tsx
View file @
f5cdbc78
...
@@ -16,7 +16,6 @@ const Settings = () => {
...
@@ -16,7 +16,6 @@ const Settings = () => {
return
(
return
(
<
PopoverRoot
<
PopoverRoot
positioning=
{
{
placement
:
'
bottom-start
'
}
}
positioning=
{
{
placement
:
'
bottom-start
'
}
}
lazyMount
open=
{
open
}
open=
{
open
}
onOpenChange=
{
onOpenChange
}
onOpenChange=
{
onOpenChange
}
>
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment