olova 2.0.2 → 2.0.4

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.
@@ -0,0 +1,18 @@
1
+ name: Publish to NPM
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - uses: actions/setup-node@v2
13
+ with:
14
+ node-version: '14'
15
+ registry-url: 'https://registry.npmjs.org'
16
+ - run: yarn publish
17
+ env:
18
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
package/README.md CHANGED
@@ -1,54 +1,258 @@
1
- # Olova JavaScript Framework
2
-
3
- Olova is a lightweight and reactive JavaScript framework that simplifies UI
4
- development with a clean, intuitive syntax. It provides a reactivity system and
5
- hooks to manage state and side effects, allowing developers to build modern web
6
- applications with ease.
7
-
8
- ## Features
9
-
10
- - **State Management**: Use the `State` hook to manage reactive state in your
11
- components.
12
- - **Side Effects**: Use the `Effect` hook to run side effects in response to
13
- state changes.
14
- - **JSX-style Syntax**: Write UI components using a simple, declarative
15
- JSX-style syntax.
16
- - **Reactivity**: Automatically re-render components when state changes.
17
-
18
- ## Installation
19
-
20
- To get started with Olova, first install the core library via npm or yarn.
21
-
22
- ```bash
23
- npm install olova
24
- ```
25
-
26
- or
27
-
28
- ```bash
29
- yarn add olova
30
- ```
31
-
32
- ## Example Usage
33
-
34
- Here is an example of a basic component in Olova:
35
-
36
- ```js
37
- import Olova, { State, Effect } from "olova";
38
-
39
- export default function Home() {
40
- const [count, setCount] = State(0);
41
-
42
- Effect(() => {
43
- console.log("Home is rendered");
44
- console.log(count);
45
- }, [count]);
46
-
47
- return (
48
- <>
49
- <h1>{count}</h1>
50
- <button onClick={() => setCount(count + 1)}>Increment</button>
51
- </>
52
- );
53
- }
54
- ```
1
+ # 🚀 Olova Framework Documentation
2
+
3
+ > A lightweight JavaScript framework for building web applications with JSX
4
+
5
+ ## What is Olova?
6
+
7
+ Olova is a simple yet powerful JavaScript framework that lets you build web
8
+ applications using JSX. It directly manipulates the DOM without a Virtual DOM,
9
+ making it lightweight and straightforward to use.
10
+
11
+ ## ⚡ Quick Start
12
+
13
+ ### Installation
14
+
15
+ Get started with a single command:
16
+
17
+ ```bash
18
+ npm create vilo@latest
19
+ ```
20
+
21
+ This command will set up a new Olova project, similar to how Vite works. You can
22
+ use it to create an Olova template or install Olova in an existing project.
23
+
24
+ Alternatively, you can install Olova directly:
25
+
26
+ ```bash
27
+ npm install olova
28
+ ```
29
+
30
+ ### Your First Olova App
31
+
32
+ ```jsx
33
+ import Olova from "olova";
34
+
35
+ const App = () => {
36
+ return (
37
+ <>
38
+ <h1>Welcome to Olova! 🎉</h1>
39
+ <p>Building web apps made simple.</p>
40
+ </>
41
+ );
42
+ };
43
+ ```
44
+
45
+ ## 🎯 Core Concepts
46
+
47
+ ### Built-in Hooks
48
+
49
+ Olova provides several essential hooks for building dynamic applications:
50
+
51
+ ```jsx
52
+ import {
53
+ $signal, // Manage component state
54
+ $effect, // Handle side effects
55
+ $memo, // Memoize values
56
+ $ref, // Reference DOM elements
57
+ $context, // Share data between components
58
+ $callback, // Memoize functions
59
+ } from "olova";
60
+ ```
61
+
62
+ ### Default Exports
63
+
64
+ Olova comes with two built-in utilities:
65
+
66
+ ```jsx
67
+ import Olova, { h, Fragment } from "olova";
68
+
69
+ // h: Element generator (automatically used for JSX transformation)
70
+ // Fragment: Wrapper for multiple elements, can be used as <></> or <Fragment></Fragment>
71
+ ```
72
+
73
+ ## 💫 Using Hooks
74
+
75
+ ### State Management
76
+
77
+ ```jsx
78
+ import Olova, { $signal } from "olova";
79
+
80
+ const Counter = () => {
81
+ const [count, setCount] = State(0);
82
+
83
+ return <button onClick={() => setCount(count + 1)}>Count: {count}</button>;
84
+ };
85
+ ```
86
+
87
+ ### Side Effects
88
+
89
+ ```jsx
90
+ import Olova, { $effect, $signal } from "olova";
91
+
92
+ const DataFetcher = () => {
93
+ const [data, setData] = State(null);
94
+
95
+ Effect(() => {
96
+ fetch("/api/data")
97
+ .then((res) => res.json())
98
+ .then(setData);
99
+ }, []); // Empty array means run once on mount
100
+
101
+ return <div>{data ? "Data loaded!" : "Loading..."}</div>;
102
+ };
103
+ ```
104
+
105
+ ### Using References
106
+
107
+ ```jsx
108
+ import Olova, { $ref } from "olova";
109
+
110
+ const FocusInput = () => {
111
+ const inputRef = $ref(null);
112
+
113
+ return <input ref={inputRef} onFocus={() => console.log("Input focused!")} />;
114
+ };
115
+ ```
116
+
117
+ ### Memoization
118
+
119
+ ```jsx
120
+ import Olova, { $memo, $signal } from "olova";
121
+
122
+ const ExpensiveComponent = ({ data }) => {
123
+ const processedData = Memo(() => {
124
+ // Expensive computation here
125
+ return data.map((item) => item * 2);
126
+ }, [data]);
127
+
128
+ return <div>{processedData.join(", ")}</div>;
129
+ };
130
+ ```
131
+
132
+ ## 🎨 Styling in Olova
133
+
134
+ Olova supports all standard CSS approaches:
135
+
136
+ ### CSS Imports
137
+
138
+ ```jsx
139
+ import "./styles.css";
140
+
141
+ const StyledComponent = () => (
142
+ <div className="my-component">Styled content</div>
143
+ );
144
+ ```
145
+
146
+ ### CSS Modules
147
+
148
+ ```jsx
149
+ import styles from "./Component.module.css";
150
+
151
+ const ModuleStyledComponent = () => (
152
+ <div className={styles.container}>Module styled content</div>
153
+ );
154
+ ```
155
+
156
+ ### Inline Styles
157
+
158
+ ```jsx
159
+ const InlineStyledComponent = () => (
160
+ <div style={{ padding: "20px", color: "blue" }}>Inline styled content</div>
161
+ );
162
+ ```
163
+
164
+ ## 🔮 How Olova Works
165
+
166
+ 1. **Direct DOM Manipulation**
167
+
168
+ 1. Olova directly updates the DOM without a Virtual DOM
169
+ 1. Efficient updates when state changes
170
+ 1. Lightweight and fast performance
171
+
172
+ 1. **JSX Transformation**
173
+
174
+ 1. Uses the `h` function to transform JSX into DOM elements
175
+ 1. Handles event binding automatically
176
+ 1. Manages component lifecycle efficiently
177
+
178
+ ## 📚 Best Practices
179
+
180
+ ### Component Structure
181
+
182
+ ```jsx
183
+ // Good: Single responsibility component
184
+ const UserProfile = ({ user }) => (
185
+ <div className="profile">
186
+ <img src={user.avatar || "/placeholder.svg"} alt={user.name} />
187
+ <h2>{user.name}</h2>
188
+ </div>
189
+ );
190
+
191
+ // Better: Using Fragment for multiple elements
192
+ const UserCard = ({ user }) => (
193
+ <>
194
+ <UserProfile user={user} />
195
+ <UserStats stats={user.stats} />
196
+ </>
197
+ );
198
+ ```
199
+
200
+ ### Hook Usage
201
+
202
+ ```jsx
203
+ // Effective use of multiple hooks
204
+ const UserDashboard = () => {
205
+ const [user, setUser] = State(null);
206
+ const userCache = $ref({});
207
+
208
+ Effect(() => {
209
+ // Side effect cleanup example
210
+ return () => {
211
+ userCache.current = {};
212
+ };
213
+ }, []);
214
+
215
+ return <div>Dashboard Content</div>;
216
+ };
217
+ ```
218
+
219
+ ## 🚀 Coming Soon
220
+
221
+ - More built-in hooks
222
+ - Enhanced development tools
223
+ - Additional utility functions
224
+ - Performance optimizations
225
+
226
+ ## 🤝 Contributing
227
+
228
+ We welcome contributions! Whether it's:
229
+
230
+ - Bug reports
231
+ - Feature requests
232
+ - Documentation improvements
233
+ - Pull requests
234
+
235
+ ## 📖 Examples
236
+
237
+ Find more examples in our [GitHub repository](https://github.com/olovajs/olova).
238
+
239
+ ## 🛠 Using Vilo
240
+
241
+ Vilo is a project creation tool for Olova, similar to Vite. You can use it to
242
+ quickly set up new Olova projects or add Olova to existing projects.
243
+
244
+ To create a new Olova project:
245
+
246
+ ```bash
247
+ npm create vilo@latest my-olova-app
248
+ cd my-olova-app
249
+ npm install
250
+ npm run dev
251
+ ```
252
+
253
+ This will set up a new Olova project with a basic template, ready for you to
254
+ start developing.
255
+
256
+ ---
257
+
258
+ Made with simplicity in mind 🌟
package/dist/olova.d.ts CHANGED
@@ -1 +1 @@
1
- declare module "olova";
1
+ declare module "olova";