Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Maxime POULAIN
Web - TPs
Commits
c651d2b7
Commit
c651d2b7
authored
Feb 07, 2022
by
Maxime POULAIN
Browse files
disable search when not in home page
parent
6d00b000
Changes
1
Hide whitespace changes
Inline
Side-by-side
SportsCars/sports-cars/src/pages/header/header.js
View file @
c651d2b7
import
{
Link
}
from
"
react-router-dom
"
;
import
{
useLocation
}
from
'
react-router-dom
'
import
'
bootstrap/dist/css/bootstrap.css
'
...
...
@@ -32,6 +33,8 @@ const navItems = menus.map(menu => {
export
const
Header
=
({
onSearchChange
})
=>
{
const
location
=
useLocation
().
pathname
;
const
searchDisabled
=
location
!==
"
/home
"
;
return
(
<
nav
className
=
"
navbar navbar-expand-md navbar-light bg-transparent
"
>
<
Link
to
=
"
home
"
className
=
"
nav-link active
"
style
=
{{
color
:
'
inherit
'
,
textDecoration
:
'
inherit
'
}}
>
...
...
@@ -39,7 +42,7 @@ export const Header = ({ onSearchChange }) => {
<
/Link
>
<
form
className
=
"
form-inline my-2 my-lg-0 ml-5
"
>
<
input
className
=
"
form-control mr-sm-2
"
type
=
"
search
"
placeholder
=
"
Search
"
onChange
=
{(
event
)
=>
onSearchChange
(
event
.
target
.
value
)}
/
>
<
input
className
=
"
form-control mr-sm-2
"
type
=
"
search
"
placeholder
=
"
Search
"
onChange
=
{(
event
)
=>
onSearchChange
(
event
.
target
.
value
)}
disabled
=
{
searchDisabled
}
/
>
<
/form
>
<
ul
className
=
"
navbar-nav flex-grow-1 d-flex flex-row justify-content-end mx-5 mb-2
"
>
{
navItems
}
...
...
Write
Preview
Supports
Markdown
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