* feat: stackblitz editor * chore: update lockfile * fix: cant fetch ?raw dynamically after bundling * feat: add codesandbox
36 lines
1.1 KiB
Vue
36 lines
1.1 KiB
Vue
<script setup lang="ts">
|
|
import { onMounted, ref } from 'vue'
|
|
import { Icon } from '@iconify/vue'
|
|
import { makeCodeSandboxParams } from '../utils/codeeditor'
|
|
import Tooltip from './Tooltip.vue'
|
|
import { Button } from '@/lib/registry/new-york/ui/button'
|
|
import { type Style } from '@/lib/registry/styles'
|
|
|
|
const props = defineProps<{
|
|
name: string
|
|
code: string
|
|
style: Style
|
|
}>()
|
|
|
|
const sources = ref<Record<string, string>>({})
|
|
|
|
onMounted(() => {
|
|
sources.value['App.vue'] = props.code
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<form action="https://codesandbox.io/api/v1/sandboxes/define" method="POST" target="_blank">
|
|
<input type="hidden" name="query" value="file=src/App.vue">
|
|
<input type="hidden" name="environment" value="server">
|
|
<input type="hidden" name="hidedevtools" value="1">
|
|
<input type="hidden" name="parameters" :value="makeCodeSandboxParams(name, style, sources)">
|
|
|
|
<Tooltip :content="`Open ${name} in CodeSandbox`">
|
|
<Button :variant="'ghost'" :size="'icon'" type="submit">
|
|
<Icon icon="ph-codesandbox-logo" />
|
|
</Button>
|
|
</Tooltip>
|
|
</form>
|
|
</template>
|