├── .nvmrc ├── typings.d.ts ├── .github ├── FUNDING.yml ├── dependabot.yml ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ ├── main.yml │ └── release.yml ├── .gitignore ├── src ├── index.tsx ├── components │ ├── header.tsx │ ├── backdrop.tsx │ ├── portal.tsx │ ├── close.tsx │ ├── icon │ │ ├── index.tsx │ │ └── list.tsx │ └── social-icons.tsx ├── hooks │ └── use-disclosure.tsx ├── interfaces.ts ├── style.css └── sharer.tsx ├── .prettierrc.json ├── .vscode ├── settings.json └── extensions.json ├── .storybook ├── preview.js ├── preview-head.html └── main.js ├── stories └── web-share-component.stories.tsx ├── tsconfig.json ├── LICENSE ├── .eslintrc.cjs ├── package.json └── README.md /.nvmrc: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /typings.d.ts: -------------------------------------------------------------------------------- 1 | // declare module "*.css"; -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: harshzalavadiya 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | node_modules 4 | .cache 5 | dist 6 | storybook-static 7 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | export type { RWebShareProps } from "./interfaces"; 2 | export { RWebShare } from "./sharer"; 3 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": false 7 | } 8 | -------------------------------------------------------------------------------- /src/components/header.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export function Header({ title }) { 4 | return
{title}
; 5 | } 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | time: "23:30" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "workbench.colorCustomizations": { 3 | "activityBar.background": "#5a56a0", 4 | "titleBar.activeBackground": "#604e98", 5 | "titleBar.activeForeground": "#FBFAF9" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.storybook/preview.js: -------------------------------------------------------------------------------- 1 | export const parameters = { 2 | actions: { argTypesRegex: "^on[A-Z].*" }, 3 | controls: { 4 | matchers: { 5 | color: /(background|color)$/i, 6 | date: /Date$/, 7 | }, 8 | }, 9 | } -------------------------------------------------------------------------------- /.storybook/preview-head.html: -------------------------------------------------------------------------------- 1 | 19 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint", 4 | "dsznajder.es7-react-js-snippets", 5 | "esbenp.prettier-vscode", 6 | "meganrogge.template-string-converter", 7 | "paragdiwan.gitpatch", 8 | "shardulm94.trailing-spaces", 9 | "wix.vscode-import-cost", 10 | "formulahendry.auto-rename-tag" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/components/backdrop.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export function Backdrop({ children, onClose }) { 4 | const handleOnClose = (e) => { 5 | if (e.target === e.currentTarget) { 6 | onClose(e); 7 | } 8 | }; 9 | 10 | return ( 11 |
12 | {children} 13 |
14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /src/components/portal.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { createPortal } from "react-dom"; 3 | 4 | export const Portal: any = ({ children }: any) => { 5 | const el = document.createElement("div"); 6 | 7 | React.useEffect(() => { 8 | document.body.appendChild(el); 9 | return () => { 10 | document.body.removeChild(el); 11 | }; 12 | }, [el]); 13 | 14 | return createPortal(children, el); 15 | }; 16 | -------------------------------------------------------------------------------- /src/hooks/use-disclosure.tsx: -------------------------------------------------------------------------------- 1 | import { useCallback, useState } from "react"; 2 | 3 | export function useDisclosure() { 4 | const [isOpen, setIsOpen] = useState(false); 5 | 6 | const onOpen = useCallback(() => setIsOpen(true), []); 7 | const onClose = useCallback(() => setIsOpen(false), []); 8 | const onToggle = useCallback(() => setIsOpen((state) => !state), []); 9 | 10 | return { isOpen, onOpen, onClose, onToggle }; 11 | } 12 | -------------------------------------------------------------------------------- /src/components/close.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface CloseButtonProps { 4 | onClose; 5 | closeText?: string; 6 | } 7 | 8 | export function CloseButton({ onClose, closeText }: CloseButtonProps) { 9 | return ( 10 | 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /.storybook/main.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | stories: [ 3 | "../stories/**/*.stories.mdx", 4 | "../stories/**/*.stories.@(js|jsx|ts|tsx)", 5 | ], 6 | addons: [ 7 | "@storybook/addon-links", 8 | "@storybook/addon-essentials", 9 | { 10 | name: '@storybook/addon-docs', 11 | options: { 12 | configureJSX: true, 13 | transcludeMarkdown: true, 14 | }, 15 | }, 16 | ], 17 | framework: "@storybook/react", 18 | }; 19 | -------------------------------------------------------------------------------- /stories/web-share-component.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import { RWebShare } from "../src"; 4 | 5 | export default { 6 | title: "Welcome", 7 | }; 8 | 9 | export const Default = () => ( 10 |
11 |