Skip to content

Commit 1838bb6

Browse files
author
issayah
committed
BToast setup conversion
1 parent 095c071 commit 1838bb6

File tree

2 files changed

+22
-41
lines changed

2 files changed

+22
-41
lines changed

src/components/BToast/BToast.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const MIN_DURATION = 5000
2626
2727
export default defineComponent({
2828
name: 'BToast',
29-
emits: ['destroyed', 'update:modelValue'],
3029
props: {
3130
...BLINK_PROPS,
3231
delay: {type: Number, default: 5000},
@@ -50,7 +49,7 @@ export default defineComponent({
5049
toastClass: {type: Array as PropType<Array<string>>},
5150
variant: {type: String as PropType<ColorVariant>},
5251
},
53-
52+
emits: ['destroyed', 'update:modelValue'],
5453
setup(props, {emit, slots}) {
5554
const isTransitioning = ref(false)
5655
const isHiding = ref(false)

src/components/BToast/BToaster.vue

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,29 @@
77
v-model="toast.options.value"
88
:title="toast.content.title"
99
:body="toast.content.body"
10-
:component="toast.content.vnode"
10+
:component="toast.content.body"
1111
:variant="toast.options.variant"
1212
@destroyed="handleDestroy"
1313
>
1414
</b-toast>
1515
</div>
1616
</template>
1717

18-
<script lang="ts">
19-
import {
20-
computed,
21-
defineComponent,
22-
getCurrentInstance,
23-
nextTick,
24-
onMounted,
25-
PropType,
26-
reactive,
27-
Ref,
28-
ref,
29-
toRefs,
30-
ToRefs,
31-
watch,
32-
} from 'vue'
33-
import {ToastInstance} from './plugin'
34-
import type {ContainerPosition} from '../../types'
18+
<script setup lang="ts">
19+
// import type {BToasterProps} from '@/types/components'
20+
import {computed} from 'vue'
21+
import type {ContainerPosition} from '@/types'
22+
import type {ToastInstance} from '@/components/BToast/plugin'
23+
24+
interface BToasterProps {
25+
position?: ContainerPosition
26+
instance: ToastInstance
27+
// appendToast?: boolean
28+
}
29+
30+
const props = withDefaults(defineProps<BToasterProps>(), {
31+
position: 'top-right',
32+
})
3533
3634
const toastPositions = {
3735
'top-left': 'top-0 start-0',
@@ -45,26 +43,10 @@ const toastPositions = {
4543
'bottom-right': 'bottom-0 end-0',
4644
}
4745
48-
export default defineComponent({
49-
name: 'BToaster',
50-
props: {
51-
position: {type: String as PropType<ContainerPosition>, default: 'top-right'},
52-
instance: {type: Object as PropType<ToastInstance>},
53-
// appendToast: {type: Boolean, default: false},
54-
},
46+
const positionClass = computed(() => toastPositions[props.position])
5547
56-
setup(props, {emit}) {
57-
const positionClass = computed(() => toastPositions[props.position])
58-
59-
const handleDestroy = (id: string) => {
60-
//we made want to disable reactivity for deletes. Future Note
61-
props.instance?.remove(id)
62-
}
63-
return {
64-
positionClass,
65-
handleDestroy,
66-
}
67-
},
68-
computed: {},
69-
})
48+
const handleDestroy = (id: string) => {
49+
//we made want to disable reactivity for deletes. Future Note
50+
props.instance?.remove(id)
51+
}
7052
</script>

0 commit comments

Comments
 (0)