jac-client 0.2.0__py3-none-any.whl → 0.2.1__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 +31 -1
- jac_client/docs/asset-serving/intro.md +209 -0
- jac_client/docs/assets/pipe_line-v2.svg +32 -0
- jac_client/docs/file-system/intro.md +90 -0
- jac_client/docs/styling/intro.md +250 -0
- jac_client/docs/styling/js-styling.md +373 -0
- jac_client/docs/styling/material-ui.md +346 -0
- jac_client/docs/styling/pure-css.md +305 -0
- jac_client/docs/styling/sass.md +409 -0
- jac_client/docs/styling/styled-components.md +401 -0
- jac_client/docs/styling/tailwind.md +303 -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 +67 -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 +27 -0
- jac_client/examples/asset-serving/css-with-image/vite.config.js +29 -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 +43 -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 +27 -0
- jac_client/examples/asset-serving/image-asset/vite.config.js +29 -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 +57 -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 +29 -0
- 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 +63 -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 +28 -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 +82 -0
- jac_client/examples/css-styling/material-ui/package.json +32 -0
- jac_client/examples/css-styling/material-ui/vite.config.js +28 -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 +63 -0
- jac_client/examples/css-styling/pure-css/package.json +28 -0
- jac_client/examples/css-styling/pure-css/styles.css +112 -0
- jac_client/examples/css-styling/pure-css/vite.config.js +28 -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 +63 -0
- jac_client/examples/css-styling/sass-example/package.json +29 -0
- jac_client/examples/css-styling/sass-example/styles.scss +158 -0
- jac_client/examples/css-styling/sass-example/vite.config.js +28 -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 +66 -0
- jac_client/examples/css-styling/styled-components/package.json +29 -0
- jac_client/examples/css-styling/styled-components/styled.js +91 -0
- jac_client/examples/css-styling/styled-components/vite.config.js +28 -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 +64 -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 +30 -0
- jac_client/examples/with-router/app.jac +1 -1
- jac_client/plugin/cli.py +5 -0
- jac_client/plugin/client.py +64 -3
- jac_client/plugin/vite_client_bundle.py +96 -1
- jac_client/tests/__init__.py +0 -1
- jac_client/tests/fixtures/cl_file/app.cl.jac +38 -0
- jac_client/tests/fixtures/cl_file/app.jac +15 -0
- jac_client/tests/fixtures/js_import/app.jac +1 -1
- jac_client/tests/fixtures/relative_import/button.jac +2 -2
- jac_client/tests/fixtures/test_fragments_spread/app.jac +2 -2
- jac_client/tests/test_asset_examples.py +339 -0
- jac_client/tests/test_cl.py +165 -87
- jac_client/tests/test_create_jac_app.py +40 -44
- {jac_client-0.2.0.dist-info → jac_client-0.2.1.dist-info}/METADATA +2 -2
- jac_client-0.2.1.dist-info/RECORD +140 -0
- jac_client-0.2.0.dist-info/RECORD +0 -72
- {jac_client-0.2.0.dist-info → jac_client-0.2.1.dist-info}/WHEEL +0 -0
- {jac_client-0.2.0.dist-info → jac_client-0.2.1.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Material-UI
|
|
2
|
+
|
|
3
|
+
Comprehensive React component library with Material Design for Jac applications.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Material-UI (MUI) provides pre-built, accessible React components following Material Design principles. This approach is perfect for:
|
|
8
|
+
- Rapid application development
|
|
9
|
+
- Consistent Material Design
|
|
10
|
+
- Accessible components out of the box
|
|
11
|
+
- Enterprise applications
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
See the complete working example: [`examples/css-styling/material-ui/`](../../examples/css-styling/material-ui/)
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### 1. Install Material-UI
|
|
20
|
+
|
|
21
|
+
Add to `package.json`:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@mui/material": "^5.15.0",
|
|
27
|
+
"@mui/icons-material": "^5.15.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2. Import Components
|
|
33
|
+
|
|
34
|
+
In your Jac file:
|
|
35
|
+
|
|
36
|
+
```jac
|
|
37
|
+
# Pages
|
|
38
|
+
cl import from react {useState, useEffect}
|
|
39
|
+
cl import from "@mui/material/Button" { default as Button }
|
|
40
|
+
cl import from "@mui/material/Card" { default as Card }
|
|
41
|
+
cl import from "@mui/material/CardContent" { default as CardContent }
|
|
42
|
+
cl import from "@mui/material/Box" { default as Box }
|
|
43
|
+
cl import from "@mui/icons-material/Add" { default as AddIcon }
|
|
44
|
+
cl import from "@mui/icons-material/Remove" { default as RemoveIcon }
|
|
45
|
+
|
|
46
|
+
cl {
|
|
47
|
+
def app() -> any {
|
|
48
|
+
return <Box sx={{"display": "flex", "justifyContent": "center"}}>
|
|
49
|
+
<Card>
|
|
50
|
+
<CardContent>
|
|
51
|
+
<Button variant="contained" onClick={handleIncrement}>
|
|
52
|
+
<AddIcon />
|
|
53
|
+
</Button>
|
|
54
|
+
</CardContent>
|
|
55
|
+
</Card>
|
|
56
|
+
</Box>;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Key Features
|
|
62
|
+
|
|
63
|
+
### Theming
|
|
64
|
+
|
|
65
|
+
Material-UI comes with a built-in theme system:
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
import { ThemeProvider, createTheme } from '@mui/material/styles';
|
|
69
|
+
|
|
70
|
+
const theme = createTheme({
|
|
71
|
+
palette: {
|
|
72
|
+
primary: {
|
|
73
|
+
main: '#1976d2',
|
|
74
|
+
},
|
|
75
|
+
secondary: {
|
|
76
|
+
main: '#dc004e',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
typography: {
|
|
80
|
+
fontFamily: 'Roboto, Arial, sans-serif',
|
|
81
|
+
},
|
|
82
|
+
spacing: 8, // 8px base unit
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Wrap your app
|
|
86
|
+
<ThemeProvider theme={theme}>
|
|
87
|
+
<App />
|
|
88
|
+
</ThemeProvider>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### sx Prop
|
|
92
|
+
|
|
93
|
+
Use the `sx` prop for styling:
|
|
94
|
+
|
|
95
|
+
```jac
|
|
96
|
+
<Box sx={{
|
|
97
|
+
display: "flex",
|
|
98
|
+
justifyContent: "center",
|
|
99
|
+
alignItems: "center",
|
|
100
|
+
minHeight: "100vh",
|
|
101
|
+
backgroundColor: "background.default"
|
|
102
|
+
}}>
|
|
103
|
+
<Card sx={{
|
|
104
|
+
maxWidth: 400,
|
|
105
|
+
padding: 2
|
|
106
|
+
}}>
|
|
107
|
+
Content
|
|
108
|
+
</Card>
|
|
109
|
+
</Box>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Component Variants
|
|
113
|
+
|
|
114
|
+
Use built-in variants:
|
|
115
|
+
|
|
116
|
+
```jac
|
|
117
|
+
<Button variant="contained" color="primary">Contained</Button>
|
|
118
|
+
<Button variant="outlined" color="secondary">Outlined</Button>
|
|
119
|
+
<Button variant="text">Text</Button>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Common Components
|
|
123
|
+
|
|
124
|
+
### Layout Components
|
|
125
|
+
|
|
126
|
+
```jac
|
|
127
|
+
# Box - Container component
|
|
128
|
+
<Box sx={{"display": "flex", "gap": 2}}>
|
|
129
|
+
<Box>Item 1</Box>
|
|
130
|
+
<Box>Item 2</Box>
|
|
131
|
+
</Box>
|
|
132
|
+
|
|
133
|
+
# Grid - Responsive grid system
|
|
134
|
+
cl import from "@mui/material/Grid" { default as Grid }
|
|
135
|
+
<Grid container spacing={2}>
|
|
136
|
+
<Grid item xs={12} md={6}>Column 1</Grid>
|
|
137
|
+
<Grid item xs={12} md={6}>Column 2</Grid>
|
|
138
|
+
</Grid>
|
|
139
|
+
|
|
140
|
+
# Stack - Flexbox container
|
|
141
|
+
cl import from "@mui/material/Stack" { default as Stack }
|
|
142
|
+
<Stack direction="row" spacing={2}>
|
|
143
|
+
<Button>Button 1</Button>
|
|
144
|
+
<Button>Button 2</Button>
|
|
145
|
+
</Stack>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Input Components
|
|
149
|
+
|
|
150
|
+
```jac
|
|
151
|
+
# TextField
|
|
152
|
+
cl import from "@mui/material/TextField" { default as TextField }
|
|
153
|
+
<TextField label="Name" variant="outlined" />
|
|
154
|
+
|
|
155
|
+
# Button
|
|
156
|
+
<Button variant="contained" color="primary" onClick={handleClick}>
|
|
157
|
+
Click Me
|
|
158
|
+
</Button>
|
|
159
|
+
|
|
160
|
+
# Select
|
|
161
|
+
cl import from "@mui/material/Select" { default as Select }
|
|
162
|
+
cl import from "@mui/material/MenuItem" { default as MenuItem }
|
|
163
|
+
<Select value={value} onChange={handleChange}>
|
|
164
|
+
<MenuItem value="option1">Option 1</MenuItem>
|
|
165
|
+
<MenuItem value="option2">Option 2</MenuItem>
|
|
166
|
+
</Select>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Feedback Components
|
|
170
|
+
|
|
171
|
+
```jac
|
|
172
|
+
# Card
|
|
173
|
+
<Card>
|
|
174
|
+
<CardContent>
|
|
175
|
+
<Typography variant="h5">Card Title</Typography>
|
|
176
|
+
<Typography variant="body2">Card content</Typography>
|
|
177
|
+
</CardContent>
|
|
178
|
+
</Card>
|
|
179
|
+
|
|
180
|
+
# Dialog
|
|
181
|
+
cl import from "@mui/material/Dialog" { default as Dialog }
|
|
182
|
+
cl import from "@mui/material/DialogTitle" { default as DialogTitle }
|
|
183
|
+
<Dialog open={open} onClose={handleClose}>
|
|
184
|
+
<DialogTitle>Dialog Title</DialogTitle>
|
|
185
|
+
</Dialog>
|
|
186
|
+
|
|
187
|
+
# Snackbar
|
|
188
|
+
cl import from "@mui/material/Snackbar" { default as Snackbar }
|
|
189
|
+
cl import from "@mui/material/Alert" { default as Alert }
|
|
190
|
+
<Snackbar open={open} autoHideDuration={6000}>
|
|
191
|
+
<Alert severity="success">Success message!</Alert>
|
|
192
|
+
</Snackbar>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Best Practices
|
|
196
|
+
|
|
197
|
+
### 1. Use sx Prop
|
|
198
|
+
|
|
199
|
+
For component-specific styling:
|
|
200
|
+
|
|
201
|
+
```jac
|
|
202
|
+
<Box sx={{
|
|
203
|
+
display: "flex",
|
|
204
|
+
justifyContent: "center",
|
|
205
|
+
padding: 2,
|
|
206
|
+
backgroundColor: "primary.main"
|
|
207
|
+
}}>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 2. Leverage Variants
|
|
211
|
+
|
|
212
|
+
Use built-in variants when possible:
|
|
213
|
+
|
|
214
|
+
```jac
|
|
215
|
+
<Button variant="contained" color="primary">Primary</Button>
|
|
216
|
+
<Typography variant="h1">Heading</Typography>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### 3. Theme Customization
|
|
220
|
+
|
|
221
|
+
Customize theme for brand colors:
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
const theme = createTheme({
|
|
225
|
+
palette: {
|
|
226
|
+
primary: {
|
|
227
|
+
main: '#your-brand-color',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### 4. Accessibility
|
|
234
|
+
|
|
235
|
+
MUI components are accessible by default:
|
|
236
|
+
|
|
237
|
+
```jac
|
|
238
|
+
<Button aria-label="Add item">
|
|
239
|
+
<AddIcon />
|
|
240
|
+
</Button>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### 5. Icons
|
|
244
|
+
|
|
245
|
+
Use @mui/icons-material for consistent icons:
|
|
246
|
+
|
|
247
|
+
```jac
|
|
248
|
+
cl import from "@mui/icons-material/Add" { default as AddIcon }
|
|
249
|
+
cl import from "@mui/icons-material/Delete" { default as DeleteIcon }
|
|
250
|
+
cl import from "@mui/icons-material/Edit" { default as EditIcon }
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Advantages
|
|
254
|
+
|
|
255
|
+
- ✅ **Pre-built, accessible components**
|
|
256
|
+
- ✅ **Consistent Material Design**
|
|
257
|
+
- ✅ **Comprehensive component library**
|
|
258
|
+
- ✅ **Built-in theming system**
|
|
259
|
+
- ✅ **TypeScript support**
|
|
260
|
+
- ✅ **Active community** and documentation
|
|
261
|
+
- ✅ **Production-ready** components
|
|
262
|
+
|
|
263
|
+
## Limitations
|
|
264
|
+
|
|
265
|
+
- ❌ **Larger bundle size**
|
|
266
|
+
- ❌ **Material Design aesthetic** (may not fit all brands)
|
|
267
|
+
- ❌ **Learning curve** for component API
|
|
268
|
+
- ❌ **Less flexibility** than custom CSS
|
|
269
|
+
- ❌ **Requires JavaScript** for styling
|
|
270
|
+
|
|
271
|
+
## When to Use
|
|
272
|
+
|
|
273
|
+
Choose Material-UI when:
|
|
274
|
+
|
|
275
|
+
- You want pre-built components
|
|
276
|
+
- You need accessible components
|
|
277
|
+
- You prefer Material Design
|
|
278
|
+
- You're building enterprise applications
|
|
279
|
+
- You want to focus on functionality over styling
|
|
280
|
+
- You need comprehensive component library
|
|
281
|
+
|
|
282
|
+
## Import Syntax
|
|
283
|
+
|
|
284
|
+
MUI components are imported from their specific packages:
|
|
285
|
+
|
|
286
|
+
```jac
|
|
287
|
+
# Material components
|
|
288
|
+
cl import from "@mui/material/Button" { default as Button }
|
|
289
|
+
cl import from "@mui/material/Card" { default as Card }
|
|
290
|
+
|
|
291
|
+
# Icons
|
|
292
|
+
cl import from "@mui/icons-material/Add" { default as AddIcon }
|
|
293
|
+
cl import from "@mui/icons-material/Delete" { default as DeleteIcon }
|
|
294
|
+
|
|
295
|
+
# Multiple imports
|
|
296
|
+
cl import from "@mui/material" {
|
|
297
|
+
Button,
|
|
298
|
+
Card,
|
|
299
|
+
CardContent,
|
|
300
|
+
Box
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Theming Example
|
|
305
|
+
|
|
306
|
+
```javascript
|
|
307
|
+
// theme.js
|
|
308
|
+
import { createTheme } from '@mui/material/styles';
|
|
309
|
+
|
|
310
|
+
export const theme = createTheme({
|
|
311
|
+
palette: {
|
|
312
|
+
mode: 'light',
|
|
313
|
+
primary: {
|
|
314
|
+
main: '#1976d2',
|
|
315
|
+
},
|
|
316
|
+
secondary: {
|
|
317
|
+
main: '#dc004e',
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
typography: {
|
|
321
|
+
fontFamily: 'Roboto, Arial, sans-serif',
|
|
322
|
+
h1: {
|
|
323
|
+
fontSize: '2.5rem',
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
spacing: 8,
|
|
327
|
+
});
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Next Steps
|
|
331
|
+
|
|
332
|
+
- Explore [Material-UI Documentation](https://mui.com/)
|
|
333
|
+
- Check out [Chakra UI](./chakra-ui.md) for alternative component library (coming soon)
|
|
334
|
+
- Learn about [Ant Design](./ant-design.md) for enterprise components (coming soon)
|
|
335
|
+
- See [Styled Components](./styled-components.md) for CSS-in-JS approach
|
|
336
|
+
|
|
337
|
+
## Resources
|
|
338
|
+
|
|
339
|
+
- [Material-UI Documentation](https://mui.com/)
|
|
340
|
+
- [Material-UI Components](https://mui.com/material-ui/getting-started/)
|
|
341
|
+
- [Material Design Guidelines](https://m3.material.io/)
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# Pure CSS
|
|
2
|
+
|
|
3
|
+
Traditional CSS with external stylesheets. The most straightforward styling approach for Jac applications.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Pure CSS is the foundation of web styling. You write CSS in a separate file and import it into your Jac code. This approach is perfect for:
|
|
8
|
+
- Simple projects
|
|
9
|
+
- Learning CSS fundamentals
|
|
10
|
+
- Maximum control over styling
|
|
11
|
+
- Minimal dependencies
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
See the complete working example: [`examples/css-styling/pure-css/`](../../examples/css-styling/pure-css/)
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### 1. Create CSS File
|
|
20
|
+
|
|
21
|
+
Create a `styles.css` file in your project:
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
.container {
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
min-height: 100vh;
|
|
29
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.card {
|
|
33
|
+
background: white;
|
|
34
|
+
border-radius: 20px;
|
|
35
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
36
|
+
padding: 40px;
|
|
37
|
+
min-width: 400px;
|
|
38
|
+
text-align: center;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.title {
|
|
42
|
+
font-size: 2rem;
|
|
43
|
+
color: #667eea;
|
|
44
|
+
margin: 0 0 10px 0;
|
|
45
|
+
font-weight: 600;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 2. Import CSS in Jac
|
|
50
|
+
|
|
51
|
+
In your Jac file, import the CSS file:
|
|
52
|
+
|
|
53
|
+
```jac
|
|
54
|
+
# Pages
|
|
55
|
+
cl import from react {useState, useEffect}
|
|
56
|
+
cl import ".styles.css";
|
|
57
|
+
|
|
58
|
+
cl {
|
|
59
|
+
def app() -> any {
|
|
60
|
+
let [count, setCount] = useState(0);
|
|
61
|
+
|
|
62
|
+
return <div className="container">
|
|
63
|
+
<div className="card">
|
|
64
|
+
<h1 className="title">Counter Application</h1>
|
|
65
|
+
<p>Count: {count}</p>
|
|
66
|
+
</div>
|
|
67
|
+
</div>;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 3. Use Class Names
|
|
73
|
+
|
|
74
|
+
Apply CSS classes using the `className` prop:
|
|
75
|
+
|
|
76
|
+
```jac
|
|
77
|
+
return <div className="container">
|
|
78
|
+
<div className="card">
|
|
79
|
+
<h1 className="title">Counter Application</h1>
|
|
80
|
+
</div>
|
|
81
|
+
</div>;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 4. Dynamic Classes
|
|
85
|
+
|
|
86
|
+
Dynamically construct class names based on state:
|
|
87
|
+
|
|
88
|
+
```jac
|
|
89
|
+
let countClass = "countDisplay " + ("positive" if count > 0 else "negative" if count < 0 else "zero");
|
|
90
|
+
|
|
91
|
+
return <div className={countClass}>{count}</div>;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Import Syntax
|
|
95
|
+
|
|
96
|
+
CSS files are imported using the `cl import` syntax:
|
|
97
|
+
|
|
98
|
+
```jac
|
|
99
|
+
cl import ".styles.css";
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This compiles to:
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
import "./styles.css";
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Vite automatically processes CSS imports and extracts them to a separate CSS file during the build process.
|
|
109
|
+
|
|
110
|
+
## Best Practices
|
|
111
|
+
|
|
112
|
+
### 1. Organize Your CSS
|
|
113
|
+
|
|
114
|
+
Use comments to separate sections:
|
|
115
|
+
|
|
116
|
+
```css
|
|
117
|
+
/* ============================================
|
|
118
|
+
Container Styles
|
|
119
|
+
============================================ */
|
|
120
|
+
.container {
|
|
121
|
+
/* styles */
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* ============================================
|
|
125
|
+
Card Styles
|
|
126
|
+
============================================ */
|
|
127
|
+
.card {
|
|
128
|
+
/* styles */
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 2. Use Semantic Class Names
|
|
133
|
+
|
|
134
|
+
Make class names descriptive and meaningful:
|
|
135
|
+
|
|
136
|
+
```css
|
|
137
|
+
/* Good */
|
|
138
|
+
.button-primary { }
|
|
139
|
+
.card-header { }
|
|
140
|
+
.navigation-menu { }
|
|
141
|
+
|
|
142
|
+
/* Avoid */
|
|
143
|
+
.btn1 { }
|
|
144
|
+
.div1 { }
|
|
145
|
+
.red { }
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 3. Use CSS Variables for Theming
|
|
149
|
+
|
|
150
|
+
Leverage CSS custom properties for theming:
|
|
151
|
+
|
|
152
|
+
```css
|
|
153
|
+
:root {
|
|
154
|
+
--primary-color: #007bff;
|
|
155
|
+
--secondary-color: #6c757d;
|
|
156
|
+
--spacing-unit: 1rem;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.button {
|
|
160
|
+
background-color: var(--primary-color);
|
|
161
|
+
padding: var(--spacing-unit);
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 4. Mobile-First Design
|
|
166
|
+
|
|
167
|
+
Design for mobile, then enhance for desktop:
|
|
168
|
+
|
|
169
|
+
```css
|
|
170
|
+
/* Mobile first */
|
|
171
|
+
.container {
|
|
172
|
+
padding: 1rem;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* Desktop */
|
|
176
|
+
@media (min-width: 768px) {
|
|
177
|
+
.container {
|
|
178
|
+
padding: 2rem;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 5. Avoid Inline Styles
|
|
184
|
+
|
|
185
|
+
Keep styles in the CSS file for maintainability:
|
|
186
|
+
|
|
187
|
+
```jac
|
|
188
|
+
// ❌ Avoid
|
|
189
|
+
<div style={{"padding": "1rem", "color": "blue"}}>
|
|
190
|
+
|
|
191
|
+
// ✅ Prefer
|
|
192
|
+
<div className="container">
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Advantages
|
|
196
|
+
|
|
197
|
+
- ✅ **No build step required** for CSS
|
|
198
|
+
- ✅ **Easy to understand** and maintain
|
|
199
|
+
- ✅ **Works with any CSS framework**
|
|
200
|
+
- ✅ **Minimal dependencies**
|
|
201
|
+
- ✅ **Great browser support**
|
|
202
|
+
- ✅ **Familiar syntax** for developers
|
|
203
|
+
|
|
204
|
+
## Limitations
|
|
205
|
+
|
|
206
|
+
- ❌ **No variables or nesting** (use CSS variables for theming)
|
|
207
|
+
- ❌ **No preprocessing features**
|
|
208
|
+
- ❌ **Global scope** (use BEM or similar for scoping)
|
|
209
|
+
- ❌ **No dynamic styling** based on props
|
|
210
|
+
- ❌ **Manual organization** required
|
|
211
|
+
|
|
212
|
+
## When to Use
|
|
213
|
+
|
|
214
|
+
Choose Pure CSS when:
|
|
215
|
+
|
|
216
|
+
- You're building a simple application
|
|
217
|
+
- You want minimal dependencies
|
|
218
|
+
- You prefer traditional CSS workflow
|
|
219
|
+
- You're learning CSS fundamentals
|
|
220
|
+
- You need maximum control
|
|
221
|
+
- You want to avoid build complexity
|
|
222
|
+
|
|
223
|
+
## CSS Variables (Custom Properties)
|
|
224
|
+
|
|
225
|
+
Use CSS custom properties for theming and dynamic values:
|
|
226
|
+
|
|
227
|
+
```css
|
|
228
|
+
:root {
|
|
229
|
+
--primary: #007bff;
|
|
230
|
+
--secondary: #6c757d;
|
|
231
|
+
--success: #28a745;
|
|
232
|
+
--danger: #dc3545;
|
|
233
|
+
--spacing-sm: 0.5rem;
|
|
234
|
+
--spacing-md: 1rem;
|
|
235
|
+
--spacing-lg: 2rem;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.button {
|
|
239
|
+
background-color: var(--primary);
|
|
240
|
+
padding: var(--spacing-md);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.button-success {
|
|
244
|
+
background-color: var(--success);
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Responsive Design
|
|
249
|
+
|
|
250
|
+
Use media queries for responsive layouts:
|
|
251
|
+
|
|
252
|
+
```css
|
|
253
|
+
.container {
|
|
254
|
+
padding: 1rem;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@media (min-width: 768px) {
|
|
258
|
+
.container {
|
|
259
|
+
padding: 2rem;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
@media (min-width: 1024px) {
|
|
264
|
+
.container {
|
|
265
|
+
padding: 3rem;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Naming Conventions
|
|
271
|
+
|
|
272
|
+
### BEM (Block Element Modifier)
|
|
273
|
+
|
|
274
|
+
```css
|
|
275
|
+
.card { } /* Block */
|
|
276
|
+
.card__header { } /* Element */
|
|
277
|
+
.card__header--highlighted { } /* Modifier */
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Utility Classes
|
|
281
|
+
|
|
282
|
+
```css
|
|
283
|
+
.text-center { text-align: center; }
|
|
284
|
+
.mt-1 { margin-top: 0.25rem; }
|
|
285
|
+
.p-2 { padding: 0.5rem; }
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Next Steps
|
|
289
|
+
|
|
290
|
+
- Learn about [CSS Variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) for advanced theming
|
|
291
|
+
- Explore [Sass/SCSS](./sass.md) for preprocessing features
|
|
292
|
+
- Check out [Tailwind CSS](./tailwind.md) for utility-first approach
|
|
293
|
+
- See [CSS Modules](./css-modules.md) for scoped styles (coming soon)
|
|
294
|
+
|
|
295
|
+
## Resources
|
|
296
|
+
|
|
297
|
+
- [MDN CSS Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS)
|
|
298
|
+
- [CSS Tricks](https://css-tricks.com/)
|
|
299
|
+
- [Can I Use](https://caniuse.com/) - Browser compatibility
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|