Skip to content

Commit cf9bd5d

Browse files
committed
docs: use LiveCodes playground for examples
1 parent 82840d4 commit cf9bd5d

File tree

5 files changed

+640
-24
lines changed

5 files changed

+640
-24
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<script setup lang="ts">
2+
import { watch } from 'vue'
3+
import { useData } from 'vitepress'
4+
import type { EmbedOptions, Playground } from 'livecodes'
5+
import LiveCodes from 'livecodes/vue'
6+
7+
const props = defineProps<{
8+
code: string
9+
styles?: string
10+
loading?: 'lazy' | 'click' | 'eager'
11+
view?: 'split' | 'editor' | 'result'
12+
mode?: 'full' | 'focus' | 'simple' | 'editor' | 'codeblock' | 'result'
13+
height?: string
14+
}>()
15+
16+
const { isDark } = useData()
17+
18+
const config: EmbedOptions['config'] = {
19+
title: 'Vue3-carousel',
20+
theme: isDark.value ? 'dark' : 'light',
21+
themeColor: 'hsl(220, 14%, 80%)',
22+
view: props.view || 'result',
23+
mode: props.mode || 'simple',
24+
activeEditor: 'script',
25+
tools: {
26+
status: 'none',
27+
},
28+
style: {
29+
language: 'css',
30+
content: props.styles || '',
31+
},
32+
script: {
33+
language: 'vue',
34+
content: props.code,
35+
title: 'App.vue',
36+
},
37+
imports: {
38+
vue: 'https://cdn.jsdelivr.net/npm/vue/dist/vue.runtime.esm-browser.prod.js',
39+
'vue3-carousel': 'https://cdn.jsdelivr.net/npm/vue3-carousel/dist/carousel.mjs',
40+
'vue3-carousel/carousel.css':
41+
'https://cdn.jsdelivr.net/npm/vue3-carousel/dist/carousel.css',
42+
},
43+
}
44+
45+
let playground: Playground | undefined
46+
const onReady = (sdk: Playground) => {
47+
playground = sdk
48+
}
49+
50+
watch(isDark, () => {
51+
if (playground) {
52+
playground.setConfig({
53+
theme: isDark.value ? 'dark' : 'light',
54+
})
55+
}
56+
})
57+
</script>
58+
59+
<template>
60+
<LiveCodes
61+
appUrl="https://v41.livecodes.io/"
62+
:config="config"
63+
@sdk-ready="onReady"
64+
:style="{ height: props.height || '250px' }"
65+
/>
66+
</template>

docs/examples.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,51 @@ If you're experiencing issues loading the live examples or you're browsing on a
66

77
A simple implementation of the carousel with default settings.
88

9-
<Example id="vue3-carousel-example-basic" />
9+
<Playground v-bind="examples.basic" />
1010

1111
## Wrap Around
1212

1313
Demonstrates a carousel with continuous wrap-around functionality.
1414

15-
<Example id="vue3-carousel-example-wrap-around" />
15+
<Playground v-bind="examples.wrapAround" />
1616

1717
## Vertical
1818

1919
Showcases a vertically scrolling carousel. Adjust the height to better fit your content.
2020

21-
<Example id="vue3-carousel-example-vertical" :height="475" />
21+
<Playground v-bind="examples.vertical" height="475px" />
2222

2323
## Breakpoints
2424

2525
An example of a responsive carousel with breakpoints for varying screen sizes.
2626

27-
<Example id="vue3-carousel-example-breakpoints" :height="300" />
27+
<Playground v-bind="examples.breakpoints" />
2828

2929
## Autoplay
3030

3131
Illustrates the carousel with autoplay functionality enabled.
3232

33-
<Example id="vue3-carousel-example-autoplay" />
33+
<Playground v-bind="examples.autoplay" />
3434

3535
## Active Classes
3636

3737
An example highlighting active items with custom classes.
3838

39-
<Example id="vue3-carousel-example-status-classes" />
39+
<Playground v-bind="examples.activeClasses" />
4040

4141
## Custom Navigation
4242

4343
A demonstration of the carousel with fully customizable navigation controls.
4444

45-
<Example id="vue3-carousel-example-custom-navigation" :height="310" />
45+
<Playground v-bind="examples.customNavigation" height="260px" />
4646

4747
## Gallery
4848

4949
Transforms the carousel into a gallery-style component.
5050

51-
<Example id="vue3-carousel-example-gallery" :height="500" />
51+
<Playground v-bind="examples.gallery" height="455px" />
5252

53-
<script>
54-
import Example from './.vitepress/components/Example.vue';
55-
export default {
56-
components: {
57-
Example,
58-
},
59-
};
53+
<script setup>
54+
import Playground from './.vitepress/components/Playground.vue';
55+
import { examples } from './examples/examples';
6056
</script>

0 commit comments

Comments
 (0)