tangled
alpha
login
or
join now
flo-bit.dev
/
blento
your personal website on atproto - mirror
blento.app
20
fork
atom
overview
issues
pulls
pipelines
try heypster
Florian
2 weeks ago
e9953b2d
b0821e40
+47
-1
4 changed files
expand all
collapse all
unified
split
package.json
pnpm-lock.yaml
src
lib
cards
GIFCard
EditingGifCard.svelte
heypster.svelte.ts
+1
package.json
···
62
62
"bits-ui": "^2.14.4",
63
63
"clsx": "^2.1.1",
64
64
"gsap": "^3.14.2",
65
65
+
"heypster-gif": "^3.0.4",
65
66
"hls.js": "^1.6.15",
66
67
"leaflet": "^1.9.4",
67
68
"link-preview-js": "^4.0.0",
+8
pnpm-lock.yaml
···
77
77
gsap:
78
78
specifier: ^3.14.2
79
79
version: 3.14.2
80
80
+
heypster-gif:
81
81
+
specifier: ^3.0.4
82
82
+
version: 3.0.4
80
83
hls.js:
81
84
specifier: ^1.6.15
82
85
version: 1.6.15
···
1965
1968
hex-rgb@4.3.0:
1966
1969
resolution: {integrity: sha512-Ox1pJVrDCyGHMG9CFg1tmrRUMRPRsAWYc/PinY0XzJU4K7y7vjNoLKIQ7BR5UJMCxNN8EM1MNDmHWA/B3aZUuw==, tarball: https://registry.npmjs.org/hex-rgb/-/hex-rgb-4.3.0.tgz}
1967
1970
engines: {node: '>=6'}
1971
1971
+
1972
1972
+
heypster-gif@3.0.4:
1973
1973
+
resolution: {integrity: sha512-GcmzNYxi1MQNipc/aF1zlVP4ACeqdVJZsP4CrVvx/oKW0VZd+Y/iT/EXaMDJL/dCYqx+unmmLPoDdAzIg8gX7w==, tarball: https://registry.npmjs.org/heypster-gif/-/heypster-gif-3.0.4.tgz}
1968
1974
1969
1975
hls.js@1.6.15:
1970
1976
resolution: {integrity: sha512-E3a5VwgXimGHwpRGV+WxRTKeSp2DW5DI5MWv34ulL3t5UNmyJWCQ1KmLEHbYzcfThfXG8amBL+fCYPneGHC4VA==, tarball: https://registry.npmjs.org/hls.js/-/hls.js-1.6.15.tgz}
···
4791
4797
function-bind: 1.1.2
4792
4798
4793
4799
hex-rgb@4.3.0: {}
4800
4800
+
4801
4801
+
heypster-gif@3.0.4: {}
4794
4802
4795
4803
hls.js@1.6.15: {}
4796
4804
+17
-1
src/lib/cards/GIFCard/EditingGifCard.svelte
···
1
1
<script lang="ts">
2
2
+
import { onMount } from 'svelte';
2
3
import type { ContentComponentProps } from '../types';
3
4
import GiphySearchModal from './GiphySearchModal.svelte';
5
5
+
import { toggleHeypster } from './heypster.svelte';
4
6
5
7
let { item = $bindable() }: ContentComponentProps = $props();
6
8
···
18
20
isSearchOpen = false;
19
21
}
20
22
23
23
+
onMount(() => {
24
24
+
25
25
+
window.addEventListener('heypsterGifClicked', (event) => {
26
26
+
if (!isSearchOpen) return;
27
27
+
const data = event.detail;
28
28
+
console.log(data);
29
29
+
item.cardData.url = data.h264;
30
30
+
toggleHeypster();
31
31
+
32
32
+
isSearchOpen = false;
33
33
+
});
34
34
+
})
35
35
+
21
36
function openSearch() {
22
37
isSearchOpen = true;
38
38
+
toggleHeypster();
23
39
}
24
40
</script>
25
41
···
72
88
{/if}
73
89
</div>
74
90
75
75
-
<GiphySearchModal bind:open={isSearchOpen} onselect={handleGifSelect} oncancel={() => (isSearchOpen = false)} />
91
91
+
<!-- <GiphySearchModal bind:open={isSearchOpen} onselect={handleGifSelect} oncancel={() => (isSearchOpen = false)} /> -->
+21
src/lib/cards/GIFCard/heypster.svelte.ts
···
1
1
+
import { env } from '$env/dynamic/public';
2
2
+
import HeypsterGifSDK from 'heypster-gif/index.js';
3
3
+
4
4
+
const heypster = $state({});
5
5
+
6
6
+
function initHeypster() {
7
7
+
heypster.sdk = new HeypsterGifSDK(env.PUBLIC_HEYPSTER_API_TOKEN, false, 'en', 'top', 'v3', {
8
8
+
provider: 'giphy',
9
9
+
key: env.PUBLIC_GIPHY_API_TOKEN
10
10
+
});
11
11
+
}
12
12
+
13
13
+
export function toggleHeypster() {
14
14
+
if (!heypster.sdk) initHeypster();
15
15
+
16
16
+
if (!heypster.sdk.popupElement) {
17
17
+
heypster.sdk = heypster.sdk.initialize();
18
18
+
}
19
19
+
20
20
+
heypster.sdk.togglePopup();
21
21
+
}