@tonycodes-ui/mortar 0.17.0 → 0.18.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/docs/native.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Native apps
2
2
 
3
- Mortar is coming to iPhone, iPad and Android as a SwiftUI package and a Jetpack Compose library, tracked in [#95](https://github.com/tonycodes/mortar/issues/95). This page covers what exists so far: the design tokens both libraries are built on, and the first SwiftUI components.
3
+ Mortar is coming to iPhone, iPad and Android as a SwiftUI package and a Jetpack Compose library, tracked in [#95](https://github.com/tonycodes/mortar/issues/95). This page covers what exists so far: the design tokens both libraries are built on, and the first SwiftUI and Jetpack Compose components.
4
4
 
5
5
  ## Tokens
6
6
 
@@ -64,6 +64,41 @@ A brand is a `MortarTheme`: its light and dark `MortarPalette`s, font family nam
64
64
 
65
65
  Rendering differs between iOS versions, so the reference images are recorded on CI's simulator, not on a developer's Mac. To add or update one, delete the old image (or add the test), push, and download the `mortar-swift-snapshots-<sha>` artifact from the failed run: it holds the newly recorded images and any failed comparisons. Review them, commit them under `__Snapshots__`, and push again.
66
66
 
67
+ ## Jetpack Compose
68
+
69
+ The library is in `native/android` (module `mortar`, package `codes.tony.mortar`) for Android 7.0 (API 24) and later. Until its Maven repository is chosen ([#95](https://github.com/tonycodes/mortar/issues/95)), build it into your local Maven repository with Gradle 8.11 and JDK 17:
70
+
71
+ ```sh
72
+ gradle -p native/android :mortar:publishToMavenLocal -Pversion=0.0.0-local
73
+ ```
74
+
75
+ ```kotlin
76
+ implementation("codes.tony:mortar:0.0.0-local")
77
+ ```
78
+
79
+ Theme the app once near its root, then use the components:
80
+
81
+ ```kotlin
82
+ setContent {
83
+ MortarTheme(brand = MortarBrand.Neutral) {
84
+ MortarButton("Save", onClick = ::save, variant = MortarButtonVariant.Primary)
85
+ }
86
+ }
87
+ ```
88
+
89
+ A brand is a `MortarBrand`: its light and dark `MortarPalette`s, `FontFamily`s and density. `MortarTheme` follows the system's dark theme unless you pass `darkTheme`; components read `Mortar.palette` and `Mortar.brand`. Text sizes are in sp, so they follow the font scale.
90
+
91
+ The components and their parameters match the SwiftUI table above, with Compose names: `MortarButton`, `MortarBadge`, `MortarCard`, `MortarTextField`, `MortarSwitch`, `MortarAvatar`, `MortarNotice` and `MortarEmptyState`. Differences:
92
+
93
+ - Medium controls and touch targets are 48dp, Material's minimum, instead of 44.
94
+ - `MortarAvatar` takes a `Painter`: load the picture with your image library (Coil, Glide) and pass null while it loads or when it fails, to show the initials.
95
+ - Icons are `ImageVector`s, such as `Icons.Filled.Share`.
96
+ - `MortarNotice(announce = true)` is a live region: polite, or assertive for `Danger`.
97
+
98
+ ### Snapshot tests
99
+
100
+ `native/android/mortar/src/test` holds unit tests and [Paparazzi](https://github.com/cashapp/paparazzi) snapshots of each component on a Pixel 5 in light, dark and twice the font size, and a branded screen on a Pixel C tablet. Paparazzi renders on the JVM, without an emulator, so the references in `src/test/snapshots` match on any machine. The **Mortar for Compose** workflow runs `gradle :mortar:verifyPaparazziDebug` on every change to `native/android`. When it fails, it records what the code renders now and uploads the images as `mortar-compose-snapshots-<sha>` to review and commit. Locally, `gradle -p native/android :mortar:recordPaparazziDebug` does the same.
101
+
67
102
  ## Brands
68
103
 
69
104
  `nativeTheme(brand)` in `src/native-theme.ts` resolves a `BrandDefinition` to literal light and dark palettes the way `tokens.css` resolves it: omitted values keep the defaults or derive from primary, and `color-mix(in oklab, …)` tints are computed in JS. Brand colours must be literal and opaque (hex, `white`, `black`, `rgb()`, `hsl()`, `oklab()` or `oklch()`). Accents use the flat `accent`, not the gradient. Fonts become family names plus a generic family; the app bundles the fonts itself.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonycodes-ui/mortar",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Mortar: a shared design foundation, application and marketing UI for React and Tailwind.",
5
5
  "type": "module",
6
6
  "files": [