Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
3ee92e97
Unverified
Commit
3ee92e97
authored
Dec 05, 2019
by
Lyza Gardner
Committed by
GitHub
Dec 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1569 from hypothesis/fix-sharing-links-links
Update sharing links to open in blank browser window
parents
bf4c06c2
9c06646f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
29 deletions
+54
-29
share-links.js
src/sidebar/components/share-links.js
+54
-29
No files found.
src/sidebar/components/share-links.js
View file @
3ee92e97
...
...
@@ -7,10 +7,42 @@ const { withServices } = require('../util/service-context');
const
SvgIcon
=
require
(
'./svg-icon'
);
/**
* A single sharing link as a list item
*/
function
ShareLink
({
iconName
,
title
,
uri
,
onClick
})
{
return
(
<
li
className
=
"share-links__link"
>
<
a
href
=
{
uri
}
title
=
{
title
}
onClick
=
{
onClick
}
target
=
"_blank"
rel
=
"noopener noreferrer"
>
<
SvgIcon
name
=
{
iconName
}
className
=
"share-links__icon"
/>
<
/a
>
<
/li
>
);
}
ShareLink
.
propTypes
=
{
/** The name of the SVG icon to use for this link */
iconName
:
propTypes
.
string
.
isRequired
,
/** link title */
title
:
propTypes
.
string
.
isRequired
,
/** URI for sharing this annotation on the given social service */
uri
:
propTypes
.
string
.
isRequired
,
/** click callback (for analytics tracking) */
onClick
:
propTypes
.
func
.
isRequired
,
};
/**
* A list of share links to social-media platforms.
*/
function
ShareLinks
({
analytics
,
analyticsEventName
,
shareURI
})
{
// Return a click callback that will track click events for the given
// social platform (`shareTarget`)
const
trackShareClick
=
shareTarget
=>
{
return
()
=>
{
analytics
.
track
(
analyticsEventName
,
shareTarget
);
...
...
@@ -23,35 +55,28 @@ function ShareLinks({ analytics, analyticsEventName, shareURI }) {
return
(
<
ul
className
=
"share-links"
>
<
li
className
=
"share-links__link"
>
<
a
href
=
{
`https://twitter.com/intent/tweet?url=
${
encodedURI
}
&hashtags=annotated`
}
<
ShareLink
iconName
=
"twitter"
title
=
"Tweet share link"
uri
=
{
`https://twitter.com/intent/tweet?url=
${
encodedURI
}
&hashtags=annotated`
}
onClick
=
{
trackShareClick
(
'twitter'
)}
>
<
SvgIcon
name
=
"twitter"
className
=
"share-links__icon"
/>
<
/a
>
<
/li
>
<
li
className
=
"share-links__link"
>
<
a
href
=
{
`https://www.facebook.com/sharer/sharer.php?u=
${
encodedURI
}
`
}
/
>
<
ShareLink
iconName
=
"facebook"
title
=
"Share on Facebook"
uri
=
{
`https://www.facebook.com/sharer/sharer.php?u=
${
encodedURI
}
`
}
onClick
=
{
trackShareClick
(
'facebook'
)}
>
<
SvgIcon
name
=
"facebook"
className
=
"share-links__icon"
/>
<
/a
>
<
/li
>
<
li
className
=
"share-links__link"
>
<
a
href
=
{
`mailto:?subject=
${
encodeURIComponent
(
/
>
<
ShareLink
iconName
=
"email"
title
=
"Share via email"
uri
=
{
`mailto:?subject=
${
encodeURIComponent
(
"Let's Annotate"
)}
&body=
${
encodedURI
}
`
}
title
=
"Share via email"
onClick
=
{
trackShareClick
(
'email'
)}
>
<
SvgIcon
name
=
"email"
className
=
"share-links__icon"
/>
<
/a
>
<
/li
>
/
>
<
/ul
>
);
}
...
...
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