Skip to content

Commit e235359

Browse files
author
Patrick Tannoury
committed
added px & py among dynamic classes (test)
1 parent df80fc3 commit e235359

File tree

6 files changed

+56
-10
lines changed

6 files changed

+56
-10
lines changed

README.MD

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# SwiftCSS
22
SwiftCSS is a CSS utility package that simplifies and streamlines the styling of your web projects using predefined classes. Similar to Tailwind CSS, it offers a wide range of predefined classes that allow you to style your web elements effortlessly. Additionally, SwiftCSS supports dynamic classes and pseudo-classes, making it a powerful tool for creating modern web interfaces.
33

4-
Dynamic Attributes
4+
## Dynamic Attributes
55
SwiftCSS provides dynamic classes that can be customized using square brackets, allowing you to apply dynamic values to your styles. Some of the available dynamic attributes include:
66

77
color-[#xxx]: Customize colors dynamically.
88
bg-[#xxx]: Set dynamic background colors.
99
text-[#xxx]: Adjust text colors dynamically.
1010
And more!
11-
Input File Integration
11+
12+
## Input File Integration
1213
Unlike many other CSS frameworks, SwiftCSS offers a straightforward solution for incorporating input files. Input files are appended on top of the output file generated by the CLI, making it easy to manage and include custom styles and configurations.
1314

1415
## Commands
@@ -53,7 +54,7 @@ Here's an example of the configuration file (swiftcss.config.js):
5354
module.exports = {
5455
fileExtensions: ["html", "js", "jsx", "ts", "tsx"],
5556
directories: ["./src"],
56-
input: "", // Specify an input file to be appended into the output file
57+
input: [""], // Specify an input file (or multiple) to be appended into the output file
5758
output: "./output.css",
5859
screens: {
5960
sd: { max: 600 },

dist/src/cli/parsers/classParser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
66
exports._PSEUDO_CLASSES = exports.PSEUDO_ELEMENTS = void 0;
77
const dynamicParser_1 = __importDefault(require("./dynamicParser"));
88
function classParser(className, baseStyle) {
9-
const finalCSS = new Set();
9+
const finalCSS = new Set(); // Also never read?
1010
const specialChars = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/g;
1111
const dynamicPseudo = /^(.*?)-\[(.*?)\]$/;
12-
var cssString = null;
12+
var cssString = null; // Is this needed? It is never used
1313
/******************* Pseudo Classes *******************/
1414
if (className.includes(':') && !className.includes('::')) {
1515
var pseudoClass = className.split(':')[0];

dist/src/cli/parsers/dynamicParser.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ function dynamicParser(className) {
3636
value: value
3737
};
3838
}
39+
else if (Array.isArray(name) && attribute === "custom") {
40+
const cssString = name.map(property => `${property}: ${value.replaceAll('_', ' ')};`).join('\n');
41+
return {
42+
className: escapedClassName,
43+
cssAttribute: cssString,
44+
name: name,
45+
value: value
46+
};
47+
}
3948
else {
4049
return {
4150
className: escapedClassName,
@@ -94,6 +103,8 @@ exports.dynamicRegistry = {
94103
'pr': { name: "padding-right", attribute: 'custom' },
95104
'pb': { name: "padding-bottom", attribute: 'custom' },
96105
'pl': { name: "padding-left", attribute: 'custom' },
106+
'px': { name: ["padding-left", "padding-right"], attribute: 'custom' },
107+
'py': { name: ["padding-top", "padding-bottom"], attribute: 'custom' },
97108
'w': { name: 'width', attribute: 'custom' },
98109
'max-h': { name: 'max-height', attribute: 'custom' },
99110
'min-h': { name: 'min-height', attribute: 'custom' },
@@ -107,5 +118,6 @@ exports.dynamicRegistry = {
107118
'grid-rows': { name: 'grid-template-rows', attribute: 'custom' },
108119
'auto-cols': { name: 'grid-auto-columns', attribute: 'custom' },
109120
'font': { name: 'font-family', attribute: 'custom' },
110-
"transition": { name: "transition", attribute: 'custom' }
121+
"transition": { name: "transition", attribute: 'custom' },
122+
"decoration": { name: "text-decoration", attribute: 'custom' }
111123
};

dist/src/style.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319639,6 +319639,29 @@
319639319639
text-transform: capitalize;
319640319640
}
319641319641

319642+
.decoration-underline {
319643+
text-decoration: underline;
319644+
}
319645+
.decoration-underline-dotted {
319646+
-webkit-text-decoration: underline dotted;
319647+
text-decoration: underline dotted;
319648+
}
319649+
.decoration-overline {
319650+
text-decoration: overline;
319651+
}
319652+
.decoration-none {
319653+
text-decoration: none;
319654+
}
319655+
.decoration-style-wavy {
319656+
text-decoration-style: wavy;
319657+
}
319658+
.decoration-style-solid {
319659+
text-decoration-style: solid;
319660+
}
319661+
.decoration-style-dotted {
319662+
text-decoration-style: dotted;
319663+
}
319664+
319642319665
.align-baseline {
319643319666
vertical-align: baseline;
319644319667
}

src/cli/parsers/classParser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import dynamicParser from "./dynamicParser";
44
interface ClassParser {
55
className: string,
66
cssAttribute: string | string[],
7-
name: string | null,
7+
name: string | string[] | null,
88
value?: string,
99
pseudo: string,
1010
pseudoSeparator: ':' | '::',
1111
pseudoSelector?: string | null
1212
}
1313

1414
export default function classParser(className: string, baseStyle: BaseStyle): ClassParser | null {
15-
const finalCSS = new Set();
15+
const finalCSS = new Set(); // Also never read?
1616
const specialChars = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/g;
1717
const dynamicPseudo = /^(.*?)-\[(.*?)\]$/;
1818

19-
var cssString: null | string = null;
19+
var cssString: null | string = null; // Is this needed? It is never used
2020
/******************* Pseudo Classes *******************/
2121
if(className.includes(':') && !className.includes('::')){
2222
var pseudoClass = className.split(':')[0]

src/cli/parsers/dynamicParser.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ export default function dynamicParser(className: string){
4040
name: name,
4141
value: value
4242
}
43+
} else if (Array.isArray(name) && attribute === "custom") {
44+
const cssString = name.map(property => `${property}: ${value.replaceAll('_', ' ')};`).join('\n');
45+
return {
46+
className: escapedClassName,
47+
cssAttribute: cssString,
48+
name: name,
49+
value: value
50+
}
4351
} else {
4452
return {
4553
className: escapedClassName,
@@ -71,7 +79,7 @@ function getValue(value: string, config: Config){
7179

7280
interface Dynamicregistry {
7381
[key: string]: {
74-
name: string
82+
name: string | string[]
7583
attribute: 'color' | 'url' | 'custom' | string[] | null
7684
}
7785
}
@@ -106,6 +114,8 @@ export const dynamicRegistry: Dynamicregistry = {
106114
'pr': {name: "padding-right", attribute: 'custom'},
107115
'pb': {name: "padding-bottom", attribute: 'custom'},
108116
'pl': {name: "padding-left", attribute: 'custom'},
117+
'px': {name: ["padding-left", "padding-right"], attribute: 'custom'},
118+
'py': {name: ["padding-top", "padding-bottom"], attribute: 'custom'},
109119
'w': {name: 'width', attribute: 'custom'},
110120
'max-h': {name: 'max-height', attribute: 'custom'},
111121
'min-h': {name: 'min-height', attribute: 'custom'},

0 commit comments

Comments
 (0)