Skip to content

Commit 587d063

Browse files
Add ts version of playground
1 parent 4263a4f commit 587d063

File tree

4 files changed

+63
-5
lines changed

4 files changed

+63
-5
lines changed

src/playground/configs/PlaygroundApp.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
<script setup>
4141
import { useCoreStore } from '@/stores/index';
42-
import PlaygroundPage from '@/playground/PlaygroundPage.vue';
42+
import PlaygroundPage from '@/playground/PlaygroundPage.ts.vue';
4343
import ThemeSelectComponent from '@/documentation/components/ThemeSelectComponent.vue';
4444
import AppBar from '@/documentation/layout/AppBar.vue';
4545

src/playground/configs/build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export CHECKMARK="$(printf '\e[1;32m\xE2\x9C\x94\e[0m')"
99
PLAYGROUND_VUE_DIR=src/playground
1010

1111
PLAYGROUND_VUE_FILE=PlaygroundPage.vue
12+
PLAYGROUND_TS_VUE_FILE=PlaygroundPage.ts.vue
1213

1314

1415
# Check if Playground.vue file exists before trying to create it #
@@ -20,3 +21,12 @@ if [ ! -f "$PLAYGROUND_VUE_DIR/$PLAYGROUND_VUE_FILE" ]; then
2021
echo ""
2122
fi
2223

24+
# Check if PlaygroundPage.ts.vue file exists before trying to create it #
25+
if [ ! -f "$PLAYGROUND_VUE_DIR/$PLAYGROUND_TS_VUE_FILE" ]; then
26+
cp "$PLAYGROUND_VUE_DIR/configs/templates/$PLAYGROUND_TS_VUE_FILE" "$PLAYGROUND_VUE_DIR/$PLAYGROUND_TS_VUE_FILE"
27+
28+
echo ""
29+
echo " ${BOLD_GREEN}${CHECKMARK}${BOLD_WHITE} $PLAYGROUND_TS_VUE_FILE file has been created.${WHITE}"
30+
echo ""
31+
fi
32+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<template>
2+
<v-col cols="12">
3+
<v-card elevation="5">
4+
<v-container>
5+
<VCodeBlock
6+
:code="options.code"
7+
:copy-button="options.copyButton"
8+
:highlightjs="options.highlightjs"
9+
:label="options.label"
10+
:lang="options.lang"
11+
:prismjs="options.prismjs"
12+
:theme="options.theme"
13+
>
14+
</VCodeBlock>
15+
</v-container>
16+
</v-card>
17+
</v-col>
18+
</template>
19+
20+
<script setup lang="ts">
21+
/* eslint-disable no-unused-vars */
22+
/* eslint-disable @typescript-eslint/no-unused-vars */
23+
const selectedLibrary = inject<Ref<{ id: string; }>>('selectedLibrary');
24+
const selectedTheme = inject<Ref<string>>('selectedTheme');
25+
26+
let code = `.foo {
27+
display: block;
28+
}`;
29+
30+
code = `<div>
31+
Hello World
32+
</div>`;
33+
34+
code = `const foo = 'bar';`;
35+
36+
const options = computed(() => ({
37+
code,
38+
copyButton: true,
39+
highlightjs: selectedLibrary?.value?.id === 'highlightjs',
40+
label: 'Playground Example',
41+
lang: 'javascript',
42+
prismjs: selectedLibrary?.value?.id === 'prismjs',
43+
tabs: true,
44+
theme: selectedTheme?.value,
45+
}));
46+
</script>

src/playground/configs/templates/PlaygroundPage.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@
2323
const selectedLibrary = inject('selectedLibrary');
2424
const selectedTheme = inject('selectedTheme');
2525
26-
const cssExample = `.foo {
26+
let code = `.foo {
2727
display: block;
2828
}`;
29-
const htmlExample = `<div>
29+
30+
code = `<div>
3031
Hello World
3132
</div>`;
32-
const jsExample = `const foo = 'bar';`;
33+
34+
code = `const foo = 'bar';`;
3335
3436
const options = computed(() => ({
35-
code: jsExample,
37+
code,
3638
copyButton: true,
3739
highlightjs: selectedLibrary.value?.id === 'highlightjs',
3840
label: 'Playground Example',

0 commit comments

Comments
 (0)