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
0594ad59
Commit
0594ad59
authored
Dec 28, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hide suggest when input is hidden on mobile
parent
add2a861
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
18 deletions
+41
-18
SearchResults.tsx
ui/pages/SearchResults.tsx
+8
-1
Transactions.tsx
ui/pages/Transactions.tsx
+1
-1
Page.tsx
ui/shared/Page/Page.tsx
+1
-3
Header.tsx
ui/snippets/header/Header.tsx
+3
-4
SearchBar.tsx
ui/snippets/searchBar/SearchBar.tsx
+18
-5
SearchBarInput.tsx
ui/snippets/searchBar/SearchBarInput.tsx
+10
-4
No files found.
ui/pages/SearchResults.tsx
View file @
0594ad59
...
@@ -102,15 +102,22 @@ const SearchResultsPageContent = () => {
...
@@ -102,15 +102,22 @@ const SearchResultsPageContent = () => {
);
);
})();
})();
const
inputRef
=
React
.
useRef
<
HTMLFormElement
>
(
null
);
const
handelHide
=
React
.
useCallback
(()
=>
{
inputRef
.
current
?.
querySelector
(
'
input
'
)?.
blur
();
},
[
]);
const
renderSearchBar
=
React
.
useCallback
(()
=>
{
const
renderSearchBar
=
React
.
useCallback
(()
=>
{
return
(
return
(
<
SearchBarInput
<
SearchBarInput
ref=
{
inputRef
}
onChange=
{
handleSearchTermChange
}
onChange=
{
handleSearchTermChange
}
onSubmit=
{
handleSubmit
}
onSubmit=
{
handleSubmit
}
value=
{
searchTerm
}
value=
{
searchTerm
}
onHide=
{
handelHide
}
/>
/>
);
);
},
[
handleSearchTermChange
,
handleSubmit
,
searchTerm
]);
},
[
handleSearchTermChange
,
handleSubmit
,
searchTerm
,
handelHide
]);
const
renderHeader
=
React
.
useCallback
(()
=>
{
const
renderHeader
=
React
.
useCallback
(()
=>
{
return
<
Header
renderSearchBar=
{
renderSearchBar
}
/>;
return
<
Header
renderSearchBar=
{
renderSearchBar
}
/>;
...
...
ui/pages/Transactions.tsx
View file @
0594ad59
...
@@ -35,7 +35,7 @@ const Transactions = () => {
...
@@ -35,7 +35,7 @@ const Transactions = () => {
];
];
return
(
return
(
<
Page
hideMobileHeaderOnScrollDown
>
<
Page
>
<
Box
h=
"100%"
>
<
Box
h=
"100%"
>
<
PageTitle
text=
"Transactions"
/>
<
PageTitle
text=
"Transactions"
/>
<
RoutedTabs
<
RoutedTabs
...
...
ui/shared/Page/Page.tsx
View file @
0594ad59
...
@@ -13,7 +13,6 @@ import NavigationDesktop from 'ui/snippets/navigation/NavigationDesktop';
...
@@ -13,7 +13,6 @@ import NavigationDesktop from 'ui/snippets/navigation/NavigationDesktop';
interface
Props
{
interface
Props
{
children
:
React
.
ReactNode
;
children
:
React
.
ReactNode
;
wrapChildren
?:
boolean
;
wrapChildren
?:
boolean
;
hideMobileHeaderOnScrollDown
?:
boolean
;
isHomePage
?:
boolean
;
isHomePage
?:
boolean
;
renderHeader
?:
()
=>
React
.
ReactNode
;
renderHeader
?:
()
=>
React
.
ReactNode
;
}
}
...
@@ -21,7 +20,6 @@ interface Props {
...
@@ -21,7 +20,6 @@ interface Props {
const
Page
=
({
const
Page
=
({
children
,
children
,
wrapChildren
=
true
,
wrapChildren
=
true
,
hideMobileHeaderOnScrollDown
,
isHomePage
,
isHomePage
,
renderHeader
,
renderHeader
,
}:
Props
)
=>
{
}:
Props
)
=>
{
...
@@ -47,7 +45,7 @@ const Page = ({
...
@@ -47,7 +45,7 @@ const Page = ({
<
Flex
flexDir=
"column"
flexGrow=
{
1
}
w=
{
{
base
:
'
100%
'
,
lg
:
'
auto
'
}
}
>
<
Flex
flexDir=
"column"
flexGrow=
{
1
}
w=
{
{
base
:
'
100%
'
,
lg
:
'
auto
'
}
}
>
{
renderHeader
?
{
renderHeader
?
renderHeader
()
:
renderHeader
()
:
<
Header
isHomePage=
{
isHomePage
}
hideOnScrollDown=
{
hideMobileHeaderOnScrollDown
}
/>
<
Header
isHomePage=
{
isHomePage
}
/>
}
}
<
ErrorBoundary
renderErrorScreen=
{
renderErrorScreen
}
>
<
ErrorBoundary
renderErrorScreen=
{
renderErrorScreen
}
>
{
renderedChildren
}
{
renderedChildren
}
...
...
ui/snippets/header/Header.tsx
View file @
0594ad59
...
@@ -13,15 +13,14 @@ import ColorModeToggler from './ColorModeToggler';
...
@@ -13,15 +13,14 @@ import ColorModeToggler from './ColorModeToggler';
type
Props
=
{
type
Props
=
{
isHomePage
?:
boolean
;
isHomePage
?:
boolean
;
hideOnScrollDown
?:
boolean
;
renderSearchBar
?:
()
=>
React
.
ReactNode
;
renderSearchBar
?:
()
=>
React
.
ReactNode
;
}
}
const
Header
=
({
hideOnScrollDown
,
isHomePage
,
renderSearchBar
}:
Props
)
=>
{
const
Header
=
({
isHomePage
,
renderSearchBar
}:
Props
)
=>
{
const
bgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
bgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
scrollDirection
=
useScrollDirection
();
const
scrollDirection
=
useScrollDirection
();
const
searchBar
=
renderSearchBar
?
renderSearchBar
()
:
<
SearchBar
withShadow=
{
!
hideOnScrollDown
}
/>;
const
searchBar
=
renderSearchBar
?
renderSearchBar
()
:
<
SearchBar
/>;
return
(
return
(
<>
<>
...
@@ -40,7 +39,7 @@ const Header = ({ hideOnScrollDown, isHomePage, renderSearchBar }: Props) => {
...
@@ -40,7 +39,7 @@ const Header = ({ hideOnScrollDown, isHomePage, renderSearchBar }: Props) => {
zIndex=
"sticky2"
zIndex=
"sticky2"
transitionProperty=
"box-shadow"
transitionProperty=
"box-shadow"
transitionDuration=
"slow"
transitionDuration=
"slow"
boxShadow=
{
!
hideOnScrollDown
&&
scrollDirection
===
'
down
'
?
'
md
'
:
'
none
'
}
boxShadow=
{
scrollDirection
===
'
down
'
?
'
md
'
:
'
none
'
}
>
>
<
Burger
/>
<
Burger
/>
<
NetworkLogo
/>
<
NetworkLogo
/>
...
...
ui/snippets/searchBar/SearchBar.tsx
View file @
0594ad59
import
{
Popover
,
PopoverTrigger
,
PopoverContent
,
PopoverBody
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
Popover
,
PopoverTrigger
,
PopoverContent
,
PopoverBody
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
_debounce
from
'
lodash/debounce
'
;
import
type
{
FormEvent
,
FocusEvent
}
from
'
react
'
;
import
type
{
FormEvent
,
FocusEvent
}
from
'
react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -10,11 +11,10 @@ import SearchBarSuggest from './SearchBarSuggest';
...
@@ -10,11 +11,10 @@ import SearchBarSuggest from './SearchBarSuggest';
import
useSearchQuery
from
'
./useSearchQuery
'
;
import
useSearchQuery
from
'
./useSearchQuery
'
;
type
Props
=
{
type
Props
=
{
withShadow
?:
boolean
;
isHomepage
?:
boolean
;
isHomepage
?:
boolean
;
}
}
const
SearchBar
=
({
isHomepage
,
withShadow
}:
Props
)
=>
{
const
SearchBar
=
({
isHomepage
}:
Props
)
=>
{
const
{
isOpen
,
onClose
,
onOpen
}
=
useDisclosure
();
const
{
isOpen
,
onClose
,
onOpen
}
=
useDisclosure
();
const
inputRef
=
React
.
useRef
<
HTMLFormElement
>
(
null
);
const
inputRef
=
React
.
useRef
<
HTMLFormElement
>
(
null
);
const
menuRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
menuRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
...
@@ -35,6 +35,11 @@ const SearchBar = ({ isHomepage, withShadow }: Props) => {
...
@@ -35,6 +35,11 @@ const SearchBar = ({ isHomepage, withShadow }: Props) => {
onOpen
();
onOpen
();
},
[
onOpen
]);
},
[
onOpen
]);
const
handelHide
=
React
.
useCallback
(()
=>
{
onClose
();
inputRef
.
current
?.
querySelector
(
'
input
'
)?.
blur
();
},
[
onClose
]);
const
handleBlur
=
React
.
useCallback
((
event
:
FocusEvent
<
HTMLFormElement
>
)
=>
{
const
handleBlur
=
React
.
useCallback
((
event
:
FocusEvent
<
HTMLFormElement
>
)
=>
{
const
isFocusInMenu
=
menuRef
.
current
?.
contains
(
event
.
relatedTarget
);
const
isFocusInMenu
=
menuRef
.
current
?.
contains
(
event
.
relatedTarget
);
if
(
!
isFocusInMenu
)
{
if
(
!
isFocusInMenu
)
{
...
@@ -48,10 +53,18 @@ const SearchBar = ({ isHomepage, withShadow }: Props) => {
...
@@ -48,10 +53,18 @@ const SearchBar = ({ isHomepage, withShadow }: Props) => {
},
[
menuPaddingX
]);
},
[
menuPaddingX
]);
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
const
inputEl
=
inputRef
.
current
;
if
(
!
inputEl
)
{
return
;
}
calculateMenuWidth
();
calculateMenuWidth
();
window
.
addEventListener
(
'
resize
'
,
calculateMenuWidth
);
const
resizeHandler
=
_debounce
(
calculateMenuWidth
,
200
);
const
resizeObserver
=
new
ResizeObserver
(
resizeHandler
);
resizeObserver
.
observe
(
inputRef
.
current
);
return
function
cleanup
()
{
return
function
cleanup
()
{
window
.
removeEventListener
(
'
resize
'
,
calculateMenuWidth
);
resizeObserver
.
unobserve
(
inputEl
);
};
};
},
[
calculateMenuWidth
]);
},
[
calculateMenuWidth
]);
...
@@ -71,8 +84,8 @@ const SearchBar = ({ isHomepage, withShadow }: Props) => {
...
@@ -71,8 +84,8 @@ const SearchBar = ({ isHomepage, withShadow }: Props) => {
onSubmit=
{
handleSubmit
}
onSubmit=
{
handleSubmit
}
onFocus=
{
handleFocus
}
onFocus=
{
handleFocus
}
onBlur=
{
handleBlur
}
onBlur=
{
handleBlur
}
onHide=
{
handelHide
}
isHomepage=
{
isHomepage
}
isHomepage=
{
isHomepage
}
withShadow=
{
withShadow
}
value=
{
searchTerm
}
value=
{
searchTerm
}
/>
/>
</
PopoverTrigger
>
</
PopoverTrigger
>
...
...
ui/snippets/searchBar/SearchBarInput.tsx
View file @
0594ad59
...
@@ -12,12 +12,12 @@ interface Props {
...
@@ -12,12 +12,12 @@ interface Props {
onSubmit
:
(
event
:
FormEvent
<
HTMLFormElement
>
)
=>
void
;
onSubmit
:
(
event
:
FormEvent
<
HTMLFormElement
>
)
=>
void
;
onBlur
?:
(
event
:
FocusEvent
<
HTMLFormElement
>
)
=>
void
;
onBlur
?:
(
event
:
FocusEvent
<
HTMLFormElement
>
)
=>
void
;
onFocus
?:
()
=>
void
;
onFocus
?:
()
=>
void
;
onHide
?:
()
=>
void
;
isHomepage
?:
boolean
;
isHomepage
?:
boolean
;
withShadow
?:
boolean
;
value
:
string
;
value
:
string
;
}
}
const
SearchBarInput
=
({
onChange
,
onSubmit
,
isHomepage
,
onFocus
,
onBlur
,
withShadow
,
value
}:
Props
,
ref
:
React
.
ForwardedRef
<
HTMLFormElement
>
)
=>
{
const
SearchBarInput
=
({
onChange
,
onSubmit
,
isHomepage
,
onFocus
,
onBlur
,
onHide
,
value
}:
Props
,
ref
:
React
.
ForwardedRef
<
HTMLFormElement
>
)
=>
{
const
[
isSticky
,
setIsSticky
]
=
React
.
useState
(
false
);
const
[
isSticky
,
setIsSticky
]
=
React
.
useState
(
false
);
const
scrollDirection
=
useScrollDirection
();
const
scrollDirection
=
useScrollDirection
();
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
...
@@ -28,7 +28,7 @@ const SearchBarInput = ({ onChange, onSubmit, isHomepage, onFocus, onBlur, withS
...
@@ -28,7 +28,7 @@ const SearchBarInput = ({ onChange, onSubmit, isHomepage, onFocus, onBlur, withS
}
else
{
}
else
{
setIsSticky
(
false
);
setIsSticky
(
false
);
}
}
},
[]);
},
[
]);
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
!
isMobile
||
isHomepage
)
{
if
(
!
isMobile
||
isHomepage
)
{
...
@@ -48,6 +48,12 @@ const SearchBarInput = ({ onChange, onSubmit, isHomepage, onFocus, onBlur, withS
...
@@ -48,6 +48,12 @@ const SearchBarInput = ({ onChange, onSubmit, isHomepage, onFocus, onBlur, withS
const
bgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
bgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
transformMobile
=
scrollDirection
!==
'
down
'
?
'
translateY(0)
'
:
'
translateY(-100%)
'
;
const
transformMobile
=
scrollDirection
!==
'
down
'
?
'
translateY(0)
'
:
'
translateY(-100%)
'
;
React
.
useEffect
(()
=>
{
if
(
isMobile
&&
scrollDirection
===
'
down
'
)
{
onHide
?.();
}
},
[
scrollDirection
,
onHide
,
isMobile
]);
return
(
return
(
<
chakra
.
form
<
chakra
.
form
ref=
{
ref
}
ref=
{
ref
}
...
@@ -65,7 +71,7 @@ const SearchBarInput = ({ onChange, onSubmit, isHomepage, onFocus, onBlur, withS
...
@@ -65,7 +71,7 @@ const SearchBarInput = ({ onChange, onSubmit, isHomepage, onFocus, onBlur, withS
paddingX=
{
{
base
:
isHomepage
?
0
:
4
,
lg
:
0
}
}
paddingX=
{
{
base
:
isHomepage
?
0
:
4
,
lg
:
0
}
}
paddingTop=
{
{
base
:
isHomepage
?
0
:
1
,
lg
:
0
}
}
paddingTop=
{
{
base
:
isHomepage
?
0
:
1
,
lg
:
0
}
}
paddingBottom=
{
{
base
:
isHomepage
?
0
:
4
,
lg
:
0
}
}
paddingBottom=
{
{
base
:
isHomepage
?
0
:
4
,
lg
:
0
}
}
boxShadow=
{
withShadow
&&
scrollDirection
!==
'
down
'
&&
isSticky
?
'
md
'
:
'
none
'
}
boxShadow=
{
scrollDirection
!==
'
down
'
&&
isSticky
?
'
md
'
:
'
none
'
}
transform=
{
{
base
:
isHomepage
?
'
none
'
:
transformMobile
,
lg
:
'
none
'
}
}
transform=
{
{
base
:
isHomepage
?
'
none
'
:
transformMobile
,
lg
:
'
none
'
}
}
transitionProperty=
"transform,box-shadow"
transitionProperty=
"transform,box-shadow"
transitionDuration=
"slow"
transitionDuration=
"slow"
...
...
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