Skip to content

Commit

Permalink
workflow(sfc-playground): make warnings dismissable
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 29, 2021
1 parent 7ab519c commit 4d9f9fd
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/sfc-playground/src/Message.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<template>
<Transition name="fade">
<pre v-if="err || warn"
<pre v-if="!dismissed && (err || warn)"
class="msg"
:class="err ? 'err' : 'warn'">{{ formatMessage(err || warn) }}</pre>
:class="err ? 'err' : 'warn'"
@click="dismissed = true">{{ formatMessage(err || warn) }}</pre>
</Transition>
</template>

<script setup lang="ts">
import { defineProps } from 'vue'
import { defineProps, ref, watch } from 'vue'
import type { CompilerError } from '@vue/compiler-sfc'
defineProps(['err', 'warn'])
const props = defineProps(['err', 'warn'])
const dismissed = ref(false)
watch(() => [props.err, props.warn], () => {
dismissed.value = false
})
function formatMessage(err: string | Error): string {
if (typeof err === 'string') {
Expand Down

0 comments on commit 4d9f9fd

Please sign in to comment.