Skip to content

Adds Threads share button and icon #542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ npm install react-share
- Hatena
- Gab
- email
- Threads
- share counts for
- Facebook
- Pinterest
Expand Down Expand Up @@ -90,6 +91,7 @@ import {
PocketShareButton,
RedditShareButton,
TelegramShareButton,
ThreadsShareButton,
TumblrShareButton,
TwitterShareButton,
ViberShareButton,
Expand Down Expand Up @@ -118,6 +120,7 @@ import {
| PocketShareButton | - | **`title`** (string): Title of the shared page. Note that if Pocket detects a title tag on the page being saved, this parameter will be ignored and the title tag of the saved page will be used instead. |
| RedditShareButton | - | **`title`** (string): Title of the shared page |
| TelegramShareButton | - | **`title`** (string): Title of the shared page<br/> |
| ThreadsShareButton | - | **`title`** (string): Title of the shared page<br> **`url`**: (string)<br/> |
| TumblrShareButton | - | **`title`** (string): Title of the shared page<br/>**`tags`**: (`Array<string>`)<br/>**`caption`** (string): Description of the shared page<br/>**`posttype`** (string, default=`link`) |
| TwitterShareButton | - | **`title`** (string): Title of the shared page<br/>**`url`**: (string)<br/>**`hashtags`** (array): Hashtags<br/>**`related`** (array): Accounts to recommend following |
| ViberShareButton | - | **`title`** (string): Title of the shared page<br/>**`separator`** (string), default=`" "`: Separates title from the url |
Expand Down Expand Up @@ -178,6 +181,7 @@ import {
PocketIcon,
RedditIcon,
TelegramIcon,
ThreadsIcon,
TumblrIcon,
TwitterIcon,
ViberIcon,
Expand Down
12 changes: 12 additions & 0 deletions demo/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
RedditShareCount,
TelegramIcon,
TelegramShareButton,
ThreadsIcon,
ThreadsShareButton,
TumblrIcon,
TumblrShareButton,
TumblrShareCount,
Expand Down Expand Up @@ -305,6 +307,16 @@ export function Demo() {
<HatenaShareCount url={shareUrl} className="Demo__some-network__share-count" />
</div>
</div>

<div className="Demo__some-network">
<ThreadsShareButton
url={shareUrl}
title={title}
className="Demo__some-network__share-button"
>
<ThreadsIcon size={32} round />
</ThreadsShareButton>
</div>
</div>
);
}
Expand Down
9 changes: 9 additions & 0 deletions src/ThreadsIcon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import createIcon from './hocs/createIcon';

const ThreadsIcon = createIcon({
color: '#000000',
networkName: 'threads',
path: 'M0 0v64h64V0zm32.28 15.75h.02c3.718.026 6.827.982 9.241 2.84 2.272 1.75 3.872 4.238 4.753 7.404l-2.763.771c-1.495-5.362-5.278-8.102-11.245-8.145-3.94.03-6.918 1.267-8.855 3.678-1.81 2.259-2.747 5.523-2.783 9.702.036 4.18.971 7.443 2.785 9.702 1.937 2.415 4.918 3.652 8.857 3.678 3.552-.026 5.902-.855 7.855-2.77 2.23-2.184 2.19-4.864 1.476-6.496-.42-.962-1.184-1.76-2.214-2.368-.26 1.83-.843 3.311-1.74 4.43-1.199 1.49-2.898 2.306-5.05 2.423-1.628.088-3.198-.295-4.414-1.085-1.44-.933-2.28-2.355-2.372-4.013-.088-1.612.553-3.094 1.801-4.173 1.193-1.03 2.87-1.636 4.852-1.75 1.46-.081 2.827-.016 4.088.192-.169-1.004-.506-1.803-1.013-2.378-.696-.793-1.77-1.196-3.194-1.206h-.04c-1.144 0-2.697.315-3.685 1.787l-2.379-1.595c1.326-1.97 3.477-3.056 6.064-3.056h.058c4.326.026 6.904 2.676 7.16 7.297q.22.093.435.19c2.018.95 3.494 2.387 4.271 4.159 1.079 2.466 1.18 6.486-2.097 9.694-2.505 2.45-5.543 3.559-9.852 3.588h-.02c-4.85-.033-8.577-1.63-11.083-4.75-2.226-2.78-3.377-6.644-3.416-11.486v-.024c.04-4.846 1.19-8.706 3.42-11.485 2.502-3.123 6.233-4.722 11.079-4.755m1.368 16.669q-.49 0-1.001.03c-2.487.14-4.038 1.28-3.95 2.901.091 1.7 1.967 2.49 3.771 2.393 1.658-.088 3.816-.735 4.18-5.025-.917-.198-1.92-.3-3-.3',
});

export default ThreadsIcon;
34 changes: 34 additions & 0 deletions src/ThreadsShareButton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import assert from './utils/assert';
import objectToGetParams from './utils/objectToGetParams';
import createShareButton from './hocs/createShareButton';

function threadsLink(url: string, { title }: { title?: string }) {
assert(url, 'threads.url');

return (
'https://threads.net/intent/post' +
objectToGetParams({
url,
text: title,
})
);
}

const ThreadsShareButton = createShareButton<{
title?: string;
via?: string;
hashtags?: string[];
related?: string[];
}>(
'threads',
threadsLink,
props => ({
title: props.title,
}),
{
windowWidth: 550,
windowHeight: 600,
},
);

export default ThreadsShareButton;
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export { default as GabIcon } from './GabIcon';
export { default as RedditShareCount } from './RedditShareCount';
export { default as TelegramIcon } from './TelegramIcon';
export { default as TelegramShareButton } from './TelegramShareButton';
export { default as ThreadsIcon } from './ThreadsIcon';
export { default as ThreadsShareButton } from './ThreadsShareButton';
export { default as TumblrIcon } from './TumblrIcon';
export { default as TumblrShareButton } from './TumblrShareButton';
export { default as TumblrShareCount } from './TumblrShareCount';
Expand Down