From 9f69cfd9b587821abc721d7921872434ae944790 Mon Sep 17 00:00:00 2001 From: ArneBo Date: Mon, 20 Jan 2025 13:53:56 +0100 Subject: [PATCH] feat(ui): destructive modals --- front/src/components/ui/Modal.vue | 32 ++- front/src/components/ui/modal.scss | 10 + front/ui-docs/components/ui/modal.md | 372 ++++++++++++++++++--------- 3 files changed, 284 insertions(+), 130 deletions(-) diff --git a/front/src/components/ui/Modal.vue b/front/src/components/ui/Modal.vue index 1bb8577e5..5c9636528 100644 --- a/front/src/components/ui/Modal.vue +++ b/front/src/components/ui/Modal.vue @@ -1,17 +1,26 @@ @@ -47,7 +49,7 @@ import Modal from "~/components/ui/Modal.vue" ```
- @@ -86,126 +88,20 @@ Make sure to add `autofocus` to the preferred button. ```
- - - Modal content - - -
- - - -### Confirm a dangerous action - -Note that confirmation dialogs interrupt the user's workflow. Consider adding a recovery functionality such as "undo" instead. - -::: tip Read more about designing user experiences around dangerous actions: - -- [How to use visual signals and spacing to differentiate between benign and dangerous options](https://www.nngroup.com/articles/proximity-consequential-options/) - - > If you need to implement dangerous actions, make sure to place them apart from other actions to prevent accidental clicks. Add contextual hints and information so that the user understands the consequences of the action. - -- [How to design a confirmation dialog](https://www.nngroup.com/articles/confirmation-dialog/) - > 1. Let the user confirm potentially destructive actions - > 2. Do not use confirmation dialogs for routine tasks - > 3. Be specific about the action and its potential consequences - > 4. Label the response buttons with their result: "Delete my account" instead of "Yes" - > 5. Make sure to give the user all information they need to decide - -::: - -```vue-html - - - - -Do you want to delete your account forever? - -You will not be able to restore your account. - - -``` - - - - -Do you want to delete your account forever? - -You will not be able to restore your account. - - - -## Nested modals - -You can nest modals to allow users to isOpen a modal from inside another modal. This can be useful when creating a multi-step workflow. - - - -```vue-html - - - - - Nested modal content - - - - -``` - -
- - - - Nested modal content + + Modal content + - -
@@ -237,10 +133,13 @@ You can nest [Funkwhale alerts](./alert) to visually highlight content within th ```
- - + Modal content @@ -262,3 +161,232 @@ You can nest [Funkwhale alerts](./alert) to visually highlight content within th
+ +# Destructive Modal + +The `destructive` prop is used to visually indicate a potentially dangerous or irreversible action. When set to `true`, the modal will have a distinctive red styling to draw the user's attention and highlight the critical nature of the action. + +| Prop | Data type | Required? | Default | Description | +|---------------|-----------|-----------|---------|--------------------------------------------------| +| `destructive` | `true` | No | `false` | Applies a red styling to emphasize dangerous actions | + + + +```vue-html + + Dangerous action consequences + +``` + +
+ + + Dangerous action consequences + +
+ +
+ +### Styling Effects + +When the `destructive` prop is set to `true`, the modal will: +- Add a red border +- Style the title in red + +To visually distinguish the modal from standard modals + +### Best Practices + +- Use the `destructive` prop sparingly +- Clearly explain the consequences of the action unsing `` +- Provide a clear way to cancel the action +- Use descriptive action button labels + +The example in the "Confirm a dangerous action" section demonstrates the recommended usage of the destructive modal. + + + +```vue-html + + + + + +``` + +
+ + + + + +
+ +
+ +## Confirm a dangerous action + +Note that confirmation dialogs interrupt the user's workflow. Consider adding a recovery functionality such as "undo" instead. + +::: tip Read more about designing user experiences around dangerous actions: + +- [How to use visual signals and spacing to differentiate between benign and dangerous options](https://www.nngroup.com/articles/proximity-consequential-options/) + + > If you need to implement dangerous actions, make sure to place them apart from other actions to prevent accidental clicks. Add contextual hints and information so that the user understands the consequences of the action. + +- [How to design a confirmation dialog](https://www.nngroup.com/articles/confirmation-dialog/) + > 1. Let the user confirm potentially destructive actions + > 2. Do not use confirmation dialogs for routine tasks + > 3. Be specific about the action and its potential consequences + > 4. Label the response buttons with their result: "Delete my account" instead of "Yes" + > 5. Make sure to give the user all information they need to decide + +::: + + + +```vue-html + + + + +Do you want to delete your account forever? + +You will not be able to restore your account. + + +``` + + + + +Do you want to delete your account forever? + +You will not be able to restore your account. + + + + + +## Nested modals + +You can nest modals to allow users to isOpen a modal from inside another modal. This can be useful when creating a multi-step workflow. + + + +```vue-html + + + + + Nested modal content + + + + +``` + +
+ + + + Nested modal content + + + +
+ +