From 9b68676e48b7dcfb63e0466bbe926396527960ab Mon Sep 17 00:00:00 2001 From: eth3lbert Date: Mon, 23 Sep 2024 16:24:04 +0800 Subject: [PATCH 1/2] CrateSidebar: Open a dialog to display report form and generate email A report form will display in a dialog when the report button is clicked. Users must select reasons and provide detail information (required when the "other" reason is chosen) before submitting. --- app/components/button-with-dialog.hbs | 19 ++++ app/components/button-with-dialog.js | 11 ++ app/components/button-with-dialog.module.css | 24 +++++ app/components/crate-report-form.hbs | 66 ++++++++++++ app/components/crate-report-form.js | 105 +++++++++++++++++++ app/components/crate-report-form.module.css | 69 ++++++++++++ app/components/crate-sidebar.hbs | 13 ++- 7 files changed, 303 insertions(+), 4 deletions(-) create mode 100644 app/components/button-with-dialog.hbs create mode 100644 app/components/button-with-dialog.js create mode 100644 app/components/button-with-dialog.module.css create mode 100644 app/components/crate-report-form.hbs create mode 100644 app/components/crate-report-form.js create mode 100644 app/components/crate-report-form.module.css diff --git a/app/components/button-with-dialog.hbs b/app/components/button-with-dialog.hbs new file mode 100644 index 00000000000..2c7220fd7da --- /dev/null +++ b/app/components/button-with-dialog.hbs @@ -0,0 +1,19 @@ + + +
+ {{#if this.isOpen}} +
+ {{yield this.toggleDialog this.isOpen}} +
+ {{/if}} +
\ No newline at end of file diff --git a/app/components/button-with-dialog.js b/app/components/button-with-dialog.js new file mode 100644 index 00000000000..9d48244cd34 --- /dev/null +++ b/app/components/button-with-dialog.js @@ -0,0 +1,11 @@ +import { action } from '@ember/object'; +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; + +export default class ButtonWithConfirmationDialog extends Component { + @tracked isOpen = false; + + @action toggleDialog(state) { + this.isOpen = state === undefined ? !this.isOpen : !!state; + } +} diff --git a/app/components/button-with-dialog.module.css b/app/components/button-with-dialog.module.css new file mode 100644 index 00000000000..b896dbbfc9f --- /dev/null +++ b/app/components/button-with-dialog.module.css @@ -0,0 +1,24 @@ +.dialog { + inset: 0px; + overflow-y: auto; + display: flex; + justify-content: center; + z-index: 20; + transition: all var(--transition-fast) ease-in; + opacity: 0; + + &.open { + position: fixed; + opacity: 1; + } +} + +.dialog__content { + --shadow: 0 25px 50px light-dark(hsla(51, 50%, 44%, 0.35), #232321); + + height: min-content; + border-radius: var(--space-3xs); + box-shadow: var(--shadow); + outline: 1px solid var(--gray-border); + margin-top: 12.5vh; +} diff --git a/app/components/crate-report-form.hbs b/app/components/crate-report-form.hbs new file mode 100644 index 00000000000..73fd5ec94d2 --- /dev/null +++ b/app/components/crate-report-form.hbs @@ -0,0 +1,66 @@ +
+

Report Crate "{{@crate}}"

+ +
+
Reasons
+
    + {{#each this.reasons as |option|}} +
  • + +
  • + {{/each}} +
+ {{#if this.reasonsInvalid}} +
+ Please choose reasons to report. +
+ {{/if}} +
+ +
+ {{#let (unique-id) as |id|}} + +