@battery/core
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -51,3 +51,3 @@ var __assign = (this && this.__assign) || function () { | ||
var matchedModifier = value.match(valuePluginMatcher)[3]; | ||
var modifierName_1 = getMatcherName(generateModifierMatchers(plugin), classMeta.source); | ||
var modifierName_1 = getMatcherName(generateModifierMatchers(plugin), matchedModifier); | ||
if (!modifierName_1) { | ||
@@ -54,0 +54,0 @@ return __assign({}, explodedSource); |
@@ -12,3 +12,4 @@ import { getMatcherName } from '../matchers/utils'; | ||
if (hasNonDefaultModifier) { | ||
var modifierName = getMatcherName(generateModifierMatchers(plugin), classMeta.source)[0]; | ||
var _a = classMeta.explodedSource, modifierSeparator = _a.modifierSeparator, modifierIdentifier_1 = _a.modifierIdentifier; | ||
var modifierName = getMatcherName(generateModifierMatchers(plugin), "" + modifierSeparator + modifierIdentifier_1)[0]; | ||
classMeta.valueModifier = modifierName; | ||
@@ -15,0 +16,0 @@ } |
@@ -10,2 +10,3 @@ import { generateCSS } from './generateCSS'; | ||
import { BatteryPlugin } from './battery-plugin'; | ||
import { padding } from './fixtures/props/padding'; | ||
var testOutput = function (source, expectation) { | ||
@@ -109,9 +110,9 @@ expect(source.replace(/\s/g, '')).toEqual(expectation.replace(/\s/g, '')); | ||
describe('standard set', function () { | ||
var classNames = ['mb2', 'mt10p', 'm3', 'mr1']; | ||
var classNames = ['mb2', 'mt10p', 'm3', 'mr1', 'p10vw']; | ||
var config = { | ||
props: [margin], | ||
props: [margin, padding], | ||
plugins: [], | ||
}; | ||
it('renders valid CSS', function () { | ||
testOutput(generateCSS(classNames, config), "\n .m3 { margin: 1.125rem }\n .mb2 { margin-bottom: 0.75rem }\n .mr1 { margin-right: 0.375rem }\n .mt10p { margin-top: 10% }\n "); | ||
testOutput(generateCSS(classNames, config), "\n .m3 { margin: 1.125rem }\n .mb2 { margin-bottom: 0.75rem }\n .mr1 { margin-right: 0.375rem }\n .mt10p { margin-top: 10% }\n .p10vw { padding:10vw }\n "); | ||
}); | ||
@@ -458,3 +459,3 @@ }); | ||
type: 'pattern', | ||
identifier: new RegExp(/\d+.\d+?/), | ||
identifier: new RegExp(/\d+(?:.\d+)?/), | ||
modifiers: [ | ||
@@ -461,0 +462,0 @@ { |
{ | ||
"name": "@battery/core", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"main": "dist/index.js", | ||
@@ -16,3 +16,4 @@ "types": "dist/index.d.ts", | ||
"devDependencies": { | ||
"@babel/core": "^7.8.7", | ||
"@babel/cli": "^7.17.6", | ||
"@babel/core": "^7.17.9", | ||
"@babel/preset-env": "^7.8.7", | ||
@@ -19,0 +20,0 @@ "@types/jest": "^24.0.13", |
@@ -52,3 +52,3 @@ import { ClassMetaData, ExplodedClassSource } from '../types/classname'; | ||
generateModifierMatchers(plugin), | ||
classMeta.source, | ||
matchedModifier, | ||
); | ||
@@ -55,0 +55,0 @@ |
@@ -18,5 +18,9 @@ import { ClassMetaData } from '../types/classname'; | ||
if (hasNonDefaultModifier) { | ||
const { | ||
modifierSeparator, | ||
modifierIdentifier, | ||
} = classMeta.explodedSource; | ||
const modifierName = getMatcherName( | ||
generateModifierMatchers(plugin), | ||
classMeta.source, | ||
`${modifierSeparator}${modifierIdentifier}`, | ||
)[0]; | ||
@@ -23,0 +27,0 @@ |
@@ -13,2 +13,3 @@ import { generateCSS } from './generateCSS'; | ||
import { BatteryPlugin } from './battery-plugin'; | ||
import { padding } from './fixtures/props/padding'; | ||
@@ -134,5 +135,5 @@ const testOutput = (source: string, expectation: string) => { | ||
describe('standard set', () => { | ||
const classNames = ['mb2', 'mt10p', 'm3', 'mr1']; | ||
const classNames = ['mb2', 'mt10p', 'm3', 'mr1', 'p10vw']; | ||
const config: BatteryConfig = { | ||
props: [margin], | ||
props: [margin, padding], | ||
plugins: [], | ||
@@ -148,2 +149,3 @@ }; | ||
.mt10p { margin-top: 10% } | ||
.p10vw { padding:10vw } | ||
`, | ||
@@ -596,3 +598,3 @@ ); | ||
type: 'pattern', | ||
identifier: new RegExp(/\d+.\d+?/), | ||
identifier: new RegExp(/\d+(?:.\d+)?/), | ||
modifiers: [ | ||
@@ -599,0 +601,0 @@ { |
import { Matchers } from '../types/matchers'; | ||
export const getMatcherName = (matchers: Matchers, testStr: string) => | ||
Object.entries(matchers).find(([, regex]) => { | ||
export const getMatcherName = (matchers: Matchers, testStr: string) => { | ||
return Object.entries(matchers).find(([, regex]) => { | ||
return regex.test(testStr); | ||
}); | ||
}; |
266367
182
6761
16