Skip to content

Commit b137924

Browse files
authored
Merge pull request #13 from JimGitFE/development
v1.4.2
2 parents 1fe4d07 + 7c2d196 commit b137924

21 files changed

+302
-178
lines changed

README.md

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
# 🎨 css-utilities-generator [![NPM](https://img.shields.io/npm/v/css-utilities-generator.svg)](https://www.npmjs.com/package/css-utilities-generator)
22

3-
```html
4-
<div className="d-f jc-sb mxw-1050">
5-
<button>Log In</button>
6-
<p>Description</p>
7-
</div>
8-
```
9-
> some-file.tsx
10-
```css
11-
.d-f { display: flex; }
12-
.jc-sb { justify-content: space-between; }
13-
.mxw-1050 { max-width: 1050px; }
14-
```
15-
> utilities.css
3+
![Preview](./preview.gif)
164

175
TypeScript utility package that generates a utilities.css file on demand with shorthand class names for common CSS properties. By using intuitive notations like d-f (display: flex) as values for className attributes inside your jsx, this package streamlines your styling process, making your main CSS structure cleaner, reusable and more maintainable while ensuring consistent, efficient application of styles across your project.
186

@@ -36,7 +24,62 @@ Run the following command to start the watcher:
3624
```
3725
Now, you can start watching for changes in your src directory and automatically regenerate the CSS utilities.
3826

39-
## Configuration file (Defaults)
27+
## Example
28+
```html
29+
<main className="ml-50 mr-50">
30+
<header className="d-f h-64px ai-c jc-sb pos-sticky top-0 z-5">
31+
<h1 className="w-fc">
32+
Site Title
33+
</h1>
34+
<nav className="w-300px">
35+
<ul className="d-f jc-sb">
36+
<li>
37+
<a href="#">Home</a>
38+
</li>
39+
<li>
40+
<a href="#">About</a>
41+
</li>
42+
<li>
43+
<a href="#">Contact</a>
44+
</li>
45+
</ul>
46+
</nav>
47+
</header>
48+
<section className="d-f fd-co ai-c jc-c h-80">
49+
<h1 className="fs-40 fw-700">
50+
Welcome!
51+
</h1>
52+
<p className="mt-2rem fs-12 o-70 fw-2">
53+
Some filler text
54+
</p>
55+
</section>
56+
</main>
57+
```
58+
> some-file.tsx
59+
```css
60+
.ml-50 { margin-left: 50px; }
61+
.mr-50 { margin-right: 50px; }
62+
.d-f { display: flex; }
63+
.h-64px { height: 64px; }
64+
.ai-c { align-items: center; }
65+
.jc-sb { justify-content: space-between; }
66+
.pos-sticky { position: sticky; }
67+
.z-5 { z-index: 5; }
68+
.w-fc { width: fit-content; }
69+
.w-300px { width: 300px; }
70+
.fd-co { flex-direction: column; }
71+
.jc-c { justify-content: center; }
72+
.h-80 { height: 80%; }
73+
.fs-40 { font-size: 40px; }
74+
.fw-700 { font-weight: 700; }
75+
.mt-2rem { margin-top: 2rem; }
76+
.fs-12 { font-size: 12px; }
77+
.o-70 { opacity: 70%; }
78+
.fw-2 { font-weight: 2; }
79+
```
80+
> utilities.css
81+
82+
## Configuration File (Defaults)
4083
```javascript
4184
{
4285
"onlyDictionary": true, /* Matching only dictionary or extension properties, Defaults to false */

dictionary.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ const dictionary: Abreviations = {
128128
/** Color */
129129
c: {name: 'color', valueExtension: ''},
130130

131+
cu: {name: 'cursor', valueExtension: ''},
132+
131133
}
132134
}
133135

dist/dictionary.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dictionary.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dictionary.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/generator.js

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/generator.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/helpers.d.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ interface utilityClass {
44
classKey: string;
55
classValue: string;
66
}
7+
/** Get the package version from package.json */
8+
declare const packageVersion: () => any;
79
/** Classes from attributes node
810
*
911
* @returns {string[]} - Array of classes
1012
* @example
1113
* ```ts
12-
* const class = extractClasses();
14+
* const class = getClassNames();
1315
* console.log(class); // d-f jc-sb ai-c h-100 h--spacing-4
1416
* ```
1517
*/
16-
declare const extractClasses: ({ ast }: {
18+
declare const getClassNames: ({ ast }: {
1719
ast: parser.ParseResult<File> | any;
18-
}) => string[];
20+
}) => string;
1921
/** Classes filter duplicates & utilities dictionary matches
2022
* @returns {string[]} - Dictionary matched classes
2123
* @example
@@ -34,7 +36,7 @@ export declare class ProcessRetriever {
3436
constructor(process: NodeJS.Process);
3537
get(flagName: string): undefined;
3638
}
37-
declare const getFilePaths: (dir: string, extensions?: string[]) => string[];
39+
declare const getFilePaths: (dir: string) => string[];
3840
declare const generateAST: (filePath: string) => parser.ParseResult<File> | any;
3941
interface Config {
4042
/**
@@ -54,10 +56,13 @@ interface Config {
5456
};
5557
};
5658
extendValues?: Record<string, string>;
59+
/** Must include filename, ex. ./src/styles/utilities.css */
5760
writeTo?: string;
5861
readFrom?: string;
62+
extensions?: string[];
63+
exclude?: string[];
5964
}
6065
declare function readConfigFile(): Config;
6166
export type { utilityClass };
62-
export { getFilePaths, generateAST, extractClasses, filterClasses, writeCSS, readConfigFile };
67+
export { getFilePaths, generateAST, getClassNames, filterClasses, writeCSS, readConfigFile, packageVersion };
6368
//# sourceMappingURL=helpers.d.ts.map

0 commit comments

Comments
 (0)