@reuters-graphics/graphics-components 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/index.d.ts +0 -1
- package/dist/components/AdSlot/AdScripts.svelte +3 -3
- package/dist/index.js +0 -1
- package/package.json +1 -6
- package/dist/@types/components/Sharer/Sharer.svelte.d.ts +0 -23
- package/dist/@types/components/Sharer/utils/copyToClipboard.d.ts +0 -2
- package/dist/@types/components/Sharer/utils/facebook.d.ts +0 -2
- package/dist/@types/components/Sharer/utils/meta.d.ts +0 -2
- package/dist/@types/components/Sharer/utils/twitter.d.ts +0 -2
- package/dist/components/Sharer/Sharer.svelte +0 -157
- package/dist/components/Sharer/utils/copyToClipboard.js +0 -10
- package/dist/components/Sharer/utils/facebook.js +0 -22
- package/dist/components/Sharer/utils/meta.js +0 -7
- package/dist/components/Sharer/utils/twitter.js +0 -22
package/dist/@types/index.d.ts
CHANGED
|
@@ -28,7 +28,6 @@ export { default as ReutersLogo } from "./components/ReutersLogo/ReutersLogo.sve
|
|
|
28
28
|
export { default as Scroller } from "./components/Scroller/Scroller.svelte";
|
|
29
29
|
export { default as SearchInput } from "./components/SearchInput/SearchInput.svelte";
|
|
30
30
|
export { default as SEO } from "./components/SEO/SEO.svelte";
|
|
31
|
-
export { default as Sharer } from "./components/Sharer/Sharer.svelte";
|
|
32
31
|
export { default as SimpleTimeline } from "./components/SimpleTimeline/SimpleTimeline.svelte";
|
|
33
32
|
export { default as SiteFooter } from "./components/SiteFooter/SiteFooter.svelte";
|
|
34
33
|
export { default as SiteHeader } from "./components/SiteHeader/SiteHeader.svelte";
|
|
@@ -5,14 +5,16 @@
|
|
|
5
5
|
import { throttle } from 'lodash-es';
|
|
6
6
|
|
|
7
7
|
let lastScroll = 0;
|
|
8
|
-
let showManagePreferences =
|
|
8
|
+
let showManagePreferences = true;
|
|
9
9
|
|
|
10
10
|
const togglePrefs = (on = true) => {
|
|
11
11
|
const btn = document.getElementById('ot-sdk-btn-floating');
|
|
12
12
|
if (!btn) return;
|
|
13
13
|
if (on) {
|
|
14
|
+
showManagePreferences = true;
|
|
14
15
|
btn.style.bottom = '';
|
|
15
16
|
} else {
|
|
17
|
+
showManagePreferences = false;
|
|
16
18
|
btn.style.bottom = '-5rem';
|
|
17
19
|
}
|
|
18
20
|
};
|
|
@@ -20,12 +22,10 @@
|
|
|
20
22
|
const handleScroll = () => {
|
|
21
23
|
if (lastScroll > window.scrollY) {
|
|
22
24
|
if (!showManagePreferences) {
|
|
23
|
-
showManagePreferences = true;
|
|
24
25
|
togglePrefs(true);
|
|
25
26
|
}
|
|
26
27
|
} else {
|
|
27
28
|
if (showManagePreferences && window.scrollY > 250) {
|
|
28
|
-
showManagePreferences = false;
|
|
29
29
|
togglePrefs(false);
|
|
30
30
|
}
|
|
31
31
|
}
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,6 @@ export { default as ReutersLogo } from './components/ReutersLogo/ReutersLogo.sve
|
|
|
35
35
|
export { default as Scroller } from './components/Scroller/Scroller.svelte';
|
|
36
36
|
export { default as SearchInput } from './components/SearchInput/SearchInput.svelte';
|
|
37
37
|
export { default as SEO } from './components/SEO/SEO.svelte';
|
|
38
|
-
export { default as Sharer } from './components/Sharer/Sharer.svelte';
|
|
39
38
|
export { default as SimpleTimeline } from './components/SimpleTimeline/SimpleTimeline.svelte';
|
|
40
39
|
export { default as SiteFooter } from './components/SiteFooter/SiteFooter.svelte';
|
|
41
40
|
export { default as SiteHeader } from './components/SiteHeader/SiteHeader.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reuters-graphics/graphics-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://reuters-graphics.github.io/graphics-components",
|
|
@@ -186,11 +186,6 @@
|
|
|
186
186
|
"./components/SearchInput/MagnifyingGlass.svelte": "./dist/components/SearchInput/MagnifyingGlass.svelte",
|
|
187
187
|
"./components/SearchInput/SearchInput.svelte": "./dist/components/SearchInput/SearchInput.svelte",
|
|
188
188
|
"./components/SearchInput/X.svelte": "./dist/components/SearchInput/X.svelte",
|
|
189
|
-
"./components/Sharer/Sharer.svelte": "./dist/components/Sharer/Sharer.svelte",
|
|
190
|
-
"./components/Sharer/utils/copyToClipboard": "./dist/components/Sharer/utils/copyToClipboard.js",
|
|
191
|
-
"./components/Sharer/utils/facebook": "./dist/components/Sharer/utils/facebook.js",
|
|
192
|
-
"./components/Sharer/utils/meta": "./dist/components/Sharer/utils/meta.js",
|
|
193
|
-
"./components/Sharer/utils/twitter": "./dist/components/Sharer/utils/twitter.js",
|
|
194
189
|
"./components/SimpleTimeline/SimpleTimeline.svelte": "./dist/components/SimpleTimeline/SimpleTimeline.svelte",
|
|
195
190
|
"./components/SiteFooter/CompanyLinks.svelte": "./dist/components/SiteFooter/CompanyLinks.svelte",
|
|
196
191
|
"./components/SiteFooter/LegalLinks.svelte": "./dist/components/SiteFooter/LegalLinks.svelte",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} SharerProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} SharerEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} SharerSlots */
|
|
4
|
-
export default class Sharer extends SvelteComponentTyped<{
|
|
5
|
-
[x: string]: never;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type SharerProps = typeof __propDef.props;
|
|
11
|
-
export type SharerEvents = typeof __propDef.events;
|
|
12
|
-
export type SharerSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponentTyped } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
[x: string]: never;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Fa from 'svelte-fa/src/fa.svelte';
|
|
3
|
-
import { faShareAlt } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
-
import { faTwitter } from '@fortawesome/free-brands-svg-icons';
|
|
5
|
-
import { faFacebookF } from '@fortawesome/free-brands-svg-icons';
|
|
6
|
-
import { throttle } from 'lodash-es';
|
|
7
|
-
import handleTweet from './utils/twitter';
|
|
8
|
-
import handlePost from './utils/facebook';
|
|
9
|
-
import UAParser from 'ua-parser-js';
|
|
10
|
-
import { onMount } from 'svelte';
|
|
11
|
-
|
|
12
|
-
const uaParser = new UAParser();
|
|
13
|
-
|
|
14
|
-
const getMetaContent = (property) => {
|
|
15
|
-
const el = document.querySelector(`meta[property="${property}"]`);
|
|
16
|
-
if (el) return el.getAttribute('content');
|
|
17
|
-
return '';
|
|
18
|
-
};
|
|
19
|
-
const handleShare = async function () {
|
|
20
|
-
if (showSecondaryDialogue) {
|
|
21
|
-
showSecondaryDialogue = false;
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (
|
|
25
|
-
navigator &&
|
|
26
|
-
navigator.share &&
|
|
27
|
-
uaParser.getBrowser().name !== 'Safari'
|
|
28
|
-
) {
|
|
29
|
-
try {
|
|
30
|
-
await navigator.share({
|
|
31
|
-
title: getMetaContent('og:title'),
|
|
32
|
-
text: getMetaContent('og:description'),
|
|
33
|
-
url: window.location.href,
|
|
34
|
-
});
|
|
35
|
-
} catch (err) {
|
|
36
|
-
console.log('Share error', err);
|
|
37
|
-
}
|
|
38
|
-
// Otherwise copy URL to a clipboard
|
|
39
|
-
} else {
|
|
40
|
-
showSecondaryDialogue = true;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
let lastScroll = 0;
|
|
44
|
-
let showShare = false;
|
|
45
|
-
let showSecondaryDialogue = false;
|
|
46
|
-
function handleScroll() {
|
|
47
|
-
if (lastScroll > window.scrollY) {
|
|
48
|
-
if (!showShare) {
|
|
49
|
-
showShare = true;
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
if (showShare) {
|
|
53
|
-
if (showSecondaryDialogue) {
|
|
54
|
-
showSecondaryDialogue = false;
|
|
55
|
-
} else {
|
|
56
|
-
showShare = false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
lastScroll = window.scrollY;
|
|
61
|
-
}
|
|
62
|
-
onMount(() => {
|
|
63
|
-
window.addEventListener('scroll', throttle(handleScroll, 250), {
|
|
64
|
-
passive: true,
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
</script>
|
|
68
|
-
|
|
69
|
-
<div class="sharetool" class:active="{showShare}">
|
|
70
|
-
<div class="drawer" class:active="{showSecondaryDialogue}">
|
|
71
|
-
<button
|
|
72
|
-
on:click="{handleShare}"
|
|
73
|
-
title="Share this!"
|
|
74
|
-
disabled="{showSecondaryDialogue}"
|
|
75
|
-
class="box-shadow-low"
|
|
76
|
-
>
|
|
77
|
-
<div><Fa fw icon="{faShareAlt}" /></div>
|
|
78
|
-
</button>
|
|
79
|
-
<button on:click="{handleTweet}" title="Twitter">
|
|
80
|
-
<div><Fa fw icon="{faTwitter}" /></div>
|
|
81
|
-
</button>
|
|
82
|
-
<button on:click="{handlePost}" title="Facebook">
|
|
83
|
-
<div><Fa fw icon="{faFacebookF}" /></div>
|
|
84
|
-
</button>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
|
|
88
|
-
<style>.sharetool.active {
|
|
89
|
-
bottom: 10px;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.sharetool {
|
|
93
|
-
position: fixed;
|
|
94
|
-
bottom: -5rem;
|
|
95
|
-
right: 10px;
|
|
96
|
-
transition: all 300ms ease;
|
|
97
|
-
z-index: 9999;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.sharetool button {
|
|
101
|
-
background: #333;
|
|
102
|
-
color: white;
|
|
103
|
-
border: 1px solid white;
|
|
104
|
-
border-radius: 50%;
|
|
105
|
-
font-size: 1.25rem;
|
|
106
|
-
text-align: center;
|
|
107
|
-
height: 2.25rem;
|
|
108
|
-
width: 2.25rem;
|
|
109
|
-
outline: none !important;
|
|
110
|
-
transition: color 0.2s;
|
|
111
|
-
cursor: pointer;
|
|
112
|
-
}
|
|
113
|
-
.sharetool button div {
|
|
114
|
-
width: 100%;
|
|
115
|
-
height: 100%;
|
|
116
|
-
display: flex;
|
|
117
|
-
align-items: center;
|
|
118
|
-
justify-content: center;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.sharetool button:active {
|
|
122
|
-
transform: translate(1px, 1px);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.sharetool button:disabled {
|
|
126
|
-
background: white;
|
|
127
|
-
color: #ddd;
|
|
128
|
-
cursor: default;
|
|
129
|
-
box-shadow: none;
|
|
130
|
-
pointer-events: none;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.drawer {
|
|
134
|
-
width: calc(2.25rem + 4px);
|
|
135
|
-
overflow-x: hidden;
|
|
136
|
-
transition: width 0.2s;
|
|
137
|
-
white-space: nowrap;
|
|
138
|
-
padding: 2px;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.drawer.active {
|
|
142
|
-
width: calc(7.25rem + 4px);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
@media only screen and (max-width: 600px) {
|
|
146
|
-
.sharetool button {
|
|
147
|
-
font-size: 1.75rem;
|
|
148
|
-
height: 3rem;
|
|
149
|
-
width: 3rem;
|
|
150
|
-
}
|
|
151
|
-
.drawer {
|
|
152
|
-
width: calc(3rem + 4px);
|
|
153
|
-
}
|
|
154
|
-
.drawer.active {
|
|
155
|
-
width: calc(9.5rem + 4px);
|
|
156
|
-
}
|
|
157
|
-
}</style>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getHref } from './meta';
|
|
2
|
-
|
|
3
|
-
const handlePost = () => {
|
|
4
|
-
const windowOptions = 'scrollbars=yes,resizable=yes,toolbar=no,location=yes';
|
|
5
|
-
const width = 550;
|
|
6
|
-
const height = 420;
|
|
7
|
-
const winHeight = screen.height;
|
|
8
|
-
const winWidth = screen.width;
|
|
9
|
-
|
|
10
|
-
const left = Math.round(winWidth / 2 - width / 2);
|
|
11
|
-
const top = winHeight > height ? Math.round(winHeight / 2 - height / 2) : 0;
|
|
12
|
-
|
|
13
|
-
const target = `https://www.facebook.com/sharer/sharer.php?u=${getHref()}`;
|
|
14
|
-
|
|
15
|
-
window.open(
|
|
16
|
-
target,
|
|
17
|
-
'intent',
|
|
18
|
-
`${windowOptions},width=${width},height=${height},left=${left},top=${top}`
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default handlePost;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export const getTitle = () => {
|
|
2
|
-
const ogTag = document.querySelector("meta[property='og:title']");
|
|
3
|
-
if (ogTag) return encodeURIComponent(ogTag.getAttribute('content'));
|
|
4
|
-
return encodeURIComponent(document.title);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const getHref = () => encodeURIComponent(window.location.href);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getHref, getTitle } from './meta';
|
|
2
|
-
|
|
3
|
-
const handleTweet = () => {
|
|
4
|
-
const windowOptions = 'scrollbars=yes,resizable=yes,toolbar=no,location=yes';
|
|
5
|
-
const width = 550;
|
|
6
|
-
const height = 420;
|
|
7
|
-
const winHeight = screen.height;
|
|
8
|
-
const winWidth = screen.width;
|
|
9
|
-
|
|
10
|
-
const left = Math.round(winWidth / 2 - width / 2);
|
|
11
|
-
const top = winHeight > height ? Math.round(winHeight / 2 - height / 2) : 0;
|
|
12
|
-
|
|
13
|
-
const target = `https://twitter.com/intent/tweet?text=${getTitle()}&via=Reuters&url=${getHref()}`;
|
|
14
|
-
|
|
15
|
-
window.open(
|
|
16
|
-
target,
|
|
17
|
-
'intent',
|
|
18
|
-
`${windowOptions},width=${width},height=${height},left=${left},top=${top}`
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default handleTweet;
|