jac-client 0.2.3__py3-none-any.whl → 0.2.8__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.
Files changed (224) hide show
  1. jac_client/examples/all-in-one/app.jac +494 -347
  2. jac_client/examples/all-in-one/assets/workers/worker.py +5 -0
  3. jac_client/examples/all-in-one/button.jac +1 -1
  4. jac_client/examples/all-in-one/components/CategoryFilter.jac +35 -0
  5. jac_client/examples/all-in-one/components/Header.jac +13 -0
  6. jac_client/examples/all-in-one/components/ProfitOverview.jac +50 -0
  7. jac_client/examples/all-in-one/components/Summary.jac +53 -0
  8. jac_client/examples/all-in-one/components/TransactionForm.jac +158 -0
  9. jac_client/examples/all-in-one/components/TransactionItem.jac +55 -0
  10. jac_client/examples/all-in-one/components/TransactionList.jac +37 -0
  11. jac_client/examples/all-in-one/components/button.jac +1 -1
  12. jac_client/examples/all-in-one/components/navigation.jac +132 -0
  13. jac_client/examples/all-in-one/constants/categories.jac +37 -0
  14. jac_client/examples/all-in-one/constants/clients.jac +13 -0
  15. jac_client/examples/all-in-one/context/BudgetContext.jac +28 -0
  16. jac_client/examples/all-in-one/hooks/useBudget.jac +116 -0
  17. jac_client/examples/all-in-one/hooks/useLocalStorage.jac +36 -0
  18. jac_client/examples/all-in-one/pages/BudgetPlanner.cl.jac +70 -0
  19. jac_client/examples/all-in-one/pages/BudgetPlanner.jac +126 -0
  20. jac_client/examples/all-in-one/pages/FeaturesTest.cl.jac +552 -0
  21. jac_client/examples/all-in-one/pages/FeaturesTest.jac +126 -0
  22. jac_client/examples/all-in-one/pages/LandingPage.jac +101 -0
  23. jac_client/examples/all-in-one/pages/loginPage.jac +132 -0
  24. jac_client/examples/all-in-one/pages/nestedDemo.jac +61 -0
  25. jac_client/examples/all-in-one/pages/notFound.jac +24 -0
  26. jac_client/examples/all-in-one/pages/signupPage.jac +133 -0
  27. jac_client/examples/all-in-one/utils/formatters.jac +52 -0
  28. jac_client/examples/asset-serving/css-with-image/{app.jac → src/app.jac} +4 -4
  29. jac_client/examples/asset-serving/image-asset/{app.jac → src/app.jac} +4 -4
  30. jac_client/examples/asset-serving/import-alias/{app.jac → src/app.jac} +5 -5
  31. jac_client/examples/basic/{app.jac → src/app.jac} +4 -4
  32. jac_client/examples/basic-auth/src/app.jac +371 -0
  33. jac_client/examples/basic-auth-with-router/{app.jac → src/app.jac} +28 -28
  34. jac_client/examples/basic-full-stack/{app.jac → src/app.jac} +166 -127
  35. jac_client/examples/css-styling/js-styling/{app.jac → src/app.jac} +7 -7
  36. jac_client/examples/css-styling/material-ui/{app.jac → src/app.jac} +6 -6
  37. jac_client/examples/css-styling/pure-css/{app.jac → src/app.jac} +7 -7
  38. jac_client/examples/css-styling/sass-example/{app.jac → src/app.jac} +7 -7
  39. jac_client/examples/css-styling/styled-components/{app.jac → src/app.jac} +6 -6
  40. jac_client/examples/css-styling/tailwind-example/{app.jac → src/app.jac} +7 -7
  41. jac_client/examples/full-stack-with-auth/{app.jac → src/app.jac} +47 -47
  42. jac_client/examples/little-x/{app.jac → src/app.jac} +27 -32
  43. jac_client/examples/little-x/src/submit-button.jac +16 -0
  44. jac_client/examples/nested-folders/nested-advance/{ButtonRoot.jac → src/ButtonRoot.jac} +1 -1
  45. jac_client/examples/nested-folders/nested-advance/{app.jac → src/app.jac} +1 -1
  46. jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/ButtonSecondL.jac +1 -1
  47. jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/Card.jac +1 -1
  48. jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/level2/ButtonThirdL.jac +1 -1
  49. jac_client/examples/nested-folders/nested-basic/{app.jac → src/app.jac} +2 -2
  50. jac_client/examples/nested-folders/nested-basic/{button.jac → src/button.jac} +1 -1
  51. jac_client/examples/nested-folders/nested-basic/{components → src/components}/button.jac +1 -1
  52. jac_client/examples/ts-support/src/app.jac +35 -0
  53. jac_client/examples/with-router/{app.jac → src/app.jac} +15 -15
  54. jac_client/plugin/cli.jac +504 -0
  55. jac_client/plugin/client.jac +45 -0
  56. jac_client/plugin/client_runtime.cl.jac +42 -0
  57. jac_client/plugin/impl/client.impl.jac +193 -0
  58. jac_client/plugin/impl/client_runtime.impl.jac +195 -0
  59. jac_client/plugin/impl/vite_client_bundle.impl.jac +72 -0
  60. jac_client/plugin/plugin_config.jac +195 -0
  61. jac_client/plugin/src/__init__.jac +20 -0
  62. jac_client/plugin/src/asset_processor.jac +33 -0
  63. jac_client/plugin/src/babel_processor.jac +18 -0
  64. jac_client/plugin/src/compiler.jac +67 -0
  65. jac_client/plugin/src/config_loader.jac +32 -0
  66. jac_client/plugin/src/impl/asset_processor.impl.jac +127 -0
  67. jac_client/plugin/src/impl/babel_processor.impl.jac +89 -0
  68. jac_client/plugin/src/impl/compiler.impl.jac +288 -0
  69. jac_client/plugin/src/impl/config_loader.impl.jac +119 -0
  70. jac_client/plugin/src/impl/import_processor.impl.jac +33 -0
  71. jac_client/plugin/src/impl/jac_to_js.impl.jac +41 -0
  72. jac_client/plugin/src/impl/package_installer.impl.jac +105 -0
  73. jac_client/plugin/src/impl/vite_bundler.impl.jac +626 -0
  74. jac_client/plugin/src/import_processor.jac +19 -0
  75. jac_client/plugin/src/jac_to_js.jac +35 -0
  76. jac_client/plugin/src/package_installer.jac +26 -0
  77. jac_client/plugin/src/vite_bundler.jac +44 -0
  78. jac_client/plugin/vite_client_bundle.jac +31 -0
  79. jac_client/tests/conftest.py +283 -0
  80. jac_client/tests/fixtures/basic-app/app.jac +2 -2
  81. jac_client/tests/fixtures/cl_file/app.cl.jac +2 -2
  82. jac_client/tests/fixtures/client_app_with_antd/app.jac +1 -1
  83. jac_client/tests/fixtures/js_import/app.jac +5 -5
  84. jac_client/tests/fixtures/spawn_test/app.jac +15 -18
  85. jac_client/tests/fixtures/with-ts/app.jac +35 -0
  86. jac_client/tests/test_cli.py +811 -0
  87. jac_client/tests/test_it.py +592 -97
  88. {jac_client-0.2.3.dist-info → jac_client-0.2.8.dist-info}/METADATA +41 -34
  89. jac_client-0.2.8.dist-info/RECORD +97 -0
  90. {jac_client-0.2.3.dist-info → jac_client-0.2.8.dist-info}/WHEEL +2 -1
  91. jac_client-0.2.8.dist-info/entry_points.txt +4 -0
  92. jac_client-0.2.8.dist-info/top_level.txt +1 -0
  93. jac_client/docs/README.md +0 -689
  94. jac_client/docs/advanced-state.md +0 -1265
  95. jac_client/docs/asset-serving/intro.md +0 -209
  96. jac_client/docs/assets/pipe_line-v2.svg +0 -32
  97. jac_client/docs/assets/pipe_line.png +0 -0
  98. jac_client/docs/file-system/app.jac.md +0 -121
  99. jac_client/docs/file-system/backend-frontend.md +0 -217
  100. jac_client/docs/file-system/intro.md +0 -72
  101. jac_client/docs/file-system/nested-imports.md +0 -348
  102. jac_client/docs/guide-example/intro.md +0 -115
  103. jac_client/docs/guide-example/step-01-setup.md +0 -270
  104. jac_client/docs/guide-example/step-02-components.md +0 -416
  105. jac_client/docs/guide-example/step-03-styling.md +0 -478
  106. jac_client/docs/guide-example/step-04-todo-ui.md +0 -477
  107. jac_client/docs/guide-example/step-05-local-state.md +0 -530
  108. jac_client/docs/guide-example/step-06-events.md +0 -749
  109. jac_client/docs/guide-example/step-07-effects.md +0 -468
  110. jac_client/docs/guide-example/step-08-walkers.md +0 -534
  111. jac_client/docs/guide-example/step-09-authentication.md +0 -586
  112. jac_client/docs/guide-example/step-10-routing.md +0 -539
  113. jac_client/docs/guide-example/step-11-final.md +0 -963
  114. jac_client/docs/imports.md +0 -1141
  115. jac_client/docs/lifecycle-hooks.md +0 -773
  116. jac_client/docs/routing.md +0 -659
  117. jac_client/docs/styling/intro.md +0 -249
  118. jac_client/docs/styling/js-styling.md +0 -367
  119. jac_client/docs/styling/material-ui.md +0 -341
  120. jac_client/docs/styling/pure-css.md +0 -299
  121. jac_client/docs/styling/sass.md +0 -403
  122. jac_client/docs/styling/styled-components.md +0 -395
  123. jac_client/docs/styling/tailwind.md +0 -298
  124. jac_client/examples/all-in-one/.babelrc +0 -9
  125. jac_client/examples/all-in-one/README.md +0 -16
  126. jac_client/examples/all-in-one/assets/burger.png +0 -0
  127. jac_client/examples/all-in-one/package.json +0 -29
  128. jac_client/examples/all-in-one/styles.css +0 -26
  129. jac_client/examples/all-in-one/vite.config.js +0 -28
  130. jac_client/examples/asset-serving/css-with-image/.babelrc +0 -9
  131. jac_client/examples/asset-serving/css-with-image/README.md +0 -91
  132. jac_client/examples/asset-serving/css-with-image/assets/burger.png +0 -0
  133. jac_client/examples/asset-serving/css-with-image/package.json +0 -28
  134. jac_client/examples/asset-serving/css-with-image/styles.css +0 -26
  135. jac_client/examples/asset-serving/css-with-image/vite.config.js +0 -28
  136. jac_client/examples/asset-serving/image-asset/.babelrc +0 -9
  137. jac_client/examples/asset-serving/image-asset/README.md +0 -119
  138. jac_client/examples/asset-serving/image-asset/assets/burger.png +0 -0
  139. jac_client/examples/asset-serving/image-asset/package.json +0 -28
  140. jac_client/examples/asset-serving/image-asset/styles.css +0 -26
  141. jac_client/examples/asset-serving/image-asset/vite.config.js +0 -28
  142. jac_client/examples/asset-serving/import-alias/.babelrc +0 -9
  143. jac_client/examples/asset-serving/import-alias/README.md +0 -83
  144. jac_client/examples/asset-serving/import-alias/assets/burger.png +0 -0
  145. jac_client/examples/asset-serving/import-alias/package.json +0 -28
  146. jac_client/examples/asset-serving/import-alias/vite.config.js +0 -28
  147. jac_client/examples/basic/.babelrc +0 -9
  148. jac_client/examples/basic/README.md +0 -16
  149. jac_client/examples/basic/package.json +0 -27
  150. jac_client/examples/basic/vite.config.js +0 -27
  151. jac_client/examples/basic-auth/.babelrc +0 -9
  152. jac_client/examples/basic-auth/README.md +0 -16
  153. jac_client/examples/basic-auth/app.jac +0 -308
  154. jac_client/examples/basic-auth/package.json +0 -27
  155. jac_client/examples/basic-auth/vite.config.js +0 -27
  156. jac_client/examples/basic-auth-with-router/.babelrc +0 -9
  157. jac_client/examples/basic-auth-with-router/README.md +0 -60
  158. jac_client/examples/basic-auth-with-router/package.json +0 -28
  159. jac_client/examples/basic-auth-with-router/vite.config.js +0 -27
  160. jac_client/examples/basic-full-stack/.babelrc +0 -9
  161. jac_client/examples/basic-full-stack/README.md +0 -18
  162. jac_client/examples/basic-full-stack/package.json +0 -28
  163. jac_client/examples/basic-full-stack/vite.config.js +0 -27
  164. jac_client/examples/css-styling/js-styling/.babelrc +0 -9
  165. jac_client/examples/css-styling/js-styling/README.md +0 -183
  166. jac_client/examples/css-styling/js-styling/package.json +0 -28
  167. jac_client/examples/css-styling/js-styling/styles.js +0 -100
  168. jac_client/examples/css-styling/js-styling/vite.config.js +0 -27
  169. jac_client/examples/css-styling/material-ui/.babelrc +0 -9
  170. jac_client/examples/css-styling/material-ui/README.md +0 -16
  171. jac_client/examples/css-styling/material-ui/package.json +0 -32
  172. jac_client/examples/css-styling/material-ui/vite.config.js +0 -27
  173. jac_client/examples/css-styling/pure-css/.babelrc +0 -9
  174. jac_client/examples/css-styling/pure-css/README.md +0 -16
  175. jac_client/examples/css-styling/pure-css/package.json +0 -28
  176. jac_client/examples/css-styling/pure-css/styles.css +0 -111
  177. jac_client/examples/css-styling/pure-css/vite.config.js +0 -27
  178. jac_client/examples/css-styling/sass-example/.babelrc +0 -9
  179. jac_client/examples/css-styling/sass-example/README.md +0 -16
  180. jac_client/examples/css-styling/sass-example/package.json +0 -29
  181. jac_client/examples/css-styling/sass-example/styles.scss +0 -153
  182. jac_client/examples/css-styling/sass-example/vite.config.js +0 -27
  183. jac_client/examples/css-styling/styled-components/.babelrc +0 -9
  184. jac_client/examples/css-styling/styled-components/README.md +0 -16
  185. jac_client/examples/css-styling/styled-components/package.json +0 -29
  186. jac_client/examples/css-styling/styled-components/styled.js +0 -90
  187. jac_client/examples/css-styling/styled-components/vite.config.js +0 -27
  188. jac_client/examples/css-styling/tailwind-example/.babelrc +0 -9
  189. jac_client/examples/css-styling/tailwind-example/README.md +0 -16
  190. jac_client/examples/css-styling/tailwind-example/global.css +0 -1
  191. jac_client/examples/css-styling/tailwind-example/package.json +0 -30
  192. jac_client/examples/css-styling/tailwind-example/vite.config.js +0 -29
  193. jac_client/examples/full-stack-with-auth/.babelrc +0 -9
  194. jac_client/examples/full-stack-with-auth/README.md +0 -16
  195. jac_client/examples/full-stack-with-auth/package.json +0 -28
  196. jac_client/examples/full-stack-with-auth/vite.config.js +0 -29
  197. jac_client/examples/little-x/package.json +0 -23
  198. jac_client/examples/little-x/submit-button.jac +0 -8
  199. jac_client/examples/nested-folders/nested-advance/.babelrc +0 -9
  200. jac_client/examples/nested-folders/nested-advance/README.md +0 -77
  201. jac_client/examples/nested-folders/nested-advance/package.json +0 -29
  202. jac_client/examples/nested-folders/nested-advance/vite.config.js +0 -28
  203. jac_client/examples/nested-folders/nested-basic/.babelrc +0 -9
  204. jac_client/examples/nested-folders/nested-basic/README.md +0 -183
  205. jac_client/examples/nested-folders/nested-basic/app.js +0 -7
  206. jac_client/examples/nested-folders/nested-basic/package.json +0 -28
  207. jac_client/examples/nested-folders/nested-basic/vite.config.js +0 -27
  208. jac_client/examples/with-router/.babelrc +0 -9
  209. jac_client/examples/with-router/README.md +0 -17
  210. jac_client/examples/with-router/package.json +0 -28
  211. jac_client/examples/with-router/vite.config.js +0 -27
  212. jac_client/plugin/cli.py +0 -244
  213. jac_client/plugin/client.py +0 -152
  214. jac_client/plugin/client_runtime.jac +0 -234
  215. jac_client/plugin/vite_client_bundle.py +0 -503
  216. jac_client/tests/fixtures/js_import/utils.js +0 -21
  217. jac_client/tests/fixtures/package-lock.json +0 -329
  218. jac_client/tests/fixtures/package.json +0 -11
  219. jac_client/tests/test_asset_examples.py +0 -322
  220. jac_client/tests/test_cl.py +0 -530
  221. jac_client/tests/test_create_jac_app.py +0 -131
  222. jac_client/tests/test_nested_file.py +0 -374
  223. jac_client-0.2.3.dist-info/RECORD +0 -171
  224. jac_client-0.2.3.dist-info/entry_points.txt +0 -4
@@ -1,249 +0,0 @@
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
@@ -1,367 +0,0 @@
1
- # JavaScript Styling
2
-
3
- Inline styles using JavaScript objects for dynamic styling in Jac applications.
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
- ## Example
14
-
15
- See the complete working example: [`examples/css-styling/js-styling/`](../../examples/css-styling/js-styling/)
16
-
17
- ## Quick Start
18
-
19
- ### 1. Define Style Objects
20
-
21
- Create `styles.js`:
22
-
23
- ```javascript
24
- const countDisplay = {
25
- fontSize: "3.75rem",
26
- fontWeight: "bold",
27
- transition: "color 0.3s ease"
28
- };
29
-
30
- export default {
31
- container: {
32
- minHeight: "100vh",
33
- background: "linear-gradient(to bottom right, #dbeafe, #e0e7ff)",
34
- display: "flex",
35
- alignItems: "center",
36
- justifyContent: "center",
37
- padding: "1rem"
38
- },
39
- card: {
40
- backgroundColor: "#ffffff",
41
- borderRadius: "1rem",
42
- boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
43
- padding: "2rem",
44
- maxWidth: "28rem",
45
- width: "100%"
46
- },
47
- countDisplayZero: {
48
- ...countDisplay,
49
- color: "#1f2937"
50
- },
51
- countDisplayPositive: {
52
- ...countDisplay,
53
- color: "#16a34a"
54
- },
55
- countDisplayNegative: {
56
- ...countDisplay,
57
- color: "#dc2626"
58
- },
59
- button: {
60
- color: "#ffffff",
61
- fontWeight: "bold",
62
- padding: "0.75rem 1.5rem",
63
- borderRadius: "0.5rem",
64
- border: "none",
65
- cursor: "pointer"
66
- },
67
- buttonDecrement: {
68
- backgroundColor: "#ef4444"
69
- },
70
- buttonReset: {
71
- backgroundColor: "#6b7280"
72
- },
73
- buttonIncrement: {
74
- backgroundColor: "#22c55e"
75
- }
76
- };
77
- ```
78
-
79
- ### 2. Import Styles
80
-
81
- ```jac
82
- # Pages
83
- cl import from react {useState, useEffect}
84
- cl import from .styles { default as styles }
85
-
86
- cl {
87
- def app() -> any {
88
- return <div style={styles.container}>
89
- <div style={styles.card}>
90
- <h1 style={styles.title}>Counter Application</h1>
91
- </div>
92
- </div>;
93
- }
94
- }
95
- ```
96
-
97
- ### 3. Apply Styles
98
-
99
- Use the `style` prop with style objects:
100
-
101
- ```jac
102
- return <div style={styles.container}>
103
- <div style={styles.card}>
104
- <h1 style={styles.title}>Counter Application</h1>
105
- </div>
106
- </div>;
107
- ```
108
-
109
- ### 4. Dynamic Styles
110
-
111
- Select styles based on state:
112
-
113
- ```jac
114
- let countStyle = styles.countDisplayZero if count == 0 else (styles.countDisplayPositive if count > 0 else styles.countDisplayNegative);
115
-
116
- return <div style={countStyle}>{count}</div>;
117
- ```
118
-
119
- ## Style Object Format
120
-
121
- JavaScript style objects use camelCase property names (React convention):
122
-
123
- ```javascript
124
- {
125
- backgroundColor: "#ffffff", // not background-color
126
- fontSize: "1.5rem", // not font-size
127
- marginTop: "10px", // not margin-top
128
- zIndex: 1, // not z-index
129
- borderTopLeftRadius: "4px" // not border-top-left-radius
130
- }
131
- ```
132
-
133
- ## Best Practices
134
-
135
- ### 1. Use Object Spread
136
-
137
- Share common styles with spread operator:
138
-
139
- ```javascript
140
- const baseButton = {
141
- padding: "0.75rem 1.5rem",
142
- borderRadius: "0.5rem",
143
- border: "none",
144
- cursor: "pointer"
145
- };
146
-
147
- export default {
148
- primaryButton: {
149
- ...baseButton,
150
- backgroundColor: "#007bff",
151
- color: "#ffffff"
152
- },
153
- secondaryButton: {
154
- ...baseButton,
155
- backgroundColor: "#6c757d",
156
- color: "#ffffff"
157
- }
158
- };
159
- ```
160
-
161
- ### 2. Organize by Component
162
-
163
- Group related styles together:
164
-
165
- ```javascript
166
- export default {
167
- // Container styles
168
- container: { ... },
169
- card: { ... },
170
-
171
- // Button styles
172
- button: { ... },
173
- buttonPrimary: { ... },
174
- buttonSecondary: { ... },
175
-
176
- // Text styles
177
- title: { ... },
178
- subtitle: { ... }
179
- };
180
- ```
181
-
182
- ### 3. Use Constants
183
-
184
- Define reusable values at the top:
185
-
186
- ```javascript
187
- const COLORS = {
188
- primary: "#007bff",
189
- secondary: "#6c757d",
190
- success: "#28a745",
191
- danger: "#dc3545"
192
- };
193
-
194
- const SPACING = {
195
- sm: "0.5rem",
196
- md: "1rem",
197
- lg: "2rem"
198
- };
199
-
200
- export default {
201
- button: {
202
- backgroundColor: COLORS.primary,
203
- padding: SPACING.md
204
- }
205
- };
206
- ```
207
-
208
- ### 4. CamelCase Properties
209
-
210
- Follow React naming convention:
211
-
212
- ```javascript
213
- // Good
214
- {
215
- backgroundColor: "#fff",
216
- fontSize: "1rem",
217
- marginTop: "10px"
218
- }
219
-
220
- // Avoid
221
- {
222
- "background-color": "#fff", // Wrong
223
- "font-size": "1rem" // Wrong
224
- }
225
- ```
226
-
227
- ### 5. Extract Complex Logic
228
-
229
- Move style calculations to functions:
230
-
231
- ```javascript
232
- export const getButtonStyle = (variant, disabled) => {
233
- const base = {
234
- padding: "0.75rem 1.5rem",
235
- borderRadius: "0.5rem",
236
- border: "none",
237
- cursor: disabled ? "not-allowed" : "pointer",
238
- opacity: disabled ? 0.5 : 1
239
- };
240
-
241
- const variants = {
242
- primary: { backgroundColor: "#007bff", color: "#ffffff" },
243
- secondary: { backgroundColor: "#6c757d", color: "#ffffff" }
244
- };
245
-
246
- return { ...base, ...variants[variant] };
247
- };
248
- ```
249
-
250
- ## Advanced Patterns
251
-
252
- ### Style Functions
253
-
254
- Create functions that return styles:
255
-
256
- ```javascript
257
- export const getButtonStyle = (variant) => ({
258
- padding: "0.75rem 1.5rem",
259
- borderRadius: "0.5rem",
260
- backgroundColor: variant === 'primary' ? '#007bff' : '#6c757d',
261
- color: '#ffffff'
262
- });
263
- ```
264
-
265
- Use in Jac:
266
-
267
- ```jac
268
- let buttonStyle = getButtonStyle("primary");
269
-
270
- return <button style={buttonStyle}>Click Me</button>;
271
- ```
272
-
273
- ### Conditional Styles
274
-
275
- Use ternary operators for conditional styles:
276
-
277
- ```javascript
278
- export default {
279
- button: (isActive, isDisabled) => ({
280
- backgroundColor: isActive ? '#007bff' : '#6c757d',
281
- opacity: isDisabled ? 0.5 : 1,
282
- cursor: isDisabled ? 'not-allowed' : 'pointer'
283
- })
284
- };
285
- ```
286
-
287
- ### Dynamic Values
288
-
289
- Calculate styles based on props:
290
-
291
- ```javascript
292
- export const getContainerStyle = (width, height) => ({
293
- width: `${width}px`,
294
- height: `${height}px`,
295
- display: "flex",
296
- alignItems: "center",
297
- justifyContent: "center"
298
- });
299
- ```
300
-
301
- ## Advantages
302
-
303
- - **Dynamic styling** based on props/state
304
- - **No CSS file needed**
305
- - **Type-safe** with TypeScript
306
- - **Component-scoped** by default
307
- - **Programmatic style generation**
308
- - **Easy to debug** (JavaScript objects)
309
- - **No build step** for styles
310
-
311
- ## Limitations
312
-
313
- - **No pseudo-classes** (hover, focus, etc.)
314
- - **No media queries**
315
- - **No CSS animations** (use JavaScript)
316
- - **Verbose** for complex styles
317
- - **No CSS preprocessor features**
318
- - **Performance** can be slower for many elements
319
-
320
- ## When to Use
321
-
322
- Choose JavaScript Styling when:
323
-
324
- - You need dynamic styles based on state
325
- - You want programmatic style generation
326
- - You prefer keeping styles in JavaScript
327
- - You're building component libraries
328
- - You need runtime style calculations
329
- - You want type safety with TypeScript
330
-
331
- ## Import Syntax
332
-
333
- Style objects are imported as JavaScript modules:
334
-
335
- ```jac
336
- # Default export
337
- cl import from .styles { default as styles }
338
-
339
- # Named exports (if using named exports)
340
- cl import from .styles { button, card, container }
341
- ```
342
-
343
- ## Combining Styles
344
-
345
- You can combine multiple style objects:
346
-
347
- ```jac
348
- let combinedStyle = {
349
- ...styles.base,
350
- ...styles.button,
351
- ...(isActive ? styles.active : {})
352
- };
353
-
354
- return <button style={combinedStyle}>Click Me</button>;
355
- ```
356
-
357
- ## Next Steps
358
-
359
- - Explore [Styled Components](./styled-components.md) for CSS-in-JS with more features
360
- - Check out [Emotion](./emotion.md) for similar CSS-in-JS approach (coming soon)
361
- - Learn about [CSS Modules](./css-modules.md) for scoped CSS (coming soon)
362
- - See [Pure CSS](./pure-css.md) for traditional CSS approach
363
-
364
- ## Resources
365
-
366
- - [React Inline Styles](https://react.dev/learn/javascript-in-jsx-with-curly-braces#using-double-curlies-css-and-other-objects-in-jsx)
367
- - [CSS-in-JS Comparison](https://github.com/MicheleBertoli/css-in-js)