Comparing version 0.8.8 to 0.9.0
@@ -1,3 +0,3 @@ | ||
import { css } from 'emotion'; | ||
declare type CssArgs = Parameters<typeof css>; | ||
import { ObjectInterpolation } from 'emotion'; | ||
declare type CSS = ObjectInterpolation<undefined>; | ||
export declare type GwenTheme = { | ||
@@ -14,3 +14,3 @@ xs: string; | ||
theme: GwenTheme; | ||
cssArray: CssArgs; | ||
cssArray: CSS[]; | ||
}; | ||
@@ -34,3 +34,4 @@ export declare class GwenBaseBase { | ||
_gethash: (obj: any) => string; | ||
css: (arg: import("emotion").Interpolation<undefined>) => this; | ||
css: (...args: CSS[]) => this; | ||
_css: <T extends string | number>(key: T, arg: CSS[T]) => any; | ||
mix: (...args: GwenBaseBase[]) => this; | ||
@@ -37,0 +38,0 @@ alignContent: (arg: string | string[] | undefined) => this; |
@@ -79,26 +79,47 @@ "use strict"; | ||
}; | ||
this.css = function (arg) { | ||
var hashKey = _this._gethash(arg); | ||
this.css = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var inst = _this; | ||
// const hashKey = this._gethash(arg); | ||
// if (this._cache[hashKey]) { | ||
// return this._cache[hashKey] as any; | ||
// } | ||
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) { | ||
var arg = args_1[_a]; | ||
if (arg) { | ||
var keys = Object.keys(arg).sort(); | ||
for (var _b = 0, keys_1 = keys; _b < keys_1.length; _b++) { | ||
var key = keys_1[_b]; | ||
inst = inst._css(key, arg[key]); | ||
} | ||
} | ||
} | ||
return inst; | ||
// this.params.cssArray = [...this.params.cssArray, ...args]; | ||
// const newInstance = new (this as any).constructor(this.theme, { | ||
// ...this.params, | ||
// cssArray: [...this.params.cssArray, ...args], | ||
// }); | ||
// this._cache[hashKey] = newInstance; | ||
// return newInstance; | ||
}; | ||
this._css = function (key, arg) { | ||
var _a; | ||
var hashKey = key + "__" + arg; | ||
// if (this._cache[hashKey]) { | ||
// return this._cache[hashKey] as any; | ||
// } | ||
// const hashKey = JSON.stringify(args); | ||
if (_this._cache[hashKey]) { | ||
// console.log(`cache hit`); | ||
return _this._cache[hashKey]; | ||
} | ||
// this.params.cssArray = [...this.params.cssArray, ...args]; | ||
var newInstance = new _this.constructor(_this.theme, __assign(__assign({}, _this.params), { cssArray: __spreadArrays(_this.params.cssArray, [arg]) })); | ||
var newInstance = new _this.constructor(_this.theme, __assign(__assign({}, _this.params), { cssArray: __spreadArrays(_this.params.cssArray, [(_a = {}, _a[key] = arg, _a)]) })); | ||
_this._cache[hashKey] = newInstance; | ||
return newInstance; | ||
}; | ||
// _css = <T extends keyof ObjectInterpolation<undefined>>(key: T, arg: ObjectInterpolation<undefined>[T]) => { | ||
// // const hashKey = JSON.stringify(args); | ||
// if (this._cache[hashKey]) { | ||
// // console.log(`cache hit`); | ||
// return this._cache[hashKey] as any; | ||
// } | ||
// // this.params.cssArray = [...this.params.cssArray, ...args]; | ||
// const newInstance = new (this as any).constructor(this.theme, { | ||
// ...this.params, | ||
// cssArray: [...this.params.cssArray, ...args], | ||
// }); | ||
// this._cache[hashKey] = newInstance; | ||
// return newInstance; | ||
// }; | ||
// cx = (...args: CxArgs): this => { | ||
@@ -117,4 +138,4 @@ // return new (this as any).constructor(this.theme, { | ||
var mixedCss = []; | ||
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) { | ||
var arg = args_1[_a]; | ||
for (var _a = 0, args_2 = args; _a < args_2.length; _a++) { | ||
var arg = args_2[_a]; | ||
mixedCss = __spreadArrays(mixedCss, arg.params.cssArray); | ||
@@ -127,3 +148,3 @@ // if (arg instanceof GwenBaseBase) { | ||
} | ||
return _this.css(mixedCss); | ||
return _this.css.apply(_this, mixedCss); | ||
// return this.cx(...flattenArg(args).map(x => x.class)); | ||
@@ -130,0 +151,0 @@ }; |
{ | ||
"name": "gwen", | ||
"version": "0.8.8", | ||
"version": "0.9.0", | ||
"description": "A utility-first CSS library designed for brevity", | ||
@@ -5,0 +5,0 @@ "main": "./lib/src/index.js", |
Sorry, the diff of this file is not supported yet
1009964
18158