-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(examples): use stackblitz to display examples
- Loading branch information
Showing
9 changed files
with
125 additions
and
449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<script setup> | ||
import { onMounted, watch, ref } from 'vue' | ||
import sdk from '@stackblitz/sdk' | ||
const props = defineProps({ | ||
id: { | ||
type: String, | ||
required: true, | ||
}, | ||
view: { | ||
type: String, | ||
default: 'preview', | ||
}, | ||
clickToLoad: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
hideNavigation: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
forceEmbedLayout: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
openFile: { | ||
type: String, | ||
default: 'src/App.vue', | ||
}, | ||
width: { | ||
type: String, | ||
default: '100%', | ||
}, | ||
height: { | ||
type: [String, Number], | ||
default: 350, | ||
}, | ||
}) | ||
const el = ref(null) | ||
const error = ref(null) | ||
const embedProject = () => { | ||
if (!el.value) { | ||
return | ||
} | ||
try { | ||
sdk.embedProjectId(el.value, props.id, { | ||
forceEmbedLayout: props.forceEmbedLayout, | ||
openFile: props.openFile, | ||
hideNavigation: props.hideNavigation, | ||
height: props.height, | ||
width: props.width, | ||
view: props.view, | ||
clickToLoad: props.clickToLoad, | ||
}) | ||
error.value = null | ||
} catch (e) { | ||
error.value = 'Failed to embed project. Please try again.' | ||
console.error(e) | ||
} | ||
} | ||
onMounted(embedProject) | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<div v-if="error" class="error-message">{{ error }}</div> | ||
<div | ||
v-else | ||
:style="{ width: props.width, height: `${props.height}px` }" | ||
ref="el" | ||
></div> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.error-message { | ||
color: red; | ||
font-weight: bold; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Configs | ||
# Config | ||
|
||
|
||
## Available Props | ||
|
Oops, something went wrong.