Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jasiukiewicztymon authored Jul 4, 2022
1 parent 09c79ca commit 8d4dd98
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ for (let i in LightJsClasses) {
}
}

styleStr += `.${LightJsClasses[i].replace(/\:/g, '\\:').replace(/\[/g, '\\[').replace(/\]/g, '\\]').replace(/\>/g, '\\>').replace(/\//g, '\\/')}`
styleStr += `.${LightJsClasses[i].replace(/\:/g, '\\:').replace(/\[/g, '\\[').replace(/\]/g, '\\]').replace(/\>/g, '\\>').replace(/\//g, '\\/').replace(/\(/g, '\\(').replace(/\)/g, '\\)').replace(/\%/g, '\\%').replace(/\-/g, '\\-').replace(/\+/g, '\\+').replace(/\*/g, '\\*').replace(/\./g, '\\.')}`

for (let j = 0; j < classParams.length - 1; j++) {
// selectors
Expand All @@ -70,7 +70,9 @@ for (let i in LightJsClasses) {
break;
if (classParams[classParams.length - 1].split('>')[0] == lightWindCssConfig.proprieties.light[k].name) {
let value = classParams[classParams.length - 1].split('>')[1]
value = value.substr(1, value.length - 2)
if (value.indexOf('calc(') != -1) {
value = value.replace(/\-/g, ' - ').replace(/\+/g, ' + ').replace(/\//g, ' / ').replace(/\*/g, ' * ')
}

for (let l in lightWindCssConfig.proprieties.light[k].values) {
if (lightWindCssConfig.proprieties.light[k].values[l].name == value)
Expand Down Expand Up @@ -103,7 +105,9 @@ for (let i in LightJsClasses) {
try {
if (classParams[classParams.length - 1].split('>')[0] == lightWindCssConfig.proprieties.global[k].propriety || lightWindCssConfig.proprieties.global[k].alias.indexOf(classParams[classParams.length - 1].split('>')[0]) != -1) {
let value = classParams[classParams.length - 1].split('>')[1]
value = value.substr(1, value.length - 2)
if (value.indexOf('calc(') != -1) {
value = value.replace(/\-/g, ' - ').replace(/\+/g, ' + ').replace(/\//g, ' / ').replace(/\*/g, ' * ')
}

for (let l in lightWindCssConfig.proprieties.global[k].values) {
if (lightWindCssConfig.proprieties.global[k].values[l].name == value)
Expand All @@ -123,7 +127,9 @@ for (let i in LightJsClasses) {

if (!isFound) {
let value = classParams[classParams.length - 1].split('>')[1]
value = value.substr(1, value.length - 2)
if (value.indexOf('calc(') != -1) {
value = value.replace(/\-/g, ' - ').replace(/\+/g, ' + ').replace(/\//g, ' / ').replace(/\*/g, ' * ')
}

if (value.startsWith('--')) {
value = `var(${value})`
Expand Down Expand Up @@ -198,7 +204,7 @@ async function classEvaluate(el, classes = null) {
}
}

styleStr += `.${el.replace(/\:/g, '\\:').replace(/\[/g, '\\[').replace(/\]/g, '\\]').replace(/\>/g, '\\>').replace(/\//g, '\\/')}`
styleStr += `.${el.replace(/\:/g, '\\:').replace(/\[/g, '\\[').replace(/\]/g, '\\]').replace(/\>/g, '\\>').replace(/\//g, '\\/').replace(/\(/g, '\\(').replace(/\)/g, '\\)').replace(/\%/g, '\\%').replace(/\-/g, '\\-').replace(/\+/g, '\\+').replace(/\*/g, '\\*').replace(/\./g, '\\.')}`

for (let j = 0; j < classParams.length - 1; j++) {
// selectors
Expand All @@ -225,7 +231,9 @@ async function classEvaluate(el, classes = null) {
break;
if (classParams[classParams.length - 1].split('>')[0] == lightWindCssConfig.proprieties.light[k].name) {
let value = classParams[classParams.length - 1].split('>')[1]
value = value.substr(1, value.length - 2)
if (value.indexOf('calc(') != -1) {
value = value.replace(/\-/g, ' - ').replace(/\+/g, ' + ').replace(/\//g, ' / ').replace(/\*/g, ' * ')
}

for (let l in lightWindCssConfig.proprieties.light[k].values) {
if (lightWindCssConfig.proprieties.light[k].values[l].name == value)
Expand Down Expand Up @@ -258,7 +266,9 @@ async function classEvaluate(el, classes = null) {
try {
if (classParams[classParams.length - 1].split('>')[0] == lightWindCssConfig.proprieties.global[k].propriety || lightWindCssConfig.proprieties.global[k].alias.indexOf(classParams[classParams.length - 1].split('>')[0]) != -1) {
let value = classParams[classParams.length - 1].split('>')[1]
value = value.substr(1, value.length - 2)
if (value.indexOf('calc(') != -1) {
value = value.replace(/\-/g, ' - ').replace(/\+/g, ' + ').replace(/\//g, ' / ').replace(/\*/g, ' * ')
}

for (let l in lightWindCssConfig.proprieties.global[k].values) {
if (lightWindCssConfig.proprieties.global[k].values[l].name == value)
Expand All @@ -278,7 +288,9 @@ async function classEvaluate(el, classes = null) {

if (!isFound) {
let value = classParams[classParams.length - 1].split('>')[1]
value = value.substr(1, value.length - 2)
if (value.indexOf('calc(') != -1) {
value = value.replace(/\-/g, ' - ').replace(/\+/g, ' + ').replace(/\//g, ' / ').replace(/\*/g, ' * ')
}

if (value.startsWith('--')) {
value = `var(${value})`
Expand Down

0 comments on commit 8d4dd98

Please sign in to comment.