Skip to content

Commit 1d4a80f

Browse files
authored
Merge pull request #428 from joaopalmeiro/feat/add-support-relive
Closes #427
2 parents 5646183 + 71a76f8 commit 1d4a80f

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

src/lib/components/relive.svelte

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<script lang="ts">
2+
import GeneralObserver from './general-observer.svelte'
3+
4+
export let reliveId: string = ''
5+
export let width: string = '100%'
6+
7+
const defaultMargin: number = 2
8+
</script>
9+
10+
<GeneralObserver>
11+
<div
12+
style={`
13+
position: relative;
14+
width: ${width};
15+
aspect-ratio: 1 / 0.7825;
16+
overflow: hidden;
17+
`}
18+
>
19+
<iframe
20+
title={`relive-${reliveId}`}
21+
src={`https://www.relive.cc/view/${reliveId}/widget`}
22+
scrolling="no"
23+
frameborder="0"
24+
allowfullscreen
25+
style={`
26+
position: absolute;
27+
top: -${defaultMargin}px;
28+
left: -${defaultMargin}px;
29+
width: calc(100% + ${defaultMargin * 2}px);
30+
height: calc(100% + ${defaultMargin * 2}px);
31+
`}
32+
/>
33+
</div>
34+
</GeneralObserver>

src/lib/components/relive.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Relive from '$lib/components/relive.svelte'
2+
import { cleanup, render } from '@testing-library/svelte'
3+
import { afterEach, describe, expect, it, vi } from 'vitest'
4+
5+
globalThis.IntersectionObserver = vi.fn(() => ({
6+
observe: () => null,
7+
unobserve: () => null,
8+
disconnect: () => null,
9+
})) as unknown as typeof globalThis.IntersectionObserver
10+
11+
describe('Relive', () => {
12+
afterEach(() => cleanup())
13+
14+
it('mounts', () => {
15+
const { container } = render(Relive)
16+
expect(container).toBeTruthy()
17+
})
18+
})

src/lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export { default as Deezer } from './components/deezer.svelte'
55
export { default as GeneralObserver } from './components/general-observer.svelte'
66
export { default as GenericEmbed } from './components/generic-embed.svelte'
77
export { default as Gist } from './components/gist.svelte'
8+
export { default as Relive } from './components/relive.svelte'
89
export { default as SimpleCast } from './components/simple-cast.svelte'
910
export { default as Slides } from './components/slides.svelte'
1011
export { default as SoundCloud } from './components/sound-cloud.svelte'
@@ -15,4 +16,3 @@ export { default as Tweet } from './components/tweet.svelte'
1516
export { default as Vimeo } from './components/vimeo.svelte'
1617
export { default as YouTube } from './components/you-tube.svelte'
1718
export { default as Zencastr } from './components/zencastr.svelte'
18-

src/routes/+page.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Deezer,
77
GenericEmbed,
88
Gist,
9+
Relive,
910
SimpleCast,
1011
Slides,
1112
SoundCloud,
@@ -70,6 +71,7 @@ or open a [PR](https://github.com/spences10/sveltekit-embed/pulls).
7071
- [Deezer](#deezer)
7172
- [GenericEmbed](#genericembed)
7273
- [Gist](#gist)
74+
- [Relive](#relive)
7375
- [SimpleCast](#simplecast)
7476
- [Slides](#slides)
7577
- [SoundCloud](#soundcloud)
@@ -252,6 +254,25 @@ Output:
252254

253255
<Gist gistUri="Ennoriel/8c89dc3615292f0a40b04f4f876afd77" />
254256

257+
## Relive
258+
259+
Props:
260+
261+
```ts
262+
reliveId: string = ''
263+
width: string = '100%'
264+
```
265+
266+
Usage:
267+
268+
```html
269+
<Relive reliveId="vAOZokmYVo6" />
270+
```
271+
272+
Output:
273+
274+
<Relive reliveId="vAOZokmYVo6" />
275+
255276
## SimpleCast
256277

257278
Props:

0 commit comments

Comments
 (0)