@dracul/customize-frontend 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,64 +1,65 @@
1
1
  <template>
2
- <v-card>
3
- <v-card-title outlined>
4
- <div v-t="'customization.lang.title'"></div>
5
- <br>
6
- </v-card-title>
7
- <v-card-subtitle v-t="'customization.lang.subtitle'">
8
- </v-card-subtitle>
9
- <v-card-text>
10
- <v-form ref="langForm" autocomplete="off" @submit.prevent="saveLang">
11
- <v-row>
12
- <v-col cols="12" md="3" lg="3">
13
- <v-select
14
- prepend-icon="language"
15
- class="pa-3"
16
- :items="langs"
17
- :item-text="'text'"
18
- :item-value="'value'"
19
- color="secondary"
20
- item-color="secondary"
21
- v-model="formLang.language"
22
- :label="$t('customization.lang.form.lang')"
23
- required
24
- ></v-select>
25
- </v-col>
26
- </v-row>
27
- </v-form>
28
- </v-card-text>
2
+ <v-card>
3
+ <v-card-title outlined>
4
+ <div v-t="'customization.lang.title'"></div>
5
+ <br>
6
+ </v-card-title>
7
+ <v-card-subtitle v-t="'customization.lang.subtitle'">
8
+ </v-card-subtitle>
9
+ <v-card-text>
10
+ <v-form ref="langForm" autocomplete="off" @submit.prevent="saveLang">
11
+ <v-row>
12
+ <v-col cols="12" md="3" lg="3">
13
+ <v-select
14
+ prepend-icon="language"
15
+ class="pa-3"
16
+ :items="langs"
17
+ :item-text="'text'"
18
+ :item-value="'value'"
19
+ color="secondary"
20
+ item-color="secondary"
21
+ v-model="formLang.language"
22
+ :label="$t('customization.lang.form.lang')"
23
+ required
24
+ ></v-select>
25
+ </v-col>
26
+ </v-row>
27
+ </v-form>
28
+ </v-card-text>
29
29
 
30
- <v-divider></v-divider>
30
+ <v-divider></v-divider>
31
31
 
32
- <v-card-actions>
33
- <v-btn @click="saveLang" text color="blue darken-4" v-t="'customization.applyButton'"></v-btn>
34
- </v-card-actions>
35
- </v-card>
32
+ <v-card-actions>
33
+ <v-spacer></v-spacer>
34
+ <v-btn @click="saveLang" large color="primary onPrimary--text" v-t="'customization.applyButton'"></v-btn>
35
+ </v-card-actions>
36
+ </v-card>
36
37
  </template>
37
38
  <script>
38
- import CustomizationProvider from "../../../../providers/CustomizationProvider";
39
- import {ClientError} from "@dracul/user-frontend";
40
- import {mapMutations} from "vuex";
39
+ import CustomizationProvider from "../../../../providers/CustomizationProvider";
40
+ import {ClientError} from "@dracul/user-frontend";
41
+ import {mapMutations} from "vuex";
41
42
 
42
- export default {
43
- name: 'customization-lang',
44
- props: {
45
- formLang: {type:Object},
46
- langs: {type: Array},
47
- },
48
- methods:{
49
- ...mapMutations([
50
- 'setLanguage'
51
- ]),
52
- saveLang() {
53
- CustomizationProvider.updateLanguage(this.formLang).then(r => {
54
- this.$root.$i18n.locale = r.data.langUpdate.language
55
- this.setLanguage(r.data.langUpdate.language)
56
- }).catch(error => {
57
- let clientError = new ClientError(error)
58
- this.inputErrors = clientError.inputErrors
59
- this.errorMessage = clientError.showMessage
60
- })
61
- },
62
- }
63
- }
43
+ export default {
44
+ name: 'customization-lang',
45
+ props: {
46
+ formLang: {type: Object},
47
+ langs: {type: Array},
48
+ },
49
+ methods: {
50
+ ...mapMutations([
51
+ 'setLanguage'
52
+ ]),
53
+ saveLang() {
54
+ CustomizationProvider.updateLanguage(this.formLang).then(r => {
55
+ this.$root.$i18n.locale = r.data.langUpdate.language
56
+ this.setLanguage(r.data.langUpdate.language)
57
+ }).catch(error => {
58
+ let clientError = new ClientError(error)
59
+ this.inputErrors = clientError.inputErrors
60
+ this.errorMessage = clientError.showMessage
61
+ })
62
+ },
63
+ }
64
+ }
64
65
  </script>
@@ -84,7 +84,8 @@
84
84
  <v-divider></v-divider>
85
85
 
86
86
  <v-card-actions>
87
- <v-btn :loading="loading" @click="saveLogo" text color="blue darken-4" v-t="'customization.applyButton'"></v-btn>
87
+ <v-spacer></v-spacer>
88
+ <v-btn :loading="loading" @click="saveLogo" large color="primary onPrimary--text" v-t="'customization.applyButton'"></v-btn>
88
89
  </v-card-actions>
89
90
 
90
91
  </v-card>
@@ -1,101 +1,115 @@
1
1
  <template>
2
- <v-row v-if="!loading">
2
+ <v-row v-if="!loading">
3
3
 
4
- <v-col cols="12" md="3">
5
- <customization-menu v-model="selected"/>
6
- </v-col>
4
+ <v-col cols="12" md="3">
5
+ <customization-menu v-model="selected"/>
6
+ </v-col>
7
7
 
8
- <v-col cols="12" md="9">
9
- <customization-lang v-if="selected === 0"
10
- :form-lang="formLang"
11
- :langs="langs"
12
- />
8
+ <v-col cols="12" md="9">
9
+ <customization-lang v-if="selected === 0"
10
+ :form-lang="formLang"
11
+ :langs="langs"
12
+ />
13
13
 
14
- <customization-colors v-if="selected === 1"
15
- :form-colors="formColors"
16
- />
14
+ <customization-colors v-if="selected === 1"
15
+ :form-colors="formColors"
16
+ />
17
17
 
18
- <customization-logo v-if="selected === 2"
19
- :form-logo="formLogo"
20
- />
18
+ <customization-logo v-if="selected === 2"
19
+ :form-logo="formLogo"
20
+ />
21
21
 
22
- </v-col>
22
+ </v-col>
23
23
 
24
- </v-row>
24
+ </v-row>
25
25
  </template>
26
26
 
27
27
  <script>
28
- import CustomizationProvider from "../../../providers/CustomizationProvider";
29
- import {LOGO_MODE_ONLYTITLE} from '../../../constants'
30
- import CustomizationMenu from "./CustomizationMenu";
31
- import CustomizationColors from "./CustomizationColors";
32
- import CustomizationLogo from "./CustomizationLogo";
33
- import CustomizationLang from "./CustomizationLang";
34
-
35
- export default {
36
- name: "CustomizationManagement",
37
- components: {CustomizationLang, CustomizationLogo, CustomizationColors, CustomizationMenu},
38
- created() {
39
- this.loading = true
40
- CustomizationProvider.customization().then(r => {
41
- this.formColors.primary = r.data.customization.colors.primary
42
- this.formColors.onPrimary = r.data.customization.colors.onPrimary
43
- this.formColors.secondary = r.data.customization.colors.secondary
44
- this.formColors.onSecondary = r.data.customization.colors.onSecondary
45
-
46
- this.formLogo.mode = r.data.customization.logo.mode
47
- this.formLogo.title = r.data.customization.logo.title
48
- this.formLogo.url = r.data.customization.logo.url
49
-
50
- this.formLang.language = r.data.customization.language
51
-
52
- }).finally(() => this.loading = false)
53
- },
54
- data() {
55
- return {
56
- modal: false,
57
- selected: 0,
58
- title: "Creando Customization",
59
- errorMessage: '',
60
- inputErrors: {},
61
- loading: false,
62
- menu: {
63
- primary: false,
64
- onPrimary: false,
65
- secondary: false,
66
- onSecondary: false,
67
- },
68
- langs: [{value: 'es', text:'Español'},{value: 'en', text: 'English'} ,{value: 'pt', text: 'Português'}],
69
-
70
- formLang: {
71
- language: null,
72
- },
73
-
74
- formLogo: {
75
- mode: LOGO_MODE_ONLYTITLE,
76
- title: 'APP',
77
- url: null
78
- },
79
- formColors: {
80
- primary: null,
81
- onPrimary: null,
82
- secondary: null,
83
- onSecondary: null,
84
- },
85
- rules: {
86
- required: value => !!value || 'Requerido'
87
- },
88
-
89
- }
28
+ import CustomizationProvider from "../../../providers/CustomizationProvider";
29
+ import {LOGO_MODE_ONLYTITLE} from '../../../constants'
30
+ import CustomizationMenu from "./CustomizationMenu";
31
+ import CustomizationColors from "./CustomizationColors";
32
+ import CustomizationLogo from "./CustomizationLogo";
33
+ import CustomizationLang from "./CustomizationLang";
34
+
35
+ export default {
36
+ name: "CustomizationManagement",
37
+ components: {CustomizationLang, CustomizationLogo, CustomizationColors, CustomizationMenu},
38
+ created() {
39
+ this.loading = true
40
+ CustomizationProvider.customization().then(r => {
41
+ this.formColors.lightTheme = r.data.customization.lightTheme
42
+ delete this.formColors.lightTheme.__typename
43
+ this.formColors.darkTheme = r.data.customization.darkTheme
44
+ delete this.formColors.darkTheme.__typename
45
+
46
+ this.formLogo.mode = r.data.customization.logo.mode
47
+ this.formLogo.title = r.data.customization.logo.title
48
+ this.formLogo.url = r.data.customization.logo.url
49
+
50
+ this.formLang.language = r.data.customization.language
51
+
52
+ }).finally(() => this.loading = false)
53
+ },
54
+ data() {
55
+ return {
56
+ modal: false,
57
+ selected: 0,
58
+ title: "Creando Customization",
59
+ errorMessage: '',
60
+ inputErrors: {},
61
+ loading: false,
62
+ menu: {
63
+ primary: false,
64
+ onPrimary: false,
65
+ secondary: false,
66
+ onSecondary: false,
67
+ },
68
+ langs: [{value: 'es', text: 'Español'}, {value: 'en', text: 'English'}, {value: 'pt', text: 'Português'}],
69
+
70
+ formLang: {
71
+ language: null,
72
+ },
73
+
74
+ formLogo: {
75
+ mode: LOGO_MODE_ONLYTITLE,
76
+ title: 'APP',
77
+ url: null
78
+ },
79
+ formColors: {
80
+ lightTheme: {
81
+ primary: null,
82
+ onPrimary: null,
83
+ secondary: null,
84
+ onSecondary: null,
85
+ background: null,
86
+ appBar: null,
87
+ onAppBar: null,
90
88
  },
89
+ darkTheme: {
90
+ primary: null,
91
+ onPrimary: null,
92
+ secondary: null,
93
+ onSecondary: null,
94
+ background: null,
95
+ onAppBar: null,
96
+ }
97
+
98
+ },
99
+ rules: {
100
+ required: value => !!value || 'Requerido'
101
+ },
91
102
 
92
103
  }
104
+ },
105
+
106
+ }
93
107
  </script>
94
108
 
95
109
  <style scoped>
96
- .colorBox {
97
- border: 1px solid grey;
98
- font-weight: bold;
99
- padding: 5px;
100
- }
110
+ .colorBox {
111
+ border: 1px solid grey;
112
+ font-weight: bold;
113
+ padding: 5px;
114
+ }
101
115
  </style>
@@ -91,13 +91,23 @@ Vue.use(Vuetify, {
91
91
  }
92
92
  });
93
93
 
94
- let colors = {
94
+ const LIGHT_THEME = {
95
95
  primary: '#3F51B5',
96
96
  onPrimary: '#FFFFFF',
97
97
  secondary: '#1565C0',
98
- onSecondary: '#FFFFFF'
98
+ onSecondary: '#FFFFFF',
99
+ background: '#F5F5F5'
99
100
  }
100
101
 
102
+ const DARK_THEME = {
103
+ primary : "#71DDC7",
104
+ onPrimary : "#000000",
105
+ secondary : "#E57FFB",
106
+ onSecondary : "#010101",
107
+ background : "#121212"
108
+ }
109
+
110
+
101
111
 
102
112
  const vuetify = new Vuetify({
103
113
  lang: {
@@ -109,10 +119,18 @@ const vuetify = new Vuetify({
109
119
  theme: {
110
120
  themes: {
111
121
  light: {
112
- primary: colors.primary,
113
- secondary: colors.secondary,
114
- onPrimary: colors.onPrimary,
115
- onSecondary: colors.onSecondary
122
+ background: LIGHT_THEME.background,
123
+ primary: LIGHT_THEME.primary,
124
+ secondary: LIGHT_THEME.secondary,
125
+ onPrimary: LIGHT_THEME.onPrimary,
126
+ onSecondary: LIGHT_THEME.onSecondary
127
+ },
128
+ dark: {
129
+ background: DARK_THEME.background,
130
+ primary: DARK_THEME.primary,
131
+ secondary: DARK_THEME.secondary,
132
+ onPrimary: DARK_THEME.onPrimary,
133
+ onSecondary: DARK_THEME.onSecondary
116
134
  }
117
135
  }
118
136
  },
@@ -14,8 +14,8 @@ class CustomizationProvider {
14
14
  query: require('./gql/customization.graphql')
15
15
  })
16
16
  }
17
-
18
-
17
+
18
+
19
19
 
20
20
  updateCustomization(form) {
21
21
  return this.gqlc.mutate({
@@ -24,10 +24,10 @@ class CustomizationProvider {
24
24
  })
25
25
  }
26
26
 
27
- updateColors(form) {
27
+ updateColors(input) {
28
28
  return this.gqlc.mutate({
29
29
  mutation: require('./gql/colorsUpdate.graphql'),
30
- variables: form
30
+ variables: {input}
31
31
  })
32
32
  }
33
33
 
@@ -1,9 +1,23 @@
1
- mutation colorsUpdate($primary:String!, $onPrimary:String!, $secondary:String!, $onSecondary:String!){
2
- colorsUpdate(input: {primary: $primary, onPrimary: $onPrimary, secondary: $secondary, onSecondary: $onSecondary }){
3
- primary
4
- onPrimary
5
- secondary
6
- onSecondary
1
+ mutation colorsUpdate($input: ColorsUpdateInput ){
2
+ colorsUpdate(input: $input){
3
+ lightTheme{
4
+ primary
5
+ onPrimary
6
+ secondary
7
+ onSecondary
8
+ background
9
+ appBar
10
+ onAppBar
11
+ }
12
+ darkTheme{
13
+ primary
14
+ onPrimary
15
+ secondary
16
+ onSecondary
17
+ background
18
+ appBar
19
+ onAppBar
20
+ }
7
21
  }
8
22
  }
9
23
 
@@ -1,10 +1,22 @@
1
1
  query customization{
2
2
  customization{
3
- colors{
3
+ lightTheme{
4
4
  primary
5
5
  onPrimary
6
6
  secondary
7
7
  onSecondary
8
+ background
9
+ appBar
10
+ onAppBar
11
+ }
12
+ darkTheme{
13
+ primary
14
+ onPrimary
15
+ secondary
16
+ onSecondary
17
+ background
18
+ appBar
19
+ onAppBar
8
20
  }
9
21
  logo{
10
22
  mode
@@ -1,10 +1,23 @@
1
- mutation customizationUpdate($id: ID!, $primary:String!, $onPrimary:String!, $secondary:String!, $onSecondary:String!, $logo:String!, $language:String!){
2
- customizationUpdate(id: $id, input: {primary: $primary, onPrimary: $onPrimary, secondary: $secondary, onSecondary: $onSecondary, logo: $logo, language: $language }){
3
- id
4
- primary
5
- onPrimary
6
- secondary
7
- onSecondary
1
+ mutation customizationUpdate($input: CustomizationInput){
2
+ customizationUpdate(input: CustomizationInput){
3
+ lightTheme{
4
+ primary
5
+ onPrimary
6
+ secondary
7
+ onSecondary
8
+ appBar
9
+ onAppBar
10
+ background
11
+ }
12
+ darkTheme{
13
+ primary
14
+ onPrimary
15
+ secondary
16
+ onSecondary
17
+ appBar
18
+ onAppBar
19
+ background
20
+ }
8
21
  logo
9
22
  language
10
23
  }
@@ -2,12 +2,21 @@ import CustomizationProvider from "../providers/CustomizationProvider";
2
2
 
3
3
  const customizationStore = {
4
4
  state: {
5
+ darkMode: false,
5
6
  vuetifyInstance: null,
6
- colors: {
7
+ lightTheme: {
7
8
  primary: '#3F51B5',
8
9
  onPrimary: '#FFFFFF',
9
10
  secondary: '#1565C0',
10
- onSecondary: '#FFFFFF'
11
+ onSecondary: '#FFFFFF',
12
+ background: '#F5F5F5'
13
+ },
14
+ darkTheme: {
15
+ primary: '#3F51B5',
16
+ onPrimary: '#FFFFFF',
17
+ secondary: '#1565C0',
18
+ onSecondary: '#FFFFFF',
19
+ background: '#F5F5F5'
11
20
  },
12
21
  logo: {
13
22
  mode: 'OnlyTitle',
@@ -17,11 +26,20 @@ const customizationStore = {
17
26
  language: 'en'
18
27
  },
19
28
  getters: {
29
+ darkMode: (state) => {
30
+ return state.darkMode
31
+ },
20
32
  getLogo: state => {
21
33
  return state.logo
22
34
  },
23
35
  getColors: state => {
24
- return state.colors
36
+ return state.lightTheme
37
+ },
38
+ getLigthTheme: state => {
39
+ return state.lightTheme
40
+ },
41
+ getDarkTheme: state => {
42
+ return state.darkTheme
25
43
  },
26
44
  getLanguage: state => {
27
45
  return state.language
@@ -33,7 +51,7 @@ const customizationStore = {
33
51
 
34
52
  CustomizationProvider.customization()
35
53
  .then(r => {
36
- commit('setColors', r.data.customization.colors)
54
+ commit('setColors', r.data.customization)
37
55
  commit('setLogo', r.data.customization.logo)
38
56
  commit('setLanguage', r.data.customization.language)
39
57
  resolve(r.data.customization)
@@ -46,6 +64,7 @@ const customizationStore = {
46
64
  commit('setLogo', logo)
47
65
  },
48
66
  setColors({commit}, colors) {
67
+ console.log(colors)
49
68
  commit('setColors', colors)
50
69
  },
51
70
  setLanguage({commit}, language) {
@@ -53,6 +72,9 @@ const customizationStore = {
53
72
  }
54
73
  },
55
74
  mutations: {
75
+ darkMode(state, val){
76
+ state.darkMode = val
77
+ },
56
78
  setVuetifyInstance(state, vuetifyInstance) {
57
79
  state.vuetifyInstance = vuetifyInstance
58
80
  },
@@ -61,22 +83,39 @@ const customizationStore = {
61
83
  state.logo.title = title
62
84
  state.logo.url = url
63
85
  },
64
- setColors(state, {primary, onPrimary, secondary, onSecondary}) {
65
- state.colors.primary = primary
66
- state.colors.onPrimary = onPrimary
67
- state.colors.secondary = secondary
68
- state.colors.onSecondary = onSecondary
86
+ setColors(state, {lightTheme, darkTheme}) {
87
+ state.lightTheme.primary = lightTheme.primary
88
+ state.lightTheme.onPrimary = lightTheme.onPrimary
89
+ state.lightTheme.secondary = lightTheme.secondary
90
+ state.lightTheme.onSecondary = lightTheme.onSecondary
91
+ state.lightTheme.background = lightTheme.background
92
+ state.lightTheme.appBar = lightTheme.appBar
93
+ state.lightTheme.onAppBar = lightTheme.onAppBar
94
+
95
+ state.darkTheme.primary = darkTheme.primary
96
+ state.darkTheme.onPrimary = darkTheme.onPrimary
97
+ state.darkTheme.secondary = darkTheme.secondary
98
+ state.darkTheme.onSecondary = darkTheme.onSecondary
99
+ state.darkTheme.background = darkTheme.background
100
+ state.darkTheme.appBar = darkTheme.appBar
101
+ state.darkTheme.onAppBar = darkTheme.onAppBar
69
102
 
70
103
  if (state.vuetifyInstance) {
71
- state.vuetifyInstance.framework.theme.themes.light.primary = primary
72
- state.vuetifyInstance.framework.theme.themes.light.onPrimary = onPrimary
73
- state.vuetifyInstance.framework.theme.themes.light.secondary = secondary
74
- state.vuetifyInstance.framework.theme.themes.light.onSecondary = onSecondary
104
+ state.vuetifyInstance.framework.theme.themes.light.primary = lightTheme.primary
105
+ state.vuetifyInstance.framework.theme.themes.light.onPrimary = lightTheme.onPrimary
106
+ state.vuetifyInstance.framework.theme.themes.light.secondary = lightTheme.secondary
107
+ state.vuetifyInstance.framework.theme.themes.light.onSecondary = lightTheme.onSecondary
108
+ state.vuetifyInstance.framework.theme.themes.light.background = lightTheme.background
109
+ state.vuetifyInstance.framework.theme.themes.light.appBar = lightTheme.appBar
110
+ state.vuetifyInstance.framework.theme.themes.light.onAppBar = lightTheme.onAppBar
75
111
 
76
- state.vuetifyInstance.framework.theme.themes.dark.primary = primary
77
- state.vuetifyInstance.framework.theme.themes.dark.onPrimary = onPrimary
78
- state.vuetifyInstance.framework.theme.themes.dark.secondary = secondary
79
- state.vuetifyInstance.framework.theme.themes.dark.onSecondary = onSecondary
112
+ state.vuetifyInstance.framework.theme.themes.dark.primary = darkTheme.primary
113
+ state.vuetifyInstance.framework.theme.themes.dark.onPrimary = darkTheme.onPrimary
114
+ state.vuetifyInstance.framework.theme.themes.dark.secondary = darkTheme.secondary
115
+ state.vuetifyInstance.framework.theme.themes.dark.onSecondary = darkTheme.onSecondary
116
+ state.vuetifyInstance.framework.theme.themes.dark.background = darkTheme.background
117
+ state.vuetifyInstance.framework.theme.themes.dark.appBar = darkTheme.appBar
118
+ state.vuetifyInstance.framework.theme.themes.dark.onAppBar = darkTheme.onAppBar
80
119
  }
81
120
 
82
121
  },
@@ -1,32 +0,0 @@
1
- const path = require('path');
2
- module.exports = {
3
- "stories": [
4
- "../src/**/*.stories.mdx",
5
- "../src/**/*.stories.@(js|jsx|ts|tsx)"
6
- ],
7
- "addons": [
8
- "@storybook/addon-links",
9
- "@storybook/addon-essentials"
10
- ],
11
- webpackFinal: async (config, { configType }) => {
12
-
13
- //GRAPHQL
14
- config.module.rules.push({
15
- test: /\.(graphql|gql)$/,
16
- use: ['graphql-tag/loader'],
17
- //include: path.resolve(__dirname, '../'),
18
- });
19
-
20
- //SASS
21
- config.module.rules.push({
22
- test: /\.s[ac]ss$/i,
23
- use: ['style-loader', 'css-loader', 'sass-loader'],
24
- include: path.resolve(__dirname, '../'),
25
- });
26
-
27
-
28
-
29
- // Return the altered config
30
- return config;
31
- },
32
- }