From 9fa8d31177170f771a27ff37e14235ba9c8f68ea Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Wed, 25 Mar 2020 22:11:45 +0100 Subject: [PATCH] Add Twitter --- src/index.ts | 1 + src/style.scss | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index ceb10a1..2cc52a4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,7 @@ type UrlBuilder = (data: PublishPreset) => string; const NETWORKS: { [name: string]: UrlBuilder } = { telegram: (d) => `https://telegram.me/share/url?url=${encodeURIComponent(d.url)}${(d.extra && d.extra.text) ? `&text=${encodeURIComponent(d.extra.text)}` : ''}`, + twitter: (d) => `https://twitter.com/intent/tweet?url=${encodeURIComponent(d.url)}&text=${encodeURIComponent(d.title)}${(d.extra && d.extra.via) ? `&via=${encodeURIComponent(d.extra.via)}` : ''}`, }; function initShareonChild(child: HTMLElement, preset: PublishPreset) { diff --git a/src/style.scss b/src/style.scss index e057a5f..c45bc3a 100644 --- a/src/style.scss +++ b/src/style.scss @@ -64,7 +64,7 @@ $width: $button-size - 2*$padding-hor; content: ''; vertical-align: bottom; } - + &.telegram { background-color: #27A7E5; @@ -74,5 +74,12 @@ $width: $button-size - 2*$padding-hor; } } + &.twitter { + background-color: #1da1f2; + + &::before { + background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23fff' d='M23.954 4.569a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.691 8.094 4.066 6.13 1.64 3.161a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.061a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.937 4.937 0 004.604 3.417 9.868 9.868 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.054 0 13.999-7.496 13.999-13.986 0-.209 0-.42-.015-.63a9.936 9.936 0 002.46-2.548l-.047-.02z'/%3E%3C/svg%3E"); + } + } } }