vaderjs 1.3.3-alpha-19 → 1.3.3-alpha-21

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/README.md CHANGED
@@ -1,158 +1,176 @@
1
- <p align="center">
2
- <a href="https://vader-js.pages.dev">
3
- <picture>
4
- <source media="(prefers-color-scheme: dark)" srcset="/icon.jpeg">
5
- <img src="./logo.png" height="128">
6
- </picture>
7
- <h1 align="center">Vader.js</h1>
8
- </a>
9
- </p>
10
-
11
- # VaderJS: A Powerful Reactive Framework for SPAs inspired by react.js!
12
-
13
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Postr-Inc/Vader.js/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/vaderjs.svg?style=flat)](https://www.npmjs.com/package/vaderjs)
14
-
15
-
16
-
17
- ## Get Started
18
-
19
- 2. Install vaderjs
20
-
21
- ```bash
22
- npm i vaderjs@latest
23
- ```
24
-
25
- 3. Install five server - recommended to watch the index.html file as you edit your code
26
-
27
- [Vscode 5 Server](https://marketplace.visualstudio.com/items?itemName=yandeu.five-server)
28
-
29
- 4. Create Proper Folders
30
-
31
- Create a pages folder - which allows you to have nextjs page like routing via buns file based router
32
-
33
- Tip: Each folder can be deep nested up to 4 levels!
34
-
35
- ```bash
36
- /pages/index.jsx = /
37
- /pages/home/[page].jsx = /home/:page
38
- /pages/path/index.jsx = /path/file
39
- ```
40
- Keyword folders - all files are passed from these folders to the `dist` folder
41
-
42
- ```bash
43
-
44
- pages - used for jsx route files
45
- src - used for your jsx components / javascript files
46
- public - used for anything
47
-
48
- ```
49
-
50
-
51
-
52
- 5. And your done - Run `npx vaderjs` and the compiled output is visible inside of the `/dist/` folder!
53
-
54
-
55
- ## Key Features & Examples
56
-
57
- ### File based routing
58
- vader's compiler automatically handles routing so you wont need to! - it uses a similar page routing to nextjs
59
-
60
- ```bash
61
- /pages/index.jsx = /
62
- /pages/home/[page].jsx = /home/:page
63
- /pages/path/index.jsx = /path/file
64
-
65
-
66
- ```
67
- For pages that have [params] you can derive it using this.request
68
-
69
-
70
- ### Simplified Component Creation
71
-
72
- ```jsx
73
- // pages/home.jsx
74
- let {Component, useState} = await import('vaderjs/client') // this will be automatically handled by vader in compile time
75
- let Mycomponent = await require('./pages/mycomponent')
76
- class Home extends Vader {
77
- constructor() {
78
- super();
79
- this.key = '2'
80
- }
81
- render() {
82
- return <>
83
- <div key={this.key}>
84
- <p>Hello World</p>
85
- </div>
86
- <Mycomponent ..props />
87
- </>
88
- }
89
- }
90
-
91
- return {default:Home}
92
- ```
93
-
94
-
95
-
96
- ### State Management
97
-
98
- ```jsx
99
- let {Component, useState} = await import('vaderjs/client')
100
-
101
- class MyApp extends Component{
102
- contructor(){
103
- super()
104
- this.key = 'static key for state changes'
105
- }
106
-
107
- render(){
108
- let [count, setCount] = useState(0)
109
- function increment(){
110
- setCount(count()+ 1)
111
- }
112
- return <>
113
- <p>Count is ${count}</p>
114
- <button onclick={()=>increment()}>Increment</button>
115
- </>
116
-
117
- }
118
- }
119
-
120
- return {default:MyApp}
121
- ```
122
-
123
-
124
- ### Function Binding
125
-
126
- Vaderjs allows you to bind functions directly to html elements just like react
127
-
128
- ```javascript
129
- // vader uses params[0] as the event target object and other parameters resolve after
130
-
131
- function click(event, otherparams){
132
- console.log(event.target, otherparams)
133
- }
134
-
135
- const hello = function(event, otherparams){
136
-
137
- }
138
-
139
- return <>
140
- <button onclick={()=>click()}>Click Me</button>
141
- </>
142
- ```
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
- ## License
153
-
154
- VaderJS is released under the MIT License. See the [LICENSE](https://github.com/Postr-Inc/Vader.js/blob/main/LICENSE) file for details.
155
-
156
- ## Join the Community
157
-
158
- Connect with the VaderJS community on [GitHub](https://github.com/Postr-Inc/Vader.js). Contribute, share feedback, and improve VaderJS for SPA development.
1
+ <p align="center">
2
+ <a href="https://vader-js.pages.dev">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="/icon.jpeg">
5
+ <img src="./logo.png" height="128">
6
+ </picture>
7
+ <h1 align="center">Vader.js</h1>
8
+ </a>
9
+ </p>
10
+
11
+ # VaderJS: A Powerful Reactive Framework for SPAs inspired by react.js!
12
+
13
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Postr-Inc/Vader.js/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/vaderjs.svg?style=flat)](https://www.npmjs.com/package/vaderjs)
14
+
15
+
16
+
17
+ ## Get Started
18
+
19
+ 2. Install vaderjs
20
+
21
+ ```bash
22
+ npm i vaderjs@latest
23
+ ```
24
+
25
+ 3. Install five server - recommended to watch the index.html file as you edit your code
26
+
27
+ [Vscode 5 Server](https://marketplace.visualstudio.com/items?itemName=yandeu.five-server)
28
+
29
+ 4. Create Proper Folders
30
+
31
+ Create a pages folder - which allows you to have nextjs page like routing via buns file based router
32
+
33
+ Tip: Each folder can be deep nested up to 4 levels!
34
+
35
+ ```bash
36
+ /pages/index.jsx = /
37
+ /pages/home/[page].jsx = /home/:page
38
+ /pages/path/index.jsx = /path/file
39
+ ```
40
+ Keyword folders - all files are passed from these folders to the `dist` folder
41
+
42
+ ```bash
43
+
44
+ pages - used for jsx route files
45
+ src - used for your jsx components / javascript files
46
+ public - used for anything
47
+
48
+ ```
49
+
50
+
51
+
52
+ 5. And your done - Run `npx vaderjs` and the compiled output is visible inside of the `/dist/` folder!
53
+
54
+
55
+ ## Key Features & Examples
56
+
57
+ ### File based routing
58
+ vader's compiler automatically handles routing so you wont need to! - it uses a similar page routing to nextjs
59
+
60
+ ```bash
61
+ /pages/index.jsx = /
62
+ /pages/home/[page].jsx = /home/:page
63
+ /pages/path/index.jsx = /path/file
64
+
65
+
66
+ ```
67
+ For pages that have [params] you can derive it using this.request
68
+
69
+
70
+ ### Simplified Component Creation
71
+
72
+ ```jsx
73
+ // pages/home.jsx
74
+ let {Component, useState} = await import('vaderjs/client') // this will be automatically handled by vader in compile time
75
+ let Mycomponent = await require('./pages/mycomponent')
76
+ class Home extends Vader {
77
+ constructor() {
78
+ super();
79
+ this.key = '2'
80
+ }
81
+ render() {
82
+ return <>
83
+ <div key={this.key}>
84
+ <p>Hello World</p>
85
+ </div>
86
+ <Mycomponent ..props />
87
+ </>
88
+ }
89
+ }
90
+
91
+ return {default:Home}
92
+ ```
93
+
94
+
95
+
96
+ ### State Management
97
+ Vaderjs uses partial hydration & full reflection
98
+
99
+ You can pass a reference to the dom target like an id for the element u want to change - or you can just swap the value and the entire component will rerender
100
+
101
+ ```jsx
102
+ let {Component, useState, useRef} = await import('vaderjs/client')
103
+
104
+ class MyApp extends Component{
105
+ contructor(){
106
+ super()
107
+ this.key = 'static key for state changes'
108
+ }
109
+
110
+ render(){
111
+ let [count, setCount] = useState(0)
112
+ let ref = useRef('')
113
+
114
+ return <>
115
+ <p ref={ref.bind}>Count is ${count}</p>
116
+ ${/**
117
+ pass anything used from the toplevel render to the lowerlevel function params to be able to invoke!
118
+ **/}
119
+ <button onclick={(setCount, count, ref)=>{
120
+ setCount(count + 1, ref.bind)
121
+ }}>Increment</button>
122
+ </>
123
+
124
+ }
125
+ }
126
+
127
+ return {default:MyApp}
128
+ ```
129
+
130
+
131
+ ### Function Binding
132
+
133
+ Vaderjs allows you to bind functions directly to html elements just like react
134
+ there are two ways - top level invokes like below
135
+
136
+ ```javascript
137
+ // vader uses params[0] as the event target object and other parameters resolve after
138
+
139
+ function click(event, otherparams){
140
+ console.log(event.target, otherparams)
141
+ }
142
+
143
+ const hello = function(event, otherparams){
144
+
145
+ }
146
+
147
+ return <>
148
+ <button onclick={()=>click()}>Click Me</button>
149
+ </>
150
+ ```
151
+
152
+ and lower level invokes - these operate the same just allow you to pass items from top level to lower level: ex - I have a variable named car and i want the button to log it i can pass it as a parameter to allow it to be added to the buttons function scope
153
+
154
+ ```jsx
155
+ let car = {
156
+ model: 'tesla',
157
+ price: 'toomiuch'
158
+ }
159
+ return <>
160
+ <button onclick={(car)=>{
161
+ console.log(car.model)
162
+ }}>Log</button>
163
+ ```
164
+
165
+
166
+
167
+
168
+
169
+
170
+ ## License
171
+
172
+ VaderJS is released under the MIT License. See the [LICENSE](https://github.com/Postr-Inc/Vader.js/blob/main/LICENSE) file for details.
173
+
174
+ ## Join the Community
175
+
176
+ Connect with the VaderJS community on [GitHub](https://github.com/Postr-Inc/Vader.js). Contribute, share feedback, and improve VaderJS for SPA development.