Skip to content

Commit aa56980

Browse files
committed
feat: ✨ new Zencastr component
1 parent b1bb5fd commit aa56980

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"sveltkit",
2323
"vieria",
2424
"vite",
25+
"zencastr",
2526
"Zrzbx"
2627
],
2728
"css.validate": false,

src/lib/components/zencastr.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 { onMount } from 'svelte'
3+
4+
export let zencastrId: string = ''
5+
6+
// TODO: want to do this the Svelte way, but using <svelte:head> doesn't work
7+
onMount(() => {
8+
const script = document.createElement('script')
9+
script.async = true
10+
script.src = 'https://zencastr.com/static/js/embed-player.js'
11+
document.body.appendChild(script)
12+
})
13+
</script>
14+
15+
<section style="display:flex; justify-content: center;">
16+
<blockquote
17+
class="zenplayer"
18+
data-episode-href={`https://zencastr.com/embed/${zencastrId}`}
19+
style="background: black; border-radius: 12px; font-family: system-ui; width: 480px; height: 480px; position: relative; color: white; margin: 0;"
20+
>
21+
<img
22+
alt=""
23+
style="width: 120px; display: inline-block; position: absolute; top: calc(50%); left: calc(50%); transform: translate(-50%, -50%);"
24+
/>
25+
<a
26+
href={`https://zencastr.com/embed/${zencastrId}`}
27+
target="_blank"
28+
rel="noopener noreferrer"
29+
style="color: white; position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); text-decoration: none;"
30+
>
31+
View on Zencastr
32+
</a>
33+
</blockquote>
34+
</section>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Zencastr from '$lib/components/zencastr.svelte'
2+
import { cleanup, render } from '@testing-library/svelte'
3+
import { afterEach, describe, expect, it } from 'vitest'
4+
5+
describe('Zencastr', () => {
6+
afterEach(() => cleanup())
7+
8+
it('mounts', () => {
9+
const { container } = render(Zencastr)
10+
expect(container).toBeTruthy()
11+
})
12+
})

src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ export { default as Toot } from './components/toot.svelte'
1414
export { default as Tweet } from './components/tweet.svelte'
1515
export { default as Vimeo } from './components/vimeo.svelte'
1616
export { default as YouTube } from './components/you-tube.svelte'
17+
export { default as Zencastr } from './components/zencastr.svelte'
1718

src/routes/+page.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Tweet,
1616
Vimeo,
1717
YouTube,
18+
Zencastr
1819
} from '$lib'
1920
import { Head } from 'svead'
2021
import { page } from '$app/stores'
@@ -470,3 +471,21 @@ Usage:
470471
Output:
471472

472473
<YouTube youTubeId="L7_z8rcbFPg" />
474+
475+
## Zencastr
476+
477+
Props:
478+
479+
```ts
480+
zencastrId: string = ''
481+
```
482+
483+
Usage:
484+
485+
```html
486+
<Zencastr zencastrId="TARGseQu" />
487+
```
488+
489+
Output:
490+
491+
<Zencastr zencastrId='TARGseQu'/>

0 commit comments

Comments
 (0)