Skip to content

Commit

Permalink
feat: add refresh preview button (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea committed Oct 29, 2023
1 parent 52977b1 commit a45b855
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { type ImportMap } from '@/utils/import-map'
import { type UserOptions } from '@/composables/store'
const loading = ref(true)
const replRef = ref<InstanceType<typeof Repl>>()
// enable experimental features
const sfcOptions: SFCOptions = {
Expand Down Expand Up @@ -63,12 +64,17 @@ const dark = useDark()
// persist state
watchEffect(() => history.replaceState({}, '', `#${store.serialize()}`))
const refreshPreview = () => {
replRef.value?.reload()
}
</script>

<template>
<div v-if="!loading" antialiased>
<Header :store="store" />
<Header :store="store" @refresh="refreshPreview" />
<Repl
ref="replRef"
:theme="dark ? 'dark' : 'light'"
:store="store"
:editor="Monaco"
Expand Down
8 changes: 8 additions & 0 deletions src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
const appVersion = import.meta.env.APP_VERSION
const replVersion = import.meta.env.REPL_VERSION
const emit = defineEmits<{
(e: 'refresh'): void
}>()
const nightly = ref(false)
const dark = useDark()
const toggleDark = useToggle(dark)
Expand Down Expand Up @@ -57,6 +60,10 @@ async function copyLink() {
await navigator.clipboard.writeText(location.href)
ElMessage.success('Sharable URL has been copied to clipboard.')
}
function refreshView() {
emit('refresh')
}
</script>

<template>
Expand Down Expand Up @@ -109,6 +116,7 @@ async function copyLink() {
</div>

<div flex="~ gap-4" text-lg>
<button hover:color-primary i-ri-refresh-line @click="refreshView" />
<button hover:color-primary i-ri-share-line @click="copyLink" />
<button
hover:color-primary
Expand Down

1 comment on commit a45b855

@vercel
Copy link

@vercel vercel bot commented on a45b855 Oct 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.