UNPKG

weex-nuke

Version:

基于 Rax 、Weex 的高性能组件体系 ~~

107 lines (84 loc) 3.54 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _nukeCore = require('../Core/index.js'); var _nukeCore2 = _interopRequireDefault(_nukeCore); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } // Privates, ideally those should be symbols var THEME_STYLE = 'themeStyle'; var THEME_STYLE_CACHE = 'themeCachedStyle'; var defaultTheme = void 0; function mergeComponentAndThemeStyles() {} var resolveStyle = function resolveStyle(style, baseStyle) { return resolveIncludes(style, baseStyle); }; var Theme = function () { function Theme(themeStyle) { _classCallCheck(this, Theme); this[THEME_STYLE] = themeStyle; this[THEME_STYLE].Core = Object.assign(_nukeCore2.default, this[THEME_STYLE].Core); this[THEME_STYLE_CACHE] = {}; } /** * Sets the given style as a default theme style. */ _createClass(Theme, [{ key: 'createComponentStyle', /** * Creates a component style by merging the theme style on top of the * provided default component style. Any rules in the theme style will * override the rules from the base component style. * * This method will also resolve any INCLUDE keywords in the theme or * component styles before returning the final style. * * @param componentName fully qualified component name. * @param defaultStyle - default component style that will be used as base style. */ value: function createComponentStyle(componentName) { if (this[THEME_STYLE_CACHE][componentName]) { return this[THEME_STYLE_CACHE][componentName]; } // const componentIncludedStyle = resolveStyle( // defaultStyle, // this[THEME_STYLE] // ); return this[THEME_STYLE_CACHE][componentName]; } }, { key: 'getComponentRelavantStyle', value: function getComponentRelavantStyle(componentName) { // if (this[THEME_STYLE_CACHE][componentName]) { // return this[THEME_STYLE_CACHE][componentName]; // } // let obj = { // Core: Object.assign(Core, this[THEME_STYLE]['Core']) // } // this[THEME_STYLE_CACHE][componentName]['Core'] = } }], [{ key: 'setDefaultThemeStyle', value: function setDefaultThemeStyle(style) { defaultTheme = new Theme(style); } /** * Returns the default theme that will be used as fallback * if the StyleProvider is not configured in the app. */ }, { key: 'getDefaultTheme', value: function getDefaultTheme() { if (!defaultTheme) { defaultTheme = new Theme({ Core: _nukeCore2.default }); } return defaultTheme; } }]); return Theme; }(); exports.default = Theme; module.exports = exports['default'];