Skip to content

Commit

Permalink
feat(Toast): add Portal (#1417)
Browse files Browse the repository at this point in the history
* feat(Toast): improve `Toast` to use Portal

* chore: docs gen

---------

Co-authored-by: malik jouda <m.jouda@approved.tech>
  • Loading branch information
malik-jouda and MalikJouda authored Nov 16, 2024
1 parent 1714513 commit 8860c10
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/content/components/toast.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ The toast that automatically closes. It should not be held open to [acquire a us
]"
/>

### Portal

When used, portals the content part into the `body`.

<!-- @include: @/meta/ToastPortal.md -->

### Title

An optional title for the toast
Expand Down
22 changes: 22 additions & 0 deletions docs/content/meta/ToastPortal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- This file was automatic generated. Do not edit it manually -->

<PropsTable :data="[
{
'name': 'disabled',
'description': '<p>Disable teleport and render the component inline</p>\n<p><a href=\'https://vuejs.org/guide/built-ins/teleport.html#disabling-teleport\' target=\'_blank\'>reference</a></p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'forceMount',
'description': '<p>Used to force mounting when more control is needed. Useful when\ncontrolling animation with Vue animation libraries.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'to',
'description': '<p>Vue native teleport component prop <code>:to</code></p>\n<p><a href=\'https://vuejs.org/guide/built-ins/teleport.html#basic-usage\' target=\'_blank\'>reference</a></p>\n',
'type': 'string | HTMLElement',
'required': false
}
]" />
1 change: 1 addition & 0 deletions packages/radix-vue/constant/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ export const components = {
toast: [
'ToastProvider',
'ToastRoot',
'ToastPortal',
'ToastAction',
'ToastClose',
'ToastViewport',
Expand Down
17 changes: 17 additions & 0 deletions packages/radix-vue/src/Toast/ToastPortal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script lang="ts">
import type { TeleportProps } from '@/Teleport'
export interface ToastPortalProps extends TeleportProps {}
</script>

<script setup lang="ts">
import { TeleportPrimitive } from '@/Teleport'
const props = defineProps<ToastPortalProps>()
</script>

<template>
<TeleportPrimitive v-bind="props">
<slot />
</TeleportPrimitive>
</template>
1 change: 1 addition & 0 deletions packages/radix-vue/src/Toast/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { default as ToastProvider, type ToastProviderProps } from './ToastProvider.vue'
export { default as ToastRoot, type ToastRootProps, type ToastRootEmits } from './ToastRoot.vue'
export { default as ToastPortal, type ToastPortalProps } from './ToastPortal.vue'
export { default as ToastAction, type ToastActionProps } from './ToastAction.vue'
export { default as ToastClose, type ToastCloseProps } from './ToastClose.vue'
export { default as ToastViewport, type ToastViewportProps } from './ToastViewport.vue'
Expand Down

0 comments on commit 8860c10

Please # to comment.