Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
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
LuckySwap
interface
Commits
a34dc73c
Unverified
Commit
a34dc73c
authored
May 15, 2020
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't always redirect for links
parent
07fee045
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
17 deletions
+26
-17
components.tsx
src/theme/components.tsx
+26
-17
No files found.
src/theme/components.tsx
View file @
a34dc73c
...
@@ -58,29 +58,38 @@ const StyledLink = styled.a`
...
@@ -58,29 +58,38 @@ const StyledLink = styled.a`
}
}
`
`
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export
function
Link
({
export
function
Link
({
onClick
,
as
,
ref
,
target
,
href
,
rel
,
...
rest
}:
HTMLProps
<
HTMLAnchorElement
>
)
{
onClick
,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
as
,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ref
,
target
=
'
_blank
'
,
href
,
rel
=
'
noopener noreferrer
'
,
...
rest
}:
HTMLProps
<
HTMLAnchorElement
>
)
{
const
handleClick
=
useCallback
(
const
handleClick
=
useCallback
(
(
event
:
React
.
MouseEvent
<
HTMLAnchorElement
>
)
=>
{
(
event
:
React
.
MouseEvent
<
HTMLAnchorElement
>
)
=>
{
onClick
&&
onClick
(
event
)
// first call back into the original onClick
onClick
&&
onClick
(
event
)
// first call back into the original onClick
if
(
!
href
)
return
if
(
!
href
)
return
// don't prevent default, don't redirect
if
(
target
===
'
_blank
'
)
{
ReactGA
.
outboundLink
({
label
:
href
},
()
=>
{
console
.
debug
(
'
Fired outbound link event
'
,
href
)
})
}
else
{
event
.
preventDefault
()
event
.
preventDefault
()
// send a ReactGA event and then trigger a location change
// send a ReactGA event and then trigger a location change
ReactGA
.
outboundLink
({
label
:
href
},
()
=>
{
ReactGA
.
outboundLink
({
label
:
href
},
()
=>
{
window
.
location
.
href
=
href
window
.
location
.
href
=
href
})
})
}
},
},
[
href
,
onClick
]
[
href
,
onClick
,
target
]
)
return
(
<
StyledLink
target=
{
target
??
'
_blank
'
}
rel=
{
rel
??
'
noopener noreferrer
'
}
href=
{
href
}
onClick=
{
handleClick
}
{
...
rest
}
/>
)
)
return
<
StyledLink
target=
{
target
}
rel=
{
rel
}
href=
{
href
}
onClick=
{
handleClick
}
{
...
rest
}
/>
}
}
const
rotate
=
keyframes
`
const
rotate
=
keyframes
`
...
...
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