@maccesar/titools 2.2.11 → 2.3.0

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 (99) hide show
  1. package/README.md +255 -713
  2. package/bin/titools.js +1 -1
  3. package/lib/commands/update.js +5 -6
  4. package/lib/config.js +1 -0
  5. package/lib/downloader.js +10 -0
  6. package/package.json +1 -1
  7. package/skills/alloy-guides/SKILL.md +46 -48
  8. package/skills/alloy-guides/references/CONTROLLERS.md +4 -6
  9. package/skills/alloy-guides/references/MODELS.md +340 -184
  10. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +3 -4
  11. package/skills/alloy-guides/references/VIEWS_STYLES.md +44 -46
  12. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +4 -5
  13. package/skills/alloy-guides/references/VIEWS_XML.md +51 -17
  14. package/skills/alloy-guides/references/WIDGETS.md +1 -1
  15. package/skills/alloy-howtos/SKILL.md +12 -13
  16. package/skills/alloy-howtos/references/cli_reference.md +40 -41
  17. package/skills/alloy-howtos/references/samples.md +3 -4
  18. package/skills/purgetss/SKILL.md +369 -356
  19. package/skills/purgetss/references/EXAMPLES.md +24 -25
  20. package/skills/purgetss/references/animation-advanced.md +555 -0
  21. package/skills/purgetss/references/animation-system.md +395 -995
  22. package/skills/purgetss/references/apply-directive.md +111 -141
  23. package/skills/purgetss/references/arbitrary-values.md +206 -480
  24. package/skills/purgetss/references/class-categories.md +277 -0
  25. package/skills/purgetss/references/class-index.md +1 -420
  26. package/skills/purgetss/references/cli-commands.md +446 -556
  27. package/skills/purgetss/references/configurable-properties.md +163 -599
  28. package/skills/purgetss/references/custom-rules.md +33 -76
  29. package/skills/purgetss/references/customization-deep-dive.md +319 -518
  30. package/skills/purgetss/references/dynamic-component-creation.md +33 -37
  31. package/skills/purgetss/references/grid-layout.md +42 -371
  32. package/skills/purgetss/references/icon-fonts.md +82 -475
  33. package/skills/purgetss/references/installation-setup.md +159 -331
  34. package/skills/purgetss/references/migration-guide.md +54 -109
  35. package/skills/purgetss/references/opacity-modifier.md +25 -222
  36. package/skills/purgetss/references/performance-tips.md +2 -2
  37. package/skills/purgetss/references/platform-modifiers.md +21 -407
  38. package/skills/purgetss/references/tikit-components.md +237 -104
  39. package/skills/purgetss/references/titanium-resets.md +20 -21
  40. package/skills/purgetss/references/ui-ux-design.md +171 -1702
  41. package/skills/ti-api/SKILL.md +109 -0
  42. package/skills/ti-api/references/api-android.md +675 -0
  43. package/skills/ti-api/references/api-app-platform.md +636 -0
  44. package/skills/ti-api/references/api-core.md +764 -0
  45. package/skills/ti-api/references/api-data-network.md +641 -0
  46. package/skills/ti-api/references/api-media.md +655 -0
  47. package/skills/ti-api/references/api-modules-ble-bluetooth.md +657 -0
  48. package/skills/ti-api/references/api-modules-coremotion-urlsession.md +411 -0
  49. package/skills/ti-api/references/api-modules-map.md +632 -0
  50. package/skills/ti-api/references/api-modules-nfc.md +725 -0
  51. package/skills/ti-api/references/api-modules-social-misc.md +526 -0
  52. package/skills/ti-api/references/api-services.md +700 -0
  53. package/skills/ti-api/references/api-ui-android.md +499 -0
  54. package/skills/ti-api/references/api-ui-extras.md +702 -0
  55. package/skills/ti-api/references/api-ui-ios-animator.md +378 -0
  56. package/skills/ti-api/references/api-ui-ios.md +756 -0
  57. package/skills/ti-api/references/api-ui-lists.md +581 -0
  58. package/skills/ti-api/references/api-ui-text-input.md +607 -0
  59. package/skills/ti-api/references/api-ui-views.md +572 -0
  60. package/skills/ti-api/references/api-ui-windows-navigation.md +676 -0
  61. package/skills/ti-api/references/api-xml-global.md +743 -0
  62. package/skills/ti-expert/SKILL.md +106 -138
  63. package/skills/ti-expert/references/adaptive-layouts.md +414 -0
  64. package/skills/ti-expert/references/alloy-builtins.md +16 -20
  65. package/skills/ti-expert/references/alloy-structure.md +40 -42
  66. package/skills/ti-expert/references/anti-patterns.md +34 -0
  67. package/skills/ti-expert/references/architecture-tiers.md +248 -0
  68. package/skills/ti-expert/references/code-conventions.md +5 -3
  69. package/skills/ti-expert/references/error-handling.md +14 -7
  70. package/skills/ti-expert/references/examples.md +4 -2
  71. package/skills/ti-expert/references/performance-optimization.md +26 -24
  72. package/skills/ti-expert/references/security-device.md +17 -14
  73. package/skills/ti-expert/references/security-fundamentals.md +60 -101
  74. package/skills/ti-expert/references/state-management.md +15 -14
  75. package/skills/ti-expert/references/testing-e2e-ci.md +30 -21
  76. package/skills/ti-expert/references/theming.md +12 -20
  77. package/skills/ti-guides/SKILL.md +13 -17
  78. package/skills/ti-guides/references/advanced-data-and-images.md +30 -10
  79. package/skills/ti-guides/references/application-frameworks.md +3 -3
  80. package/skills/ti-guides/references/coding-best-practices.md +31 -2
  81. package/skills/ti-guides/references/commonjs-advanced.md +46 -4
  82. package/skills/ti-guides/references/hello-world.md +9 -13
  83. package/skills/ti-guides/references/hyperloop-native-access.md +4 -1
  84. package/skills/ti-guides/references/javascript-primer.md +13 -5
  85. package/skills/ti-guides/references/resources.md +0 -2
  86. package/skills/ti-guides/references/style-and-conventions.md +1 -0
  87. package/skills/ti-guides/references/tiapp-config.md +0 -32
  88. package/skills/ti-howtos/SKILL.md +43 -45
  89. package/skills/ti-howtos/references/buffer-codec-streams.md +25 -3
  90. package/skills/ti-howtos/references/debugging-profiling.md +14 -25
  91. package/skills/ti-howtos/references/google-maps-v2.md +3 -3
  92. package/skills/ti-howtos/references/ios-map-kit.md +8 -1
  93. package/skills/ti-howtos/references/notification-services.md +0 -1
  94. package/skills/ti-howtos/references/webpack-build-pipeline.md +3 -0
  95. package/skills/ti-ui/SKILL.md +47 -49
  96. package/skills/ti-ui/references/application-structures.md +3 -2
  97. package/skills/ti-ui/references/orientation.md +17 -9
  98. package/skills/ti-ui/references/platform-ui-ios.md +63 -0
  99. package/skills/ti-ui/references/scrolling-views.md +39 -0
@@ -7,9 +7,8 @@ When creating components dynamically in Controllers (not declaratively in XML),
7
7
  1. **`$.UI.create()`** - Create components with PurgeTSS classes (Recommended)
8
8
  2. **`Alloy.createStyle()` + `applyProperties()`** - Apply PurgeTSS styles to existing components
9
9
 
10
- :::tip BEST PRACTICE
11
- **Always prefer `$.UI.create()` for dynamic components** - it's cleaner, more readable, and PurgeTSS will process the classes automatically during build.
12
- :::
10
+ > **💡 BEST PRACTICE**
11
+ > **Always prefer `$.UI.create()` for dynamic components** - it's cleaner, more readable, and PurgeTSS will process the classes automatically during build.
13
12
 
14
13
  ---
15
14
 
@@ -110,17 +109,17 @@ classes: [
110
109
  ```javascript
111
110
  function createListItem(text, icon) {
112
111
  const container = $.UI.create('View', {
113
- classes: ['horizontal', 'm-4', 'p-4', 'bg-white', 'rounded-lg']
112
+ classes: ['horizontal', 'bg-white', 'rounded-lg']
114
113
  })
115
114
 
116
115
  const iconView = $.UI.create('Label', {
117
116
  text: icon,
118
- classes: ['text-2xl', 'mr-4']
117
+ classes: ['m-4', 'text-2xl']
119
118
  })
120
119
 
121
120
  const label = $.UI.create('Label', {
122
121
  text: text,
123
- classes: ['text-base', 'font-semibold']
122
+ classes: ['my-4', 'text-base', 'font-semibold']
124
123
  })
125
124
 
126
125
  container.add(iconView)
@@ -212,7 +211,7 @@ Alloy.createStyle('index', {
212
211
 
213
212
  ```javascript
214
213
  // lib/factories/formFactory.js
215
- exports.createFormField = function fieldType, options) {
214
+ exports.createFormField = function(fieldType, options) {
216
215
  const baseClasses = ['w-screen', 'h-12', 'mx-4', 'border-gray-300', 'border-(1)', 'rounded-lg']
217
216
 
218
217
  switch (fieldType) {
@@ -252,17 +251,17 @@ function createProductCard(product) {
252
251
  })
253
252
 
254
253
  const info = $.UI.create('View', {
255
- classes: ['vertical', 'p-4']
254
+ classes: ['vertical']
256
255
  })
257
256
 
258
257
  const title = $.UI.create('Label', {
259
258
  text: product.name,
260
- classes: ['text-lg', 'font-bold', 'mb-2']
259
+ classes: ['mx-4', 'mt-4', 'text-lg', 'font-bold']
261
260
  })
262
261
 
263
262
  const price = $.UI.create('Label', {
264
263
  text: `$${product.price}`,
265
- classes: ['text-xl', 'text-green-600', 'font-bold']
264
+ classes: ['mx-4', 'mb-4', 'text-xl', 'text-green-600', 'font-bold']
266
265
  })
267
266
 
268
267
  info.add(title)
@@ -301,22 +300,22 @@ function applyTheme(theme) {
301
300
  // controllers/dashboard/grid.js
302
301
  function createIconGrid(items) {
303
302
  const grid = $.UI.create('View', {
304
- classes: ['w-screen', 'grid-cols-4', 'gap-4', 'p-4']
303
+ classes: ['w-screen', 'grid-cols-4', 'gap-4']
305
304
  })
306
305
 
307
306
  items.forEach(item => {
308
307
  const icon = $.UI.create('View', {
309
- classes: ['vertical', 'items-center']
308
+ classes: ['vertical']
310
309
  })
311
310
 
312
311
  const iconView = $.UI.create('Label', {
313
312
  text: item.icon,
314
- classes: ['text-3xl', 'mb-2', 'text-blue-500']
313
+ classes: ['mx-auto', 'mt-4', 'text-3xl', 'text-blue-500']
315
314
  })
316
315
 
317
316
  const label = $.UI.create('Label', {
318
317
  text: item.label,
319
- classes: ['text-xs', 'text-center', 'text-gray-600']
318
+ classes: ['mx-2', 'mb-4', 'text-xs', 'text-center', 'text-gray-600']
320
319
  })
321
320
 
322
321
  icon.add(iconView)
@@ -334,15 +333,14 @@ function createIconGrid(items) {
334
333
 
335
334
  ### PurgeTSS Processes Classes During Build
336
335
 
337
- :::info HOW IT WORKS
338
- When you use `$.UI.create()` or `Alloy.createStyle()` with classes:
339
-
340
- 1. PurgeTSS scans your controllers for these class references
341
- 2. It adds the classes to the generated `app.tss`
342
- 3. At runtime, Alloy applies the styles to your components
343
-
344
- This means you get **full PurgeTSS power** even with dynamic components!
345
- :::
336
+ > **️ℹ️ HOW IT WORKS**
337
+ > When you use `$.UI.create()` or `Alloy.createStyle()` with classes:
338
+ >
339
+ > 1. PurgeTSS scans your controllers for these class references
340
+ > 2. It adds the classes to the generated `app.tss`
341
+ > 3. At runtime, Alloy applies the styles to your components
342
+ >
343
+ > This means you get **full PurgeTSS power** even with dynamic components!
346
344
 
347
345
  ### Class Verification
348
346
 
@@ -427,11 +425,10 @@ function setState(state) {
427
425
  }
428
426
  ```
429
427
 
430
- :::tip When to Use `classes` vs `applyProperties`
431
- - Use `classes` when you want to swap entire style sets (e.g., active/inactive states)
432
- - Use `applyProperties` with direct values when changing individual properties (e.g., text, enabled)
433
- - Combine both for complex state changes
434
- :::
428
+ > **💡 When to Use `classes` vs `applyProperties`**
429
+ > - Use `classes` when you want to swap entire style sets (e.g., active/inactive states)
430
+ > - Use `applyProperties` with direct values when changing individual properties (e.g., text, enabled)
431
+ > - Combine both for complex state changes
435
432
 
436
433
  ---
437
434
 
@@ -497,12 +494,11 @@ view.applyProperties(Alloy.createStyle('index', {
497
494
  | **`Alloy.createStyle()`** | Styling existing components | `Alloy.createStyle('view', { classes: 'bg-white' })` |
498
495
  | **`applyProperties()`** | Apply style to component | `component.applyProperties(style)` |
499
496
 
500
- :::tip REMEMBER
501
- Both methods give you **full access to PurgeTSS utilities**:
502
- - All color classes (`bg-*`, `text-*`, `border-*`)
503
- - All spacing classes (`m-*`, `p-*`, `gap-*`)
504
- - All layout classes (`horizontal`, `vertical`)
505
- - All typography classes (`text-*`, `font-*`)
506
- - Platform modifiers (`ios:*`, `android:*`)
507
- - Arbitrary values (`w-(100px)`, `bg-(#ff0000)`)
508
- :::
497
+ > **💡 REMEMBER**
498
+ > Both methods give you **full access to PurgeTSS utilities**:
499
+ > - All color classes (`bg-*`, `text-*`, `border-*`)
500
+ > - All spacing classes (`m-*`, `gap-*`, and `p-*` where the Titanium component supports padding)
501
+ > - All layout classes (`horizontal`, `vertical`)
502
+ > - All typography classes (`text-*`, `font-*`)
503
+ > - Platform modifiers (`ios:*`, `android:*`)
504
+ > - Arbitrary values (`w-(100px)`, `bg-(#ff0000)`)
@@ -1,20 +1,17 @@
1
- # Grid Layout System
1
+ # Grid System
2
2
 
3
- The PurgeTSS grid system is a layout tool with utilities to lay out columns and rows using Titanium's layout properties.
3
+ The grid system is a small layout tool that lets you build rows and columns with utility classes.
4
4
 
5
- :::caution Not CSS Grid
6
- **PurgeTSS grid does NOT work like CSS Grid.** Titanium lacks native CSS Grid support. The PurgeTSS grid system is an abstraction using `horizontal` and `vertical` layouts with percentage widths and margins.
7
- :::
5
+ > **WARNING**
6
+ > PurgeTSS grid is not CSS Grid. It is a Titanium-oriented layout helper built around horizontal and vertical layout behavior.
8
7
 
9
- ## Basic Structure
10
-
11
- This is the most basic layout for using the grid system:
8
+ The snippet below shows the simplest layout. From there, you can mix columns and rows as needed.
12
9
 
13
10
  ```xml
14
11
  <Alloy>
15
- <View class='grid'>
12
+ <View class="grid">
16
13
  <View class="grid-cols-4">
17
- <!-- Remove gap View if you don't need gutters between columns -->
14
+ <!-- Remove if you don't need a gutter between columns (or rows) -->
18
15
  <View class="gap-1">
19
16
  <!-- ANY CONTENT GOES HERE -->
20
17
  </View>
@@ -31,393 +28,67 @@ This is the most basic layout for using the grid system:
31
28
 
32
29
  ## Column Grid
33
30
 
34
- ### `.grid-cols-{n}`
35
-
36
- With `grid-cols`, you tell the grid system how many columns you want to fit in each row:
37
-
38
- - `grid-cols-1` - 1 column per row (100% width each)
39
- - `grid-cols-2` - 2 columns per row (50% width each)
40
- - `grid-cols-3` - 3 columns per row (33.33% width each)
41
- - `grid-cols-4` - 4 columns per row (25% width each)
42
- - And so on...
43
-
44
- ```xml
45
- <View class="grid">
46
- <View class="grid-cols-2">
47
- <!-- Each view is 50% width -->
48
- </View>
49
- <View class="grid-cols-2">
50
- <!-- Each view is 50% width -->
51
- </View>
52
- </View>
53
- ```
54
-
55
- ### `.col-span-{n}`
31
+ ### `grid-cols-{n}`
56
32
 
57
- With `col-span`, you set the number of columns each element will occupy in a **12-column grid**:
33
+ Use `grid-cols` to set how many columns fit in each row. For example, `.grid-cols-2` fits two views per row, `.grid-cols-3` fits three, and so on.
58
34
 
59
- - `col-span-1` - Spans 1 column (8.33% width)
60
- - `col-span-2` - Spans 2 columns (16.66% width)
61
- - `col-span-3` - Spans 3 columns (25% width)
62
- - `col-span-4` - Spans 4 columns (33.33% width)
63
- - `col-span-6` - Spans 6 columns (50% width)
64
- - `col-span-12` - Spans 12 columns (100% width)
35
+ ### `col-span-{n}`
65
36
 
66
- If you set a view with `.col-span-3`, you can add three more views of equal width to fill the row, or any other combination like 3-6-3, 2-4-6, etc., as long as the sum fills a **12-column grid**.
37
+ Use `col-span` to set how many columns an element occupies in a 12-column grid.
67
38
 
68
- ```xml
69
- <!-- 12-column grid examples -->
70
- <View class="grid">
71
- <!-- 3 + 3 + 3 + 3 = 12 -->
72
- <View class="col-span-3">...</View>
73
- <View class="col-span-3">...</View>
74
- <View class="col-span-3">...</View>
75
- <View class="col-span-3">...</View>
76
- </View>
77
-
78
- <View class="grid">
79
- <!-- 6 + 6 = 12 -->
80
- <View class="col-span-6">...</View>
81
- <View class="col-span-6">...</View>
82
- </View>
83
-
84
- <View class="grid">
85
- <!-- 4 + 4 + 4 = 12 -->
86
- <View class="col-span-4">...</View>
87
- <View class="col-span-4">...</View>
88
- <View class="col-span-4">...</View>
89
- </View>
90
- ```
39
+ If a view uses `.col-span-3`, you can add three more views of the same width to fill the row. Other combos like 3-6-3 or 2-4-6 work too, as long as the total is 12.
91
40
 
92
41
  ## Row Grid
93
42
 
94
- ### `.grid-rows-{n}`
95
-
96
- With `grid-rows`, you tell the grid system how many rows you want to fit in each column:
97
-
98
- - `grid-rows-2` - 2 rows per column
99
- - `grid-rows-3` - 3 rows per column
100
- - And so on...
101
-
102
- ```xml
103
- <View class="grid-flow-row">
104
- <View class="grid-rows-2">
105
- <!-- Each view is 50% height -->
106
- </View>
107
- <View class="grid-rows-2">
108
- <!-- Each view is 50% height -->
109
- </View>
110
- </View>
111
- ```
112
-
113
- ### `.row-span-{n}`
114
-
115
- With `row-span`, you set the number of rows each element will occupy in a **12-row grid**:
116
-
117
- - `row-span-1` through `row-span-12`
118
-
119
- If you set a view with `.row-span-3`, you can add three more views of equal height to fill the column, or any other combination like 3-6-3, 2-4-6, etc., as long as the sum fills a **12-row grid**.
120
-
121
- ```xml
122
- <!-- 12-row grid example -->
123
- <View class="grid-flow-row">
124
- <!-- 6 + 6 = 12 -->
125
- <View class="row-span-6">...</View>
126
- <View class="row-span-6">...</View>
127
- </View>
128
- ```
129
-
130
- ## Gutter Utilities
131
-
132
- The gap utilities add spacing between grid items.
133
-
134
- :::warning Important Note on Gaps
135
- **`gap-{size}` adds margin to ALL sides** (top, right, bottom, left), not just between elements. This is different from CSS gap and can cause layout issues if not used carefully.
136
- :::
137
-
138
- ### Available Gap Utilities
139
-
140
- - **`gap-{size}`** - Gap between rows and columns
141
- - **`gap-x-{size}`** - Gap between columns only
142
- - **`gap-y-{size}`** - Gap between rows only
143
- - **`gap-t-{size}`** - Gap on top side
144
- - **`gap-r-{size}`** - Gap on right side
145
- - **`gap-b-{size}`** - Gap on bottom side
146
- - **`gap-l-{size}`** - Gap on left side
147
-
148
- ```xml
149
- <View class="grid">
150
- <View class="gap-1">
151
- <!-- 4px margin on all sides -->
152
- </View>
153
- <View class="gap-1">
154
- <!-- 4px margin on all sides -->
155
- </View>
156
- </View>
157
- ```
158
-
159
- ## Direction Utilities
160
-
161
- Control the flow direction of the grid:
162
-
163
- - **`.grid`** or **`.grid-flow-col`** - Sets `layout: 'horizontal'` (columns flow left to right)
164
- - **`.grid-flow-row`** - Sets `layout: 'vertical'` (rows flow top to bottom)
165
-
166
- ```xml
167
- <!-- Horizontal grid (default) -->
168
- <View class="grid">
169
- <View class="col-span-6">...</View>
170
- <View class="col-span-6">...</View>
171
- </View>
172
-
173
- <!-- Vertical grid -->
174
- <View class="grid-flow-row">
175
- <View class="row-span-6">...</View>
176
- <View class="row-span-6">...</View>
177
- </View>
178
- ```
179
-
180
- ## Alignment Utilities
181
-
182
- Align items within the grid:
183
-
184
- - **`.start`** - Aligns element to the start of a row
185
- - **`.center`** - Aligns element to the center of a row
186
- - **`.end`** - Aligns element to the end of a row
187
-
188
- ```xml
189
- <View class="grid">
190
- <View class="start col-span-4">...</View>
191
- <View class="center col-span-4">...</View>
192
- <View class="end col-span-4">...</View>
193
- </View>
194
- ```
195
-
196
- ## Common Layout Patterns
197
-
198
- ### Two-Column Layout
199
-
200
- ```xml
201
- <View class="grid">
202
- <View class="col-span-6 bg-blue-100">
203
- <Label text="Left Column" />
204
- </View>
205
- <View class="col-span-6 bg-green-100">
206
- <Label text="Right Column" />
207
- </View>
208
- </View>
209
- ```
210
-
211
- ### Three-Column Layout
43
+ ### `grid-rows-{n}`
212
44
 
213
- ```xml
214
- <View class="grid">
215
- <View class="col-span-4 bg-blue-100">
216
- <Label text="Column 1" />
217
- </View>
218
- <View class="col-span-4 bg-green-100">
219
- <Label text="Column 2" />
220
- </View>
221
- <View class="col-span-4 bg-red-100">
222
- <Label text="Column 3" />
223
- </View>
224
- </View>
225
- ```
45
+ Use `grid-rows` to set how many rows fit in each column. For example, `.grid-rows-2` fits two views per column, `.grid-rows-3` fits three, and so on.
226
46
 
227
- ### Sidebar + Main Content
47
+ ### `row-span-{n}`
228
48
 
229
- ```xml
230
- <View class="grid">
231
- <View class="col-span-3 bg-gray-100">
232
- <Label text="Sidebar" />
233
- </View>
234
- <View class="col-span-9 bg-white">
235
- <Label text="Main Content" />
236
- </View>
237
- </View>
238
- ```
49
+ Use `row-span` to set how many rows an element occupies in a 12-row grid.
239
50
 
240
- ### Asymmetric Layout
51
+ If a view uses `.row-span-3`, you can add three more views of the same height to fill the column. Other combos like 3-6-3 or 2-4-6 work too, as long as the total is 12.
241
52
 
242
- ```xml
243
- <View class="grid">
244
- <View class="col-span-8 bg-blue-100">
245
- <Label text="Wide Column" />
246
- </View>
247
- <View class="col-span-4 bg-green-100">
248
- <Label text="Narrow Column" />
249
- </View>
250
- </View>
251
- ```
53
+ ## Available Utilities
252
54
 
253
- ## Grid System Pitfalls and Solutions
55
+ These are the available utilities to control the grid.
254
56
 
255
- ### Problem: Gap Breaks Percentage Widths
57
+ ### Gutter Utilities
256
58
 
257
- ```xml
258
- <!-- This may overflow -->
259
- <View class="grid grid-cols-2">
260
- <View class="col-span-6 gap-2">
261
- <!-- 50% width + 8px margin all sides = overflow -->
262
- </View>
263
- <View class="col-span-6 gap-2">
264
- <!-- Same issue -->
265
- </View>
266
- </View>
267
- ```
59
+ - `gap-{size}`: Change the gap between rows and columns.
60
+ - `gap-x-{size}` and `gap-y-{size}`: Change the gap between rows and columns independently.
61
+ - `gap-{side}-{size}`: Change the gap on a specific side (t=top, r=right, b=bottom, l=left).
268
62
 
269
- **Solution**: Use explicit widths with margins
63
+ ### Column Span Utilities
270
64
 
271
- ```xml
272
- <!-- ✅ Better approach -->
273
- <View class="horizontal w-screen">
274
- <View class="w-(48%) mr-2">
275
- <!-- Card 1 -->
276
- </View>
277
- <View class="w-(48%) ml-2">
278
- <!-- Card 2 -->
279
- </View>
280
- </View>
281
- ```
65
+ - `col-span-{n}`: Make an element span `n` columns.
282
66
 
283
- ### Problem: Grid Without w-screen
67
+ ### Row Span Utilities
284
68
 
285
- ```xml
286
- <!-- ❌ Parent doesn't have explicit width -->
287
- <View>
288
- <View class="grid grid-cols-2">
289
- <!-- Percentage widths may not work correctly -->
290
- </View>
291
- </View>
292
- ```
69
+ - `row-span-{n}`: Make an element span `n` rows.
293
70
 
294
- **Solution**: Add `w-screen` to parent
71
+ ### Direction Utilities
295
72
 
296
- ```xml
297
- <!-- Parent has explicit width -->
298
- <View class="w-screen">
299
- <View class="grid grid-cols-2">
300
- <!-- Percentage widths work correctly -->
301
- </View>
302
- </View>
303
- ```
304
-
305
- ### Problem: Missing Gap Container
306
-
307
- ```xml
308
- <!-- ❌ Gap not applied correctly -->
309
- <View class="grid">
310
- <View class="col-span-6 bg-white">
311
- <!-- Content -->
312
- </View>
313
- </View>
314
- ```
315
-
316
- **Solution**: Wrap content in gap View
317
-
318
- ```xml
319
- <!-- ✅ Correct structure -->
320
- <View class="grid">
321
- <View class="col-span-6">
322
- <View class="gap-2 bg-white">
323
- <!-- Content -->
324
- </View>
325
- </View>
326
- </View>
327
- ```
73
+ - `grid` or `grid-flow-col`: Set the layout property to horizontal.
74
+ - `grid-flow-row`: Set the layout property to vertical.
328
75
 
329
- ## When to Use Grid vs. Manual Layout
76
+ ### Column Utilities
330
77
 
331
- ### Use Grid System When:
332
- - You need simple column layouts (2, 3, 4 columns)
333
- - Content is uniform in size
334
- - You don't need complex gutters
335
- - Building a dashboard or card grid
78
+ - `grid-cols-{n}`: Create grids with `n` equally sized columns.
336
79
 
337
- ### Use Manual Layout When:
338
- - You need precise control over spacing
339
- - Using percentage widths with margins
340
- - Creating adaptive layouts (tablet vs handheld)
341
- - Dealing with complex responsive behavior
80
+ ### Row Utilities
342
81
 
343
- ```xml
344
- <!-- Manual layout for more control -->
345
- <View class="horizontal mb-4 w-screen">
346
- <View class="w-(48%) vertical mr-2 rounded-xl bg-white shadow">
347
- <!-- Card content -->
348
- </View>
349
- <View class="w-(48%) vertical ml-2 rounded-xl bg-white shadow">
350
- <!-- Card content -->
351
- </View>
352
- </View>
353
- ```
82
+ - `grid-rows-{n}`: Create grids with `n` equally sized rows.
354
83
 
355
- ## Complete Utility Reference
356
-
357
- | Utility | Purpose | Example |
358
- | ---------------- | ------------------------ | ------------------------------ |
359
- | `.grid` | Horizontal layout | `<View class="grid">` |
360
- | `.grid-flow-col` | Horizontal layout | `<View class="grid-flow-col">` |
361
- | `.grid-flow-row` | Vertical layout | `<View class="grid-flow-row">` |
362
- | `.grid-cols-{n}` | N columns per row | `<View class="grid-cols-2">` |
363
- | `.grid-rows-{n}` | N rows per column | `<View class="grid-rows-2">` |
364
- | `.col-span-{n}` | Span N columns (12-grid) | `<View class="col-span-6">` |
365
- | `.row-span-{n}` | Span N rows (12-grid) | `<View class="row-span-6">` |
366
- | `.gap-{size}` | Gap all sides | `<View class="gap-4">` |
367
- | `.gap-x-{size}` | Gap horizontal | `<View class="gap-x-4">` |
368
- | `.gap-y-{size}` | Gap vertical | `<View class="gap-y-4">` |
369
- | `.start` | Align to start | `<View class="start">` |
370
- | `.center` | Align to center | `<View class="center">` |
371
- | `.end` | Align to end | `<View class="end">` |
372
-
373
- ## Real-World Example
84
+ ### Row Placement Utilities
374
85
 
375
- ```xml
376
- <Alloy>
377
- <Window class="bg-gray-100">
378
- <ScrollView class="vertical h-screen w-screen">
86
+ Control horizontal alignment of elements within a row:
379
87
 
380
- <!-- Header -->
381
- <View class="bg-white p-4">
382
- <Label class="text-xl font-bold text-gray-800" text="Dashboard" />
383
- </View>
88
+ | Class | Effect | Use case |
89
+ | --- | --- | --- |
90
+ | `start` | Align to the start of the row | Left-aligned content |
91
+ | `end` | Align to the end of the row | Right-aligned buttons or labels |
92
+ | `center` | Align to the center of the row | Centered content blocks |
384
93
 
385
- <!-- Stats Grid -->
386
- <View class="m-4 grid">
387
- <View class="col-span-6">
388
- <View class="gap-2 rounded-lg bg-white p-4">
389
- <Label class="text-2xl font-bold text-blue-600" text="1,234" />
390
- <Label class="text-sm text-gray-500" text="Total Users" />
391
- </View>
392
- </View>
393
- <View class="col-span-6">
394
- <View class="gap-2 rounded-lg bg-white p-4">
395
- <Label class="text-2xl font-bold text-green-600" text="$56.7k" />
396
- <Label class="text-sm text-gray-500" text="Revenue" />
397
- </View>
398
- </View>
399
- </View>
400
-
401
- <!-- Three Column Section -->
402
- <View class="m-4 grid">
403
- <View class="col-span-4">
404
- <View class="h-32 gap-2 rounded-lg bg-white p-4">
405
- <Label class="text-center text-gray-800" text="Card 1" />
406
- </View>
407
- </View>
408
- <View class="col-span-4">
409
- <View class="h-32 gap-2 rounded-lg bg-white p-4">
410
- <Label class="text-center text-gray-800" text="Card 2" />
411
- </View>
412
- </View>
413
- <View class="col-span-4">
414
- <View class="h-32 gap-2 rounded-lg bg-white p-4">
415
- <Label class="text-center text-gray-800" text="Card 3" />
416
- </View>
417
- </View>
418
- </View>
419
-
420
- </ScrollView>
421
- </Window>
422
- </Alloy>
423
- ```
94
+ These apply to child views inside a `grid-cols-*` container and control horizontal placement within the grid cell.