Skip to content

Commit 841acdc

Browse files
authored
Merge pull request #19 from JimGitFE/development
Development 1.5.4
2 parents 8f85cf6 + ba91145 commit 841acdc

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-utilities-generator",
3-
"version": "1.5.3",
3+
"version": "1.5.4",
44
"description": "TypeScript utility package that simplifies working with CSS properties by providing shorthand notations for common CSS class names. Ideal for developers who want to streamline their CSS styling process, this package helps you translate short, intuitive class names into full CSS properties and values, ensuring your code is cleaner and more maintainable.",
55
"main": "dist/generator.js",
66
"types": "dist/generator.d.ts",

src/helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function inDictionary(dictionary: Record<string, any>, shortKey: string): boolea
7777
* ```
7878
*/
7979
const filterClasses = (classes: string[]): utilityClass[] => {
80-
const {acceptAnyVariable: notAcceptAny = true, acceptAnyKey = false, acceptAnyValue = true} = readConfigFile()
80+
const {acceptAnyVariable = false, acceptAnyKey = false, acceptAnyValue = true} = readConfigFile()
8181
let utilityClasses: utilityClass[] = [];
8282

8383
/** @example ["m-1.6:hover", "m", "1.6"] */
@@ -98,7 +98,7 @@ const filterClasses = (classes: string[]): utilityClass[] => {
9898
const isDuplicate = utilityClasses.some((p) => p.fullClass === singleClass);
9999

100100
// Key exist in dictionary
101-
const valueCheck = (!notAcceptAny || acceptAnyKey) || (inDictionary(shortKeys, classKey))
101+
const valueCheck = (acceptAnyVariable || acceptAnyKey) || (inDictionary(shortKeys, classKey))
102102

103103
if (!isDuplicate && (valueCheck)) {
104104
// Generate Valid utilityClass
@@ -122,8 +122,8 @@ const filterClasses = (classes: string[]): utilityClass[] => {
122122
const valueIsNum = /^\d+$/.test(String(classValue))
123123

124124
// Key & Value exist in dictionary || or use them as is
125-
const keyCheck = (!notAcceptAny || acceptAnyKey) || inDictionary(shortKeys, classKey)
126-
const valueCheck = (!notAcceptAny || acceptAnyValue) || (valueIsNum || inDictionary(shortValues, classValue))
125+
const keyCheck = (acceptAnyVariable || acceptAnyKey) || inDictionary(shortKeys, classKey)
126+
const valueCheck = (acceptAnyVariable || acceptAnyValue) || (valueIsNum || inDictionary(shortValues, classValue))
127127

128128

129129
if (!isDuplicate && (keyCheck && valueCheck)) {

src/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { addScriptToPackageJson, writeFileInRoot, askUser, isValidPath } from '.
44

55
/** Default configuration */
66
let cuconfig = {
7-
acceptAnyVariable: true,
7+
acceptAnyVariable: false,
88
acceptAnyValue: true,
99
readFrom: "./",
1010
writeTo: "./styles/utilities.css",

src/tests/config.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@ const { createConfigFile, deleteConfigFile } = require('../../dist/tests/utils.j
33

44
// acceptAnyVariable Config
55

6-
test('Accept only keys & values in dictionary {"acceptAnyVariable": true} ', () => {
6+
test('Accept only keys & values in dictionary {"acceptAnyVariable": false} ', () => {
77
// Test proeprties in dictionary
88
const attributes = ["height-25px", "anykey-anyvalue"]
99

1010
// Usage
11-
createConfigFile({"acceptAnyVariable": true});
11+
createConfigFile({"acceptAnyVariable": false});
1212

1313
expect(filterClasses(attributes)).toEqual([
1414

1515
]);
1616
});
1717

18-
test('Accept any property key & value {"acceptAnyVariable": false}', () => {
18+
test('Accept any property key & value {"acceptAnyVariable": true}', () => {
1919
// Test any properties
2020
const attributes = ["height-2rem", "anykey-anyvalue"]
2121

2222
// Usage
23-
createConfigFile({"acceptAnyVariable": false});
23+
createConfigFile({"acceptAnyVariable": true});
2424

2525
expect(filterClasses(attributes)).toEqual([
2626
{ fullClass: 'height-2rem', classKey: 'height', classValue: '2rem' },
2727
{ fullClass: 'anykey-anyvalue', classKey: 'anykey', classValue: 'anyvalue' },
2828
]);
2929
});
3030

31-
test('Accept any property key & value {"acceptAnyVariable": false}', () => {
31+
test('Accept any property key & value {"acceptAnyVariable": true}', () => {
3232
// Test any properties
3333
const attributes = ["height-2rem", "anykey-anyvalue"]
3434

3535
// Usage
36-
createConfigFile({"acceptAnyVariable": false});
36+
createConfigFile({"acceptAnyVariable": true});
3737

3838
expect(filterClasses(attributes)).toEqual([
3939
{ fullClass: 'height-2rem', classKey: 'height', classValue: '2rem' },

src/tests/playground.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { filterClasses } from "../helpers";
2323

2424

2525
// /* with config:
26-
// * acceptAnyVariable: false
26+
// * acceptAnyVariable: true
2727
// */
2828

2929
// console.log(filterClasses(["h-100"])) // {height: 100px}
@@ -41,7 +41,7 @@ import { filterClasses } from "../helpers";
4141
// console.log(filterClasses(["h-100%"])) //
4242

4343
// /* with config:
44-
// * acceptAnyVariable: true
44+
// * acceptAnyVariable: false
4545
// */
4646

4747
// console.log(filterClasses(["h-100"])) // {height: 100px}

0 commit comments

Comments
 (0)