jac-client 0.2.2__py3-none-any.whl → 0.2.6__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/examples/all-in-one/src/app.jac +841 -0
- jac_client/examples/all-in-one/{button.jac → src/button.jac} +1 -1
- jac_client/examples/all-in-one/{components → src/components}/button.jac +1 -1
- jac_client/examples/asset-serving/css-with-image/{app.jac → src/app.jac} +2 -2
- jac_client/examples/asset-serving/image-asset/{app.jac → src/app.jac} +2 -2
- jac_client/examples/asset-serving/import-alias/{app.jac → src/app.jac} +7 -7
- jac_client/examples/basic/{app.jac → src/app.jac} +2 -2
- jac_client/examples/basic-auth/src/app.jac +377 -0
- jac_client/examples/basic-auth-with-router/{app.jac → src/app.jac} +18 -18
- jac_client/examples/basic-full-stack/{app.jac → src/app.jac} +175 -130
- jac_client/examples/css-styling/js-styling/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/material-ui/{app.jac → src/app.jac} +5 -5
- jac_client/examples/css-styling/pure-css/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/sass-example/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/styled-components/{app.jac → src/app.jac} +5 -5
- jac_client/examples/css-styling/tailwind-example/{app.jac → src/app.jac} +6 -6
- jac_client/examples/full-stack-with-auth/{app.jac → src/app.jac} +37 -37
- jac_client/examples/little-x/{app.jac → src/app.jac} +27 -32
- jac_client/examples/little-x/src/submit-button.jac +16 -0
- jac_client/examples/nested-folders/nested-advance/{ButtonRoot.jac → src/ButtonRoot.jac} +1 -1
- jac_client/examples/nested-folders/nested-advance/{app.jac → src/app.jac} +1 -1
- jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/ButtonSecondL.jac +1 -1
- jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/Card.jac +1 -1
- jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/level2/ButtonThirdL.jac +1 -1
- jac_client/examples/nested-folders/nested-basic/{app.jac → src/app.jac} +2 -2
- jac_client/examples/nested-folders/nested-basic/{button.jac → src/button.jac} +1 -1
- jac_client/examples/nested-folders/nested-basic/{components → src/components}/button.jac +1 -1
- jac_client/examples/ts-support/src/app.jac +35 -0
- jac_client/examples/with-router/{app.jac → src/app.jac} +11 -11
- jac_client/plugin/cli.jac +547 -0
- jac_client/plugin/client.jac +52 -0
- jac_client/plugin/client_runtime.cl.jac +38 -0
- jac_client/plugin/impl/client.impl.jac +134 -0
- jac_client/plugin/impl/client_runtime.impl.jac +177 -0
- jac_client/plugin/impl/vite_client_bundle.impl.jac +72 -0
- jac_client/plugin/plugin_config.jac +195 -0
- jac_client/plugin/src/__init__.jac +20 -0
- jac_client/plugin/src/asset_processor.jac +33 -0
- jac_client/plugin/src/babel_processor.jac +18 -0
- jac_client/plugin/src/compiler.jac +66 -0
- jac_client/plugin/src/config_loader.jac +32 -0
- jac_client/plugin/src/impl/asset_processor.impl.jac +127 -0
- jac_client/plugin/src/impl/babel_processor.impl.jac +84 -0
- jac_client/plugin/src/impl/compiler.impl.jac +251 -0
- jac_client/plugin/src/impl/config_loader.impl.jac +119 -0
- jac_client/plugin/src/impl/import_processor.impl.jac +33 -0
- jac_client/plugin/src/impl/jac_to_js.impl.jac +41 -0
- jac_client/plugin/src/impl/package_installer.impl.jac +105 -0
- jac_client/plugin/src/impl/vite_bundler.impl.jac +513 -0
- jac_client/plugin/src/import_processor.jac +19 -0
- jac_client/plugin/src/jac_to_js.jac +35 -0
- jac_client/plugin/src/package_installer.jac +26 -0
- jac_client/plugin/src/vite_bundler.jac +36 -0
- jac_client/plugin/vite_client_bundle.jac +31 -0
- jac_client/tests/conftest.py +281 -0
- jac_client/tests/fixtures/basic-app/app.jac +2 -2
- jac_client/tests/fixtures/cl_file/app.cl.jac +2 -2
- jac_client/tests/fixtures/client_app_with_antd/app.jac +1 -1
- jac_client/tests/fixtures/js_import/app.jac +5 -5
- jac_client/tests/fixtures/spawn_test/app.jac +7 -7
- jac_client/tests/fixtures/with-ts/app.jac +35 -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.6.dist-info}/METADATA +30 -24
- jac_client-0.2.6.dist-info/RECORD +74 -0
- {jac_client-0.2.2.dist-info → jac_client-0.2.6.dist-info}/WHEEL +2 -1
- jac_client-0.2.6.dist-info/entry_points.txt +4 -0
- jac_client-0.2.6.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/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/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/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/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/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/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/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/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/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/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/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/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/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/package.json +0 -28
- jac_client/examples/full-stack-with-auth/vite.config.js +0 -29
- 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/README.md +0 -77
- 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.js +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/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/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/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,395 +0,0 @@
|
|
|
1
|
-
# Styled Components
|
|
2
|
-
|
|
3
|
-
CSS-in-JS library with component-scoped styles and dynamic styling for Jac applications.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Styled Components allows you to write CSS-in-JS using template literals. Styles are scoped to components and can be dynamic based on props. This approach is perfect for:
|
|
8
|
-
- Component-scoped styles
|
|
9
|
-
- Dynamic styling based on props
|
|
10
|
-
- CSS-in-JS with full CSS features
|
|
11
|
-
- React component libraries
|
|
12
|
-
|
|
13
|
-
## Example
|
|
14
|
-
|
|
15
|
-
See the complete working example: [`examples/css-styling/styled-components/`](../../examples/css-styling/styled-components/)
|
|
16
|
-
|
|
17
|
-
## Quick Start
|
|
18
|
-
|
|
19
|
-
### 1. Install styled-components
|
|
20
|
-
|
|
21
|
-
Add to `package.json`:
|
|
22
|
-
|
|
23
|
-
```json
|
|
24
|
-
{
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"styled-components": "^6.1.13"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### 2. Create Styled Components
|
|
32
|
-
|
|
33
|
-
Create `styled.js`:
|
|
34
|
-
|
|
35
|
-
```javascript
|
|
36
|
-
import styled from "styled-components";
|
|
37
|
-
|
|
38
|
-
export const Container = styled.div`
|
|
39
|
-
min-height: 100vh;
|
|
40
|
-
background: linear-gradient(to bottom right, #dbeafe, #e0e7ff);
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
justify-content: center;
|
|
44
|
-
padding: 1rem;
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
export const Card = styled.div`
|
|
48
|
-
background-color: #ffffff;
|
|
49
|
-
border-radius: 1rem;
|
|
50
|
-
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
51
|
-
padding: 2rem;
|
|
52
|
-
max-width: 28rem;
|
|
53
|
-
width: 100%;
|
|
54
|
-
`;
|
|
55
|
-
|
|
56
|
-
export const Button = styled.button`
|
|
57
|
-
color: #ffffff;
|
|
58
|
-
font-weight: bold;
|
|
59
|
-
padding: 0.75rem 1.5rem;
|
|
60
|
-
border-radius: 0.5rem;
|
|
61
|
-
background-color: ${props => props.bgColor};
|
|
62
|
-
|
|
63
|
-
&:hover {
|
|
64
|
-
transform: scale(1.05);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
&:active {
|
|
68
|
-
transform: scale(0.95);
|
|
69
|
-
}
|
|
70
|
-
`;
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### 3. Import and Use in Jac
|
|
74
|
-
|
|
75
|
-
```jac
|
|
76
|
-
# Pages
|
|
77
|
-
cl import from react {useState, useEffect}
|
|
78
|
-
cl import from .styled {
|
|
79
|
-
Container,
|
|
80
|
-
Card,
|
|
81
|
-
Button
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
cl {
|
|
85
|
-
def app() -> any {
|
|
86
|
-
return <Container>
|
|
87
|
-
<Card>
|
|
88
|
-
<Button bgColor="#ef4444" onClick={handleClick}>
|
|
89
|
-
Click Me
|
|
90
|
-
</Button>
|
|
91
|
-
</Card>
|
|
92
|
-
</Container>;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Key Features
|
|
98
|
-
|
|
99
|
-
### Dynamic Styling with Props
|
|
100
|
-
|
|
101
|
-
Styled components can access props for dynamic styling:
|
|
102
|
-
|
|
103
|
-
```javascript
|
|
104
|
-
const Button = styled.button`
|
|
105
|
-
background-color: ${props => props.bgColor || '#007bff'};
|
|
106
|
-
color: ${props => props.primary ? 'white' : 'black'};
|
|
107
|
-
padding: ${props => props.large ? '1rem 2rem' : '0.75rem 1.5rem'};
|
|
108
|
-
`;
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Pseudo-classes
|
|
112
|
-
|
|
113
|
-
Use CSS pseudo-classes:
|
|
114
|
-
|
|
115
|
-
```javascript
|
|
116
|
-
const Button = styled.button`
|
|
117
|
-
background-color: #007bff;
|
|
118
|
-
|
|
119
|
-
&:hover {
|
|
120
|
-
background-color: #0056b3;
|
|
121
|
-
transform: scale(1.05);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
&:active {
|
|
125
|
-
transform: scale(0.95);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
&:focus {
|
|
129
|
-
outline: 2px solid #007bff;
|
|
130
|
-
outline-offset: 2px;
|
|
131
|
-
}
|
|
132
|
-
`;
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Media Queries
|
|
136
|
-
|
|
137
|
-
Responsive design with media queries:
|
|
138
|
-
|
|
139
|
-
```javascript
|
|
140
|
-
const Container = styled.div`
|
|
141
|
-
padding: 1rem;
|
|
142
|
-
|
|
143
|
-
@media (min-width: 768px) {
|
|
144
|
-
padding: 2rem;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
@media (min-width: 1024px) {
|
|
148
|
-
padding: 3rem;
|
|
149
|
-
}
|
|
150
|
-
`;
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Theming
|
|
154
|
-
|
|
155
|
-
Use ThemeProvider for global themes:
|
|
156
|
-
|
|
157
|
-
```javascript
|
|
158
|
-
import { ThemeProvider } from 'styled-components';
|
|
159
|
-
|
|
160
|
-
const theme = {
|
|
161
|
-
colors: {
|
|
162
|
-
primary: '#007bff',
|
|
163
|
-
secondary: '#6c757d',
|
|
164
|
-
success: '#28a745',
|
|
165
|
-
},
|
|
166
|
-
spacing: {
|
|
167
|
-
sm: '0.5rem',
|
|
168
|
-
md: '1rem',
|
|
169
|
-
lg: '2rem',
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
// In your app
|
|
174
|
-
<ThemeProvider theme={theme}>
|
|
175
|
-
<App />
|
|
176
|
-
</ThemeProvider>
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
Access theme in styled components:
|
|
180
|
-
|
|
181
|
-
```javascript
|
|
182
|
-
const Button = styled.button`
|
|
183
|
-
background-color: ${props => props.theme.colors.primary};
|
|
184
|
-
padding: ${props => props.theme.spacing.md};
|
|
185
|
-
`;
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
## Best Practices
|
|
189
|
-
|
|
190
|
-
### 1. Component Naming
|
|
191
|
-
|
|
192
|
-
Use PascalCase for styled components:
|
|
193
|
-
|
|
194
|
-
```javascript
|
|
195
|
-
// Good
|
|
196
|
-
const PrimaryButton = styled.button`...`;
|
|
197
|
-
const CardHeader = styled.div`...`;
|
|
198
|
-
|
|
199
|
-
// Avoid
|
|
200
|
-
const button = styled.button`...`;
|
|
201
|
-
const card_header = styled.div`...`;
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### 2. Extract Common Styles
|
|
205
|
-
|
|
206
|
-
Create base components and extend them:
|
|
207
|
-
|
|
208
|
-
```javascript
|
|
209
|
-
const ButtonBase = styled.button`
|
|
210
|
-
color: #ffffff;
|
|
211
|
-
font-weight: bold;
|
|
212
|
-
padding: 0.75rem 1.5rem;
|
|
213
|
-
border-radius: 0.5rem;
|
|
214
|
-
border: none;
|
|
215
|
-
cursor: pointer;
|
|
216
|
-
`;
|
|
217
|
-
|
|
218
|
-
const PrimaryButton = styled(ButtonBase)`
|
|
219
|
-
background-color: #007bff;
|
|
220
|
-
|
|
221
|
-
&:hover {
|
|
222
|
-
background-color: #0056b3;
|
|
223
|
-
}
|
|
224
|
-
`;
|
|
225
|
-
|
|
226
|
-
const SecondaryButton = styled(ButtonBase)`
|
|
227
|
-
background-color: #6c757d;
|
|
228
|
-
|
|
229
|
-
&:hover {
|
|
230
|
-
background-color: #545b62;
|
|
231
|
-
}
|
|
232
|
-
`;
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### 3. Use Props Wisely
|
|
236
|
-
|
|
237
|
-
Keep prop-based styling simple:
|
|
238
|
-
|
|
239
|
-
```javascript
|
|
240
|
-
// Good
|
|
241
|
-
const Button = styled.button`
|
|
242
|
-
background-color: ${props => props.variant === 'primary' ? '#007bff' : '#6c757d'};
|
|
243
|
-
`;
|
|
244
|
-
|
|
245
|
-
// Avoid complex logic in template literals
|
|
246
|
-
const Button = styled.button`
|
|
247
|
-
background-color: ${props => {
|
|
248
|
-
if (props.variant === 'primary') {
|
|
249
|
-
if (props.disabled) return '#ccc';
|
|
250
|
-
return '#007bff';
|
|
251
|
-
}
|
|
252
|
-
// ... too complex
|
|
253
|
-
}};
|
|
254
|
-
`;
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
### 4. Organize Files
|
|
258
|
-
|
|
259
|
-
Group related styled components together:
|
|
260
|
-
|
|
261
|
-
```javascript
|
|
262
|
-
// components/Button.styled.js
|
|
263
|
-
export const Button = styled.button`...`;
|
|
264
|
-
export const ButtonGroup = styled.div`...`;
|
|
265
|
-
|
|
266
|
-
// components/Card.styled.js
|
|
267
|
-
export const Card = styled.div`...`;
|
|
268
|
-
export const CardHeader = styled.div`...`;
|
|
269
|
-
export const CardBody = styled.div`...`;
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
### 5. Performance
|
|
273
|
-
|
|
274
|
-
Use `React.memo` for expensive styled components:
|
|
275
|
-
|
|
276
|
-
```javascript
|
|
277
|
-
const ExpensiveComponent = React.memo(styled.div`
|
|
278
|
-
/* complex styles */
|
|
279
|
-
`);
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
## Advanced Patterns
|
|
283
|
-
|
|
284
|
-
### Extending Components
|
|
285
|
-
|
|
286
|
-
Extend existing styled components:
|
|
287
|
-
|
|
288
|
-
```javascript
|
|
289
|
-
const Button = styled.button`
|
|
290
|
-
padding: 0.75rem 1.5rem;
|
|
291
|
-
border-radius: 0.5rem;
|
|
292
|
-
`;
|
|
293
|
-
|
|
294
|
-
const PrimaryButton = styled(Button)`
|
|
295
|
-
background-color: #007bff;
|
|
296
|
-
color: white;
|
|
297
|
-
`;
|
|
298
|
-
|
|
299
|
-
const LargeButton = styled(Button)`
|
|
300
|
-
padding: 1rem 2rem;
|
|
301
|
-
font-size: 1.25rem;
|
|
302
|
-
`;
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
### Conditional Rendering
|
|
306
|
-
|
|
307
|
-
Use conditional logic in styles:
|
|
308
|
-
|
|
309
|
-
```javascript
|
|
310
|
-
const Container = styled.div`
|
|
311
|
-
display: ${props => props.hidden ? 'none' : 'flex'};
|
|
312
|
-
opacity: ${props => props.disabled ? 0.5 : 1};
|
|
313
|
-
pointer-events: ${props => props.disabled ? 'none' : 'auto'};
|
|
314
|
-
`;
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
### Animations
|
|
318
|
-
|
|
319
|
-
Use CSS animations:
|
|
320
|
-
|
|
321
|
-
```javascript
|
|
322
|
-
const FadeIn = styled.div`
|
|
323
|
-
animation: fadeIn 0.5s ease-in;
|
|
324
|
-
|
|
325
|
-
@keyframes fadeIn {
|
|
326
|
-
from {
|
|
327
|
-
opacity: 0;
|
|
328
|
-
transform: translateY(-10px);
|
|
329
|
-
}
|
|
330
|
-
to {
|
|
331
|
-
opacity: 1;
|
|
332
|
-
transform: translateY(0);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
`;
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
## Advantages
|
|
339
|
-
|
|
340
|
-
- **Component-scoped styles** (no CSS conflicts)
|
|
341
|
-
- **Dynamic styling** based on props
|
|
342
|
-
- **Full CSS features** (pseudo-classes, media queries)
|
|
343
|
-
- **Type-safe** with TypeScript
|
|
344
|
-
- **Automatic vendor prefixing**
|
|
345
|
-
- **Dead code elimination**
|
|
346
|
-
- **No class name collisions**
|
|
347
|
-
|
|
348
|
-
## Limitations
|
|
349
|
-
|
|
350
|
-
- **Runtime overhead** (styles generated at runtime)
|
|
351
|
-
- **Learning curve** for CSS-in-JS
|
|
352
|
-
- **Larger bundle size** than CSS
|
|
353
|
-
- **Requires JavaScript** for styling
|
|
354
|
-
- **Debugging** can be harder
|
|
355
|
-
|
|
356
|
-
## When to Use
|
|
357
|
-
|
|
358
|
-
Choose Styled Components when:
|
|
359
|
-
|
|
360
|
-
- You want component-scoped styles
|
|
361
|
-
- You need dynamic styling based on props
|
|
362
|
-
- You prefer CSS-in-JS approach
|
|
363
|
-
- You're building component libraries
|
|
364
|
-
- You want full CSS features in JavaScript
|
|
365
|
-
- You want to avoid class name conflicts
|
|
366
|
-
|
|
367
|
-
## Import Syntax
|
|
368
|
-
|
|
369
|
-
Styled components are imported as JavaScript modules:
|
|
370
|
-
|
|
371
|
-
```jac
|
|
372
|
-
cl import from .styled {
|
|
373
|
-
Container,
|
|
374
|
-
Card,
|
|
375
|
-
Button
|
|
376
|
-
}
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
For external packages:
|
|
380
|
-
|
|
381
|
-
```jac
|
|
382
|
-
cl import from "styled-components" { default as styled }
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
## Next Steps
|
|
386
|
-
|
|
387
|
-
- Explore [Emotion](./emotion.md) for similar CSS-in-JS (coming soon)
|
|
388
|
-
- Check out [Vanilla Extract](./vanilla-extract.md) for zero-runtime CSS-in-JS (coming soon)
|
|
389
|
-
- Learn about [JavaScript Styling](./js-styling.md) for inline styles
|
|
390
|
-
- See [CSS Modules](./css-modules.md) for scoped CSS (coming soon)
|
|
391
|
-
|
|
392
|
-
## Resources
|
|
393
|
-
|
|
394
|
-
- [Styled Components Documentation](https://styled-components.com/docs)
|
|
395
|
-
- [Styled Components Best Practices](https://styled-components.com/docs/basics#styling-any-component)
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
# Tailwind CSS
|
|
2
|
-
|
|
3
|
-
Utility-first CSS framework for rapid UI development in Jac applications.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Tailwind CSS provides low-level utility classes that you can compose to build custom designs. This approach is perfect for:
|
|
8
|
-
- Rapid UI development
|
|
9
|
-
- Consistent design systems
|
|
10
|
-
- Responsive designs
|
|
11
|
-
- Modern, utility-based styling
|
|
12
|
-
|
|
13
|
-
## Example
|
|
14
|
-
|
|
15
|
-
See the complete working example: [`examples/css-styling/tailwind-example/`](../../examples/css-styling/tailwind-example/)
|
|
16
|
-
|
|
17
|
-
## Quick Start
|
|
18
|
-
|
|
19
|
-
### 1. Install Tailwind CSS
|
|
20
|
-
|
|
21
|
-
Add to `package.json`:
|
|
22
|
-
|
|
23
|
-
```json
|
|
24
|
-
{
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@tailwindcss/vite": "^4.0.0"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### 2. Configure Vite
|
|
32
|
-
|
|
33
|
-
Update `vite.config.js`:
|
|
34
|
-
|
|
35
|
-
```javascript
|
|
36
|
-
import { defineConfig } from "vite";
|
|
37
|
-
import tailwindcss from '@tailwindcss/vite'
|
|
38
|
-
|
|
39
|
-
export default defineConfig({
|
|
40
|
-
plugins: [tailwindcss()],
|
|
41
|
-
// ... other config
|
|
42
|
-
});
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### 3. Add Tailwind Directives
|
|
46
|
-
|
|
47
|
-
Create `global.css`:
|
|
48
|
-
|
|
49
|
-
```css
|
|
50
|
-
@import "tailwindcss";
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 4. Import CSS in Jac
|
|
54
|
-
|
|
55
|
-
```jac
|
|
56
|
-
# Pages
|
|
57
|
-
cl import from react {useState, useEffect}
|
|
58
|
-
cl import ".global.css";
|
|
59
|
-
|
|
60
|
-
cl {
|
|
61
|
-
def app() -> any {
|
|
62
|
-
return <div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100">
|
|
63
|
-
<h1 className="text-3xl font-bold">Hello, Tailwind!</h1>
|
|
64
|
-
</div>;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Using Utility Classes
|
|
70
|
-
|
|
71
|
-
### Spacing
|
|
72
|
-
|
|
73
|
-
```jac
|
|
74
|
-
<div className="p-4 m-2 gap-4">
|
|
75
|
-
{/* padding: 1rem, margin: 0.5rem, gap: 1rem */}
|
|
76
|
-
</div>
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### Colors
|
|
80
|
-
|
|
81
|
-
```jac
|
|
82
|
-
<div className="bg-blue-500 text-white hover:bg-blue-600">
|
|
83
|
-
{/* Blue background, white text, darker blue on hover */}
|
|
84
|
-
</div>
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Layout
|
|
88
|
-
|
|
89
|
-
```jac
|
|
90
|
-
<div className="flex items-center justify-center">
|
|
91
|
-
{/* Flexbox with centered items */}
|
|
92
|
-
</div>
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Responsive
|
|
96
|
-
|
|
97
|
-
```jac
|
|
98
|
-
<div className="text-sm md:text-lg lg:text-xl">
|
|
99
|
-
{/* Small on mobile, large on tablet, xl on desktop */}
|
|
100
|
-
</div>
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Dynamic Classes
|
|
104
|
-
|
|
105
|
-
Combine static and dynamic classes:
|
|
106
|
-
|
|
107
|
-
```jac
|
|
108
|
-
let countColorClass = "text-gray-800" if count == 0 else ("text-green-600" if count > 0 else "text-red-600");
|
|
109
|
-
|
|
110
|
-
return <div className={"text-6xl font-bold " + countColorClass + " transition-colors duration-300"}>
|
|
111
|
-
{count}
|
|
112
|
-
</div>;
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Common Utility Patterns
|
|
116
|
-
|
|
117
|
-
### Buttons
|
|
118
|
-
|
|
119
|
-
```jac
|
|
120
|
-
<button className="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded">
|
|
121
|
-
Click Me
|
|
122
|
-
</button>
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Cards
|
|
126
|
-
|
|
127
|
-
```jac
|
|
128
|
-
<div className="bg-white rounded-lg shadow-lg p-6">
|
|
129
|
-
<h2 className="text-2xl font-bold mb-4">Card Title</h2>
|
|
130
|
-
<p className="text-gray-600">Card content</p>
|
|
131
|
-
</div>
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### Flexbox Layouts
|
|
135
|
-
|
|
136
|
-
```jac
|
|
137
|
-
<div className="flex flex-col md:flex-row gap-4">
|
|
138
|
-
<div className="flex-1">Column 1</div>
|
|
139
|
-
<div className="flex-1">Column 2</div>
|
|
140
|
-
</div>
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Grid Layouts
|
|
144
|
-
|
|
145
|
-
```jac
|
|
146
|
-
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
147
|
-
<div>Item 1</div>
|
|
148
|
-
<div>Item 2</div>
|
|
149
|
-
<div>Item 3</div>
|
|
150
|
-
</div>
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Best Practices
|
|
154
|
-
|
|
155
|
-
### 1. Use Responsive Prefixes
|
|
156
|
-
|
|
157
|
-
Design mobile-first with responsive breakpoints:
|
|
158
|
-
|
|
159
|
-
```jac
|
|
160
|
-
<div className="text-sm md:text-base lg:text-lg">
|
|
161
|
-
Responsive text
|
|
162
|
-
</div>
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### 2. Combine Utilities
|
|
166
|
-
|
|
167
|
-
Chain multiple utilities for complex styles:
|
|
168
|
-
|
|
169
|
-
```jac
|
|
170
|
-
<button className="bg-blue-500 hover:bg-blue-600 text-white font-bold py-3 px-6 rounded-lg shadow-lg transition-all duration-200 transform hover:scale-105">
|
|
171
|
-
Button
|
|
172
|
-
</button>
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### 3. Use Hover/Focus States
|
|
176
|
-
|
|
177
|
-
Leverage pseudo-class variants:
|
|
178
|
-
|
|
179
|
-
```jac
|
|
180
|
-
<button className="bg-blue-500 hover:bg-blue-600 focus:ring-2 focus:ring-blue-300">
|
|
181
|
-
Interactive Button
|
|
182
|
-
</button>
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### 4. Leverage Transitions
|
|
186
|
-
|
|
187
|
-
Add smooth transitions:
|
|
188
|
-
|
|
189
|
-
```jac
|
|
190
|
-
<div className="transition-all duration-200 hover:scale-105">
|
|
191
|
-
Hoverable element
|
|
192
|
-
</div>
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### 5. Use Arbitrary Values
|
|
196
|
-
|
|
197
|
-
For custom values:
|
|
198
|
-
|
|
199
|
-
```jac
|
|
200
|
-
<div className="w-[500px] h-[300px] bg-[#1da1f2]">
|
|
201
|
-
Custom dimensions and color
|
|
202
|
-
</div>
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## Configuration
|
|
206
|
-
|
|
207
|
-
Customize Tailwind in `tailwind.config.js`:
|
|
208
|
-
|
|
209
|
-
```javascript
|
|
210
|
-
export default {
|
|
211
|
-
theme: {
|
|
212
|
-
extend: {
|
|
213
|
-
colors: {
|
|
214
|
-
'brand': '#your-color',
|
|
215
|
-
},
|
|
216
|
-
spacing: {
|
|
217
|
-
'128': '32rem',
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
## Advantages
|
|
225
|
-
|
|
226
|
-
- **Rapid development** with utility classes
|
|
227
|
-
- **Consistent design system**
|
|
228
|
-
- **Responsive by default**
|
|
229
|
-
- **Small bundle size** (unused classes are purged)
|
|
230
|
-
- **Great documentation** and ecosystem
|
|
231
|
-
- **Highly customizable**
|
|
232
|
-
|
|
233
|
-
## Limitations
|
|
234
|
-
|
|
235
|
-
- **Can get verbose** with many classes
|
|
236
|
-
- **Learning curve** for utility-first approach
|
|
237
|
-
- **Less semantic** than component-based CSS
|
|
238
|
-
- **Requires build step**
|
|
239
|
-
- **HTML can get cluttered**
|
|
240
|
-
|
|
241
|
-
## When to Use
|
|
242
|
-
|
|
243
|
-
Choose Tailwind CSS when:
|
|
244
|
-
|
|
245
|
-
- You want to build UIs quickly
|
|
246
|
-
- You prefer utility classes over custom CSS
|
|
247
|
-
- You need a consistent design system
|
|
248
|
-
- You're building modern, responsive designs
|
|
249
|
-
- You want a small bundle size
|
|
250
|
-
- You prefer configuration over writing CSS
|
|
251
|
-
|
|
252
|
-
## Purging Unused Classes
|
|
253
|
-
|
|
254
|
-
Tailwind automatically removes unused classes in production builds, keeping bundle size small. No configuration needed with Vite plugin.
|
|
255
|
-
|
|
256
|
-
## Customization
|
|
257
|
-
|
|
258
|
-
### Custom Colors
|
|
259
|
-
|
|
260
|
-
```javascript
|
|
261
|
-
// tailwind.config.js
|
|
262
|
-
export default {
|
|
263
|
-
theme: {
|
|
264
|
-
extend: {
|
|
265
|
-
colors: {
|
|
266
|
-
'brand-blue': '#1e40af',
|
|
267
|
-
'brand-purple': '#7c3aed',
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
}
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
### Custom Spacing
|
|
275
|
-
|
|
276
|
-
```javascript
|
|
277
|
-
theme: {
|
|
278
|
-
extend: {
|
|
279
|
-
spacing: {
|
|
280
|
-
'18': '4.5rem',
|
|
281
|
-
'88': '22rem',
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
}
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
## Next Steps
|
|
288
|
-
|
|
289
|
-
- Explore [Tailwind CSS Documentation](https://tailwindcss.com/docs)
|
|
290
|
-
- Check out [UnoCSS](./unocss.md) for similar utility-first approach (coming soon)
|
|
291
|
-
- Learn about [CSS Modules](./css-modules.md) for component-scoped styles (coming soon)
|
|
292
|
-
- See [Pure CSS](./pure-css.md) for traditional CSS approach
|
|
293
|
-
|
|
294
|
-
## Resources
|
|
295
|
-
|
|
296
|
-
- [Tailwind CSS Documentation](https://tailwindcss.com/docs)
|
|
297
|
-
- [Tailwind UI Components](https://tailwindui.com/)
|
|
298
|
-
- [Tailwind Play](https://play.tailwindcss.com/) - Online playground
|