2024-11-26 11:59:11 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { ref, watchEffect } from 'vue'
|
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
import Alert from '~/components/ui/Alert.vue'
|
|
|
|
import Button from '~/components/ui/Button.vue'
|
|
|
|
import Modal from '~/components/ui/Modal.vue'
|
|
|
|
|
2024-11-26 11:59:11 +00:00
|
|
|
const open = ref(false)
|
|
|
|
const open2 = ref(false)
|
|
|
|
|
|
|
|
const open3 = ref(false)
|
|
|
|
const alertOpen = ref(true)
|
|
|
|
watchEffect(() => {
|
|
|
|
if (open3.value === false) {
|
|
|
|
alertOpen.value = true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const open4 = ref(false)
|
|
|
|
const open5 = ref(false)
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
# Modal
|
|
|
|
|
|
|
|
| Prop | Data type | Required? | Default | Description |
|
|
|
|
| --------- | ----------------- | --------- | ------- | -------------------------------- |
|
|
|
|
| `title` | `string` | Yes | | The modal title |
|
|
|
|
| `v-model` | `true` \| `false` | Yes | | Whether the modal is open or not |
|
|
|
|
|
|
|
|
## Modal open
|
|
|
|
|
|
|
|
```vue-html
|
2024-12-04 15:06:34 +00:00
|
|
|
<Modal v-model="open" title="My modal">
|
2024-11-26 11:59:11 +00:00
|
|
|
Modal content
|
2024-12-04 15:06:34 +00:00
|
|
|
</Modal>
|
2024-11-26 11:59:11 +00:00
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="open = true">
|
2024-11-26 11:59:11 +00:00
|
|
|
Open modal
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
```
|
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Modal v-model="open" title="My modal">
|
2024-11-26 11:59:11 +00:00
|
|
|
Modal content
|
2024-12-04 15:06:34 +00:00
|
|
|
</Modal>
|
|
|
|
<Button @click="open = true">
|
2024-11-26 11:59:11 +00:00
|
|
|
Open modal
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
|
|
|
|
## Modal actions
|
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
Use the `#actions` slot to add actions to a modal. Actions typically take the form of [buttons](./button).
|
2024-11-26 11:59:11 +00:00
|
|
|
|
|
|
|
```vue-html
|
2024-12-04 15:06:34 +00:00
|
|
|
<Modal v-model="open" title="My modal">
|
2024-11-26 11:59:11 +00:00
|
|
|
Modal content
|
|
|
|
|
|
|
|
<template #actions>
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="open = false" color="secondary">
|
2024-11-26 11:59:11 +00:00
|
|
|
Cancel
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="open = false">
|
2024-11-26 11:59:11 +00:00
|
|
|
Ok
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
</template>
|
2024-12-04 15:06:34 +00:00
|
|
|
</Modal>
|
2024-11-26 11:59:11 +00:00
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="open = true">
|
2024-11-26 11:59:11 +00:00
|
|
|
Open modal
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
```
|
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Modal v-model="open2" title="My modal">
|
2024-11-26 11:59:11 +00:00
|
|
|
Modal content
|
|
|
|
<template #actions>
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="open2 = false" color="secondary">
|
2024-11-26 11:59:11 +00:00
|
|
|
Cancel
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
|
|
|
<Button @click="open2 = false">
|
2024-11-26 11:59:11 +00:00
|
|
|
Ok
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
</template>
|
2024-12-04 15:06:34 +00:00
|
|
|
</Modal>
|
|
|
|
<Button @click="open2 = true">
|
2024-11-26 11:59:11 +00:00
|
|
|
Open modal
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
|
|
|
|
## Nested modals
|
|
|
|
|
|
|
|
You can nest modals to allow users to open a modal from inside another modal. This can be useful when creating a multi-step workflow.
|
|
|
|
|
|
|
|
```vue-html
|
2024-12-04 15:06:34 +00:00
|
|
|
<Modal v-model="open" title="My modal">
|
|
|
|
<Modal v-model="openNested" title="My modal">
|
2024-11-26 11:59:11 +00:00
|
|
|
Nested modal content
|
2024-12-04 15:06:34 +00:00
|
|
|
</Modal>
|
2024-11-26 11:59:11 +00:00
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="openNested = true">
|
2024-11-26 11:59:11 +00:00
|
|
|
Open nested modal
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
|
|
|
</Modal>
|
2024-11-26 11:59:11 +00:00
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="open = true">
|
2024-11-26 11:59:11 +00:00
|
|
|
Open modal
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
```
|
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Modal v-model="open4" title="My modal">
|
|
|
|
<Modal v-model="open5" title="My modal">
|
2024-11-26 11:59:11 +00:00
|
|
|
Nested modal content
|
2024-12-04 15:06:34 +00:00
|
|
|
</Modal>
|
|
|
|
<Button @click="open5 = true">
|
2024-11-26 11:59:11 +00:00
|
|
|
Open nested modal
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
|
|
|
</Modal>
|
|
|
|
<Button @click="open4 = true">
|
2024-11-26 11:59:11 +00:00
|
|
|
Open modal
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
|
|
|
|
## Alert inside modal
|
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
You can nest [Funkwhale alerts](./alert) to visually highlight content within the modal.
|
2024-11-26 11:59:11 +00:00
|
|
|
|
|
|
|
```vue-html
|
2024-12-04 15:06:34 +00:00
|
|
|
<Modal v-model="open" title="My modal">
|
2024-11-26 11:59:11 +00:00
|
|
|
Modal content
|
|
|
|
|
|
|
|
<template #alert v-if="alertOpen">
|
|
|
|
<fw-alert>
|
|
|
|
Alert content
|
|
|
|
|
|
|
|
<template #actions>
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="alertOpen = false">Close alert</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
</template>
|
|
|
|
</fw-alert>
|
|
|
|
</template>
|
2024-12-04 15:06:34 +00:00
|
|
|
</Modal>
|
2024-11-26 11:59:11 +00:00
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="open = true">
|
2024-11-26 11:59:11 +00:00
|
|
|
Open modal
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
```
|
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Modal v-model="open3" title="My modal">
|
2024-11-26 11:59:11 +00:00
|
|
|
Modal content
|
|
|
|
<template #alert v-if="alertOpen">
|
2024-12-04 15:06:34 +00:00
|
|
|
<Alert>
|
2024-11-26 11:59:11 +00:00
|
|
|
Alert content
|
|
|
|
<template #actions>
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="alertOpen = false">Close alert</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
</template>
|
2024-12-04 15:06:34 +00:00
|
|
|
</Alert>
|
2024-11-26 11:59:11 +00:00
|
|
|
</template>
|
|
|
|
<template #actions>
|
2024-12-04 15:06:34 +00:00
|
|
|
<Button @click="open3 = false" color="secondary">
|
2024-11-26 11:59:11 +00:00
|
|
|
Cancel
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
|
|
|
<Button @click="open3 = false">
|
2024-11-26 11:59:11 +00:00
|
|
|
Ok
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|
2024-11-26 11:59:11 +00:00
|
|
|
</template>
|
2024-12-04 15:06:34 +00:00
|
|
|
</Modal>
|
|
|
|
<Button @click="open3 = true">
|
2024-11-26 11:59:11 +00:00
|
|
|
Open modal
|
2024-12-04 15:06:34 +00:00
|
|
|
</Button>
|