UNPKG

1.22 kBJavaScriptView Raw
1/**
2 * @copyright Copyright (c) 2019 Maxim Khorin <maksimovichu@gmail.com>
3 */
4'use strict';
5
6const Base = require('../base/Component');
7
8module.exports = class View extends Base {
9
10 constructor (config) {
11 super({
12 // parent: new View
13 // original: new View
14 theme: config.parent && config.parent.theme, // theme name
15 ThemeSet: require('./ThemeSet'),
16 ...config
17 });
18 }
19
20 async init () {
21 if (this.original) {
22 this.original.createThemeMap();
23 this.parent = this.original.isEmpty() ? this.parent : this.original;
24 }
25 this.createThemeMap();
26 }
27
28 createThemeMap () {
29 this.themeSet = ClassHelper.spawn(this.ThemeSet, {
30 theme: this.theme,
31 parent: this.parent && this.parent.themeSet,
32 directory: this.module.getPath(),
33 isOrigin: this.parent && this.parent === this.original
34 });
35 }
36
37 getTheme (name) {
38 return this.themeSet.get(name);
39 }
40
41 isEmpty () {
42 return this.themeSet.isEmpty();
43 }
44};
45
46const ClassHelper = require('../helper/ClassHelper');
\No newline at end of file