* Losely based on: https://sharingbuttons.io/
(props)
| 7 | * Losely based on: https://sharingbuttons.io/ |
| 8 | */ |
| 9 | function ShareButton(props) { |
| 10 | let { type, title, description, ...rest } = props; |
| 11 | const site = window.location.href; |
| 12 | title = encodeURIComponent(title); |
| 13 | description = encodeURIComponent(description); |
| 14 | switch (type) { |
| 15 | case "Facebook": |
| 16 | return ( |
| 17 | <ColoredButton |
| 18 | color="#3b5998" |
| 19 | href={`https://facebook.com/sharer/sharer.php?u=${site}`} |
| 20 | startIcon={ |
| 21 | <SvgIcon> |
| 22 | <path d="M18.77 7.46H14.5v-1.9c0-.9.6-1.1 1-1.1h3V.5h-4.33C10.24.5 9.5 3.44 9.5 5.32v2.15h-3v4h3v12h5v-12h3.85l.42-4z" /> |
| 23 | </SvgIcon> |
| 24 | } |
| 25 | {...rest} |
| 26 | > |
| 27 | Share on Facebook |
| 28 | </ColoredButton> |
| 29 | ); |
| 30 | case "Twitter": { |
| 31 | return ( |
| 32 | <ColoredButton |
| 33 | color="#55acee" |
| 34 | href={`https://twitter.com/intent/tweet/?text=${description}&url=${site}`} |
| 35 | startIcon={ |
| 36 | <SvgIcon> |
| 37 | <path d="M23.44 4.83c-.8.37-1.5.38-2.22.02.93-.56.98-.96 1.32-2.02-.88.52-1.86.9-2.9 1.1-.82-.88-2-1.43-3.3-1.43-2.5 0-4.55 2.04-4.55 4.54 0 .36.03.7.1 1.04-3.77-.2-7.12-2-9.36-4.75-.4.67-.6 1.45-.6 2.3 0 1.56.8 2.95 2 3.77-.74-.03-1.44-.23-2.05-.57v.06c0 2.2 1.56 4.03 3.64 4.44-.67.2-1.37.2-2.06.08.58 1.8 2.26 3.12 4.25 3.16C5.78 18.1 3.37 18.74 1 18.46c2 1.3 4.4 2.04 6.97 2.04 8.35 0 12.92-6.92 12.92-12.93 0-.2 0-.4-.02-.6.9-.63 1.96-1.22 2.56-2.14z" /> |
nothing calls this directly
no outgoing calls
no test coverage detected