Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Web - TPs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maxime POULAIN
Web - TPs
Commits
c651d2b7
Commit
c651d2b7
authored
Feb 7, 2022
by
Maxime POULAIN
Browse files
Options
Downloads
Patches
Plain Diff
disable search when not in home page
parent
6d00b000
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
SportsCars/sports-cars/src/pages/header/header.js
+4
-1
4 additions, 1 deletion
SportsCars/sports-cars/src/pages/header/header.js
with
4 additions
and
1 deletion
SportsCars/sports-cars/src/pages/header/header.js
+
4
−
1
View file @
c651d2b7
import
{
Link
}
from
"
react-router-dom
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
{
useLocation
}
from
'
react-router-dom
'
import
'
bootstrap/dist/css/bootstrap.css
'
import
'
bootstrap/dist/css/bootstrap.css
'
...
@@ -32,6 +33,8 @@ const navItems = menus.map(menu => {
...
@@ -32,6 +33,8 @@ const navItems = menus.map(menu => {
export
const
Header
=
({
onSearchChange
})
=>
{
export
const
Header
=
({
onSearchChange
})
=>
{
const
location
=
useLocation
().
pathname
;
const
searchDisabled
=
location
!==
"
/home
"
;
return
(
return
(
<
nav
className
=
"
navbar navbar-expand-md navbar-light bg-transparent
"
>
<
nav
className
=
"
navbar navbar-expand-md navbar-light bg-transparent
"
>
<
Link
to
=
"
home
"
className
=
"
nav-link active
"
style
=
{{
color
:
'
inherit
'
,
textDecoration
:
'
inherit
'
}}
>
<
Link
to
=
"
home
"
className
=
"
nav-link active
"
style
=
{{
color
:
'
inherit
'
,
textDecoration
:
'
inherit
'
}}
>
...
@@ -39,7 +42,7 @@ export const Header = ({ onSearchChange }) => {
...
@@ -39,7 +42,7 @@ export const Header = ({ onSearchChange }) => {
<
/Link
>
<
/Link
>
<
form
className
=
"
form-inline my-2 my-lg-0 ml-5
"
>
<
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
>
<
/form
>
<
ul
className
=
"
navbar-nav flex-grow-1 d-flex flex-row justify-content-end mx-5 mb-2
"
>
<
ul
className
=
"
navbar-nav flex-grow-1 d-flex flex-row justify-content-end mx-5 mb-2
"
>
{
navItems
}
{
navItems
}
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment