@cryptic-css/core
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -9,3 +9,3 @@ import props from "./props"; | ||
if (props[k]) { | ||
generated += props[k](k, v[k], v); | ||
generated += props[k](v[k], k, v); | ||
} | ||
@@ -12,0 +12,0 @@ } |
@@ -1,7 +0,18 @@ | ||
import ccss, { setValueMap } from "./"; | ||
import ccss, { setValueMap, setProps, pipe, mapValue } from "./"; | ||
setValueMap({ | ||
r: { | ||
global: 6 | ||
}, | ||
size: { | ||
small: { | ||
fts: 10 | ||
}, | ||
large: { | ||
fts: 32 | ||
} | ||
} | ||
}); | ||
setProps({ | ||
size: pipe(mapValue, ccss) | ||
}); | ||
describe('ccss tests', () => { | ||
@@ -60,3 +71,8 @@ describe('Evaluations', () => { | ||
}); | ||
it('can use custom prop', () => { | ||
expect(ccss({ | ||
size: 'large' | ||
}).trim()).toBe(`font-size: 32rem;`); | ||
}); | ||
}); | ||
}); |
@@ -1,7 +0,7 @@ | ||
export declare const toCSSRule: (cssProp: any) => (key: any, input: any) => string; | ||
export declare const parseSingle: (prop: any, input: any) => any; | ||
export declare const parseArray: (prop: any, input: any) => any; | ||
export declare const mapValue: (prop: any, input: any) => any; | ||
export declare const pipe: (...fs: any[]) => (prop: any, input: any, original: any) => any; | ||
export declare const parsePseudo: (prop: any, input: any) => string; | ||
export declare const toCSSRule: (cssProp: any) => (input: any) => string; | ||
export declare const parseSingle: (input: any) => any; | ||
export declare const parseArray: (input: any) => any; | ||
export declare const mapValue: (input: any, prop: any) => any; | ||
export declare const pipe: (...fs: any[]) => (input: any, prop: any, original: any) => any; | ||
export declare const parsePseudo: (input: any, prop: any) => string; | ||
/** | ||
@@ -19,2 +19,2 @@ * You can pass children to your ccss supporting both pseudo classes and nested selectors | ||
*/ | ||
export declare const child: (prop: any, input: any) => string; | ||
export declare const child: (input: any) => string; |
import options from "./options"; | ||
import { valueMap, pseudoMap } from "./maps"; | ||
import ccss from "./ccss"; | ||
export const toCSSRule = cssProp => (key, input) => { | ||
export const toCSSRule = cssProp => input => { | ||
return input === undefined ? '' : `${cssProp}: ${input};`; | ||
}; | ||
export const parseSingle = (prop, input) => { | ||
export const parseSingle = input => { | ||
switch (typeof input) { | ||
@@ -18,7 +18,7 @@ case 'number': | ||
const applyArray = (prop, input) => { | ||
const applyArray = input => { | ||
let out = ''; | ||
for (const i of input) { | ||
out += `${parseSingle(prop, i)} `; | ||
out += `${parseSingle(i)} `; | ||
} | ||
@@ -29,15 +29,15 @@ | ||
export const parseArray = (prop, input) => { | ||
export const parseArray = input => { | ||
switch (true) { | ||
case Array.isArray(input): | ||
return applyArray(prop, input); | ||
return applyArray(input); | ||
case input: | ||
return applyArray(prop, [1]); | ||
return parseSingle(1); | ||
default: | ||
return parseSingle(prop, input); | ||
return parseSingle(input); | ||
} | ||
}; | ||
export const mapValue = (prop, input) => { | ||
export const mapValue = (input, prop) => { | ||
var _valueMap$prop; | ||
@@ -52,5 +52,5 @@ | ||
return (prop, input, original) => { | ||
return (input, prop, original) => { | ||
for (const f of fs) { | ||
input = f(prop, input, original); | ||
input = f(input, prop, original); | ||
} | ||
@@ -61,3 +61,3 @@ | ||
}; | ||
export const parsePseudo = (prop, input) => ` | ||
export const parsePseudo = (input, prop) => ` | ||
:${pseudoMap[prop]} { | ||
@@ -80,3 +80,3 @@ ${ccss(input)} | ||
export const child = (prop, input) => { | ||
export const child = input => { | ||
let generated = ''; // eslint-disable-next-line no-restricted-syntax | ||
@@ -83,0 +83,0 @@ |
{ | ||
"name": "@cryptic-css/core", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "> TODO: description", | ||
@@ -35,3 +35,3 @@ "author": "Viktor Vincze <viktor.vincze@doclerholding.com>", | ||
}, | ||
"gitHead": "204bc1505ce5ffa497273ac5595cf71a17f7d795" | ||
"gitHead": "dcd133f2ef9eb5ad9b3d85924c0e48f939f5b667" | ||
} |
@@ -1,2 +0,2 @@ | ||
import ccss, { setValueMap } from '@' | ||
import ccss, { setValueMap, setProps, pipe, mapValue } from '@' | ||
@@ -6,5 +6,17 @@ setValueMap({ | ||
global: 6 | ||
}, | ||
size: { | ||
small: { | ||
fts: 10 | ||
}, | ||
large: { | ||
fts: 32 | ||
} | ||
} | ||
}) | ||
setProps({ | ||
size: pipe(mapValue, ccss) | ||
}) | ||
describe('ccss tests', () => { | ||
@@ -51,3 +63,11 @@ describe('Evaluations', () => { | ||
}) | ||
it('can use custom prop', () => { | ||
expect( | ||
ccss({ | ||
size: 'large' | ||
}).trim() | ||
).toBe(`font-size: 32rem;`) | ||
}) | ||
}) | ||
}) |
@@ -10,3 +10,3 @@ import { TCCSSCoreProp } from './types' | ||
if (props[k]) { | ||
generated += props[k](k, v[k], v) | ||
generated += props[k](v[k], k, v) | ||
} | ||
@@ -13,0 +13,0 @@ } |
@@ -1,7 +0,7 @@ | ||
export declare const toCSSRule: (cssProp: any) => (key: any, input: any) => string; | ||
export declare const parseSingle: (prop: any, input: any) => any; | ||
export declare const parseArray: (prop: any, input: any) => any; | ||
export declare const mapValue: (prop: any, input: any) => any; | ||
export declare const pipe: (...fs: any[]) => (prop: any, input: any, original: any) => any; | ||
export declare const parsePseudo: (prop: any, input: any) => string; | ||
export declare const toCSSRule: (cssProp: any) => (input: any) => string; | ||
export declare const parseSingle: (input: any) => any; | ||
export declare const parseArray: (input: any) => any; | ||
export declare const mapValue: (input: any, prop: any) => any; | ||
export declare const pipe: (...fs: any[]) => (input: any, prop: any, original: any) => any; | ||
export declare const parsePseudo: (input: any, prop: any) => string; | ||
/** | ||
@@ -19,2 +19,2 @@ * You can pass children to your ccss supporting both pseudo classes and nested selectors | ||
*/ | ||
export declare const child: (prop: any, input: any) => string; | ||
export declare const child: (input: any) => string; |
@@ -5,7 +5,7 @@ import options from './options' | ||
export const toCSSRule = cssProp => (key, input) => { | ||
export const toCSSRule = cssProp => input => { | ||
return input === undefined ? '' : `${cssProp}: ${input};` | ||
} | ||
export const parseSingle = (prop, input) => { | ||
export const parseSingle = input => { | ||
switch (typeof input) { | ||
@@ -20,6 +20,6 @@ case 'number': | ||
const applyArray = (prop, input) => { | ||
const applyArray = input => { | ||
let out = '' | ||
for (const i of input) { | ||
out += `${parseSingle(prop, i)} ` | ||
out += `${parseSingle(i)} ` | ||
} | ||
@@ -29,14 +29,14 @@ return out | ||
export const parseArray = (prop, input) => { | ||
export const parseArray = input => { | ||
switch (true) { | ||
case Array.isArray(input): | ||
return applyArray(prop, input) | ||
return applyArray(input) | ||
case input: | ||
return applyArray(prop, [1]) | ||
return parseSingle(1) | ||
default: | ||
return parseSingle(prop, input) | ||
return parseSingle(input) | ||
} | ||
} | ||
export const mapValue = (prop, input) => { | ||
export const mapValue = (input, prop) => { | ||
return valueMap?.[prop]?.[input] || input | ||
@@ -46,5 +46,5 @@ } | ||
export const pipe = function(...fs) { | ||
return (prop, input, original) => { | ||
return (input, prop, original) => { | ||
for (const f of fs) { | ||
input = f(prop, input, original) | ||
input = f(input, prop, original) | ||
} | ||
@@ -55,3 +55,3 @@ return input | ||
export const parsePseudo = (prop, input) => ` | ||
export const parsePseudo = (input, prop) => ` | ||
:${pseudoMap[prop]} { | ||
@@ -74,3 +74,3 @@ ${ccss(input)} | ||
*/ | ||
export const child = (prop, input) => { | ||
export const child = input => { | ||
let generated = '' | ||
@@ -77,0 +77,0 @@ // eslint-disable-next-line no-restricted-syntax |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7598
1320415