Skip to content

Commit eff0a65

Browse files
authored
Merge pull request #309 from matiasfha/stackblitz
2 parents 1aee1d6 + 776180d commit eff0a65

File tree

5 files changed

+97
-3
lines changed

5 files changed

+97
-3
lines changed

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
"license": "MIT",
1919
"scripts": {
2020
"dev": "vite dev",
21-
"build": "pnpm un sveltekit-embed && pnpm i -D sveltekit-embed && vite build",
22-
"package": "svelte-kit package",
21+
"build": "pnpm run sveltekit-embed && pnpm i -D sveltekit-embed && vite build",
22+
"package": "svelte-package",
2323
"preview": "vite preview",
2424
"test": "playwright test",
2525
"check": "svelte-check --tsconfig ./tsconfig.json",
2626
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
2727
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
2828
"format": "pretty-quick",
29-
"package:local": "svelte-kit package && pnpm i -D ./package"
29+
"package:local": "svelte-package && pnpm i -D ./package"
3030
},
3131
"husky": {
3232
"hooks": {
@@ -37,6 +37,7 @@
3737
"@playwright/test": "1.26.0",
3838
"@sveltejs/adapter-auto": "next",
3939
"@sveltejs/kit": "next",
40+
"@sveltejs/package": "1.0.0-next.5",
4041
"@tailwindcss/typography": "0.5.7",
4142
"@typescript-eslint/eslint-plugin": "5.38.1",
4243
"@typescript-eslint/parser": "5.38.1",
@@ -47,6 +48,7 @@
4748
"eslint-plugin-svelte3": "4.0.0",
4849
"husky": "8.0.1",
4950
"mdsvex": "0.10.6",
51+
"package": "link:package",
5052
"postcss": "8.4.16",
5153
"postcss-load-config": "4.0.1",
5254
"prettier": "2.7.1",

pnpm-lock.yaml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<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
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()}`
29+
</script>
30+
31+
<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+
/>
43+
</GeneralObserver>

src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { default as GenericEmbed } from './components/generic-embed.svelte'
77
export { default as SimpleCast } from './components/simple-cast.svelte'
88
export { default as SoundCloud } from './components/sound-cloud.svelte'
99
export { default as Spotify } from './components/spotify.svelte'
10+
export { default as StackBlitz } from './components/stackblitz.svelte'
1011
export { default as Tweet } from './components/tweet.svelte'
1112
export { default as Vimeo } from './components/vimeo.svelte'
1213
export { default as YouTube } from './components/you-tube.svelte'

src/routes/+page.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Tweet,
1212
Vimeo,
1313
YouTube,
14+
StackBlitz
1415
} from 'sveltekit-embed'
1516
import { Head } from 'svead'
1617
import { page } from '$app/stores'
@@ -322,3 +323,31 @@ Usage:
322323
Output:
323324

324325
<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)