From bd7e9d2790b94dec0b57ab410837bde0908407b0 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas Date: Fri, 30 Apr 2021 15:24:00 +0530 Subject: [PATCH] chore: Add i18n and components into storybook (#2188) * chore: Add i18n and store into storybook * Use empty store to init storybook --- .storybook/preview.js | 27 +++++++++++++++++++++ app/javascript/shared/store/globalConfig.js | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.storybook/preview.js b/.storybook/preview.js index 6cb7f0a79..40a2ce3ea 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -1,5 +1,32 @@ +import { addDecorator } from '@storybook/vue'; +import Vue from 'vue'; +import Vuex from 'vuex'; +import VueI18n from 'vue-i18n'; + +import WootUiKit from '../app/javascript/dashboard/components'; +import i18n from '../app/javascript/dashboard/i18n'; + import '../app/javascript/dashboard/assets/scss/storybook.scss'; +Vue.use(VueI18n); +Vue.use(WootUiKit); +Vue.use(Vuex); + +const store = new Vuex.Store({}); +const i18nConfig = new VueI18n({ + locale: 'en', + messages: i18n, +}); + +addDecorator(() => ({ + template: '', + i18n: i18nConfig, + store, + beforeCreate: function() { + this.$root._i18n = this.$i18n; + }, +})); + export const parameters = { actions: { argTypesRegex: '^on[A-Z].*' }, controls: { diff --git a/app/javascript/shared/store/globalConfig.js b/app/javascript/shared/store/globalConfig.js index bcf4603a9..73feb88b5 100644 --- a/app/javascript/shared/store/globalConfig.js +++ b/app/javascript/shared/store/globalConfig.js @@ -10,7 +10,7 @@ const { PRIVACY_URL: privacyURL, TERMS_URL: termsURL, WIDGET_BRAND_URL: widgetBrandURL, -} = window.globalConfig; +} = window.globalConfig || {}; const state = { appVersion,