jac-client 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl
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.
- jac_client/examples/all-in-one/assets/workers/worker.py +5 -0
- jac_client/tests/conftest.py +281 -0
- jac_client/tests/test_cli.py +755 -0
- jac_client/tests/test_it.py +347 -67
- {jac_client-0.2.2.dist-info → jac_client-0.2.4.dist-info}/METADATA +30 -24
- jac_client-0.2.4.dist-info/RECORD +10 -0
- {jac_client-0.2.2.dist-info → jac_client-0.2.4.dist-info}/WHEEL +2 -1
- jac_client-0.2.4.dist-info/entry_points.txt +4 -0
- jac_client-0.2.4.dist-info/top_level.txt +1 -0
- jac_client/docs/README.md +0 -689
- jac_client/docs/advanced-state.md +0 -1265
- jac_client/docs/asset-serving/intro.md +0 -209
- jac_client/docs/assets/pipe_line-v2.svg +0 -32
- jac_client/docs/assets/pipe_line.png +0 -0
- jac_client/docs/file-system/app.jac.md +0 -121
- jac_client/docs/file-system/backend-frontend.md +0 -217
- jac_client/docs/file-system/intro.md +0 -72
- jac_client/docs/file-system/nested-imports.md +0 -348
- jac_client/docs/guide-example/intro.md +0 -115
- jac_client/docs/guide-example/step-01-setup.md +0 -270
- jac_client/docs/guide-example/step-02-components.md +0 -416
- jac_client/docs/guide-example/step-03-styling.md +0 -478
- jac_client/docs/guide-example/step-04-todo-ui.md +0 -477
- jac_client/docs/guide-example/step-05-local-state.md +0 -530
- jac_client/docs/guide-example/step-06-events.md +0 -749
- jac_client/docs/guide-example/step-07-effects.md +0 -468
- jac_client/docs/guide-example/step-08-walkers.md +0 -534
- jac_client/docs/guide-example/step-09-authentication.md +0 -586
- jac_client/docs/guide-example/step-10-routing.md +0 -539
- jac_client/docs/guide-example/step-11-final.md +0 -963
- jac_client/docs/imports.md +0 -1141
- jac_client/docs/lifecycle-hooks.md +0 -773
- jac_client/docs/routing.md +0 -659
- jac_client/docs/styling/intro.md +0 -249
- jac_client/docs/styling/js-styling.md +0 -367
- jac_client/docs/styling/material-ui.md +0 -341
- jac_client/docs/styling/pure-css.md +0 -299
- jac_client/docs/styling/sass.md +0 -403
- jac_client/docs/styling/styled-components.md +0 -395
- jac_client/docs/styling/tailwind.md +0 -298
- jac_client/examples/all-in-one/.babelrc +0 -9
- jac_client/examples/all-in-one/README.md +0 -16
- jac_client/examples/all-in-one/app.jac +0 -426
- jac_client/examples/all-in-one/assets/burger.png +0 -0
- jac_client/examples/all-in-one/button.jac +0 -7
- jac_client/examples/all-in-one/components/button.jac +0 -7
- jac_client/examples/all-in-one/package.json +0 -29
- jac_client/examples/all-in-one/styles.css +0 -26
- jac_client/examples/all-in-one/vite.config.js +0 -28
- jac_client/examples/asset-serving/css-with-image/.babelrc +0 -9
- jac_client/examples/asset-serving/css-with-image/README.md +0 -91
- jac_client/examples/asset-serving/css-with-image/app.jac +0 -88
- jac_client/examples/asset-serving/css-with-image/assets/burger.png +0 -0
- jac_client/examples/asset-serving/css-with-image/package.json +0 -28
- jac_client/examples/asset-serving/css-with-image/styles.css +0 -26
- jac_client/examples/asset-serving/css-with-image/vite.config.js +0 -28
- jac_client/examples/asset-serving/image-asset/.babelrc +0 -9
- jac_client/examples/asset-serving/image-asset/README.md +0 -119
- jac_client/examples/asset-serving/image-asset/app.jac +0 -55
- jac_client/examples/asset-serving/image-asset/assets/burger.png +0 -0
- jac_client/examples/asset-serving/image-asset/package.json +0 -28
- jac_client/examples/asset-serving/image-asset/styles.css +0 -26
- jac_client/examples/asset-serving/image-asset/vite.config.js +0 -28
- jac_client/examples/asset-serving/import-alias/.babelrc +0 -9
- jac_client/examples/asset-serving/import-alias/README.md +0 -83
- jac_client/examples/asset-serving/import-alias/app.jac +0 -111
- jac_client/examples/asset-serving/import-alias/assets/burger.png +0 -0
- jac_client/examples/asset-serving/import-alias/package.json +0 -28
- jac_client/examples/asset-serving/import-alias/vite.config.js +0 -28
- jac_client/examples/basic/.babelrc +0 -9
- jac_client/examples/basic/README.md +0 -16
- jac_client/examples/basic/app.jac +0 -21
- jac_client/examples/basic/package.json +0 -27
- jac_client/examples/basic/vite.config.js +0 -27
- jac_client/examples/basic-auth/.babelrc +0 -9
- jac_client/examples/basic-auth/README.md +0 -16
- jac_client/examples/basic-auth/app.jac +0 -308
- jac_client/examples/basic-auth/package.json +0 -27
- jac_client/examples/basic-auth/vite.config.js +0 -27
- jac_client/examples/basic-auth-with-router/.babelrc +0 -9
- jac_client/examples/basic-auth-with-router/README.md +0 -60
- jac_client/examples/basic-auth-with-router/app.jac +0 -464
- jac_client/examples/basic-auth-with-router/package.json +0 -28
- jac_client/examples/basic-auth-with-router/vite.config.js +0 -27
- jac_client/examples/basic-full-stack/.babelrc +0 -9
- jac_client/examples/basic-full-stack/README.md +0 -18
- jac_client/examples/basic-full-stack/app.jac +0 -320
- jac_client/examples/basic-full-stack/package.json +0 -28
- jac_client/examples/basic-full-stack/vite.config.js +0 -27
- jac_client/examples/css-styling/js-styling/.babelrc +0 -9
- jac_client/examples/css-styling/js-styling/README.md +0 -183
- jac_client/examples/css-styling/js-styling/app.jac +0 -84
- jac_client/examples/css-styling/js-styling/package.json +0 -28
- jac_client/examples/css-styling/js-styling/styles.js +0 -100
- jac_client/examples/css-styling/js-styling/vite.config.js +0 -27
- jac_client/examples/css-styling/material-ui/.babelrc +0 -9
- jac_client/examples/css-styling/material-ui/README.md +0 -16
- jac_client/examples/css-styling/material-ui/app.jac +0 -122
- jac_client/examples/css-styling/material-ui/package.json +0 -32
- jac_client/examples/css-styling/material-ui/vite.config.js +0 -27
- jac_client/examples/css-styling/pure-css/.babelrc +0 -9
- jac_client/examples/css-styling/pure-css/README.md +0 -16
- jac_client/examples/css-styling/pure-css/app.jac +0 -64
- jac_client/examples/css-styling/pure-css/package.json +0 -28
- jac_client/examples/css-styling/pure-css/styles.css +0 -111
- jac_client/examples/css-styling/pure-css/vite.config.js +0 -27
- jac_client/examples/css-styling/sass-example/.babelrc +0 -9
- jac_client/examples/css-styling/sass-example/README.md +0 -16
- jac_client/examples/css-styling/sass-example/app.jac +0 -64
- jac_client/examples/css-styling/sass-example/package.json +0 -29
- jac_client/examples/css-styling/sass-example/styles.scss +0 -153
- jac_client/examples/css-styling/sass-example/vite.config.js +0 -27
- jac_client/examples/css-styling/styled-components/.babelrc +0 -9
- jac_client/examples/css-styling/styled-components/README.md +0 -16
- jac_client/examples/css-styling/styled-components/app.jac +0 -71
- jac_client/examples/css-styling/styled-components/package.json +0 -29
- jac_client/examples/css-styling/styled-components/styled.js +0 -90
- jac_client/examples/css-styling/styled-components/vite.config.js +0 -27
- jac_client/examples/css-styling/tailwind-example/.babelrc +0 -9
- jac_client/examples/css-styling/tailwind-example/README.md +0 -16
- jac_client/examples/css-styling/tailwind-example/app.jac +0 -63
- jac_client/examples/css-styling/tailwind-example/global.css +0 -1
- jac_client/examples/css-styling/tailwind-example/package.json +0 -30
- jac_client/examples/css-styling/tailwind-example/vite.config.js +0 -29
- jac_client/examples/full-stack-with-auth/.babelrc +0 -9
- jac_client/examples/full-stack-with-auth/README.md +0 -16
- jac_client/examples/full-stack-with-auth/app.jac +0 -722
- jac_client/examples/full-stack-with-auth/package.json +0 -28
- jac_client/examples/full-stack-with-auth/vite.config.js +0 -29
- jac_client/examples/little-x/app.jac +0 -724
- jac_client/examples/little-x/package.json +0 -23
- jac_client/examples/little-x/submit-button.jac +0 -8
- jac_client/examples/nested-folders/nested-advance/.babelrc +0 -9
- jac_client/examples/nested-folders/nested-advance/ButtonRoot.jac +0 -11
- jac_client/examples/nested-folders/nested-advance/README.md +0 -77
- jac_client/examples/nested-folders/nested-advance/app.jac +0 -35
- jac_client/examples/nested-folders/nested-advance/level1/ButtonSecondL.jac +0 -19
- jac_client/examples/nested-folders/nested-advance/level1/Card.jac +0 -43
- jac_client/examples/nested-folders/nested-advance/level1/level2/ButtonThirdL.jac +0 -25
- jac_client/examples/nested-folders/nested-advance/package.json +0 -29
- jac_client/examples/nested-folders/nested-advance/vite.config.js +0 -28
- jac_client/examples/nested-folders/nested-basic/.babelrc +0 -9
- jac_client/examples/nested-folders/nested-basic/README.md +0 -183
- jac_client/examples/nested-folders/nested-basic/app.jac +0 -13
- jac_client/examples/nested-folders/nested-basic/app.js +0 -7
- jac_client/examples/nested-folders/nested-basic/button.jac +0 -7
- jac_client/examples/nested-folders/nested-basic/components/button.jac +0 -7
- jac_client/examples/nested-folders/nested-basic/package.json +0 -28
- jac_client/examples/nested-folders/nested-basic/vite.config.js +0 -27
- jac_client/examples/with-router/.babelrc +0 -9
- jac_client/examples/with-router/README.md +0 -17
- jac_client/examples/with-router/app.jac +0 -323
- jac_client/examples/with-router/package.json +0 -28
- jac_client/examples/with-router/vite.config.js +0 -27
- jac_client/plugin/cli.py +0 -244
- jac_client/plugin/client.py +0 -152
- jac_client/plugin/client_runtime.jac +0 -234
- jac_client/plugin/vite_client_bundle.py +0 -503
- jac_client/tests/fixtures/basic-app/app.jac +0 -23
- jac_client/tests/fixtures/cl_file/app.cl.jac +0 -48
- jac_client/tests/fixtures/cl_file/app.jac +0 -15
- jac_client/tests/fixtures/client_app_with_antd/app.jac +0 -34
- jac_client/tests/fixtures/js_import/app.jac +0 -34
- jac_client/tests/fixtures/js_import/utils.js +0 -21
- jac_client/tests/fixtures/package-lock.json +0 -329
- jac_client/tests/fixtures/package.json +0 -11
- jac_client/tests/fixtures/relative_import/app.jac +0 -11
- jac_client/tests/fixtures/relative_import/button.jac +0 -7
- jac_client/tests/fixtures/spawn_test/app.jac +0 -129
- jac_client/tests/fixtures/test_fragments_spread/app.jac +0 -67
- jac_client/tests/test_asset_examples.py +0 -322
- jac_client/tests/test_cl.py +0 -530
- jac_client/tests/test_create_jac_app.py +0 -131
- jac_client/tests/test_nested_file.py +0 -374
- jac_client-0.2.2.dist-info/RECORD +0 -171
- jac_client-0.2.2.dist-info/entry_points.txt +0 -4
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "littlex-vite-bundler",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Vite bundler for LittleX Jac application",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "vite build"
|
|
8
|
-
},
|
|
9
|
-
"devDependencies": {
|
|
10
|
-
"vite": "^5.0.0"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"antd": "^5.27.6",
|
|
14
|
-
"bootstrap": "^5.3.8",
|
|
15
|
-
"lodash": "^4.17.21",
|
|
16
|
-
"pluralize": "^8.0.0",
|
|
17
|
-
"precise-ui": "^2.1.17",
|
|
18
|
-
"react": "^18.2.0",
|
|
19
|
-
"react-animated-components": "^3.0.1",
|
|
20
|
-
"react-bootstrap": "^2.10.10",
|
|
21
|
-
"react-dom": "^18.2.0"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# Nested Folder Levels Example
|
|
2
|
-
|
|
3
|
-
This example demonstrates multiple levels of folder nesting and how relative imports work across different directory levels.
|
|
4
|
-
|
|
5
|
-
## Project Structure
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
nested-advance/
|
|
9
|
-
├── app.jac # Root entry point
|
|
10
|
-
├── ButtonRoot.jac # Root level button
|
|
11
|
-
└── level1/
|
|
12
|
-
├── ButtonSecondL.jac # Second level button
|
|
13
|
-
├── Card.jac # Card component (imports from root and level2)
|
|
14
|
-
└── level2/
|
|
15
|
-
└── ButtonThirdL.jac # Third level button
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Import Patterns Demonstrated
|
|
19
|
-
|
|
20
|
-
### 1. Root Level (`app.jac`)
|
|
21
|
-
```jac
|
|
22
|
-
# Import from root
|
|
23
|
-
cl import from .ButtonRoot { ButtonRoot }
|
|
24
|
-
|
|
25
|
-
# Import from level1
|
|
26
|
-
cl import from .level1.ButtonSecondL { ButtonSecondL }
|
|
27
|
-
|
|
28
|
-
# Import from level1/level2
|
|
29
|
-
cl import from .level1.level2.ButtonThirdL { ButtonThirdL }
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### 2. Second Level (`level1/ButtonSecondL.jac`)
|
|
33
|
-
```jac
|
|
34
|
-
# Import from root (go up one level with ..)
|
|
35
|
-
cl import from ..ButtonRoot { ButtonRoot }
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### 3. Card Component (`level1/Card.jac`)
|
|
39
|
-
This demonstrates importing from both above and below:
|
|
40
|
-
```jac
|
|
41
|
-
# Import from root (go up two levels with ..)
|
|
42
|
-
cl import from ..ButtonRoot { ButtonRoot }
|
|
43
|
-
|
|
44
|
-
# Import from level2 (go down one level with .level2)
|
|
45
|
-
cl import from .level2.ButtonThirdL { ButtonThirdL }
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### 4. Third Level (`level1/level2/ButtonThirdL.jac`)
|
|
49
|
-
```jac
|
|
50
|
-
# Import from root (go up three levels with ...)
|
|
51
|
-
cl import from ...ButtonRoot { ButtonRoot }
|
|
52
|
-
|
|
53
|
-
# Import from second level (go up one level with ..)
|
|
54
|
-
cl import from ..ButtonSecondL { ButtonSecondL }
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Running the Example
|
|
58
|
-
|
|
59
|
-
Make sure node modules are installed:
|
|
60
|
-
```bash
|
|
61
|
-
npm install
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
To run your Jac code, use the Jac CLI:
|
|
65
|
-
```bash
|
|
66
|
-
jac serve app.jac
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Key Concepts
|
|
70
|
-
|
|
71
|
-
- **Single dot (`.`)** - Current directory
|
|
72
|
-
- **Double dot (`..`)** - Parent directory (one level up)
|
|
73
|
-
- **Triple dot (`...`)** - Two levels up
|
|
74
|
-
- **Multiple dots** - Continue going up the directory tree
|
|
75
|
-
- **Dot notation after dots** - Go down into subdirectories (e.g., `.level2`)
|
|
76
|
-
|
|
77
|
-
This example shows how folder structure is preserved during compilation, ensuring all relative imports work correctly!
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# Nested Folder Levels Example
|
|
2
|
-
cl import from .ButtonRoot { ButtonRoot }
|
|
3
|
-
cl import from .level1.ButtonSecondL { ButtonSecondL }
|
|
4
|
-
cl import from .level1.level2.ButtonThirdL { ButtonThirdL }
|
|
5
|
-
cl import from .level1.Card { Card }
|
|
6
|
-
|
|
7
|
-
cl def app() -> any {
|
|
8
|
-
return <div
|
|
9
|
-
style={{padding: "20px"}}
|
|
10
|
-
>
|
|
11
|
-
<h1>
|
|
12
|
-
Nested Folder Levels Demo
|
|
13
|
-
</h1>
|
|
14
|
-
<div
|
|
15
|
-
style={{margin: "10px 0"}}
|
|
16
|
-
>
|
|
17
|
-
<ButtonRoot />
|
|
18
|
-
</div>
|
|
19
|
-
<div
|
|
20
|
-
style={{margin: "10px 0"}}
|
|
21
|
-
>
|
|
22
|
-
<ButtonSecondL />
|
|
23
|
-
</div>
|
|
24
|
-
<div
|
|
25
|
-
style={{margin: "10px 0"}}
|
|
26
|
-
>
|
|
27
|
-
<ButtonThirdL />
|
|
28
|
-
</div>
|
|
29
|
-
<div
|
|
30
|
-
style={{margin: "10px 0"}}
|
|
31
|
-
>
|
|
32
|
-
<Card />
|
|
33
|
-
</div>
|
|
34
|
-
</div>;
|
|
35
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Second Level Button (level1/)
|
|
2
|
-
cl import from antd { Button }
|
|
3
|
-
cl import from ..ButtonRoot { ButtonRoot }
|
|
4
|
-
|
|
5
|
-
cl def ButtonSecondL() -> any {
|
|
6
|
-
return <div>
|
|
7
|
-
<Button
|
|
8
|
-
type="default"
|
|
9
|
-
size="large"
|
|
10
|
-
>
|
|
11
|
-
Second Level Button (imports from root)
|
|
12
|
-
</Button>
|
|
13
|
-
<div
|
|
14
|
-
style={{marginTop: "10px"}}
|
|
15
|
-
>
|
|
16
|
-
<ButtonRoot />
|
|
17
|
-
</div>
|
|
18
|
-
</div>;
|
|
19
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# Card Component on Second Level
|
|
2
|
-
# Imports from both above (root) and below (level2)
|
|
3
|
-
cl import from ..ButtonRoot {
|
|
4
|
-
ButtonRoot
|
|
5
|
-
}
|
|
6
|
-
cl import from .level2.ButtonThirdL { ButtonThirdL }
|
|
7
|
-
|
|
8
|
-
cl def Card() -> any {
|
|
9
|
-
return <div
|
|
10
|
-
style={{
|
|
11
|
-
border: "2px solid #007bff",
|
|
12
|
-
borderRadius: "8px",
|
|
13
|
-
padding: "20px",
|
|
14
|
-
margin: "10px 0",
|
|
15
|
-
backgroundColor: "#f8f9fa"
|
|
16
|
-
}}
|
|
17
|
-
>
|
|
18
|
-
<h3>
|
|
19
|
-
Card Component (Second Level)
|
|
20
|
-
</h3>
|
|
21
|
-
<p>
|
|
22
|
-
This card imports from:
|
|
23
|
-
</p>
|
|
24
|
-
<ul>
|
|
25
|
-
<li>
|
|
26
|
-
Root level: ButtonRoot (using ..)
|
|
27
|
-
</li>
|
|
28
|
-
<li>
|
|
29
|
-
Third level: ButtonThirdL (using .level2)
|
|
30
|
-
</li>
|
|
31
|
-
</ul>
|
|
32
|
-
<div
|
|
33
|
-
style={{marginTop: "15px"}}
|
|
34
|
-
>
|
|
35
|
-
<ButtonRoot />
|
|
36
|
-
</div>
|
|
37
|
-
<div
|
|
38
|
-
style={{marginTop: "10px"}}
|
|
39
|
-
>
|
|
40
|
-
<ButtonThirdL />
|
|
41
|
-
</div>
|
|
42
|
-
</div>;
|
|
43
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Third Level Button (level1/level2/)
|
|
2
|
-
cl import from antd { Button }
|
|
3
|
-
cl import from ...ButtonRoot { ButtonRoot }
|
|
4
|
-
cl import from ..ButtonSecondL { ButtonSecondL }
|
|
5
|
-
|
|
6
|
-
cl def ButtonThirdL() -> any {
|
|
7
|
-
return <div>
|
|
8
|
-
<Button
|
|
9
|
-
type="dashed"
|
|
10
|
-
size="large"
|
|
11
|
-
>
|
|
12
|
-
Third Level Button (imports from root and second level)
|
|
13
|
-
</Button>
|
|
14
|
-
<div
|
|
15
|
-
style={{marginTop: "10px"}}
|
|
16
|
-
>
|
|
17
|
-
<ButtonRoot />
|
|
18
|
-
</div>
|
|
19
|
-
<div
|
|
20
|
-
style={{marginTop: "10px"}}
|
|
21
|
-
>
|
|
22
|
-
<ButtonSecondL />
|
|
23
|
-
</div>
|
|
24
|
-
</div>;
|
|
25
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "nested-advance",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "npm run compile && vite build",
|
|
7
|
-
"dev": "vite dev",
|
|
8
|
-
"preview": "vite preview",
|
|
9
|
-
"compile": "babel src --out-dir build --extensions \".jsx,.js\" --out-file-extension .js"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [],
|
|
12
|
-
"author": "",
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"description": "Jac application: nested-advance",
|
|
15
|
-
"type": "module",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@babel/cli": "^7.28.3",
|
|
18
|
-
"@babel/core": "^7.28.5",
|
|
19
|
-
"@babel/preset-env": "^7.28.5",
|
|
20
|
-
"@babel/preset-react": "^7.28.5",
|
|
21
|
-
"vite": "^6.4.1"
|
|
22
|
-
},
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"antd": "^6.0.0",
|
|
25
|
-
"react": "^19.2.0",
|
|
26
|
-
"react-dom": "^19.2.0",
|
|
27
|
-
"react-router-dom": "^6.30.1"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineConfig } from "vite";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
|
-
|
|
6
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
|
-
export default defineConfig({
|
|
9
|
-
root: ".", // base folder
|
|
10
|
-
build: {
|
|
11
|
-
rollupOptions: {
|
|
12
|
-
input: "build/main.js", // your compiled entry file
|
|
13
|
-
output: {
|
|
14
|
-
entryFileNames: "client.[hash].js", // name of the final js file
|
|
15
|
-
assetFileNames: "[name].[ext]",
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
outDir: "dist", // final bundled output
|
|
19
|
-
emptyOutDir: true,
|
|
20
|
-
},
|
|
21
|
-
publicDir: false,
|
|
22
|
-
resolve: {
|
|
23
|
-
alias: {
|
|
24
|
-
"@jac-client/utils": path.resolve(__dirname, "src/client_runtime.js"),
|
|
25
|
-
"@jac-client/assets": path.resolve(__dirname, "src/assets"),
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
});
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
# JavaScript Styling Example
|
|
2
|
-
|
|
3
|
-
This example demonstrates styling a Jac application using JavaScript objects for inline styles.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
JavaScript styling uses JavaScript objects to define styles, which are then applied via the `style` prop. This approach is perfect for:
|
|
8
|
-
- Dynamic styling based on state
|
|
9
|
-
- Programmatic style generation
|
|
10
|
-
- Component-scoped styles without CSS files
|
|
11
|
-
- React-style inline styling
|
|
12
|
-
|
|
13
|
-
## Project Structure
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
js-styling/
|
|
17
|
-
├── app.jac # Main application component
|
|
18
|
-
├── styles.js # Style objects exported as default
|
|
19
|
-
├── package.json # Dependencies
|
|
20
|
-
└── vite.config.js # Vite configuration
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Setup
|
|
24
|
-
|
|
25
|
-
1. Install dependencies:
|
|
26
|
-
```bash
|
|
27
|
-
npm install
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
2. Run the application:
|
|
31
|
-
```bash
|
|
32
|
-
jac serve app.jac
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## How It Works
|
|
36
|
-
|
|
37
|
-
### 1. Define Style Objects
|
|
38
|
-
|
|
39
|
-
In `styles.js`, export a default object with all styles:
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
const countDisplay = {
|
|
43
|
-
fontSize: "3.75rem",
|
|
44
|
-
fontWeight: "bold",
|
|
45
|
-
transition: "color 0.3s ease"
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export default {
|
|
49
|
-
container: {
|
|
50
|
-
minHeight: "100vh",
|
|
51
|
-
background: "linear-gradient(to bottom right, #dbeafe, #e0e7ff)",
|
|
52
|
-
display: "flex",
|
|
53
|
-
alignItems: "center",
|
|
54
|
-
justifyContent: "center",
|
|
55
|
-
padding: "1rem"
|
|
56
|
-
},
|
|
57
|
-
card: {
|
|
58
|
-
backgroundColor: "#ffffff",
|
|
59
|
-
borderRadius: "1rem",
|
|
60
|
-
boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
|
61
|
-
padding: "2rem",
|
|
62
|
-
maxWidth: "28rem",
|
|
63
|
-
width: "100%"
|
|
64
|
-
},
|
|
65
|
-
countDisplayZero: {
|
|
66
|
-
...countDisplay,
|
|
67
|
-
color: "#1f2937"
|
|
68
|
-
},
|
|
69
|
-
countDisplayPositive: {
|
|
70
|
-
...countDisplay,
|
|
71
|
-
color: "#16a34a"
|
|
72
|
-
},
|
|
73
|
-
// ... more styles
|
|
74
|
-
};
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### 2. Import Styles
|
|
78
|
-
|
|
79
|
-
In your Jac file:
|
|
80
|
-
|
|
81
|
-
```jac
|
|
82
|
-
cl import from .styles { default as styles }
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### 3. Apply Styles
|
|
86
|
-
|
|
87
|
-
Use the `style` prop with style objects:
|
|
88
|
-
|
|
89
|
-
```jac
|
|
90
|
-
return <div style={styles.container}>
|
|
91
|
-
<div style={styles.card}>
|
|
92
|
-
<h1 style={styles.title}>Counter Application</h1>
|
|
93
|
-
</div>
|
|
94
|
-
</div>;
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### 4. Dynamic Styles
|
|
98
|
-
|
|
99
|
-
Select styles based on state:
|
|
100
|
-
|
|
101
|
-
```jac
|
|
102
|
-
let countStyle = styles.countDisplayZero if count == 0 else (styles.countDisplayPositive if count > 0 else styles.countDisplayNegative);
|
|
103
|
-
|
|
104
|
-
return <div style={countStyle}>{count}</div>;
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## Style Object Format
|
|
108
|
-
|
|
109
|
-
JavaScript style objects use camelCase property names (React convention):
|
|
110
|
-
|
|
111
|
-
```javascript
|
|
112
|
-
{
|
|
113
|
-
backgroundColor: "#ffffff", // not background-color
|
|
114
|
-
fontSize: "1.5rem", // not font-size
|
|
115
|
-
marginTop: "10px", // not margin-top
|
|
116
|
-
zIndex: 1 // not z-index
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Best Practices
|
|
121
|
-
|
|
122
|
-
1. **Use object spread**: Share common styles with spread operator
|
|
123
|
-
2. **Organize by component**: Group related styles together
|
|
124
|
-
3. **Use constants**: Define reusable values at the top
|
|
125
|
-
4. **CamelCase properties**: Follow React naming convention
|
|
126
|
-
5. **Extract complex logic**: Move style calculations to functions
|
|
127
|
-
|
|
128
|
-
## Advantages
|
|
129
|
-
|
|
130
|
-
- ✅ Dynamic styling based on props/state
|
|
131
|
-
- ✅ No CSS file needed
|
|
132
|
-
- ✅ Type-safe (with TypeScript)
|
|
133
|
-
- ✅ Component-scoped by default
|
|
134
|
-
- ✅ Programmatic style generation
|
|
135
|
-
|
|
136
|
-
## Limitations
|
|
137
|
-
|
|
138
|
-
- ❌ No pseudo-classes (hover, focus, etc.)
|
|
139
|
-
- ❌ No media queries
|
|
140
|
-
- ❌ No CSS animations (use JavaScript)
|
|
141
|
-
- ❌ Verbose for complex styles
|
|
142
|
-
- ❌ No CSS preprocessor features
|
|
143
|
-
|
|
144
|
-
## When to Use
|
|
145
|
-
|
|
146
|
-
Choose JavaScript Styling when:
|
|
147
|
-
- You need dynamic styles based on state
|
|
148
|
-
- You want programmatic style generation
|
|
149
|
-
- You prefer keeping styles in JavaScript
|
|
150
|
-
- You're building component libraries
|
|
151
|
-
- You need runtime style calculations
|
|
152
|
-
|
|
153
|
-
## Advanced Patterns
|
|
154
|
-
|
|
155
|
-
### Style Functions
|
|
156
|
-
|
|
157
|
-
Create functions that return styles:
|
|
158
|
-
|
|
159
|
-
```javascript
|
|
160
|
-
export const getButtonStyle = (variant) => ({
|
|
161
|
-
...buttonBase,
|
|
162
|
-
backgroundColor: variant === 'primary' ? '#007bff' : '#6c757d'
|
|
163
|
-
});
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Conditional Styles
|
|
167
|
-
|
|
168
|
-
Use ternary operators for conditional styles:
|
|
169
|
-
|
|
170
|
-
```javascript
|
|
171
|
-
export default {
|
|
172
|
-
button: {
|
|
173
|
-
backgroundColor: isActive ? '#007bff' : '#6c757d',
|
|
174
|
-
opacity: isDisabled ? 0.5 : 1,
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Next Steps
|
|
180
|
-
|
|
181
|
-
- Explore [Styled Components](../styled-components/) for CSS-in-JS with more features
|
|
182
|
-
- Check out [Emotion](../emotion-example/) for similar CSS-in-JS approach (coming soon)
|
|
183
|
-
- Learn about [CSS Modules](../css-modules/) for scoped CSS (coming soon)
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
cl import from .components.button { CustomButton }
|
|
2
|
-
cl import from .button { CustomButtonRoot }
|
|
3
|
-
|
|
4
|
-
cl def RelativeImport() -> any {
|
|
5
|
-
return <div>
|
|
6
|
-
<CustomButton />
|
|
7
|
-
<CustomButtonRoot />
|
|
8
|
-
</div>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
cl def app() -> any {
|
|
12
|
-
return <RelativeImport />;
|
|
13
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "bootstrap-example",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "npm run compile && vite build",
|
|
7
|
-
"dev": "vite dev",
|
|
8
|
-
"preview": "vite preview",
|
|
9
|
-
"compile": "babel src --out-dir build --extensions \".jsx,.js\" --out-file-extension .js"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [],
|
|
12
|
-
"author": "",
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"description": "Jac application: bootstrap-example",
|
|
15
|
-
"type": "module",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@babel/cli": "^7.28.3",
|
|
18
|
-
"@babel/core": "^7.28.5",
|
|
19
|
-
"@babel/preset-env": "^7.28.5",
|
|
20
|
-
"@babel/preset-react": "^7.28.5",
|
|
21
|
-
"vite": "^6.4.1"
|
|
22
|
-
},
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"react": "^19.2.0",
|
|
25
|
-
"react-dom": "^19.2.0",
|
|
26
|
-
"react-router-dom": "^6.30.1"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineConfig } from "vite";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
|
-
|
|
6
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
|
-
export default defineConfig({
|
|
9
|
-
root: ".", // base folder
|
|
10
|
-
build: {
|
|
11
|
-
rollupOptions: {
|
|
12
|
-
input: "build/main.js", // your compiled entry file
|
|
13
|
-
output: {
|
|
14
|
-
entryFileNames: "client.[hash].js", // name of the final js file
|
|
15
|
-
assetFileNames: "[name].[ext]",
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
outDir: "dist", // final bundled output
|
|
19
|
-
emptyOutDir: true,
|
|
20
|
-
},
|
|
21
|
-
publicDir: false,
|
|
22
|
-
resolve: {
|
|
23
|
-
alias: {
|
|
24
|
-
"@jac-client/utils": path.resolve(__dirname, "src/client_runtime.js"),
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
});
|