diff --git a/app/components/confirm_modal_component.rb b/app/components/confirm_modal_component.rb new file mode 100644 index 0000000000..5df7d9ba54 --- /dev/null +++ b/app/components/confirm_modal_component.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class ConfirmModalComponent < ModalComponent + def initialize(id:, confirm_actions: nil, controllers: nil) + super(id: id, close_button: true) + @confirm_actions = confirm_actions + @controllers = controllers + end + + private + + def close_button_class + "secondary" + end +end diff --git a/app/components/confirm_modal_component/confirm_modal_component.html.haml b/app/components/confirm_modal_component/confirm_modal_component.html.haml new file mode 100644 index 0000000000..58feccb1ec --- /dev/null +++ b/app/components/confirm_modal_component/confirm_modal_component.html.haml @@ -0,0 +1,8 @@ +%div{ id: @id, "data-controller": "modal #{@controllers}", "data-action": "keyup@document->modal#closeIfEscapeKey" } + .reveal-modal-bg.fade{ "data-modal-target": "background", "data-action": "click->modal#close" } + .reveal-modal.fade.tiny.help-modal{ "data-modal-target": "modal" } + = content + + .modal-actions + %input{ class: "button icon-plus #{close_button_class}", type: 'button', value: t('js.admin.modals.cancel'), "data-action": "click->modal#close" } + %input{ class: "button icon-plus primary", type: 'button', value: t('js.admin.modals.confirm'), "data-action": @confirm_actions } diff --git a/app/components/confirm_modal_component/confirm_modal_component.scss b/app/components/confirm_modal_component/confirm_modal_component.scss new file mode 100644 index 0000000000..ccbf18169c --- /dev/null +++ b/app/components/confirm_modal_component/confirm_modal_component.scss @@ -0,0 +1,4 @@ +.modal-actions { + display: flex; + justify-content: space-around; +} diff --git a/app/webpacker/css/admin/all.scss b/app/webpacker/css/admin/all.scss index f0de698f7b..7ee28e2e08 100644 --- a/app/webpacker/css/admin/all.scss +++ b/app/webpacker/css/admin/all.scss @@ -127,3 +127,4 @@ @import "app/components/pagination_component/pagination_component"; @import "app/components/table_header_component/table_header_component"; @import "app/components/search_input_component/search_input_component"; +@import 'app/components/confirm_modal_component/confirm_modal_component'; diff --git a/app/webpacker/css/darkswarm/all.scss b/app/webpacker/css/darkswarm/all.scss index 3738d945c6..d57b326c58 100644 --- a/app/webpacker/css/darkswarm/all.scss +++ b/app/webpacker/css/darkswarm/all.scss @@ -77,3 +77,4 @@ ofn-modal { @import '../admin/shared/scroll_bar'; @import 'app/components/help_modal_component/help_modal_component'; +@import 'app/components/confirm_modal_component/confirm_modal_component'; diff --git a/config/locales/en.yml b/config/locales/en.yml index 0c97da073e..3016c015a4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3036,8 +3036,10 @@ See the %{link} to find out more about %{sitename}'s features and to start using deleting_item_will_cancel_order: "This operation will result in one or more empty orders, which will be cancelled. Do you wish to proceed?" modals: got_it: "Got it" + confirm: "Confirm" close: "Close" continue: "Continue" + cancel: "Cancel" invite: "Invite" invite_title: "Invite an unregistered user" tag_rule_help: