Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/sfc-playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ const sfcOptions = {
}
}

// persist state
const autoUrl = ref(true);
watchEffect(() => {
if(!autoUrl.value) return;
const newHash = store
.serialize()
.replace(/^#/, useSSRMode.value ? `#__SSR__` : `#`)
Expand All @@ -68,6 +69,7 @@ function toggleSSR() {
:ssr="useSSRMode"
@toggle-dev="toggleDevMode"
@toggle-ssr="toggleSSR"
v-model:auto-url="autoUrl"
/>
<Repl
@keydown.ctrl.s.prevent
Expand Down
27 changes: 24 additions & 3 deletions packages/sfc-playground/src/Header.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<script setup lang="ts">
import { downloadProject } from './download/download'
import { ref, onMounted } from 'vue'
import { ref, onMounted, defineEmits, computed } from 'vue'
import Sun from './icons/Sun.vue'
import Moon from './icons/Moon.vue'
import Share from './icons/Share.vue'
import Download from './icons/Download.vue'
import GitHub from './icons/GitHub.vue'

// @ts-ignore
const props = defineProps(['store', 'dev', 'ssr'])
const { store } = props
const props = defineProps(['store', 'dev', 'ssr', 'autoUrl'])
const { store, autoUrl } = props
const emit = defineEmits(['update:autoUrl']);

const currentCommit = __COMMIT__
const activeVersion = ref(`@${currentCommit}`)
const publishedVersions = ref<string[]>()
const expanded = ref(false)

const autoUrlRef = computed({
get: () => autoUrl,
set: value => emit("update:autoUrl", value)
});

async function toggle() {
expanded.value = !expanded.value
if (!publishedVersions.value) {
Expand Down Expand Up @@ -97,6 +103,10 @@ async function fetchVersions(): Promise<string[]> {
<span>Vue SFC Playground</span>
</h1>
<div class="links">
<div class="url-generation">
<input type="checkbox" v-model="autoUrlRef" id="auto-url">
<label for="auto-url">Auto URL</label>
</div>
<div class="version" @click.stop>
<span class="active-version" @click="toggle">
Version
Expand Down Expand Up @@ -347,4 +357,15 @@ h1 img {
.links > * + * {
margin-left: 4px;
}

.url-generation {
display: flex;
flex-direction: row;
margin: 0 2px;
align-items: center;
gap: 2px;
border-right: 2px solid var(--border);
padding: 5px;
user-select: none;
}
</style>