chaitail 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/index.html +15 -0
- package/demo/script.js +3 -0
- package/package.json +17 -0
- package/src/ChaiCSS.js +56 -0
- package/src/applyClass.js +57 -0
- package/src/index.js +1 -0
package/demo/index.html
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>ChaiTail</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body class="chai-bg-black">
|
|
9
|
+
<div class="chai-p-20 chai-bg-red chai-text-white chai-rounded-10">
|
|
10
|
+
<h1 class="chai-bg-blue chai-p-10 chai-text-yellow">Welcome To ChaiTail</h1>
|
|
11
|
+
<p class="chai-text-red">Try it</p>
|
|
12
|
+
</div>
|
|
13
|
+
<script type="module" src="./script.js"></script>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
package/demo/script.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chaitail",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A lightweight utility first CSS framework",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"CSS",
|
|
11
|
+
"Tailwind",
|
|
12
|
+
"ChaiTail"
|
|
13
|
+
],
|
|
14
|
+
"author": "Vishal Patil",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"type": "module"
|
|
17
|
+
}
|
package/src/ChaiCSS.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const ChaiCSS = {
|
|
2
|
+
// Layout
|
|
3
|
+
"chai-flex": { display: "flex" },
|
|
4
|
+
"chai-block": { display: "block" },
|
|
5
|
+
"chai-inline": { display: "inline" },
|
|
6
|
+
"chai-hidden": { display: "none" },
|
|
7
|
+
|
|
8
|
+
// Flexbox
|
|
9
|
+
"chai-flex-row": { flexDirection: "row" },
|
|
10
|
+
"chai-flex-col": { flexDirection: "column" },
|
|
11
|
+
"chai-justify-center": { justifyContent: "center" },
|
|
12
|
+
"chai-justify-between": { justifyContent: "space-between" },
|
|
13
|
+
"chai-justify-around": { justifyContent: "space-around" },
|
|
14
|
+
"chai-items-center": { alignItems: "center" },
|
|
15
|
+
"chai-items-start": { alignItems: "flex-start" },
|
|
16
|
+
"chai-items-end": { alignItems: "flex-end" },
|
|
17
|
+
|
|
18
|
+
// Text alignment
|
|
19
|
+
"chai-text-left": { textAlign: "left" },
|
|
20
|
+
"chai-text-center": { textAlign: "center" },
|
|
21
|
+
"chai-text-right": { textAlign: "right" },
|
|
22
|
+
|
|
23
|
+
// Font weight
|
|
24
|
+
"chai-font-bold": { fontWeight: "bold" },
|
|
25
|
+
"chai-font-normal": { fontWeight: "normal" },
|
|
26
|
+
"chai-font-light": { fontWeight: "300" },
|
|
27
|
+
|
|
28
|
+
// Position
|
|
29
|
+
"chai-relative": { position: "relative" },
|
|
30
|
+
"chai-absolute": { position: "absolute" },
|
|
31
|
+
"chai-fixed": { position: "fixed" },
|
|
32
|
+
|
|
33
|
+
// Overflow
|
|
34
|
+
"chai-overflow-hidden": { overflow: "hidden" },
|
|
35
|
+
"chai-overflow-auto": { overflow: "auto" },
|
|
36
|
+
|
|
37
|
+
// Cursor
|
|
38
|
+
"chai-cursor-pointer": { cursor: "pointer" },
|
|
39
|
+
|
|
40
|
+
// Borders
|
|
41
|
+
"chai-border": { border: "1px solid black" },
|
|
42
|
+
"chai-border-none": { border: "none" },
|
|
43
|
+
|
|
44
|
+
// Width / Height (basic)
|
|
45
|
+
"chai-w-full": { width: "100%" },
|
|
46
|
+
"chai-h-full": { height: "100%" },
|
|
47
|
+
|
|
48
|
+
// Display helpers
|
|
49
|
+
"chai-center": {
|
|
50
|
+
display: "flex",
|
|
51
|
+
justifyContent: "center",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default ChaiCSS;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import ChaiCSS from "./ChaiCSS.js";
|
|
2
|
+
|
|
3
|
+
function parseChaiClass(cls) {
|
|
4
|
+
const parts = cls.split("-");
|
|
5
|
+
|
|
6
|
+
if (parts[0] !== "chai") return null;
|
|
7
|
+
|
|
8
|
+
const type = parts[1];
|
|
9
|
+
const value = parts[2];
|
|
10
|
+
|
|
11
|
+
switch (type) {
|
|
12
|
+
case "p":
|
|
13
|
+
return { padding: value + "px" };
|
|
14
|
+
|
|
15
|
+
case "m":
|
|
16
|
+
return { margin: value + "px" };
|
|
17
|
+
|
|
18
|
+
case "bg":
|
|
19
|
+
return { backgroundColor: value };
|
|
20
|
+
|
|
21
|
+
case "text":
|
|
22
|
+
if (value === "center") return { textAlign: "center" };
|
|
23
|
+
return { color: value };
|
|
24
|
+
|
|
25
|
+
case "flex":
|
|
26
|
+
return { display: "flex" };
|
|
27
|
+
|
|
28
|
+
case "rounded":
|
|
29
|
+
return { borderRadius: value + "px" };
|
|
30
|
+
|
|
31
|
+
default:
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function applyClasses(element) {
|
|
37
|
+
element.classList.forEach((cls) => {
|
|
38
|
+
let style = ChaiCSS[cls];
|
|
39
|
+
|
|
40
|
+
if (!style) {
|
|
41
|
+
style = parseChaiClass(cls);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (style) {
|
|
45
|
+
Object.assign(element.style, style);
|
|
46
|
+
|
|
47
|
+
if (cls.startsWith("chai-")) {
|
|
48
|
+
element.classList.remove(cls);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function initChai() {
|
|
55
|
+
const elements = document.querySelectorAll("[class]");
|
|
56
|
+
elements.forEach(applyClasses);
|
|
57
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { initChai, applyClasses } from "./applyClass.js";
|