feat(Alert/Toast)!: add orientation prop

This commit is contained in:
Benjamin Canac
2025-02-05 13:36:46 +01:00
parent cd0a9d39d8
commit 2c192ac145
15 changed files with 659 additions and 347 deletions

View File

@@ -0,0 +1,27 @@
<script setup lang="ts">
const toast = useToast()
const props = defineProps<{
orientation: 'horizontal' | 'vertical'
}>()
function showToast() {
toast.add({
title: 'Uh oh! Something went wrong.',
orientation: props.orientation,
actions: [{
icon: 'i-lucide-refresh-cw',
label: 'Retry',
color: 'neutral',
variant: 'outline',
onClick: (e) => {
e?.stopPropagation()
}
}]
})
}
</script>
<template>
<UButton label="Show toast" color="neutral" variant="outline" @click="showToast" />
</template>

View File

@@ -215,8 +215,30 @@ props:
---
::
::note
Actions renders differently when the description is not set. You can try to remove it.
### Orientation
Use the `orientation` prop to change the orientation of the Alert.
::component-code
---
prettier: true
ignore:
- title
- actions
- color
- variant
props:
title: 'Heads up!'
description: 'You can change the primary color in your app config.'
color: neutral
variant: outline
orientation: horizontal
actions:
- label: Action 1
- label: Action 2
color: neutral
variant: subtle
---
::
## Examples

View File

@@ -154,8 +154,21 @@ name: 'toast-actions-example'
---
::
::note
Actions renders differently when the description is not set. You can try to remove it.
### Orientation
Use the `orientation` prop to change the orientation of the Toast.
::component-example
---
options:
- name: 'orientation'
label: 'orientation'
default: 'horizontal'
items:
- horizontal
- vertical
name: 'toast-orientation-example'
---
::
## Examples