Skip to content

Thread #23

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

Merged
merged 2 commits into from
Feb 22, 2024
Merged
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
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Social media share buttons for your next React.js, Next.js apps.
- Refind
- Skype
- Telegram
- Threads
- Trello
- Tumblr
- Twitter
Expand Down Expand Up @@ -512,6 +513,28 @@ import { TrelloShareBtn } from 'dv-social-share'

---

## ThreadsShare

#### 👨‍💻 Code


```js copy
import { ThreadsShareBtn } from 'dv-social-share'

<ThreadsShareBtn url="https://dv-social-share.vercel.app" title="dv-social-share is a social share buttons for your next React.js & Next.js apps." />
```

#### 📖 ThreadsShareBtn Props

| Props | Type | Default | Description | Required |
| :----------- | :------ | :------ | :---------------------------------------------------------------------------------------------------------------------------- | :------- |
| url | string | | The URL of the to be page. | ✅ |
| title | string | | Description of the shared page. | ❌ |
| openInNewTab | boolean | false | Open share window in a new tab if set to `true`. | ❌ |
| imgConfig | object | | A imgConfig contains width (number; e.g. 32/64), height (number; e.g. 32/64) & bgColor (string; e.g. '#FF0000') for the Image | ❌ |

---

## TumblrShare

#### 👨‍💻 Code
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dv-social-share",
"version": "0.0.6-1",
"version": "0.0.7",
"description": "Social media share buttons for your next apps like React, Next.js in TypeScript.",
"author": "Dhaval Vira <dhavalveera@gmail.com> (https://github.com/dhavalveera)",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {
},
],
// external: builtins,
external: ['react'],
external: ['react', 'react-dom'],
plugins: [
resolve(),
babel({
Expand All @@ -35,7 +35,7 @@ export default {
// }),
// nodeResolve(),
commonjs({
extensions: ['.js', '.ts', '.tsx'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
}),
terser(),
],
Expand Down
35 changes: 35 additions & 0 deletions src/Buttons/ThreadsShare/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// UTILS
import { generateQueryParams } from '../../utils'

// Make Share Button => Contains Main Logic
import MakeShareButton from '../../ShareButton'

// Icon
import { ThreadsShareIcon } from '../../Icons'

// CONSTANTS
import { defaultImgConfig, dontOpenShareDialogOnClick, THREADS_NAME } from '../../constants'

type GenerateThreadsLinkType = { title?: string; separator?: string }

type ThreadsShareBtnTypes = {
url: string
title?: string
separator?: string
openInNewTab?: boolean
imgConfig?: {
width?: number
height?: number
bgColor?: string
}
}

const generateThreadsLink = (url: string, { title, separator = ' :: ' }: GenerateThreadsLinkType) => {
return `https://www.threads.net/intent/post${generateQueryParams({ text: title ? title + separator + url : url })}`
}

const ThreadsShareBtn = ({ url, title, separator, openInNewTab, imgConfig }: ThreadsShareBtnTypes) => {
return MakeShareButton(THREADS_NAME, generateThreadsLink(url, { title, separator }), ThreadsShareIcon, openInNewTab || dontOpenShareDialogOnClick, imgConfig || defaultImgConfig)
}

export default ThreadsShareBtn
4 changes: 2 additions & 2 deletions src/Buttons/WhatsAppShare/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Utils
import { generateQueryParams, isMobileOrTablet } from '../../utils'
import { generateQueryParams } from '../../utils'

// Make Share Button => Contains Main logic
import MakeShareButton from '../../ShareButton'
Expand All @@ -25,7 +25,7 @@ type WhatsAppShareBtnTypes = {
}

const generateWhatsAppLink = (url: string, { title, separator = ' :: ' }: GenerateWhatsAppLinkTypes) => {
return `https://${isMobileOrTablet() ? 'api' : 'web'}.whatsapp.com/send${generateQueryParams({ text: title ? title + separator + url : url })}`
return `https://api.whatsapp.com/send${generateQueryParams({ text: title ? title + separator + url : url })}`
}

const WhatsAppShareBtn = ({ url, title, separator, openInNewTab, imgConfig }: WhatsAppShareBtnTypes) => {
Expand Down
3 changes: 3 additions & 0 deletions src/Icons/ThreadsShareIcon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const ThreadsShareIcon: string = 'data:image/webp;base64,UklGRlYKAABXRUJQVlA4WAoAAAAIAAAA9QAA9QAAVlA4INQJAABwPACdASr2APYAPpVGlUYjIqEWmoQcNAlE9Ldwty8Ae3ivlTdA6+Mv8J2k/4Tzbrvwl/yH7tfw/MnvH4AXrz/R70DZX0CO7/o/TUMgDgKaAH6F9BLPb9P+wz5WfsO/c72eSYO3PdIM28zWsQO3FIRpc5+Lc1rEDtzo1oDj/7+OFhWi/txvjCIY7nJuZomren2OIEgzburg198wW3fQO29a/Jl4VQJi2HLXkuOqihDx45rWDVwPEVmlGsx7ypzZjIJI1BPEw8kRvm8NHlwG+FU1Np/MHv3En0FNgUD8ozL7+CwqYldbw0Jcsrcx//N+blD1AydOlJwlrWEVC5nKe7FeZPKQoODkBtGcN64D6P9YZIs4INPR1zRro66Ddv26jAKbdoS4OwuNi+jWt41Ny/uHaNzJOqeTdgpRoZtoS+xGwaflkLBh454NTaOEvADgeTWbltL5a9zxZyGL2JofpXMCa53yDOOtYj1IdBtn2ZUMmJDYZWWko++RMW4Rm6nIuHbuT5dCM8EmNGjsaeDUgNHhA7F14QOS5wBT+xRG0FbB5XY1EwDAquXd29iB25zJaTBj9wy4UP7f4yAYxK9kf1kO5ozGeuSeQBXMym/oONMTXc4O0y/1FrTaQYSHCAK5mtYgdue6QZt5mtYgaAAA/ugLJGieWitNn/LOpV+uICsCtdJLA1B1rm9VmMRrI2Ja8BvYK2U2DZ3447Y7C2W8wW3wWUPe2j+VsFKWc3OfuJ7ETDq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wSVUJFfEunAljj41I5NkJLUo8fArThHvtgeZTa7VHERgGsMal0F9uecJiz3Ja3nTmg2b0Y7U58ACMFx437B0BVUjeQ6IzatuH/TX7t7vpOuGTRZZOeE2zVGN1ww5WBT0OryjZ7BDqqphc5IO6YegYWymAR3hGkK5zwssMLGE7fZVQcvms/PyaO011H/Q+ewxWKTDeuJrbQ3IJciKVy3QMt+Z7GblGPfpbTXga5Xeza4VnUe99PrnvcRTYY+0E7ttVo2hm4IrUTa+qdTC4dsUULKkF7WiMjNVEsP4G2M6fvpknbqx9yjz+krK6rd4n35dX9e809v5iiCn1rmiYYoIe1byGPGdMxsJl1YMeIl4kXvRHB17YqXc8Pn1WkLzg5VQCJnxsP8N1nOrEtx77cteesutdlZULidFv9iG8Kxg40izQaImirA9UmniLl426HoAAAAEVYSUZbAAAASUkqAAgAAAABAGmHBAABAAAAGgAAAAAAAAABAIaSBwAyAAAALAAAAAAAAABBU0NJSQAAADEuODIuMC0yU1JOU0NaM1BLSjVGWUIzMkVPQ09LWDRYSS4wLjItMAA='

export default ThreadsShareIcon
1 change: 1 addition & 0 deletions src/Icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export { default as RedditShareIcon } from './RedditShareIcon'
export { default as RefindShareIcon } from './RefindShareIcon'
export { default as SkypeShareIcon } from './SkypeShare'
export { default as TelegramShareIcon } from './TelegramShareIcon'
export { default as ThreadsShareIcon } from './ThreadsShareIcon'
export { default as TrelloShareIcon } from './TrelloShareIcon'
export { default as TumblrShareIcon } from './TumblrShareIcon'
export { default as TwitterShareIcon } from './TwitterShareIcon'
Expand Down
2 changes: 0 additions & 2 deletions src/ShareButton/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ const MakeShareButton = (name: string, url: string, Icon: string, openShareDialo
CustomWindow(url, windowConfig, openShareDialogOnClick)
}

console.log({ name, url, Icon, imgConfig })

return createElement(
'button',
{ type: 'button', 'aria-label': `${name}-Share`, title: name, onClick: handleOnClick, className: ShareBtnCss },
Expand Down
1 change: 1 addition & 0 deletions src/constants/ButtonNames/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const REDDIT_NAME: string = 'Reddit'
export const REFIND_NAME: string = 'Refind'
export const SKYPE_NAME: string = 'Skype'
export const TELEGRAM_NAME: string = 'Telegram'
export const THREADS_NAME:string = 'Threads'
export const TRELLO_NAME: string = 'Trello'
export const TUMBLR_NAME: string = 'Tumblr'
export const TWITTER_NAME: string = 'Twitter'
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export { default as RedditShareBtn } from './Buttons/RedditShare'
export { default as RefindShareBtn } from './Buttons/RefindShare'
export { default as SkypeShareBtn } from './Buttons/SkypeShare'
export { default as TelegramShareBtn } from './Buttons/TelegramShare'
export { default as ThreadsShareBtn } from './Buttons/ThreadsShare'
export { default as TrelloShareBtn } from './Buttons/TrelloShare'
export { default as TumblrShareBtn } from './Buttons/TumblrShare'
export { default as TwitterShareBtn } from './Buttons/TwitterShare'
Expand Down