Skip to content

Commit 67c5789

Browse files
committed
feat: ✨ add StackBlitz component
Thanks @matiasfha 🙏
1 parent eff0a65 commit 67c5789

File tree

4 files changed

+78
-75
lines changed

4 files changed

+78
-75
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sveltekit-embed",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"author": {
55
"name": "Scott Spence",
66
"email": "[email protected]",
@@ -18,7 +18,7 @@
1818
"license": "MIT",
1919
"scripts": {
2020
"dev": "vite dev",
21-
"build": "pnpm run sveltekit-embed && pnpm i -D sveltekit-embed && vite build",
21+
"build": "pnpm un sveltekit-embed && pnpm i -D sveltekit-embed && vite build",
2222
"package": "svelte-package",
2323
"preview": "vite preview",
2424
"test": "playwright test",
@@ -59,7 +59,7 @@
5959
"svelte-check": "2.9.0",
6060
"svelte-preprocess": "4.10.7",
6161
"svelte2tsx": "0.5.19",
62-
"sveltekit-embed": "0.0.5",
62+
"sveltekit-embed": "^0.0.5",
6363
"tailwindcss": "3.1.8",
6464
"tslib": "2.4.0",
6565
"typescript": "4.8.3",

pnpm-lock.yaml

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
<script lang="ts">
2-
import GeneralObserver from "./general-observer.svelte"
3-
4-
export let width: string = '100'
5-
export let height: string = '500'
6-
export let id: string = ''
7-
export let view: 'editor' | 'preview' | 'default' = 'default'
8-
export let clickToLoad: boolean = true //ctl
9-
export let hideNavigation: boolean = false //hideNavigation
10-
export let hideExplorer: boolean = true
11-
export let theme: string | 'light' | 'dark' | 'default' = 'dark'
12-
export let file: string | undefined
2+
import GeneralObserver from './general-observer.svelte'
133
14-
let baseUrl = `https://stackblitz.com/edit/${id}?embed=1
15-
const config = {
16-
ctl: `${clickToLoad ? 1 : 0}`,
17-
hideExplorer: `${hideExplorer ? 1 : 0}`,
18-
hideNavigation: `${hideNavigation ? 1: 0}`,
19-
theme
20-
}
21-
if(view !== 'default') {
22-
config['view'] = view
23-
}
24-
if(file) {
25-
config['file'] = file
26-
}
27-
const queryString = new URLSearchParams(config)
28-
const src = `${baseUrl}&${queryString.toString()}`
4+
export let width: string = '100'
5+
export let height: string = '500'
6+
export let id: string = ''
7+
export let view: 'editor' | 'preview' | 'default' = 'default'
8+
export let clickToLoad: boolean = true //ctl
9+
export let hideNavigation: boolean = false //hideNavigation
10+
export let hideExplorer: boolean = true
11+
export let theme: string | 'light' | 'dark' | 'default' = 'dark'
12+
export let file: string | undefined
13+
14+
let baseUrl = `https://stackblitz.com/edit/${id}?embed=1`
15+
const config = {
16+
ctl: `${clickToLoad ? 1 : 0}`,
17+
hideExplorer: `${hideExplorer ? 1 : 0}`,
18+
hideNavigation: `${hideNavigation ? 1 : 0}`,
19+
theme,
20+
}
21+
if (view !== 'default') {
22+
config['view'] = view
23+
}
24+
if (file) {
25+
config['file'] = file
26+
}
27+
const queryString = new URLSearchParams(config)
28+
const src = `${baseUrl}&${queryString.toString()}`
2929
</script>
3030

3131
<GeneralObserver {height} {width}>
32-
<iframe
33-
{height}
34-
class="stackblitz-sveltekit-embed"
35-
title={`stackblitz-${id}`}
36-
{src}
37-
frameborder="no"
38-
allowfullscreen
39-
style={`
40-
width: 100%;
41-
`}
42-
/>
32+
<iframe
33+
{height}
34+
class="stackblitz-sveltekit-embed"
35+
title={`stackblitz-${id}`}
36+
{src}
37+
frameborder="no"
38+
allowfullscreen
39+
style={`
40+
width: 100%;
41+
`}
42+
/>
4343
</GeneralObserver>

src/routes/+page.md

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
SimpleCast,
99
SoundCloud,
1010
Spotify,
11+
StackBlitz,
1112
Tweet,
1213
Vimeo,
1314
YouTube,
14-
StackBlitz
1515
} from 'sveltekit-embed'
1616
import { Head } from 'svead'
1717
import { page } from '$app/stores'
@@ -261,6 +261,32 @@ Output:
261261
height="180px"
262262
/>
263263

264+
## StackBlitz
265+
266+
Props:
267+
268+
```ts
269+
width: string = '100'
270+
height: string = '500'
271+
id: string = ''
272+
view: 'editor' | 'preview' | 'default' = 'default'
273+
clickToLoad: boolean = true
274+
hideNavigation: boolean = false
275+
hideExplorer: boolean = true
276+
theme: string | 'light' | 'dark' | 'default' = 'dark'
277+
file: string | undefined
278+
```
279+
280+
Usage:
281+
282+
```html
283+
<StackBlitz id="vitejs-vite-yyoood" theme="light" />
284+
```
285+
286+
Output:
287+
288+
<StackBlitz id="vitejs-vite-yyoood" hideNavigation />
289+
264290
## Tweet
265291

266292
Props:
@@ -323,31 +349,3 @@ Usage:
323349
Output:
324350

325351
<YouTube youTubeId="L7_z8rcbFPg" />
326-
327-
328-
## StackBlitz
329-
330-
Props:
331-
332-
```ts
333-
334-
width: string = '100'
335-
height: string = '500'
336-
id: string = ''
337-
view: 'editor' | 'preview' | 'default' = 'default'
338-
clickToLoad: boolean = true
339-
hideNavigation: boolean = false
340-
hideExplorer: boolean = true
341-
theme: string | 'light' | 'dark' | 'default' = 'dark'
342-
file: string | undefined
343-
```
344-
345-
Usage:
346-
347-
```html
348-
<StackBlitz id="vitejs-vite-yyoood" theme="light"/>
349-
```
350-
351-
Output:
352-
353-
<StackBlitz id="vitejs-vite-yyoood" hideNavigation />

0 commit comments

Comments
 (0)