Skip to content

Commit a4ead5d

Browse files
committed
docs(examples): use stackblitz to display examples
1 parent b9a4a50 commit a4ead5d

File tree

9 files changed

+125
-449
lines changed

9 files changed

+125
-449
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<script setup>
2+
import { onMounted, watch, ref } from 'vue'
3+
import sdk from '@stackblitz/sdk'
4+
5+
const props = defineProps({
6+
id: {
7+
type: String,
8+
required: true,
9+
},
10+
view: {
11+
type: String,
12+
default: 'preview',
13+
},
14+
clickToLoad: {
15+
type: Boolean,
16+
default: false,
17+
},
18+
hideNavigation: {
19+
type: Boolean,
20+
default: true,
21+
},
22+
forceEmbedLayout: {
23+
type: Boolean,
24+
default: true,
25+
},
26+
openFile: {
27+
type: String,
28+
default: 'src/App.vue',
29+
},
30+
width: {
31+
type: String,
32+
default: '100%',
33+
},
34+
height: {
35+
type: [String, Number],
36+
default: 350,
37+
},
38+
})
39+
40+
const el = ref(null)
41+
const error = ref(null)
42+
43+
const embedProject = () => {
44+
if (!el.value) {
45+
return
46+
}
47+
try {
48+
sdk.embedProjectId(el.value, props.id, {
49+
forceEmbedLayout: props.forceEmbedLayout,
50+
openFile: props.openFile,
51+
hideNavigation: props.hideNavigation,
52+
height: props.height,
53+
width: props.width,
54+
view: props.view,
55+
clickToLoad: props.clickToLoad,
56+
})
57+
error.value = null
58+
} catch (e) {
59+
error.value = 'Failed to embed project. Please try again.'
60+
console.error(e)
61+
}
62+
}
63+
64+
onMounted(embedProject)
65+
</script>
66+
67+
<template>
68+
<div>
69+
<div v-if="error" class="error-message">{{ error }}</div>
70+
<div
71+
v-else
72+
:style="{ width: props.width, height: `${props.height}px` }"
73+
ref="el"
74+
></div>
75+
</div>
76+
</template>
77+
78+
<style scoped>
79+
.error-message {
80+
color: red;
81+
font-weight: bold;
82+
}
83+
</style>

docs/.vitepress/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
text: 'Introduction',
1919
items: [
2020
{ text: 'Getting Started', link: '/getting-started' },
21-
{ text: 'Configs', link: '/configs' },
21+
{ text: 'Config', link: '/config' },
2222
{ text: 'Examples', link: '/examples' },
2323
],
2424
},

docs/api/methods.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ Slide to the previous slide
3333

3434
Update `slideWidth` value based on `itemsToShow` and the current carousel width
3535

36-
## updateBreakpointsConfigs()
36+
## updateBreakpointsConfig()
3737

38-
Update the current carousel configs based on `breakpoints` settings and screen width
38+
Update the current carousel config based on `breakpoints` settings and screen width
3939

4040
## updateSlidesData()
4141

@@ -46,16 +46,16 @@ Update all the slide related date includes:
4646
- `maxSlide`
4747
- `minSlide`
4848

49-
## initDefaultConfigs()
49+
## initDefaultConfig()
5050

5151
Init carousel default configurations
5252

5353
## restartCarousel()
5454

5555
Restart the carousel settings and data, internally it calls:
5656

57-
- `initDefaultConfigs`
57+
- `initDefaultConfig`
5858
- `resetAutoplay`
59-
- `updateBreakpointsConfigs`
59+
- `updateBreakpointsConfig`
6060
- `updateSlidesData`
6161
- `updateSlideWidth`

docs/configs.md renamed to docs/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Configs
1+
# Config
22

33

44
## Available Props

0 commit comments

Comments
 (0)