@melcanz85/chaincss 1.5.2 → 1.5.3

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.
Files changed (2) hide show
  1. package/README.md +154 -18
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @melcanz85/chaincss
2
2
 
3
- A JavaScript-to-CSS transpiler that converts JS objects into optimized CSS.
3
+ A Simple JavaScript-to-CSS transpiler that converts JS objects into optimized CSS.
4
4
 
5
5
  ## 🚀 Installation
6
6
 
@@ -10,26 +10,162 @@
10
10
 
11
11
  📦 Usage (Node.js)
12
12
 
13
- const chaincss = require('@melcanz85/chaincss');
13
+ First download nodemon and concurrently packages then change the script on your package.json to:
14
14
 
15
- const css = chaincss({
16
- body: {
17
- margin: 0,
18
- padding: '20px',
19
- backgroundColor: '#f0f0f0'
15
+ "scripts": {
16
+ "start": "concurrently \"nodemon server.js\" \"nodemon --watch chaincss.jcss --watch processor.js --watch chain.jcss --exec 'node chaincss/processor.js'\""
20
17
  }
21
- });
22
18
 
23
- console.log(css);
24
- // Output: body { margin: 0; padding: 20px; background-color: #f0f0f0; }
25
-
26
- 🖥️ Usage (CLI)
27
-
28
- # Convert JS file to CSS
29
- npx chaincss input.js output.css
30
-
31
- # Watch mode (auto-recompile on changes)
32
- npx chaincss input.js output.css --watch
19
+ you do this to make your development easy as it watches the changes to those files and automatically update the css output of your project in this case the chainstyle.css.
20
+
21
+ Make a folder for your chaincsss and make 3 files, 1 is your main file (chaincss.jcss) then for the chaining (chain.jcss) and then the third is the processor file (processor.js).
22
+
23
+ Make a public folder for your frontend and make 2 files index.html for your website structure and css file for the output of your chaincss in this example (chainstyle.css) you can name your files whatever you want just make sure its the same with the script on your package.json and file extensions for your chaincss files should be .jcss except for the processor file which should be a js file.
24
+
25
+ Example structure of the project:
26
+
27
+ website/
28
+
29
+ ├── chaincss/ # Folder 1
30
+ │ ├── chaincss.jcss
31
+ │ └── chain.jcss
32
+ | |__ processor.js
33
+
34
+ ├── node_modules/ # Folder 2 (dependencies)
35
+ │ └── [dependency files and folders]
36
+
37
+ ├── public/ # Folder 3
38
+ │ ├── index.html
39
+ │ └── chainstyle.css
40
+
41
+ ├── package.json # Package configuration file
42
+
43
+ └── package-lock.json # Locked dependency versions
44
+
45
+ In processor.js put this lines of code:
46
+
47
+ const jss = require("@melcanz85/chaincss");
48
+ try {
49
+ // Process your main file (chaincss.jcss) and write to the output (.
50
+ jss.processJSS('./chaincss/chaincss.jcss', './public/style.css');
51
+ } catch (err) {
52
+ console.error('Error processing JSS file:', err.stack);
53
+ // Exit the process with a non-zero status code
54
+ process.exit(1);
55
+ }
56
+
57
+ Example codes:
58
+
59
+ //main (chaincss.jcss)
60
+ <@
61
+ const style = get('../../chaincss.jcss/chain.jcss');
62
+
63
+ // STYLE MODIFICATION HAPPENS HERE
64
+ style.navA.color = 'red';
65
+
66
+ // COMPILING THE STYLE JS TO PURE CSS OR THE STYLE.CSS FILE
67
+ compile(style);
68
+ @>
69
+
70
+ @media (max-width: 768px) {
71
+ <@
72
+ run(
73
+ chaincss.flexDirection('column').alignItems('flex-start').block('header'),
74
+ chaincss.order(1).block('.logo'),
75
+ chaincss.order(2).block('.search-bar'),
76
+ chaincss.order(3).block('h1'),
77
+ chaincss.order(5).block('nav'),
78
+ chaincss.order(4).display('flex').width('100%').justifyContent('flex-end').block('.burgerWrapper'),
79
+ chaincss.display('flex').flexDirection('column').justifyContent('space-around').padding('4px').margin('5px 1px').width('30px').height('30px').cursor('pointer').block('.burger'),
80
+ chaincss.display('none').flexDirection('column').block('nav ul'),
81
+ chaincss.margin('10px 1px').block('nav ul li'),
82
+ chaincss.display('flex').block('nav ul.active'),
83
+ chaincss.width('100px').marginTop('10px').block('.search-bar'),
84
+ chaincss.width('100%').block('.search-bar input'),
85
+ chaincss.flex('1 1 100%').padding('50px').block('.box'),
86
+ chaincss.position('static').block('footer')
87
+ );
88
+ @>
89
+ }
90
+
91
+ ## As you notice theres 2 blocks in the code each surrounded by <@ @> delimiters except for the @media. The first block is when you make a separate chaining file, in this example (chain.jcss). First line retrieves the file using get() method. Then in between retrieving file and compiling is where you can modify your style it will overwrite the styling from your chaining code (chain.jcss). This is useful when your project is done and you want to make small changes/modifications to your style, instead of scrolling down to your chaining code you can just overwrites it in the main jcss.
92
+
93
+ Note: you can write css syntax code directly in the main jcss as you can see in the example the @media css syntax for mobile rendering but anything that is jcss syntax you have to put it inside <@ @> delimiters.
94
+
95
+ //Chaining (chain.jcss) example:
96
+
97
+ const bodyBgColor = '#f0f0f0';
98
+ const headerBgCOlor = '#333';
99
+ const bodyLineHeight = '1.6';
100
+ const bodyFontFamily = 'Arial, sans-serif';
101
+ const headerAlignItems = 'center';
102
+ const searchBarFontSize = '16px';
103
+
104
+ const resetDefaultBrowStyle = chaincss
105
+ .margin('0')
106
+ .padding('0')
107
+ .block('body', 'h1', 'h2', 'h3', 'p', 'ul');
108
+
109
+ const bodyStyle = chaincss
110
+ .fontFamily(bodyFontFamily)
111
+ .lineHeight(bodyLineHeight)
112
+ .bgColor(bodyBgColor)
113
+ .block('body');
114
+
115
+ // Site Header
116
+ const header = chaincss
117
+ .display('flex')
118
+ .alignItems(headerAlignItems)
119
+ .justifyContent('space-between')
120
+ .bgColor(headerBgCOlor)
121
+ .color(texcolor)
122
+ .padding('10px 20px')
123
+ .flexWrap('wrap')
124
+ .block('header');
125
+
126
+ const logoImgHeigth = chaincss
127
+ .height(logoHeight)
128
+ .block('.logo img');
129
+
130
+ // Burger button
131
+ const burgerWrapper = chaincss
132
+ .display('none')
133
+ .block('.burgerWrapper');
134
+
135
+ const burgerLine = chaincss
136
+ .width('100%')
137
+ .height('3px')
138
+ .bgColor('white')
139
+ .block('.line');
140
+
141
+ // search Bar
142
+ const divSearchBar = chaincss
143
+ .display('flex')
144
+ .flexGrow('1')
145
+ .justifyContent('flex-end')
146
+ .block('.search-bar');
147
+
148
+ const inputSearchBar = chaincss
149
+ .padding('5px')
150
+ .fontSize(searchBarFontSize)
151
+ .border('none')
152
+ .borderRadius('4px')
153
+ .width('200px')
154
+ .transition('w 0.4s ease-in-out')
155
+ .block('.search-bar input');
156
+
157
+ module.exports = {
158
+ resetDefaultBrowStyle,
159
+ bodyStyle,
160
+ header,
161
+ logoImgHeigth,
162
+ burgerWrapper,
163
+ burgerLine,
164
+ divSearchBar,
165
+ inputSearchBar
166
+ };
167
+
168
+ ## In this example you can see the chaining pattern of code its like writing css code but in javascript fashion where you can manipulate its values through variables. In css you have to scroll down and find each block to change it. In this case you just find it through variables.
33
169
 
34
170
  ✨ Features
35
171
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melcanz85/chaincss",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "A simple package transpiler for js to css",
5
5
  "main": "chaincss.js",
6
6
  "bin": {