From 97c155f626bc4a26f935200ccfce8114df6f39e0 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 19 Jan 2024 20:33:34 +0100 Subject: [PATCH] Add wizard component [SCI-10035] --- .../packs/vue/design_system/modals.js | 56 ++++++++++++++ .../vue/design_system/wizard_steps/step_1.vue | 37 ++++++++++ .../vue/design_system/wizard_steps/step_2.vue | 41 +++++++++++ .../vue/design_system/wizard_steps/step_3.vue | 42 +++++++++++ app/javascript/vue/shared/wizard_modal.vue | 73 +++++++++++++++++++ app/views/design_elements/_modals.html.erb | 16 ++++ app/views/design_elements/index.html.erb | 1 + config/webpack/webpack.config.js | 3 +- 8 files changed, 268 insertions(+), 1 deletion(-) create mode 100644 app/javascript/packs/vue/design_system/modals.js create mode 100644 app/javascript/packs/vue/design_system/wizard_steps/step_1.vue create mode 100644 app/javascript/packs/vue/design_system/wizard_steps/step_2.vue create mode 100644 app/javascript/packs/vue/design_system/wizard_steps/step_3.vue create mode 100644 app/javascript/vue/shared/wizard_modal.vue create mode 100644 app/views/design_elements/_modals.html.erb diff --git a/app/javascript/packs/vue/design_system/modals.js b/app/javascript/packs/vue/design_system/modals.js new file mode 100644 index 000000000..66f138567 --- /dev/null +++ b/app/javascript/packs/vue/design_system/modals.js @@ -0,0 +1,56 @@ +import { createApp } from 'vue/dist/vue.esm-bundler.js'; +import { shallowRef } from 'vue'; + +import WizardModal from '../../../vue/shared/wizard_modal.vue'; +import Step1 from './wizard_steps/step_1.vue'; +import Step2 from './wizard_steps/step_2.vue'; +import Step3 from './wizard_steps/step_3.vue'; +import { mountWithTurbolinks } from '../helpers/turbolinks.js'; + +const app = createApp({ + components: { + Step1, + Step2, + Step3 + }, + methods: { + fireAlert() { + alert('Fired!'); + } + }, + data() { + return { + wizardConfig: { + title: 'Wizard steps', + subtitle: 'Wizard subtitle description', + steps: [ + { + id: 'step1', + icon: 'sn-icon sn-icon-open', + label: 'Step 1', + component: shallowRef(Step1) + }, + { + id: 'step2', + icon: 'sn-icon sn-icon-edit', + label: 'Step 2', + component: shallowRef(Step2) + }, + { + id: 'step3', + icon: 'sn-icon sn-icon-inventory', + label: 'Step 3', + component: shallowRef(Step3) + } + ] + }, + wizardParams: { + text: 'Some text' + }, + showWizard: false + }; + } +}); +app.component('WizardModal', WizardModal); +app.config.globalProperties.i18n = window.I18n; +mountWithTurbolinks(app, '#modals'); diff --git a/app/javascript/packs/vue/design_system/wizard_steps/step_1.vue b/app/javascript/packs/vue/design_system/wizard_steps/step_1.vue new file mode 100644 index 000000000..bd7f8851c --- /dev/null +++ b/app/javascript/packs/vue/design_system/wizard_steps/step_1.vue @@ -0,0 +1,37 @@ + + + diff --git a/app/javascript/packs/vue/design_system/wizard_steps/step_2.vue b/app/javascript/packs/vue/design_system/wizard_steps/step_2.vue new file mode 100644 index 000000000..590836b8c --- /dev/null +++ b/app/javascript/packs/vue/design_system/wizard_steps/step_2.vue @@ -0,0 +1,41 @@ + + + diff --git a/app/javascript/packs/vue/design_system/wizard_steps/step_3.vue b/app/javascript/packs/vue/design_system/wizard_steps/step_3.vue new file mode 100644 index 000000000..c8571e599 --- /dev/null +++ b/app/javascript/packs/vue/design_system/wizard_steps/step_3.vue @@ -0,0 +1,42 @@ + + + diff --git a/app/javascript/vue/shared/wizard_modal.vue b/app/javascript/vue/shared/wizard_modal.vue new file mode 100644 index 000000000..cdc2b4ee3 --- /dev/null +++ b/app/javascript/vue/shared/wizard_modal.vue @@ -0,0 +1,73 @@ + + + diff --git a/app/views/design_elements/_modals.html.erb b/app/views/design_elements/_modals.html.erb new file mode 100644 index 000000000..a241d91b2 --- /dev/null +++ b/app/views/design_elements/_modals.html.erb @@ -0,0 +1,16 @@ +
+

Modals

+
+ + +
+
+ + +<%= javascript_include_tag 'vue_design_system_modals' %> diff --git a/app/views/design_elements/index.html.erb b/app/views/design_elements/index.html.erb index e69de29bb..b9138c5ca 100644 --- a/app/views/design_elements/index.html.erb +++ b/app/views/design_elements/index.html.erb @@ -0,0 +1 @@ +<%= render partial: 'modals' %> diff --git a/config/webpack/webpack.config.js b/config/webpack/webpack.config.js index 3d286cedf..2241edbf6 100644 --- a/config/webpack/webpack.config.js +++ b/config/webpack/webpack.config.js @@ -49,7 +49,8 @@ const entryList = { vue_components_manage_stock_value_modal: './app/javascript/packs/vue/manage_stock_value_modal.js', vue_legacy_datetime_picker: './app/javascript/packs/vue/legacy/datetime_picker.js', vue_open_locally_menu: './app/javascript/packs/vue/open_locally_menu.js', - vue_scinote_edit_download: './app/javascript/packs/vue/scinote_edit_download.js' + vue_scinote_edit_download: './app/javascript/packs/vue/scinote_edit_download.js', + vue_design_system_modals: './app/javascript/packs/vue/design_system/modals.js' } // Engine pack loading based on https://github.com/rails/webpacker/issues/348#issuecomment-635480949