File tree Expand file tree Collapse file tree 9 files changed +125
-449
lines changed Expand file tree Collapse file tree 9 files changed +125
-449
lines changed Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ module.exports = {
18
18
text : 'Introduction' ,
19
19
items : [
20
20
{ text : 'Getting Started' , link : '/getting-started' } ,
21
- { text : 'Configs ' , link : '/configs ' } ,
21
+ { text : 'Config ' , link : '/config ' } ,
22
22
{ text : 'Examples' , link : '/examples' } ,
23
23
] ,
24
24
} ,
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ Slide to the previous slide
33
33
34
34
Update ` slideWidth ` value based on ` itemsToShow ` and the current carousel width
35
35
36
- ## updateBreakpointsConfigs ()
36
+ ## updateBreakpointsConfig ()
37
37
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
39
39
40
40
## updateSlidesData()
41
41
@@ -46,16 +46,16 @@ Update all the slide related date includes:
46
46
- ` maxSlide `
47
47
- ` minSlide `
48
48
49
- ## initDefaultConfigs ()
49
+ ## initDefaultConfig ()
50
50
51
51
Init carousel default configurations
52
52
53
53
## restartCarousel()
54
54
55
55
Restart the carousel settings and data, internally it calls:
56
56
57
- - ` initDefaultConfigs `
57
+ - ` initDefaultConfig `
58
58
- ` resetAutoplay `
59
- - ` updateBreakpointsConfigs `
59
+ - ` updateBreakpointsConfig `
60
60
- ` updateSlidesData `
61
61
- ` updateSlideWidth `
Original file line number Diff line number Diff line change 1
- # Configs
1
+ # Config
2
2
3
3
4
4
## Available Props
You can’t perform that action at this time.
0 commit comments