jac-client 0.2.0__py3-none-any.whl → 0.2.2__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/docs/README.md +50 -20
- jac_client/docs/advanced-state.md +13 -14
- jac_client/docs/asset-serving/intro.md +209 -0
- jac_client/docs/assets/pipe_line-v2.svg +32 -0
- jac_client/docs/file-system/app.jac.md +121 -0
- jac_client/docs/file-system/backend-frontend.md +217 -0
- jac_client/docs/file-system/intro.md +72 -0
- jac_client/docs/file-system/nested-imports.md +348 -0
- jac_client/docs/guide-example/intro.md +11 -13
- jac_client/docs/guide-example/step-01-setup.md +30 -20
- jac_client/docs/guide-example/step-02-components.md +24 -24
- jac_client/docs/guide-example/step-03-styling.md +24 -24
- jac_client/docs/guide-example/step-04-todo-ui.md +17 -17
- jac_client/docs/guide-example/step-05-local-state.md +23 -23
- jac_client/docs/guide-example/step-06-events.md +23 -24
- jac_client/docs/guide-example/step-07-effects.md +27 -28
- jac_client/docs/guide-example/step-08-walkers.md +23 -23
- jac_client/docs/guide-example/step-09-authentication.md +18 -18
- jac_client/docs/guide-example/step-10-routing.md +20 -21
- jac_client/docs/guide-example/step-11-final.md +34 -35
- jac_client/docs/imports.md +4 -5
- jac_client/docs/lifecycle-hooks.md +12 -13
- jac_client/docs/routing.md +21 -22
- jac_client/docs/styling/intro.md +249 -0
- jac_client/docs/styling/js-styling.md +367 -0
- jac_client/docs/styling/material-ui.md +341 -0
- jac_client/docs/styling/pure-css.md +299 -0
- jac_client/docs/styling/sass.md +403 -0
- jac_client/docs/styling/styled-components.md +395 -0
- jac_client/docs/styling/tailwind.md +298 -0
- jac_client/examples/all-in-one/.babelrc +9 -0
- jac_client/examples/all-in-one/README.md +16 -0
- jac_client/examples/all-in-one/app.jac +426 -0
- jac_client/examples/all-in-one/assets/burger.png +0 -0
- jac_client/examples/all-in-one/button.jac +7 -0
- jac_client/examples/all-in-one/components/button.jac +7 -0
- jac_client/examples/all-in-one/package.json +29 -0
- jac_client/examples/all-in-one/styles.css +26 -0
- jac_client/examples/all-in-one/vite.config.js +28 -0
- jac_client/examples/asset-serving/css-with-image/.babelrc +9 -0
- jac_client/examples/asset-serving/css-with-image/README.md +91 -0
- jac_client/examples/asset-serving/css-with-image/app.jac +88 -0
- jac_client/examples/asset-serving/css-with-image/assets/burger.png +0 -0
- jac_client/examples/asset-serving/css-with-image/package.json +28 -0
- jac_client/examples/asset-serving/css-with-image/styles.css +26 -0
- jac_client/examples/asset-serving/css-with-image/vite.config.js +28 -0
- jac_client/examples/asset-serving/image-asset/.babelrc +9 -0
- jac_client/examples/asset-serving/image-asset/README.md +119 -0
- jac_client/examples/asset-serving/image-asset/app.jac +55 -0
- jac_client/examples/asset-serving/image-asset/assets/burger.png +0 -0
- jac_client/examples/asset-serving/image-asset/package.json +28 -0
- jac_client/examples/asset-serving/image-asset/styles.css +26 -0
- jac_client/examples/asset-serving/image-asset/vite.config.js +28 -0
- jac_client/examples/asset-serving/import-alias/.babelrc +9 -0
- jac_client/examples/asset-serving/import-alias/README.md +83 -0
- jac_client/examples/asset-serving/import-alias/app.jac +111 -0
- jac_client/examples/asset-serving/import-alias/assets/burger.png +0 -0
- jac_client/examples/asset-serving/import-alias/package.json +28 -0
- jac_client/examples/asset-serving/import-alias/vite.config.js +28 -0
- jac_client/examples/basic/app.jac +14 -9
- jac_client/examples/basic/package.json +1 -1
- jac_client/examples/basic/vite.config.js +0 -1
- jac_client/examples/basic-auth/package.json +1 -1
- jac_client/examples/basic-auth/vite.config.js +0 -1
- jac_client/examples/basic-auth-with-router/package.json +1 -1
- jac_client/examples/basic-auth-with-router/vite.config.js +0 -1
- jac_client/examples/basic-full-stack/package.json +1 -1
- jac_client/examples/basic-full-stack/vite.config.js +0 -1
- jac_client/examples/css-styling/js-styling/.babelrc +9 -0
- jac_client/examples/css-styling/js-styling/README.md +183 -0
- jac_client/examples/css-styling/js-styling/app.jac +84 -0
- jac_client/examples/css-styling/js-styling/package.json +28 -0
- jac_client/examples/css-styling/js-styling/styles.js +100 -0
- jac_client/examples/css-styling/js-styling/vite.config.js +27 -0
- jac_client/examples/css-styling/material-ui/.babelrc +9 -0
- jac_client/examples/css-styling/material-ui/README.md +16 -0
- jac_client/examples/css-styling/material-ui/app.jac +122 -0
- jac_client/examples/css-styling/material-ui/package.json +32 -0
- jac_client/examples/css-styling/material-ui/vite.config.js +27 -0
- jac_client/examples/css-styling/pure-css/.babelrc +9 -0
- jac_client/examples/css-styling/pure-css/README.md +16 -0
- jac_client/examples/css-styling/pure-css/app.jac +64 -0
- jac_client/examples/css-styling/pure-css/package.json +28 -0
- jac_client/examples/css-styling/pure-css/styles.css +111 -0
- jac_client/examples/css-styling/pure-css/vite.config.js +27 -0
- jac_client/examples/css-styling/sass-example/.babelrc +9 -0
- jac_client/examples/css-styling/sass-example/README.md +16 -0
- jac_client/examples/css-styling/sass-example/app.jac +64 -0
- jac_client/examples/css-styling/sass-example/package.json +29 -0
- jac_client/examples/css-styling/sass-example/styles.scss +153 -0
- jac_client/examples/css-styling/sass-example/vite.config.js +27 -0
- jac_client/examples/css-styling/styled-components/.babelrc +9 -0
- jac_client/examples/css-styling/styled-components/README.md +16 -0
- jac_client/examples/css-styling/styled-components/app.jac +71 -0
- jac_client/examples/css-styling/styled-components/package.json +29 -0
- jac_client/examples/css-styling/styled-components/styled.js +90 -0
- jac_client/examples/css-styling/styled-components/vite.config.js +27 -0
- jac_client/examples/css-styling/tailwind-example/.babelrc +9 -0
- jac_client/examples/css-styling/tailwind-example/README.md +16 -0
- jac_client/examples/css-styling/tailwind-example/app.jac +63 -0
- jac_client/examples/css-styling/tailwind-example/global.css +1 -0
- jac_client/examples/css-styling/tailwind-example/package.json +30 -0
- jac_client/examples/css-styling/tailwind-example/vite.config.js +29 -0
- jac_client/examples/full-stack-with-auth/app.jac +20 -33
- jac_client/examples/full-stack-with-auth/package.json +1 -1
- jac_client/examples/full-stack-with-auth/vite.config.js +0 -1
- jac_client/examples/little-x/app.jac +327 -218
- jac_client/examples/little-x/submit-button.jac +1 -1
- jac_client/examples/nested-folders/nested-advance/.babelrc +9 -0
- jac_client/examples/nested-folders/nested-advance/ButtonRoot.jac +11 -0
- jac_client/examples/nested-folders/nested-advance/README.md +77 -0
- jac_client/examples/nested-folders/nested-advance/app.jac +35 -0
- jac_client/examples/nested-folders/nested-advance/level1/ButtonSecondL.jac +19 -0
- jac_client/examples/nested-folders/nested-advance/level1/Card.jac +43 -0
- jac_client/examples/nested-folders/nested-advance/level1/level2/ButtonThirdL.jac +25 -0
- jac_client/examples/nested-folders/nested-advance/package.json +29 -0
- jac_client/examples/nested-folders/nested-advance/vite.config.js +28 -0
- jac_client/examples/nested-folders/nested-basic/.babelrc +9 -0
- jac_client/examples/nested-folders/nested-basic/README.md +183 -0
- jac_client/examples/nested-folders/nested-basic/app.jac +13 -0
- jac_client/examples/nested-folders/nested-basic/app.js +7 -0
- jac_client/examples/nested-folders/nested-basic/button.jac +7 -0
- jac_client/examples/nested-folders/nested-basic/components/button.jac +7 -0
- jac_client/examples/nested-folders/nested-basic/package.json +28 -0
- jac_client/examples/nested-folders/nested-basic/vite.config.js +27 -0
- jac_client/examples/with-router/app.jac +1 -1
- jac_client/examples/with-router/package.json +1 -1
- jac_client/examples/with-router/vite.config.js +0 -1
- jac_client/plugin/cli.py +7 -2
- jac_client/plugin/client.py +68 -5
- jac_client/plugin/client_runtime.jac +1 -1
- jac_client/plugin/vite_client_bundle.py +162 -14
- jac_client/tests/__init__.py +0 -1
- jac_client/tests/fixtures/basic-app/app.jac +7 -2
- jac_client/tests/fixtures/cl_file/app.cl.jac +48 -0
- jac_client/tests/fixtures/cl_file/app.jac +15 -0
- jac_client/tests/fixtures/client_app_with_antd/app.jac +14 -8
- jac_client/tests/fixtures/js_import/app.jac +19 -15
- jac_client/tests/fixtures/js_import/utils.js +0 -1
- jac_client/tests/fixtures/package.json +1 -1
- jac_client/tests/fixtures/relative_import/app.jac +4 -6
- jac_client/tests/fixtures/relative_import/button.jac +7 -6
- jac_client/tests/fixtures/spawn_test/app.jac +1 -5
- jac_client/tests/fixtures/test_fragments_spread/app.jac +24 -10
- jac_client/tests/test_asset_examples.py +322 -0
- jac_client/tests/test_cl.py +480 -426
- jac_client/tests/test_create_jac_app.py +125 -133
- jac_client/tests/test_it.py +329 -0
- jac_client/tests/test_nested_file.py +374 -0
- {jac_client-0.2.0.dist-info → jac_client-0.2.2.dist-info}/METADATA +2 -2
- jac_client-0.2.2.dist-info/RECORD +171 -0
- jac_client-0.2.0.dist-info/RECORD +0 -72
- {jac_client-0.2.0.dist-info → jac_client-0.2.2.dist-info}/WHEEL +0 -0
- {jac_client-0.2.0.dist-info → jac_client-0.2.2.dist-info}/entry_points.txt +0 -0
jac_client/docs/routing.md
CHANGED
|
@@ -4,7 +4,7 @@ Learn how to create multi-page applications with client-side routing using Jac's
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Table of Contents
|
|
8
8
|
|
|
9
9
|
- [What is Routing?](#what-is-routing)
|
|
10
10
|
- [Getting Started](#getting-started)
|
|
@@ -77,21 +77,21 @@ cl {
|
|
|
77
77
|
# Page Components
|
|
78
78
|
def Home() -> any {
|
|
79
79
|
return <div>
|
|
80
|
-
<h1
|
|
80
|
+
<h1> Home Page</h1>
|
|
81
81
|
<p>Welcome to the home page!</p>
|
|
82
82
|
</div>;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
def About() -> any {
|
|
86
86
|
return <div>
|
|
87
|
-
<h1
|
|
87
|
+
<h1>ℹ About Page</h1>
|
|
88
88
|
<p>Learn more about our application.</p>
|
|
89
89
|
</div>;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
def Contact() -> any {
|
|
93
93
|
return <div>
|
|
94
|
-
<h1
|
|
94
|
+
<h1> Contact Page</h1>
|
|
95
95
|
<p>Email: contact@example.com</p>
|
|
96
96
|
</div>;
|
|
97
97
|
}
|
|
@@ -126,9 +126,9 @@ cl {
|
|
|
126
126
|
5. URLs will be hash-based: `#/`, `#/about`, `#/contact`
|
|
127
127
|
|
|
128
128
|
**Key Points:**
|
|
129
|
-
-
|
|
130
|
-
-
|
|
131
|
-
-
|
|
129
|
+
- Use `element={<Home />}` to render components
|
|
130
|
+
- No configuration needed - just wrap and go
|
|
131
|
+
- Hash-based URLs work everywhere
|
|
132
132
|
|
|
133
133
|
---
|
|
134
134
|
|
|
@@ -397,7 +397,7 @@ cl {
|
|
|
397
397
|
}
|
|
398
398
|
|
|
399
399
|
return <div>
|
|
400
|
-
<h1
|
|
400
|
+
<h1> Dashboard</h1>
|
|
401
401
|
<p>Welcome! You are logged in.</p>
|
|
402
402
|
<p>This is protected content only visible to authenticated users.</p>
|
|
403
403
|
</div>;
|
|
@@ -475,21 +475,21 @@ cl {
|
|
|
475
475
|
|
|
476
476
|
def Home() -> any {
|
|
477
477
|
return <div>
|
|
478
|
-
<h1
|
|
478
|
+
<h1> Home Page</h1>
|
|
479
479
|
<p>Welcome to the home page!</p>
|
|
480
480
|
</div>;
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
def About() -> any {
|
|
484
484
|
return <div>
|
|
485
|
-
<h1
|
|
485
|
+
<h1>ℹ About Page</h1>
|
|
486
486
|
<p>Learn more about our application.</p>
|
|
487
487
|
</div>;
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
def Contact() -> any {
|
|
491
491
|
return <div>
|
|
492
|
-
<h1
|
|
492
|
+
<h1> Contact Page</h1>
|
|
493
493
|
<p>Email: contact@example.com</p>
|
|
494
494
|
</div>;
|
|
495
495
|
}
|
|
@@ -521,7 +521,7 @@ cl {
|
|
|
521
521
|
users = ["Alice", "Bob", "Charlie"];
|
|
522
522
|
|
|
523
523
|
return <div>
|
|
524
|
-
<h1
|
|
524
|
+
<h1> User List</h1>
|
|
525
525
|
{users.map(lambda user: any -> any {
|
|
526
526
|
return <div key={user}>
|
|
527
527
|
<Link to={"/user/" + user}>{user}</Link>
|
|
@@ -535,7 +535,7 @@ cl {
|
|
|
535
535
|
let username = params.id;
|
|
536
536
|
|
|
537
537
|
return <div>
|
|
538
|
-
<h1
|
|
538
|
+
<h1> Profile: {username}</h1>
|
|
539
539
|
<p>Viewing profile for {username}</p>
|
|
540
540
|
<Link to="/">← Back to User List</Link>
|
|
541
541
|
</div>;
|
|
@@ -558,10 +558,10 @@ cl {
|
|
|
558
558
|
|
|
559
559
|
### 1. **Use Correct Route Syntax**
|
|
560
560
|
```jac
|
|
561
|
-
#
|
|
561
|
+
# CORRECT - Use element prop with JSX
|
|
562
562
|
<Route path="/" element={<Home />} />
|
|
563
563
|
|
|
564
|
-
#
|
|
564
|
+
# WRONG - Don't pass component without JSX
|
|
565
565
|
<Route path="/" component={Home} />
|
|
566
566
|
```
|
|
567
567
|
|
|
@@ -581,19 +581,19 @@ cl import from "@jac-client/utils" {
|
|
|
581
581
|
|
|
582
582
|
### 3. **Use Hooks for Navigation**
|
|
583
583
|
```jac
|
|
584
|
-
#
|
|
584
|
+
# CORRECT - Use useNavigate hook
|
|
585
585
|
def MyComponent() -> any {
|
|
586
586
|
let navigate = useNavigate();
|
|
587
587
|
navigate("/dashboard");
|
|
588
588
|
}
|
|
589
589
|
|
|
590
|
-
#
|
|
590
|
+
# OLD - Global navigate() function (still works for backward compatibility)
|
|
591
591
|
navigate("/dashboard");
|
|
592
592
|
```
|
|
593
593
|
|
|
594
594
|
### 4. **Protected Routes Pattern**
|
|
595
595
|
```jac
|
|
596
|
-
#
|
|
596
|
+
# CORRECT - Check auth in component
|
|
597
597
|
def ProtectedPage() -> any {
|
|
598
598
|
if not jacIsLoggedIn() {
|
|
599
599
|
return <Navigate to="/login" />;
|
|
@@ -604,10 +604,10 @@ def ProtectedPage() -> any {
|
|
|
604
604
|
|
|
605
605
|
### 5. **Use Link for Navigation**
|
|
606
606
|
```jac
|
|
607
|
-
#
|
|
607
|
+
# CORRECT - Use Link component
|
|
608
608
|
<Link to="/about">About</Link>
|
|
609
609
|
|
|
610
|
-
#
|
|
610
|
+
# WRONG - Regular anchor tags cause page reload
|
|
611
611
|
<a href="#/about">About</a>
|
|
612
612
|
```
|
|
613
613
|
|
|
@@ -656,5 +656,4 @@ def Navigation() -> any {
|
|
|
656
656
|
- **No Configuration**: Just wrap your app in `<Router>` and start routing!
|
|
657
657
|
- **Production-ready**: Battle-tested routing for real applications
|
|
658
658
|
|
|
659
|
-
Routing in Jac is simple, powerful, and production-ready!
|
|
660
|
-
|
|
659
|
+
Routing in Jac is simple, powerful, and production-ready!
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# Styling in Jac
|
|
2
|
+
|
|
3
|
+
This guide covers all styling approaches available in Jac web applications. Each approach is demonstrated with a complete, working counter application example.
|
|
4
|
+
|
|
5
|
+
## Quick Navigation
|
|
6
|
+
|
|
7
|
+
### Available Examples
|
|
8
|
+
|
|
9
|
+
| Styling Approach | Documentation | Example Location |
|
|
10
|
+
|------------------|---------------|------------------|
|
|
11
|
+
| [**Pure CSS**](./pure-css.md) | Traditional CSS with external stylesheet | [`examples/css-styling/pure-css/`](../../examples/css-styling/pure-css/) |
|
|
12
|
+
| [**Tailwind CSS**](./tailwind.md) | Utility-first CSS framework | [`examples/css-styling/tailwind-example/`](../../examples/css-styling/tailwind-example/) |
|
|
13
|
+
| [**Sass/SCSS**](./sass.md) | CSS preprocessor with variables, mixins, nesting | [`examples/css-styling/sass-example/`](../../examples/css-styling/sass-example/) |
|
|
14
|
+
| [**Styled Components**](./styled-components.md) | CSS-in-JS with styled-components | [`examples/css-styling/styled-components/`](../../examples/css-styling/styled-components/) |
|
|
15
|
+
| [**JavaScript Styling**](./js-styling.md) | Inline styles using JavaScript objects | [`examples/css-styling/js-styling/`](../../examples/css-styling/js-styling/) |
|
|
16
|
+
| [**Material-UI**](./material-ui.md) | React component library with Material Design | [`examples/css-styling/material-ui/`](../../examples/css-styling/material-ui/) |
|
|
17
|
+
|
|
18
|
+
## Styling Approaches Overview
|
|
19
|
+
|
|
20
|
+
### Traditional CSS
|
|
21
|
+
- **Pure CSS** — Standard CSS with external stylesheets
|
|
22
|
+
- Maximum control, minimal dependencies
|
|
23
|
+
- Perfect for simple projects and learning
|
|
24
|
+
|
|
25
|
+
### CSS Preprocessors
|
|
26
|
+
- **Sass/SCSS** — Variables, nesting, mixins, and functions
|
|
27
|
+
- Better organization for large projects
|
|
28
|
+
- DRY principles with reusable code
|
|
29
|
+
|
|
30
|
+
### Utility-First CSS
|
|
31
|
+
- **Tailwind CSS** — On-demand utility classes
|
|
32
|
+
- Rapid UI development
|
|
33
|
+
- Consistent design system
|
|
34
|
+
|
|
35
|
+
### CSS-in-JS Libraries
|
|
36
|
+
- **Styled Components** — CSS-in-JS with template literals
|
|
37
|
+
- Component-scoped styles
|
|
38
|
+
- Dynamic styling with props
|
|
39
|
+
|
|
40
|
+
- **JavaScript Styling** — Inline styles using JavaScript objects
|
|
41
|
+
- Programmatic style generation
|
|
42
|
+
- Dynamic styles based on state
|
|
43
|
+
|
|
44
|
+
### Component Libraries
|
|
45
|
+
- **Material-UI** — Comprehensive React component library
|
|
46
|
+
- Pre-built, accessible components
|
|
47
|
+
- Material Design system
|
|
48
|
+
|
|
49
|
+
## Choosing the Right Approach
|
|
50
|
+
|
|
51
|
+
### Decision Matrix
|
|
52
|
+
|
|
53
|
+
| Approach | Complexity | Bundle Size | Runtime Cost | Best For |
|
|
54
|
+
|----------|-----------|-------------|--------------|----------|
|
|
55
|
+
| Pure CSS | Low | Small | None | Simple projects |
|
|
56
|
+
| Tailwind | Medium | Small* | None | Rapid development |
|
|
57
|
+
| Sass/SCSS | Medium | Small | None | Large projects |
|
|
58
|
+
| Styled Components | Medium | Medium | Medium | Component libraries |
|
|
59
|
+
| JavaScript Styling | Low | Small | Low | Dynamic styles |
|
|
60
|
+
| Material-UI | Low | Large | Low | Enterprise apps |
|
|
61
|
+
|
|
62
|
+
*Tailwind bundle size is small after purging unused classes.
|
|
63
|
+
|
|
64
|
+
### Quick Decision Guide
|
|
65
|
+
|
|
66
|
+
**Choose Pure CSS if**:
|
|
67
|
+
- Building a simple application
|
|
68
|
+
- Wanting minimal dependencies
|
|
69
|
+
- Learning CSS fundamentals
|
|
70
|
+
|
|
71
|
+
**Choose Tailwind CSS if**:
|
|
72
|
+
- Building modern UIs quickly
|
|
73
|
+
- Preferring utility classes
|
|
74
|
+
- Needing responsive design
|
|
75
|
+
|
|
76
|
+
**Choose Sass/SCSS if**:
|
|
77
|
+
- Working on large projects
|
|
78
|
+
- Needing variables and mixins
|
|
79
|
+
- Wanting better organization
|
|
80
|
+
|
|
81
|
+
**Choose Styled Components if**:
|
|
82
|
+
- Wanting component-scoped styles
|
|
83
|
+
- Needing dynamic styling
|
|
84
|
+
- Preferring CSS-in-JS
|
|
85
|
+
|
|
86
|
+
**Choose JavaScript Styling if**:
|
|
87
|
+
- Needing dynamic styles
|
|
88
|
+
- Preferring JavaScript
|
|
89
|
+
- Building component libraries
|
|
90
|
+
|
|
91
|
+
**Choose Material-UI if**:
|
|
92
|
+
- Wanting pre-built components
|
|
93
|
+
- Needing accessibility
|
|
94
|
+
- Preferring Material Design
|
|
95
|
+
|
|
96
|
+
## Import Syntax
|
|
97
|
+
|
|
98
|
+
All styling approaches use the `cl import` syntax for client-side imports:
|
|
99
|
+
|
|
100
|
+
### CSS Files
|
|
101
|
+
|
|
102
|
+
```jac
|
|
103
|
+
# Pure CSS
|
|
104
|
+
cl import ".styles.css";
|
|
105
|
+
|
|
106
|
+
# Sass/SCSS
|
|
107
|
+
cl import ".styles.scss";
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### JavaScript Modules
|
|
111
|
+
|
|
112
|
+
```jac
|
|
113
|
+
# Default export
|
|
114
|
+
cl import from .styles { default as styles }
|
|
115
|
+
|
|
116
|
+
# Named exports
|
|
117
|
+
cl import from .styled { Container, Card, Button }
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### External Packages
|
|
121
|
+
|
|
122
|
+
```jac
|
|
123
|
+
# Styled Components
|
|
124
|
+
cl import from "styled-components" { default as styled }
|
|
125
|
+
|
|
126
|
+
# Material-UI
|
|
127
|
+
cl import from "@mui/material/Button" { default as Button }
|
|
128
|
+
cl import from "@mui/icons-material/Add" { default as AddIcon }
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Running Examples
|
|
132
|
+
|
|
133
|
+
Each example is a complete, runnable project:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Navigate to example directory
|
|
137
|
+
cd jac_client/examples/css-styling/<example-name>
|
|
138
|
+
|
|
139
|
+
# Install dependencies
|
|
140
|
+
npm install
|
|
141
|
+
|
|
142
|
+
# Run the application
|
|
143
|
+
jac serve app.jac
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
## Best Practices
|
|
148
|
+
|
|
149
|
+
### General Styling
|
|
150
|
+
|
|
151
|
+
1. **Consistency**: Choose one approach per project
|
|
152
|
+
2. **Performance**: Consider bundle size and runtime cost
|
|
153
|
+
3. **Maintainability**: Keep styles organized and documented
|
|
154
|
+
4. **Accessibility**: Ensure styles don't break accessibility
|
|
155
|
+
5. **Responsive**: Design mobile-first
|
|
156
|
+
|
|
157
|
+
### CSS Files
|
|
158
|
+
|
|
159
|
+
1. **Organization**: Use comments to separate sections
|
|
160
|
+
2. **Naming**: Use semantic class names (BEM, etc.)
|
|
161
|
+
3. **Specificity**: Avoid overly specific selectors
|
|
162
|
+
4. **Variables**: Use CSS custom properties for theming
|
|
163
|
+
|
|
164
|
+
### CSS-in-JS
|
|
165
|
+
|
|
166
|
+
1. **Scoping**: Leverage component-scoped styles
|
|
167
|
+
2. **Performance**: Memoize expensive styled components
|
|
168
|
+
3. **Theming**: Use theme providers for global styles
|
|
169
|
+
4. **Props**: Keep prop-based styling simple
|
|
170
|
+
|
|
171
|
+
### Component Libraries
|
|
172
|
+
|
|
173
|
+
1. **Customization**: Use theme system for brand colors
|
|
174
|
+
2. **Variants**: Prefer built-in variants when possible
|
|
175
|
+
3. **Composition**: Compose components for flexibility
|
|
176
|
+
4. **Accessibility**: Use accessible components by default
|
|
177
|
+
|
|
178
|
+
## Resources
|
|
179
|
+
|
|
180
|
+
- [Import System Documentation](../imports.md)
|
|
181
|
+
- [Routing Documentation](../routing.md)
|
|
182
|
+
- [Lifecycle Hooks](../lifecycle-hooks.md)
|
|
183
|
+
- [Complete Example Guide](../guide-example/intro.md)
|
|
184
|
+
|
|
185
|
+
> **Upcoming Styling Patterns**
|
|
186
|
+
|
|
187
|
+
<div style="border: 1.5px solid #ffa500; background: #fff4cc; color: #333; padding: 1.2em 1.4em; border-radius: 8px; margin: 2em 0;">
|
|
188
|
+
|
|
189
|
+
The following styling approaches are <strong>planned</strong> for documentation in Jac, but full code examples are coming soon:
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
<strong>CSS-in-JS Libraries</strong>
|
|
194
|
+
<ul>
|
|
195
|
+
<li><strong>Emotion</strong> — CSS-in-JS with similar API to styled-components</li>
|
|
196
|
+
<li><strong>Styled JSX</strong> — CSS-in-JS (Next.js style)</li>
|
|
197
|
+
</ul>
|
|
198
|
+
|
|
199
|
+
<strong>CSS Modules</strong>
|
|
200
|
+
<ul>
|
|
201
|
+
<li><strong>CSS Modules</strong> — Scoped CSS with local class names</li>
|
|
202
|
+
</ul>
|
|
203
|
+
|
|
204
|
+
<strong>Modern CSS</strong>
|
|
205
|
+
<ul>
|
|
206
|
+
<li><strong>CSS Variables (Custom Properties)</strong> — Native CSS variables for theming</li>
|
|
207
|
+
<li><strong>PostCSS</strong> — CSS transformations and plugins</li>
|
|
208
|
+
</ul>
|
|
209
|
+
|
|
210
|
+
<strong>Component Libraries</strong>
|
|
211
|
+
<ul>
|
|
212
|
+
<li><strong>Chakra UI</strong> — Modular and accessible component library</li>
|
|
213
|
+
<li><strong>Ant Design</strong> — Enterprise-focused component library</li>
|
|
214
|
+
<li><strong>Radix UI</strong> — Unstyled, accessible primitives</li>
|
|
215
|
+
<li><strong>Mantine</strong> — Full-featured React components</li>
|
|
216
|
+
</ul>
|
|
217
|
+
|
|
218
|
+
<strong>CSS Frameworks</strong>
|
|
219
|
+
<ul>
|
|
220
|
+
<li><strong>Bulma</strong> — Flexbox-based CSS framework</li>
|
|
221
|
+
<li><strong>Foundation</strong> — Responsive framework</li>
|
|
222
|
+
<li><strong>Semantic UI</strong> — Natural language class names</li>
|
|
223
|
+
</ul>
|
|
224
|
+
|
|
225
|
+
<strong>Zero-runtime CSS-in-JS</strong>
|
|
226
|
+
<ul>
|
|
227
|
+
<li><strong>Vanilla Extract</strong> — Type-safe, zero-runtime CSS-in-JS</li>
|
|
228
|
+
<li><strong>Linaria</strong> — Zero-runtime CSS-in-JS</li>
|
|
229
|
+
<li><strong>Stitches</strong> — CSS-in-JS with variants API</li>
|
|
230
|
+
</ul>
|
|
231
|
+
|
|
232
|
+
<strong>Utility-first</strong>
|
|
233
|
+
<ul>
|
|
234
|
+
<li><strong>UnoCSS</strong> — On-demand atomic CSS engine</li>
|
|
235
|
+
</ul>
|
|
236
|
+
|
|
237
|
+
<em>Examples for these patterns will be added soon.</em>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
## Contributing
|
|
241
|
+
|
|
242
|
+
When adding new styling examples:
|
|
243
|
+
|
|
244
|
+
1. Create a new directory in `examples/css-styling/`
|
|
245
|
+
2. Include a complete working counter app
|
|
246
|
+
3. Add a README.md with setup instructions
|
|
247
|
+
4. Create a documentation file in `docs/styling/`
|
|
248
|
+
5. Update this intro.md file
|
|
249
|
+
6. Follow the existing example structure
|