Skip to content

Commit 4da459d

Browse files
Merge pull request #26 from robinsimonklein/feat/preview-object-array-default-value
Preview object & array default value
2 parents 3370d40 + fad2b4f commit 4da459d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/components/core/CopyButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Button size="icon-sm" variant="ghost" @click.prevent="copy(text)">
2+
<Button size="icon-sm" variant="ghost" @click.prevent.stop="copy(text)">
33
<Check v-if="copied" class="h-3.5 w-3.5" />
44
<Copy v-else class="h-3.5 w-3.5" />
55
</Button>

src/components/stimulus/members/values/StimulusControllerValuesRow.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@
99
</tr>
1010
<tr v-if="value.defaultValue">
1111
<td>Default</td>
12-
<CodeInline :code="value.defaultValue.toString()" language="javascript" />
12+
<template v-if="value.type === 'object' || value.type === 'array'">
13+
<Popover v-if="value.defaultValue">
14+
<PopoverTrigger>
15+
<button class="inline-flex items-center capitalize italic text-muted-foreground">
16+
<span>{{ value.type }}</span>
17+
<ChevronRight class="h-4" />
18+
</button>
19+
</PopoverTrigger>
20+
<PopoverContent>
21+
<CodeBlock :code="JSON.stringify(value.defaultValue, null, 2)" language="javascript" />
22+
</PopoverContent>
23+
</Popover>
24+
</template>
25+
<template v-else>
26+
<CodeInline :code="JSON.stringify(value.defaultValue)" language="javascript" />
27+
</template>
1328
</tr>
1429
</table>
1530
<hr class="my-2" />
@@ -44,6 +59,9 @@ import ValueType from '@/components/core/ValueType.vue';
4459
import CodeInline from '@/components/core/code/CodeInline.vue';
4560
import { Action } from '@/enum';
4661
import { useBridge } from '@/composables/useBridge.ts';
62+
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
63+
import CodeBlock from '@/components/core/CodeBlock.vue';
64+
import { ChevronRight } from 'lucide-vue-next';
4765
4866
const { executeAction } = useBridge();
4967

0 commit comments

Comments
 (0)