@maccesar/titools 2.8.0 → 2.10.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.
- package/package.json +1 -1
- package/skills/purgetss/SKILL.md +36 -0
- package/skills/purgetss/references/EXAMPLES.md +86 -24
- package/skills/purgetss/references/app-branding.md +554 -0
- package/skills/purgetss/references/appearance-module.md +161 -0
- package/skills/purgetss/references/apply-directive.md +87 -31
- package/skills/purgetss/references/arbitrary-values.md +4 -0
- package/skills/purgetss/references/class-categories.md +10 -7
- package/skills/purgetss/references/class-index.md +25 -18
- package/skills/purgetss/references/cli-commands.md +309 -8
- package/skills/purgetss/references/configurable-properties.md +11 -7
- package/skills/purgetss/references/custom-rules.md +7 -3
- package/skills/purgetss/references/customization-deep-dive.md +73 -4
- package/skills/purgetss/references/dynamic-component-creation.md +29 -14
- package/skills/purgetss/references/grid-layout.md +20 -8
- package/skills/purgetss/references/icon-fonts.md +4 -0
- package/skills/purgetss/references/installation-setup.md +3 -8
- package/skills/purgetss/references/ios-large-titles.md +141 -0
- package/skills/purgetss/references/migration-guide.md +162 -25
- package/skills/purgetss/references/multi-density-images.md +363 -0
- package/skills/purgetss/references/opacity-modifier.md +4 -0
- package/skills/purgetss/references/performance-tips.md +5 -0
- package/skills/purgetss/references/platform-modifiers.md +4 -0
- package/skills/purgetss/references/semantic-colors.md +386 -0
- package/skills/purgetss/references/smart-mappings.md +50 -28
- package/skills/purgetss/references/tikit-components.md +3 -1
- package/skills/purgetss/references/titanium-resets.md +46 -15
- package/skills/purgetss/references/ui-ux-design.md +32 -6
- package/skills/purgetss/references/values-and-units.md +120 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Values and Units
|
|
2
|
+
|
|
3
|
+
PurgeTSS writes plain numeric values into your TSS files. **Titanium decides how to interpret them at runtime**, based on `ti.ui.defaultunit` in `tiapp.xml`.
|
|
4
|
+
|
|
5
|
+
This is a foundational concept worth knowing before you start tweaking spacing scales, custom colors, or arbitrary values — it's the difference between "8 pixels" and "8 dp" being the same number on disk but very different on a high-DPI device.
|
|
6
|
+
|
|
7
|
+
## The short version
|
|
8
|
+
|
|
9
|
+
Numeric values produced by PurgeTSS utility classes are **unitless**. When PurgeTSS compiles `rounded-lg` to:
|
|
10
|
+
|
|
11
|
+
```tss
|
|
12
|
+
'.rounded-lg': { borderRadius: 8 }
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
the `8` is **not a pixel value**. Titanium reads it at runtime using the unit declared in `tiapp.xml`:
|
|
16
|
+
|
|
17
|
+
```xml
|
|
18
|
+
<ti:app>
|
|
19
|
+
<property name="ti.ui.defaultunit" type="string">dp</property>
|
|
20
|
+
</ti:app>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The Alloy project template has used `dp` by default for years, so most PurgeTSS projects are working with **density-independent pixels**, not raw pixels. In practice, `borderRadius: 8` usually means `8dp`, not `8px`.
|
|
24
|
+
|
|
25
|
+
## Why this matters
|
|
26
|
+
|
|
27
|
+
Saying `rounded-lg` gives you "8 pixels" is only correct if your `tiapp.xml` explicitly sets `ti.ui.defaultunit` to `px`. Most projects do not.
|
|
28
|
+
|
|
29
|
+
A more accurate way to describe it is:
|
|
30
|
+
|
|
31
|
+
> `rounded-lg` applies `borderRadius: 8` — which Titanium interprets as **8 units of `ti.ui.defaultunit`**, defaulting to `dp` on standard Alloy projects.
|
|
32
|
+
|
|
33
|
+
This applies to every utility class that sets a dimension:
|
|
34
|
+
|
|
35
|
+
| Category | Utility classes |
|
|
36
|
+
| ---------- | -------------------------------------------------------------------------------------------- |
|
|
37
|
+
| Spacing | `m-*`, `p-*`, `mt-*`, `mb-*`, `mx-*`, `my-*`, `top-*`, `left-*`, `right-*`, `bottom-*` |
|
|
38
|
+
| Sizes | `w-*`, `h-*`, `size-*`, `wh-*` |
|
|
39
|
+
| Corners | `rounded-*`, `border-radius-*` |
|
|
40
|
+
| Borders | `border-*` (width) |
|
|
41
|
+
| Typography | `text-*` (font size), `letter-spacing-*`, `line-spacing-*` |
|
|
42
|
+
| Shadows | `drop-shadow-*`, `shadow-radius-*` |
|
|
43
|
+
| Elevation | `elevation-*`, `max-elevation-*` |
|
|
44
|
+
| Transforms | `translate-*`, `move-by-*` |
|
|
45
|
+
| Offsets | `x-offset-*`, `y-offset-*` |
|
|
46
|
+
|
|
47
|
+
## Valid values for `ti.ui.defaultunit`
|
|
48
|
+
|
|
49
|
+
Titanium recognizes these unit identifiers:
|
|
50
|
+
|
|
51
|
+
| Value | Meaning | Notes |
|
|
52
|
+
| -------- | -------------------------- | --------------------------------------------------------------------------- |
|
|
53
|
+
| `dp` | Density-independent pixels | Alloy template default. Good default for cross-density consistency. |
|
|
54
|
+
| `dip` | Alias for `dp` | Same as `dp`. |
|
|
55
|
+
| `px` | Raw pixels | Usually a poor fit for UI sizing on high-DPI devices. |
|
|
56
|
+
| `mm` | Millimeters | Physical measurement. |
|
|
57
|
+
| `cm` | Centimeters | Physical measurement. |
|
|
58
|
+
| `in` | Inches | Physical measurement. |
|
|
59
|
+
| `pt` | Points (1/72 inch) | Physical measurement. |
|
|
60
|
+
| `system` | Platform default | iOS uses points; Android uses pixels. This is inconsistent across platforms. |
|
|
61
|
+
|
|
62
|
+
## Forcing pixels explicitly
|
|
63
|
+
|
|
64
|
+
Some PurgeTSS classes use explicit pixel values written as **strings**:
|
|
65
|
+
|
|
66
|
+
```tss
|
|
67
|
+
'.border-radius-px': { borderRadius: '1px' }
|
|
68
|
+
'.w-px': { width: '1px' }
|
|
69
|
+
'.h-px': { height: '1px' }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
If a value includes its own suffix, such as `'1px'`, `'2pt'`, or `'4mm'`, Titanium uses that unit directly and **ignores `ti.ui.defaultunit`**.
|
|
73
|
+
|
|
74
|
+
Use these when you actually need a 1px line or another exact unit (typical case: hairline dividers between rows).
|
|
75
|
+
|
|
76
|
+
## Percentages are unit-independent
|
|
77
|
+
|
|
78
|
+
Fractional utility classes produce percentage strings. Titanium resolves those against the **parent size**, not against `ti.ui.defaultunit`:
|
|
79
|
+
|
|
80
|
+
```tss
|
|
81
|
+
'.w-1/2': { width: '50%' }
|
|
82
|
+
'.h-full': { height: '100%' }
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
These behave the same no matter which default unit your app uses.
|
|
86
|
+
|
|
87
|
+
## Titanium constants are unit-independent
|
|
88
|
+
|
|
89
|
+
Utility classes that resolve to Titanium layout constants also ignore units:
|
|
90
|
+
|
|
91
|
+
```tss
|
|
92
|
+
'.w-auto': { width: Ti.UI.SIZE }
|
|
93
|
+
'.h-screen': { height: Ti.UI.FILL }
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`Ti.UI.SIZE` and `Ti.UI.FILL` are layout directives, not numeric dimensions.
|
|
97
|
+
|
|
98
|
+
## Checking your project's setting
|
|
99
|
+
|
|
100
|
+
Open `tiapp.xml` and look for:
|
|
101
|
+
|
|
102
|
+
```xml
|
|
103
|
+
<property name="ti.ui.defaultunit" type="string">dp</property>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
If that property is missing, Titanium falls back to `system`. That means iOS and Android can interpret the same number differently, so it is better to set `dp` explicitly.
|
|
107
|
+
|
|
108
|
+
## Summary
|
|
109
|
+
|
|
110
|
+
- PurgeTSS writes **unitless numeric values** into `app.tss`.
|
|
111
|
+
- Titanium resolves those values using `ti.ui.defaultunit` in `tiapp.xml`.
|
|
112
|
+
- In most Alloy projects, that unit is `dp`, **not raw pixels**.
|
|
113
|
+
- Values ending in `-px` (written as quoted strings) force raw pixels regardless of the project setting.
|
|
114
|
+
- Percentage-based and `auto`/`screen` utilities are unit-independent.
|
|
115
|
+
|
|
116
|
+
## Related
|
|
117
|
+
|
|
118
|
+
- [Arbitrary Values](./arbitrary-values.md) — parentheses notation `(20px)`, `(2rem)`, `(#ff0000)` for one-off values.
|
|
119
|
+
- [Customization Deep Dive](./customization-deep-dive.md) — defining your own spacing scale via `theme.spacing`.
|
|
120
|
+
- [Class Index](./class-index.md) — the full set of generated classes and their numeric vs. percentage vs. constant outputs.
|