@@ -38,10 +38,10 @@ Vue.use(VueThemeManager,themeOptions);
38
38
...
39
39
```
40
40
41
- > #### For Nuxt 2x
41
+ > #### For Nuxt
42
42
43
43
``` javascript
44
- // plugin /vue_theme_manager.js
44
+ // plugins /vue_theme_manager.js
45
45
import Vue from ' vue'
46
46
import VueThemeManager from ' vue-theme-manager'
47
47
@@ -64,19 +64,19 @@ Vue.use(VueThemeManager,themeOptions);
64
64
65
65
``` javascript
66
66
// nuxt.config.js
67
- plugins: {
67
+ plugins: [
68
68
...
69
69
70
- {src: ' @plugin /vue_theme_manager' ,mode: ' client' }
70
+ {src: ' @plugins /vue_theme_manager' ,mode: ' client' }
71
71
72
72
...
73
- }
73
+ ]
74
74
```
75
75
76
76
>
77
77
78
78
## Plugin Options
79
- Plugin accepts ` object ` during initialization with props [ This is Optional] :
79
+ Plugin accepts ` object ` or ` jsonstring ` during initialization with props [ This is Optional] :
80
80
81
81
``` javascript
82
82
Vue .use (VueThemeManager,{activate: ,styles})
@@ -88,10 +88,10 @@ Plugin accepts `object` during initialization with props [This is Optional]:
88
88
## Template Usage
89
89
90
90
91
- > For Vue2x and Vue3
91
+ > For Vue2x and Vue3x
92
92
93
93
``` HTML
94
- App.vue <! root app ! -- >
94
+ App.vue <!-- root app !-->
95
95
96
96
<!-- register theme-manager-plugin-globally for all component template !-->
97
97
<div id =" app" :style =" VueThemeManager" >
@@ -108,7 +108,7 @@ Plugin accepts `object` during initialization with props [This is Optional]:
108
108
> For Nuxt
109
109
110
110
```HTML
111
- /layout/default.vue <! root app !-->
111
+ /layout/default.vue <!-- root app !-->
112
112
113
113
<!-- register theme-manager-plugin-globally for all component template !-->
114
114
<nuxt :style="VueThemeManager" />
@@ -163,43 +163,57 @@ Hello World
163
163
backgroundColor:'#101010'
164
164
}
165
165
*/
166
+
167
+
168
+
166
169
// we can still go further
167
170
let themeName = ' light'
168
171
this .console .log (JSON .stringify (this .$AppTheme .theme [themeName].textColor ,null ,2 ))
169
172
// returns '#ededed'
170
173
171
- this .console .log (JSON . stringify ( this .$AppTheme .textColor , null , 2 ) )
174
+ this .console .log (this .$AppTheme .textColor )
172
175
// returns currently selected theme textColor '#ededed'
173
176
174
177
175
178
179
+
180
+
176
181
/* This will be called once Theme Plugin has been initialized
177
182
This can be used in your App.vue or default.vue file or any other component
178
183
you wish to use it in
179
184
*/
180
185
this .$AppTheme .onReady ((themeExistInDeviceDB )=> {
181
186
if (themeExistInDeviceDB){
182
- this .$AppTheme .setThemeFromStorage ();
187
+ this .$AppTheme .setThemeFromStorage ();// this is to set theme from db
183
188
}
184
189
});
185
190
186
191
187
192
193
+
194
+
188
195
// This will be called when New Theme has been Selected
189
- this , $AppTheme .onThemeChanged ((themeName ,themeOptions )=> {
196
+ this . $AppTheme .onThemeChanged ((themeName ,themeOptions )=> {
190
197
...
191
198
// do what ever you want with the results
192
199
})
193
200
194
201
195
- this .$AppTheme .addTheme ({textColor: ' red' ,backgroundColor: ' gold' ,' splash' ,true });
196
- // this.$AppTheme.addTheme({options,themeName,activate}})
202
+
203
+
204
+
205
+ this .$AppTheme .addTheme ({textColor: ' red' ,backgroundColor: ' gold' }," splash" ,true );
206
+ // this.$AppTheme.addTheme({options},themeName,activate)
207
+
197
208
/*
198
209
*options = "object" or "json-string" @required
199
210
*themeName = "String" intended name for theme @optional default is "default"
200
211
*activate = boolean --activate theme or not
201
212
*/
202
213
214
+
215
+
216
+
203
217
this .$AppTheme .saveTheme (); // save theme to db
204
218
205
219
// this can also be changed like this
@@ -212,18 +226,24 @@ this.$AppTheme.activateTheme(themeName);
212
226
213
227
214
228
229
+
230
+
215
231
this .$AppTheme .getTheme (themeName,array);
216
232
// returns object of themeOptions
217
- array = themeoptions to be gotten like [' textColor' ,' backgroundColor' ]
218
- themeName = name of theme to get options from
233
+
234
+ // themeName = name of theme to get options from @required
235
+ array = themeoptions to be gotten like [' textColor' ,' backgroundColor' ] @optional
236
+
219
237
// /generally data can be accessed like this
220
- this .$AppTheme .getTheme ([ ' textColor ' ], ' splash ' ).texColor
238
+ this .$AppTheme .getTheme (' splash ' ,[ ' textColor ' ] ).texColor
221
239
// result 'red'
222
240
```
223
241
242
+
243
+
224
244
## Points to Note
225
245
226
246
1 . camel case ` textColor ` are changed to kebal case ` text-color ` only for css variables
227
247
2 . css variables are dynamic and should be accessed like this ` var(--text-color) `
228
248
3 . Try as much as possible to name your theme options with camel case ` textColor, accentColor, backgroundColor `
229
- 4 . css variables acess only the currently selected theme
249
+ 4 . css variables acess only the currently selected theme
0 commit comments