@tonycodes-ui/mortar 0.17.0 → 0.19.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/CHANGELOG.md +2 -2
- package/catalog.json +119 -119
- package/dist/agent-data.json +1 -1
- package/docs/email.md +2 -0
- package/docs/native.md +40 -1
- package/package.json +1 -1
package/docs/email.md
CHANGED
|
@@ -104,6 +104,8 @@ Every template takes `productName`, and optionally `theme`, `logo`, `footer` (re
|
|
|
104
104
|
| `Receipt` | An order confirmation or receipt | `orderNumber`, `date`, `items`, `total`; optional `lines`, `paymentMethod`, `href` ("View order"), `title` |
|
|
105
105
|
| `Notification` | A product notification | `title`, `children` (a string becomes a paragraph); optional `action` (`{ label, href }`), `preview`, `preferencesHref` |
|
|
106
106
|
|
|
107
|
+
To see every template rendered, at phone and desktop widths and in three brands, with its plain-text part, open the playground's **Email preview** (`?page=email`).
|
|
108
|
+
|
|
107
109
|
Send a password reset only to an address that has an account, and show the same "check your email" page either way, so the form never reveals whether an account exists.
|
|
108
110
|
|
|
109
111
|
## Rules
|
package/docs/native.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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
|
+
|
|
5
|
+
The playground's **Native gallery** (`?page=native`) shows each component on the web beside its SwiftUI and Compose snapshot references, in light, dark and large text.
|
|
4
6
|
|
|
5
7
|
## Tokens
|
|
6
8
|
|
|
@@ -58,12 +60,49 @@ A brand is a `MortarTheme`: its light and dark `MortarPalette`s, font family nam
|
|
|
58
60
|
| `MortarNotice` | Notice | Tone, message, actions, dismiss button, VoiceOver announcement. |
|
|
59
61
|
| `MortarEmptyState` | EmptyState | SF Symbol, description, action, dashed, centred or leading. |
|
|
60
62
|
|
|
63
|
+
On both platforms the switch sits at the end of its row, after the label, as in iOS and Android settings; on the web it comes first.
|
|
64
|
+
|
|
61
65
|
### Snapshot tests
|
|
62
66
|
|
|
63
67
|
`native/apple/Tests/MortarTests` renders each component on an iPhone simulator in light, dark and a large accessibility text size, and a branded screen on iPad, with [swift-snapshot-testing](https://github.com/pointfreeco/swift-snapshot-testing). The **Mortar for SwiftUI** workflow runs them on macOS on every change to `Package.swift` or `native/apple`, and builds the package for Mac.
|
|
64
68
|
|
|
65
69
|
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
70
|
|
|
71
|
+
## Jetpack Compose
|
|
72
|
+
|
|
73
|
+
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:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
gradle -p native/android :mortar:publishToMavenLocal -Pversion=0.0.0-local
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```kotlin
|
|
80
|
+
implementation("codes.tony:mortar:0.0.0-local")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Theme the app once near its root, then use the components:
|
|
84
|
+
|
|
85
|
+
```kotlin
|
|
86
|
+
setContent {
|
|
87
|
+
MortarTheme(brand = MortarBrand.Neutral) {
|
|
88
|
+
MortarButton("Save", onClick = ::save, variant = MortarButtonVariant.Primary)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
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.
|
|
94
|
+
|
|
95
|
+
The components and their parameters match the SwiftUI table above, with Compose names: `MortarButton`, `MortarBadge`, `MortarCard`, `MortarTextField`, `MortarSwitch`, `MortarAvatar`, `MortarNotice` and `MortarEmptyState`. Differences:
|
|
96
|
+
|
|
97
|
+
- Medium controls and touch targets are 48dp, Material's minimum, instead of 44.
|
|
98
|
+
- `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.
|
|
99
|
+
- Icons are `ImageVector`s, such as `Icons.Filled.Share`.
|
|
100
|
+
- `MortarNotice(announce = true)` is a live region: polite, or assertive for `Danger`.
|
|
101
|
+
|
|
102
|
+
### Snapshot tests
|
|
103
|
+
|
|
104
|
+
`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.
|
|
105
|
+
|
|
67
106
|
## Brands
|
|
68
107
|
|
|
69
108
|
`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.
|