Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: config builder #48

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions __tests__/builder/config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as assert from "assert";

import { promises as fsAsync } from "fs";
import path from "path";

import { clear, height } from "../../src/modules/sampleConfig";

describe("Config builder", () => {
it("should build clear module config", async () => {
const output = clear();

const expected = await fsAsync.readFile(
path.join(__dirname, "./fixtures/clear.ts"),
"utf-8"
);

/** Check the transformed file with the expected file */
assert.strictEqual(expected, output);
});

it("should build clear module config", async () => {
const output = height();

const expected = await fsAsync.readFile(
path.join(__dirname, "./fixtures/height.ts"),
"utf-8"
);

/** Check the transformed file with the expected file */
assert.strictEqual(expected, output);
});
});
83 changes: 83 additions & 0 deletions __tests__/builder/fixtures/clear.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* =========
* CSS "clear" module definitions.
* =========
* */
const clearConfig = {
/**
* Supported CSS definitions
*
* Define identifiers for each declaration based on your preference.
* Defaults to https://docs.emmet.io/cheat-sheet/
* **/
names: {
/** clear:none; **/
"cl:n": "cl:n",
/** clear:left; **/
"cl:l": "cl:l",
/** clear:right; **/
"cl:r": "cl:r",
/** clear:both; **/
"cl:b": "cl:b",
},

/**
* List of definitions to include.
* Remove items from this list if you do not
* want it to be included in the output
* **/
whitelist: [
/** clear:none; **/
"cl:n",
/** clear:left; **/
"cl:l",
/** clear:right; **/
"cl:r",
/** clear:both; **/
"cl:b",
],
/**
* List of definitions to exclude.
* If the number of exclusions is very minimal
* use this config instead of "whitelist"
* **/
blacklist: [],
/**
* Flag to enable definitions with responsive
* breakpoints
* **/
isResponsive: false,
/**
* List of responsive definitions to include
* Remove items from this list if you do not
* want it to be included in the output
* **/
responsiveWhiteList: [
/** clear:none; **/
"cl:n",
/** clear:left; **/
"cl:l",
/** clear:right; **/
"cl:r",
/** clear:both; **/
"cl:b",
],
/**
* List of responsive definitions to exclude.
* If the number of exclusions is very minimal
* use this config instead of "responsiveWhiteList"
* **/
responsiveBlackList: [],
pseudoClasses: {
/** clear:none; **/
"cl:n": [":hover", ":focus", ":active"],
/** clear:left; **/
"cl:l": [":hover", ":focus", ":active"],
/** clear:right; **/
"cl:r": [":hover", ":focus", ":active"],
/** clear:both; **/
"cl:b": [":hover", ":focus", ":active"],
},
};

module.exports = clearConfig;
115 changes: 115 additions & 0 deletions __tests__/builder/fixtures/height.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* =========
* CSS "height" module definitions.
* =========
* */
const heightConfig = {
/**
* Supported CSS definitions
*
* Define identifiers for each declaration based on your preference.
* Defaults to https://docs.emmet.io/cheat-sheet/
* **/
names: {
/** height:; **/
h: "h",
/** height:auto; **/
"h:a": "h:a",
/** max-height:; **/
mah: "mah",
/** max-height:none; **/
"mah:n": "mah:n",
/** min-height:; **/
mih: "mih",
},

/**
* Variables for height:;
*
* eg., {
* [key]: [value];
* }
* */
heightValues: {},
/**
* Variables for max-height:;
*
* eg., {
* [key]: [value];
* }
* */
maxHeightValues: {},
/**
* Variables for min-height:;
*
* eg., {
* [key]: [value];
* }
* */
minHeightValues: {},
/**
* List of definitions to include.
* Remove items from this list if you do not
* want it to be included in the output
* **/
whitelist: [
/** height:; **/
"h",
/** height:auto; **/
"h:a",
/** max-height:; **/
"mah",
/** max-height:none; **/
"mah:n",
/** min-height:; **/
"mih",
],
/**
* List of definitions to exclude.
* If the number of exclusions is very minimal
* use this config instead of "whitelist"
* **/
blacklist: [],
/**
* Flag to enable definitions with responsive
* breakpoints
* **/
isResponsive: false,
/**
* List of responsive definitions to include
* Remove items from this list if you do not
* want it to be included in the output
* **/
responsiveWhiteList: [
/** height:; **/
"h",
/** height:auto; **/
"h:a",
/** max-height:; **/
"mah",
/** max-height:none; **/
"mah:n",
/** min-height:; **/
"mih",
],
/**
* List of responsive definitions to exclude.
* If the number of exclusions is very minimal
* use this config instead of "responsiveWhiteList"
* **/
responsiveBlackList: [],
pseudoClasses: {
/** height:; **/
h: [":hover", ":focus", ":active"],
/** height:auto; **/
"h:a": [":hover", ":focus", ":active"],
/** max-height:; **/
mah: [":hover", ":focus", ":active"],
/** max-height:none; **/
"mah:n": [":hover", ":focus", ":active"],
/** min-height:; **/
mih: [":hover", ":focus", ":active"],
},
};

module.exports = heightConfig;
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@utilitycss/utility",
"version": "1.0.4",
"version": "1.0.6",
"description": "Generator for Utility CSS frameworks",
"author": "Andrea Moretti (@axyz) <[email protected]>",
"repository": "utilitycss/utility",
Expand All @@ -18,18 +18,19 @@
"utility": "dist/cli.js"
},
"dependencies": {
"@utilitycss/electron-doc": "^0.0.2",
"chalk": "^4.1.0",
"commander": "7.0.0",
"cssstats": "^4.0.0",
"deepmerge": "^4.2.2",
"open": "^7.4.0",
"chalk": "^4.1.0",
"lodash": "^4.17.20",
"mocha": "^8.3.0",
"open": "^7.4.0",
"postcss": "8.2.6"
},
"devDependencies": {
"@types/mocha": "^8.2.0",
"@types/lodash": "^4.14.168",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.27",
"@types/prettier": "^2.2.1",
"@typescript-eslint/eslint-plugin": "^4.15.0",
Expand Down
Loading