Skip to content

Commit f23f618

Browse files
Update README.md
1 parent ec2bc8f commit f23f618

File tree

1 file changed

+38
-18
lines changed

1 file changed

+38
-18
lines changed

README.md

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ Vue.use(VueThemeManager,themeOptions);
3838
...
3939
```
4040

41-
> #### For Nuxt 2x
41+
> #### For Nuxt
4242
4343
```javascript
44-
//plugin/vue_theme_manager.js
44+
//plugins/vue_theme_manager.js
4545
import Vue from 'vue'
4646
import VueThemeManager from 'vue-theme-manager'
4747

@@ -64,19 +64,19 @@ Vue.use(VueThemeManager,themeOptions);
6464

6565
```javascript
6666
//nuxt.config.js
67-
plugins:{
67+
plugins:[
6868
...
6969

70-
{src:'@plugin/vue_theme_manager',mode:'client'}
70+
{src:'@plugins/vue_theme_manager',mode:'client'}
7171

7272
...
73-
}
73+
]
7474
```
7575

7676
>
7777
7878
## 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]:
8080

8181
```javascript
8282
Vue.use(VueThemeManager,{activate:,styles})
@@ -88,10 +88,10 @@ Plugin accepts `object` during initialization with props [This is Optional]:
8888
## Template Usage
8989

9090

91-
> For Vue2x and Vue3
91+
> For Vue2x and Vue3x
9292
9393
```HTML
94-
App.vue <! root app !-->
94+
App.vue <!-- root app !-->
9595

9696
<!-- register theme-manager-plugin-globally for all component template !-->
9797
<div id="app" :style="VueThemeManager">
@@ -108,7 +108,7 @@ Plugin accepts `object` during initialization with props [This is Optional]:
108108
> For Nuxt
109109
110110
```HTML
111-
/layout/default.vue <! root app !-->
111+
/layout/default.vue <!-- root app !-->
112112
113113
<!-- register theme-manager-plugin-globally for all component template !-->
114114
<nuxt :style="VueThemeManager" />
@@ -163,43 +163,57 @@ Hello World
163163
backgroundColor:'#101010'
164164
}
165165
*/
166+
167+
168+
166169
// we can still go further
167170
let themeName = 'light'
168171
this.console.log(JSON.stringify(this.$AppTheme.theme[themeName].textColor,null,2))
169172
//returns '#ededed'
170173

171-
this.console.log(JSON.stringify(this.$AppTheme.textColor,null,2))
174+
this.console.log(this.$AppTheme.textColor)
172175
//returns currently selected theme textColor '#ededed'
173176

174177

175178

179+
180+
176181
/*This will be called once Theme Plugin has been initialized
177182
This can be used in your App.vue or default.vue file or any other component
178183
you wish to use it in
179184
*/
180185
this.$AppTheme.onReady((themeExistInDeviceDB)=>{
181186
if(themeExistInDeviceDB){
182-
this.$AppTheme.setThemeFromStorage();
187+
this.$AppTheme.setThemeFromStorage();//this is to set theme from db
183188
}
184189
});
185190

186191

187192

193+
194+
188195
//This will be called when New Theme has been Selected
189-
this,$AppTheme.onThemeChanged((themeName,themeOptions)=>{
196+
this.$AppTheme.onThemeChanged((themeName,themeOptions)=>{
190197
...
191198
//do what ever you want with the results
192199
})
193200

194201

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+
197208
/*
198209
*options = "object" or "json-string" @required
199210
*themeName = "String" intended name for theme @optional default is "default"
200211
*activate = boolean --activate theme or not
201212
*/
202213

214+
215+
216+
203217
this.$AppTheme.saveTheme(); //save theme to db
204218

205219
//this can also be changed like this
@@ -212,18 +226,24 @@ this.$AppTheme.activateTheme(themeName);
212226

213227

214228

229+
230+
215231
this.$AppTheme.getTheme(themeName,array);
216232
//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+
219237
///generally data can be accessed like this
220-
this.$AppTheme.getTheme(['textColor'],'splash').texColor
238+
this.$AppTheme.getTheme('splash',['textColor']).texColor
221239
//result 'red'
222240
```
223241

242+
243+
224244
## Points to Note
225245

226246
1. camel case `textColor` are changed to kebal case `text-color` only for css variables
227247
2. css variables are dynamic and should be accessed like this `var(--text-color)`
228248
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

Comments
 (0)