Comparing version 1.0.0-iron-5 to 1.0.0-iron-6
{ | ||
"name": "alga-css", | ||
"version": "1.0.0-iron-5", | ||
"version": "1.0.0-iron-6", | ||
"description": "Alga CSS is a scope-first CSS toolkit for quickly mix or compose CSS references and share CSS properties between components", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -21,2 +21,21 @@ module.exports = { | ||
bd: 'border', | ||
bdWidth: 'borderWidth', | ||
bdStyle: 'borderStyle', | ||
bdColor: 'borderColor', | ||
bt: 'borderTop', | ||
btWidth: 'borderTopWidth', | ||
btStyle: 'borderTopStyle', | ||
btColor: 'borderTopColor', | ||
br: 'borderRight', | ||
brWidth: 'borderRightWidth', | ||
brStyle: 'borderRightStyle', | ||
brColor: 'borderRightColor', | ||
bb: 'borderBottom', | ||
bbWidth: 'borderBottomWidth', | ||
bbStyle: 'borderBottomStyle', | ||
bbColor: 'borderBottomColor', | ||
bl: 'borderLeft', | ||
blWidth: 'borderLeftWidth', | ||
blStyle: 'borderLeftStyle', | ||
blColor: 'borderLeftColor', | ||
bg: 'background', | ||
@@ -42,4 +61,8 @@ bgAttach: 'backgroundAttachment', | ||
rounded: 'borderRadius', | ||
roundedTopRight: 'borderTopRightRadius', | ||
roundedTopLeft: 'borderTopLeftRadius', | ||
roundedBottomRight: 'borderBottomRightRadius', | ||
roundedBottomLeft: 'borderBottomLeftRadius', | ||
justify: 'justifyContent', | ||
items: 'alignItems' | ||
} |
@@ -21,3 +21,3 @@ const postcss = require('postcss') | ||
const root = postcss.parse(data.replaceAll(/\{(\w+)\.(\w+)\}/g, '$1($2)')) | ||
const root = postcss.parse(data.replaceAll(/\{([A-Za-z0-9\-\_]+)\.([A-Za-z0-9\-\_]+)\}/g, '$1($2)')) /* (\w+) */ | ||
for(let rnode of root.nodes) { | ||
@@ -97,2 +97,8 @@ // Convert define into property | ||
} else if(rnode.type === 'atrule' && rnode.name === 'alga' && 'nodes' in rnode) { | ||
const refOpt = { | ||
...opts, | ||
refs: component[componentName]['refs'] || {}, | ||
props: component[componentName]['props'] || {} | ||
} | ||
let param = rnode.params.trim() | ||
@@ -142,2 +148,3 @@ if(param.startsWith('refs(') || param.startsWith('props(')) { | ||
let ifRecursiveDefineObj = recursive(ifnode, { | ||
...refOpt, | ||
'provide': component[componentName]['provide'] | ||
@@ -152,2 +159,3 @@ }) | ||
let recursiveDefineObj = recursive(dnode, { | ||
...refOpt, | ||
'provide': component[componentName]['provide'] | ||
@@ -154,0 +162,0 @@ }) |
@@ -112,3 +112,5 @@ const postcss = require('postcss') | ||
ruleArray.push(newRule) | ||
if(newRule.nodes.length >= 1) { | ||
ruleArray.push(newRule) | ||
} | ||
} | ||
@@ -115,0 +117,0 @@ } |
@@ -14,3 +14,3 @@ const screen = require('../configs/screen.js') | ||
if(node.type === 'decl' && node.prop === 'ref') { | ||
recursiveObj[param] = Object.assign({}, recursiveObj[param], reference(node.value)) | ||
recursiveObj[param] = Object.assign({}, recursiveObj[param], reference(node.value, opt)) | ||
} else if(node.type === 'decl' && node.prop.startsWith('ref-')) { | ||
@@ -34,15 +34,15 @@ let splitRefs = node.prop.split('-')[1] | ||
let screenObj = {} | ||
screenObj[node.prop] = Object.assign({}, screenObj[node.prop], reference(node.value)) | ||
screenObj[node.prop] = Object.assign({}, screenObj[node.prop], reference(node.value, opt)) | ||
recursiveObj[param] = Object.assign({}, recursiveObj[param], screenObj) | ||
} else if(node.type === 'decl' && node.prop.startsWith('state-')) { | ||
let stateObj = {} | ||
stateObj[node.prop] = Object.assign({}, stateObj[node.prop], reference(node.value)) | ||
stateObj[node.prop] = Object.assign({}, stateObj[node.prop], reference(node.value, opt)) | ||
recursiveObj[param] = Object.assign({}, recursiveObj[param], stateObj) | ||
} else if(node.type === 'decl' && node.prop.startsWith('prefers-')) { | ||
let prefersObj = {} | ||
prefersObj[node.prop] = Object.assign({}, prefersObj[node.prop], reference(node.value)) | ||
prefersObj[node.prop] = Object.assign({}, prefersObj[node.prop], reference(node.value, opt)) | ||
recursiveObj[param] = Object.assign({}, recursiveObj[param], prefersObj) | ||
} else if(node.type === 'decl' && node.prop.startsWith('if-')) { | ||
let conditionalObj = {} | ||
conditionalObj[node.prop] = Object.assign({}, conditionalObj[node.prop], reference(node.value)) | ||
conditionalObj[node.prop] = Object.assign({}, conditionalObj[node.prop], reference(node.value, opt)) | ||
recursiveObj[param] = Object.assign({}, recursiveObj[param], conditionalObj) | ||
@@ -56,3 +56,3 @@ } else if(node.type === 'atrule' && node.name === 'if' && 'nodes' in node) { | ||
if(condVal.type === 'decl' && condVal.prop === 'ref') { | ||
conditionalObj['if-'+propsConditional+'-'+valueConditional] = Object.assign({}, conditionalObj['if-'+propsConditional+'-'+valueConditional], reference(condVal)) | ||
conditionalObj['if-'+propsConditional+'-'+valueConditional] = Object.assign({}, conditionalObj['if-'+propsConditional+'-'+valueConditional], reference(condVal, opt)) | ||
} else if(condVal.type === 'decl' && condVal.prop.startsWith('ref-')) { | ||
@@ -59,0 +59,0 @@ let splitRefs = condVal.prop.split('-')[1] |
@@ -19,2 +19,3 @@ const camelDash = require('../helpers/camelDash.js') | ||
} | ||
const refObj = {} | ||
@@ -21,0 +22,0 @@ refObj[camelDash(props[0])] = value(props[1], refOpt) |
@@ -12,2 +12,11 @@ const camelDash = require('../helpers/camelDash.js') | ||
} | ||
if(newValue.startsWith('calc(')) { | ||
newValue = newValue.split('_').map(item => { | ||
if(item.startsWith('refs(') || item.startsWith('props(')) { | ||
const splitValues = item.split(/\(|\)/g) | ||
item = opt[splitValues[0]][camelDash(splitValues[1])] || item | ||
} | ||
return item | ||
}).join('') | ||
} | ||
if(newValue.startsWith('refs(') || newValue.startsWith('props(')) { | ||
@@ -14,0 +23,0 @@ const splitValues = newValue.split(/\(|\)/g) |
Sorry, the diff of this file is not supported yet
97270
1162