diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-04-05 17:51:12 +0200 | 
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-04-05 17:51:12 +0200 | 
| commit | 0c1d12c7f951db56e501145bd73071480273340a (patch) | |
| tree | c2f694b31f5248bcc33c0cfa3eb685164ada2b6e /src/components/atoms/links/sharing-link.tsx | |
| parent | e8bac61a7f0be6c60624b00e06ab8d00efc932f8 (diff) | |
chore: add a SharingLink component
Diffstat (limited to 'src/components/atoms/links/sharing-link.tsx')
| -rw-r--r-- | src/components/atoms/links/sharing-link.tsx | 48 | 
1 files changed, 48 insertions, 0 deletions
| diff --git a/src/components/atoms/links/sharing-link.tsx b/src/components/atoms/links/sharing-link.tsx new file mode 100644 index 0000000..ca53ef9 --- /dev/null +++ b/src/components/atoms/links/sharing-link.tsx @@ -0,0 +1,48 @@ +import { FC } from 'react'; +import { useIntl } from 'react-intl'; +import styles from './sharing-link.module.scss'; + +export type SharingMedium = +  | 'diaspora' +  | 'email' +  | 'facebook' +  | 'journal-du-hacker' +  | 'linkedin' +  | 'twitter'; + +export type SharingLinkProps = { +  /** +   * The sharing medium id. +   */ +  medium: SharingMedium; +  /** +   * The sharing url. +   */ +  url: string; +}; + +/** + * SharingLink component + * + * Render a sharing link. + */ +const SharingLink: FC<SharingLinkProps> = ({ medium, url }) => { +  const intl = useIntl(); +  const text = intl.formatMessage( +    { +      defaultMessage: 'Share on {name}', +      description: 'Sharing: share on social network text', +      id: 'ureXFw', +    }, +    { name: medium } +  ); +  const mediumClass = `link--${medium}`; + +  return ( +    <a href={url} className={`${styles.link} ${styles[mediumClass]}`}> +      <span className="screen-reader-text">{text}</span> +    </a> +  ); +}; + +export default SharingLink; | 
