stylized-component
Advanced tools
Comparing version 0.0.5 to 0.0.6
export { Theme } from './Theme'; | ||
export { ThemedComponent } from './ThemedComponent'; | ||
export { ThemedComponent, themeKey } from './ThemedComponent'; | ||
export { ThemeProvider, ThemeProps } from './ThemeProvider'; |
@@ -5,4 +5,5 @@ "use strict"; | ||
exports.ThemedComponent = ThemedComponent_1.ThemedComponent; | ||
exports.themeKey = ThemedComponent_1.themeKey; | ||
var ThemeProvider_1 = require("./ThemeProvider"); | ||
exports.ThemeProvider = ThemeProvider_1.ThemeProvider; | ||
//# sourceMappingURL=index.js.map |
/// <reference types="react" /> | ||
import * as React from 'react'; | ||
import * as PropTypes from 'prop-types'; | ||
import 'reflect-metadata'; | ||
import { ThemeProviderContext } from './ThemeProvider'; | ||
@@ -15,3 +16,3 @@ import { Theme } from './Theme'; | ||
}; | ||
styleId: string; | ||
static styleId: string; | ||
context: ThemeProviderContext; | ||
@@ -21,1 +22,2 @@ theme: Partial<ComponentTheme>; | ||
} | ||
export declare const themeKey: (key: string) => (target: Function) => void; |
@@ -16,2 +16,3 @@ "use strict"; | ||
var PropTypes = require("prop-types"); | ||
require("reflect-metadata"); | ||
var ThemedComponent = /** @class */ (function (_super) { | ||
@@ -22,3 +23,7 @@ __extends(ThemedComponent, _super); | ||
var theme = _.extend({}, context.theme, _.get(props, 'theme')); | ||
_this.theme = _.get(_this, 'theme.overrides[this.styleId]'); | ||
var styleId = Reflect.getMetadata('themeKey', _this); | ||
_this.theme = _.get(theme, "overrides['" + styleId + "']", {}); | ||
console.log('theme', "overrides['" + styleId + "']", theme, _this.theme, styleId); | ||
console.log('style', styleId); | ||
console.log('this', _this); | ||
return _this; | ||
@@ -29,5 +34,11 @@ } | ||
}; | ||
ThemedComponent.styleId = ''; | ||
return ThemedComponent; | ||
}(React.Component)); | ||
exports.ThemedComponent = ThemedComponent; | ||
exports.themeKey = function (key) { | ||
return function (target) { | ||
Reflect.defineMetadata('themeKey', key, target); | ||
}; | ||
}; | ||
//# sourceMappingURL=ThemedComponent.js.map |
{ | ||
"name": "stylized-component", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "A design prototype", | ||
@@ -17,5 +17,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@types/reflect-metadata": "0.0.5", | ||
"lodash": "^4.17.4", | ||
"prop-types": "^15.5.2", | ||
"react": "^16.0.7" | ||
"react": "^16.0.7", | ||
"reflect-metadata": "^0.1.10" | ||
}, | ||
@@ -22,0 +24,0 @@ "devDependencies": { |
export { Theme } from './Theme'; | ||
export { ThemedComponent } from './ThemedComponent'; | ||
export { ThemedComponent, themeKey } from './ThemedComponent'; | ||
export { ThemeProvider, ThemeProps } from './ThemeProvider'; |
import * as _ from 'lodash'; | ||
import * as React from 'react'; | ||
import * as PropTypes from 'prop-types'; | ||
import 'reflect-metadata'; | ||
@@ -16,4 +17,4 @@ import { ThemeProps, ThemeProviderContext } from './ThemeProvider'; | ||
}; | ||
static styleId = ''; | ||
styleId: string; | ||
context: ThemeProviderContext; | ||
@@ -25,4 +26,15 @@ theme: Partial<ComponentTheme>; | ||
const theme = _.extend({}, context.theme, _.get(props, 'theme')) as Theme; | ||
this.theme = _.get(this, 'theme.overrides[this.styleId]'); | ||
const styleId = Reflect.getMetadata('themeKey', this); | ||
this.theme = _.get(theme, `overrides['${styleId}']`, {}); | ||
console.log('theme', `overrides['${styleId}']`, theme, this.theme, styleId); | ||
console.log('style', styleId); | ||
console.log('this', this); | ||
} | ||
} | ||
export const themeKey = (key: string) => { | ||
return function (target: Function) { | ||
Reflect.defineMetadata('themeKey', key, target); | ||
}; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18584
393
5
+ Addedreflect-metadata@^0.1.10
+ Added@types/reflect-metadata@0.0.5(transitive)
+ Addedreflect-metadata@0.1.14(transitive)