cradova 1.4.1 → 2.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/README.md CHANGED
@@ -1,35 +1,59 @@
1
- <a><img src="cradova.png" alt="logo" width="80" height="80" align="right"></a>
2
-
3
- # Cradova.js
1
+ <br/>
2
+ <p align="center">
3
+ <a href="https://github.com/fridaycandour/cradova">
4
+ <img src="cradova.png" alt="Logo" width="80" height="80">
5
+ </a>
6
+
7
+ <h1 align="center">Cradova</h1>
8
+
9
+ <p align="center">
10
+ Cradova is a JavaScript framework for building Single Page Applications and PWAs.
11
+ <br/>
12
+ <br/>
13
+ <a href="https://github.com/fridaycandour/cradova#examples"><strong>Explore the docs »</strong></a>
14
+ <br/>
15
+ <br/>
16
+ <a href="https://t.me/cradovaframework">Join Community</a>
17
+ .
18
+ <a href="https://github.com/fridaycandour/cradova/issues">Report Bug</a>
19
+ .
20
+ <a href="https://github.com/fridaycandour/cradova/issues">Request Feature</a>
21
+ </p>
22
+ </p>
23
+
24
+ ![Contributors](https://img.shields.io/github/contributors/fridaycandour/cradova?color=dark-green) ![Issues](https://img.shields.io/github/issues/fridaycandour/cradova) ![License](https://img.shields.io/github/license/fridaycandour/cradova)
4
25
  [![npm Version](https://img.shields.io/npm/v/cradova.svg)](https://www.npmjs.com/package/cradova)
5
26
  [![License](https://img.shields.io/npm/l/cradova.svg)](https://github.com/cradova/cradova.js/blob/next/LICENSE)
6
27
  [![npm Downloads](https://img.shields.io/npm/dm/cradova.svg)](https://www.npmjs.com/package/cradova)
7
- [![Build Status](https://img.shields.io/travis/cradova/cradova.js/next.svg?colorB=brightgreen)](https://www.npmjs.com/package/cradova)
8
- [![Donate at OpenCollective](https://img.shields.io/opencollective/all/cradova.svg?colorB=brightgreen)](https://opencollective.com/cradova)
9
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/cradova/cradova.js/blob/next/contributing.md)
28
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/cradova/cradova.js/blob/next/contributing.md)![Forks](https://img.shields.io/github/forks/fridaycandour/cradova?style=social) ![Stargazers](https://img.shields.io/github/stars/fridaycandour/cradova?style=social)
10
29
 
11
-
12
- ## Contents
30
+ # Contents
13
31
 
14
- - [What is Cradova](#what-is-cradovajs)
15
- - [Why did we build Cradova?](#whats-the-benefit)
32
+ - [What is Cradova](#what-is-cradova)
33
+ - [Why Cradova?](#whats-the-benefit)
16
34
  - [Installation](#installation)
17
35
  - [Examples](#examples)
18
36
  - [Documentation](#documentation)
19
37
  - [Getting Help](#getting-help)
20
38
  - [Contributing](#contributing)
21
39
 
22
- ## What is cradova.js?
40
+ ## What is Cradova?
23
41
 
24
42
  Cradova is a JavaScript framework for building Single Page Applications and PWAs.
25
43
 
26
- It's small, fast and provides state management, routing and XHR utilities out of the box.
44
+ It's small, fast and provides state management, routing and a rest API utility out of the box.
45
+
46
+ Cradova follows the [VJS specification](https://github.com/fridaycandour/cradova/blob/main/spec.md)
27
47
 
28
48
  ## What's the benefit?
29
- We aim to be fast and simple with and no hidden abstractions whatsoever.
30
- We don't use visual DOM or any diff algorithms to manage the DOM.
31
49
 
32
- Cradova has been used in production and we will update this README to reflect our lessons as we go.
50
+ Cradova is aimed to be fast and simple with and fewer abstractions and yet easily composable.
51
+
52
+ We don't use visual DOM or diff algorithms to manage the DOM.
53
+
54
+ State management is done more elegantly with the predictive model, manually and easily with all the speed.
55
+
56
+ Cradova has been used on a couple of projects in production and we will update this page to reflect our progress as we keep improving.
33
57
 
34
58
  ## Installation
35
59
 
@@ -51,36 +75,58 @@ Cradova has been used in production and we will update this README to reflect ou
51
75
  npm i cradova
52
76
  ```
53
77
 
54
-
55
78
  ## Examples
79
+
56
80
  Many aspects of Cradova are not reflected in the following example. More functionality will be entailed in future docs.
57
81
 
58
82
  Here's an example of create a basic component in Cradova:
59
83
 
60
84
  ```js
61
- import _, { frag } from "cradova";
85
+ // cradova v2.0.0 comes with all html tags prebuilt and fully typed
86
+ // this gives your app more performance gain.
87
+ import _, { h1 } from "cradova";
88
+
89
+ function Hello(name) {
90
+ return h1("Hello " + name, {
91
+ className: "title",
92
+ style: {
93
+ color: "grey",
94
+ },
95
+ });
96
+ }
97
+
98
+ // document fragment empty cradova call _()
99
+
100
+ const html = _(Hello("peter"), Hello("joe"));
101
+
102
+ document.body.append(html);
103
+ ```
104
+
105
+ ```js
106
+ // regular example
107
+ import _ from "cradova";
62
108
 
63
109
  function Hello(name) {
64
110
  return _("h1", "Hello " + name);
65
111
  }
66
112
 
67
- // calling Hello returns the HTML
68
- const html = Hello("peter")(); // or
69
- // using frag
70
- const html = frag(Hello("peter"), Hello("joe"));
113
+ const html = _(Hello("peter"), Hello("joe"));
114
+
71
115
  document.body.append(html);
72
116
  ```
73
117
 
74
118
  ## Using Screen
119
+
75
120
  ```js
76
121
  import _, { Screen, Router } from "cradova";
77
122
 
78
123
  function HelloMessage(name) {
79
124
  // an effect run once after screen renders
80
125
  this.effect(() => {
81
- return new Promise((res) => {
126
+ const name = new Promise((res) => {
82
127
  res("friday");
83
128
  });
129
+ this.updateState(await name)
84
130
  });
85
131
  // effects can be used to make api calls needed for the page
86
132
  return _("div", "Hello " + name);
@@ -95,24 +141,25 @@ const home = new Screen({
95
141
  Router.route("/", home);
96
142
 
97
143
  // navigates to that page
98
- // Router.navigate("/home");
144
+ // Router.navigate("/home", data, force);
99
145
  // get the page ready in the background
100
146
  // Router.packageScreen("/home");
147
+ // get route params for this page
148
+ // Router.getParams();
101
149
 
102
150
  ```
103
151
 
104
152
  ## State management
105
153
 
106
154
  ```js
107
- // we have
108
-
109
155
  // dispatch - global (element) requires state ID
110
156
 
111
157
  // element can have this.updateState when shouldUpdate is true
112
158
 
113
- // Ref components (global and local)
159
+ // Ref components
114
160
 
115
161
  // state can be managed from a store when using createSignal or simpleStores
162
+ // this method is not yet documented
116
163
 
117
164
  import _, { Ref } from "cradova";
118
165
 
@@ -129,10 +176,21 @@ function counter() {
129
176
  });
130
177
  }
131
178
 
132
- function HelloMessage(name) {
179
+ function dataCounter() {
180
+ return _("h1| 0", {
181
+ shouldUpdate: true,
182
+ $num: "0", // data-num
183
+ onclick() {
184
+ const num = Number(this.getAttribute("data-num")) + 1;
185
+ this.updateState({ text: num, $num: num });
186
+ },
187
+ });
188
+ }
189
+
190
+ function HelloMessage(name = "no name") {
133
191
  return _("div.foo#bar", {
134
192
  shouldUpdate: true,
135
- text: "hello " + (name || "no name"),
193
+ text: "hello " + name,
136
194
  onclick() {
137
195
  const name = prompt("what are your names");
138
196
  this.updateState({ text: "hello " + name });
@@ -140,13 +198,13 @@ function HelloMessage(name) {
140
198
  });
141
199
  }
142
200
 
143
- const nameRef = new Ref(function ({ name }) {
201
+ const nameRef = new Ref(function ( name ) {
144
202
  const self = this;
145
203
  return _("div.foo#bar", {
146
204
  text: "hello" + (name || "no name"),
147
205
  onclick() {
148
206
  const name = prompt();
149
- self.updateState({ name });
207
+ self.updateState(name);
150
208
  },
151
209
  });
152
210
  });
@@ -154,8 +212,9 @@ const nameRef = new Ref(function ({ name }) {
154
212
  function Home() {
155
213
  return _("div.foo#bar",
156
214
  counter,
215
+ dataCounter,
157
216
  HelloMessage,
158
- nameRef.render({ name: "no name" })
217
+ nameRef.render( "no name" )
159
218
  );
160
219
  }
161
220
 
@@ -169,22 +228,27 @@ Router.route("/", home);
169
228
  ```
170
229
 
171
230
  ## Documentation
231
+
172
232
  We are currently building cradova's documentation and we have only a few hands, if you're interested in helping you can join the community, learn first hand, and support cradova's progress.
173
233
 
174
234
  ## Getting Help
235
+
175
236
  To get further insights and help on Cradova, visit our new [Telegram Community Chat](https://t.me/cradovaframework).
176
237
 
177
238
  ## Contributing
178
- We are currently working to set up:
179
239
 
240
+ We are currently working to [set](https://github.com/fridaycandour/cradova/blob/main/contributing.md) up the following:
241
+
242
+ - building cradova CLI (in progress)
180
243
  - Cradova Documentation Website
181
244
  - UI component libraries for cradova
182
245
  - Sample projects
183
246
  - maintenance and promotion
184
- - building cradova CLI
185
-
186
247
 
187
248
  ## Sponsor
188
- Your support is appriciated and needed to advance Cradova further into the future.\
189
- Sponsorships can be done via [Patreon](https://www.patreon.com/FridayCandour).\
190
- Both monthly-recurring sponsorships and one-time donations are accepted. Recurring sponsorships will be entitled to logo placements in Tiers.
249
+
250
+ Your support is appreciated and needed to advance Cradova for more performance and improvements.
251
+
252
+ Sponsorships can be done via [Patreon](https://www.patreon.com/FridayCandour) and [KO-FI](https://www.ko-fi.com/fridaycandour).
253
+
254
+ Both monthly-recurring sponsorships and one-time donations are accepted.