oneslash-design-system 2.12.0 → 2.13.1
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/README.md +1 -1
- package/dist/DESIGN.md +36 -6
- package/dist/native-mapping.json +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ The Swift package `OneSlashDesign` (iOS 26 and macOS 26 and later) is this repos
|
|
|
45
45
|
5. Use `.odsProminentButton()` instead of `.buttonStyle(.borderedProminent)`: under `.odsTheme` a prominent label is otherwise unreadable on most themes.
|
|
46
46
|
6. `ODSBanner`, `ODSTag` and `ODSAvatar` are the parts SwiftUI has no control for.
|
|
47
47
|
|
|
48
|
-
[DESIGN.md](./dist/DESIGN.md) has the rules for a "100% ODS" native app and the table that maps each web component to its native control.
|
|
48
|
+
[DESIGN.md](./dist/DESIGN.md) has the rules for a "100% ODS" native app and the table that maps each web component to its native control. An Android app wraps its content in `OneSlashTheme(theme = OdsTheme.Forest) { … }` from the Compose library in `native/android` (`io.github.oneslash-app:oneslash-design`; see [PUBLISHING.md](./native/android/PUBLISHING.md) for whether it is on Maven Central yet).
|
|
49
49
|
|
|
50
50
|
## Building a page
|
|
51
51
|
|
package/dist/DESIGN.md
CHANGED
|
@@ -223,7 +223,7 @@ Platforms: iOS 26 and macOS 26 and later.
|
|
|
223
223
|
4. Apply one theme at the scene root: `.odsTheme(.forest)`. The themes are `ODSTheme.default`, `.forest`, `.clay`, `.indigo` and `.wine`. The modifier sets the `odsTheme` environment value and the primary, secondary and tertiary foreground styles from the theme's text colors. It sets no tint and no background. The foreground styles are fixed colors, resolved for the current appearance and resolved again when it changes: system toolbars and menus resolve a dynamic root color without the window's appearance, which draws dark glyphs on a dark toolbar. Under the modifier, text-like controls (borderless buttons, links) take `text.primary`, not the accent; to give one the accent, apply `.foregroundStyle(.tint)` to it (the tint is the `AccentColor` asset). `text.disabled` is the tertiary level, so `.foregroundStyle(.tertiary)` is the disabled text color. Apply `.odsToolbarMenuLabel()` to the label of a toolbar `Menu`: without it, an iPhone toolbar menu draws its label white in both appearances. Menu item icons take `text.primary`.
|
|
224
224
|
5. Read the theme with `@Environment(\.odsTheme) private var theme` for backgrounds and status colors, for example `theme.background.default` and `theme.error.main`. Each color has the same group and key names as the color table above.
|
|
225
225
|
6. Spacing, radius and motion are constants for our own content views: `ODSSpacing`, `ODSRadius` and `ODSDuration` (in seconds).
|
|
226
|
-
7. Prominent buttons: use `.odsProminentButton()` (or `.odsProminentButton(.glass)`) instead of `.buttonStyle(.borderedProminent)`. Under `.odsTheme` a prominent label takes `text.primary`, which is unreadable on the accent in most themes; the modifier keeps the system style and sets the label to `accent.contrast`. On the Mac, while the user has chosen their own system accent, the label is white.
|
|
226
|
+
7. Prominent buttons: use `.odsProminentButton()` (or `.odsProminentButton(.glass)`) instead of `.buttonStyle(.borderedProminent)`. Under `.odsTheme` a prominent label takes `text.primary`, which is unreadable on the accent in most themes; the modifier keeps the system style and sets the label to `accent.contrast`. On the Mac, while the user has chosen their own system accent, the label is white. In a Mac window that is not the active one the system drops the accent fill, and the label is `text.primary`.
|
|
227
227
|
8. Parts: `ODSBanner`, `ODSTag` and `ODSAvatar` cover what SwiftUI has no control for. See "Parts" below. For an empty state use the system `ContentUnavailableView`.
|
|
228
228
|
9. Fonts: `Font.ods(_ role: ODSTextRole)` returns the system text style for a type role. See the type roles table below. Native apps use the system fonts with Dynamic Type; Inter and Fira Code stay on the web.
|
|
229
229
|
|
|
@@ -234,6 +234,36 @@ Limits to know:
|
|
|
234
234
|
- Each scene needs its own `.odsTheme`, for example a macOS `Settings` scene as well as the main window.
|
|
235
235
|
- For motion, prefer the platform's springs. Use `ODSDuration` only for our own content views.
|
|
236
236
|
|
|
237
|
+
### The Android rules
|
|
238
|
+
|
|
239
|
+
On Android the Material components ship inside the app, not the OS. These rules are the counterpart of the OS-update rules.
|
|
240
|
+
|
|
241
|
+
1. Stable, public API only. No experimental opt-ins in shared code, no reflection, no internal Compose API.
|
|
242
|
+
2. Material components keep their standard form. Color them through the theme, not per-call color overrides.
|
|
243
|
+
3. System bars are the system's. Edge to edge; take insets from `WindowInsets`; set no bar colors.
|
|
244
|
+
4. Brand enters only through the theme: the Material color scheme and the ODS extended colors.
|
|
245
|
+
5. No fixed system metrics. No hard-coded bar heights or inset numbers.
|
|
246
|
+
6. System type. The Material type scale with the device font, in `sp`, so font scaling works.
|
|
247
|
+
7. Material Symbols for icons.
|
|
248
|
+
8. Colors come from the theme. No branching on dark mode in screens.
|
|
249
|
+
9. Build with the current SDK and the current Compose release, and check both once a year.
|
|
250
|
+
|
|
251
|
+
### Adopting the Compose library
|
|
252
|
+
|
|
253
|
+
Kotlin and Jetpack Compose with Material 3. The library is `io.github.oneslash-app:oneslash-design`, with the same version as the npm package. It is in `native/android` of the repository and is published to Maven Central once publishing is set up; check before depending on it by coordinates.
|
|
254
|
+
|
|
255
|
+
1. Wrap the app's content once: `OneSlashTheme(theme = OdsTheme.Forest) { … }`. The themes are `OdsTheme.Default`, `Forest`, `Clay`, `Indigo` and `Wine`. It follows the system's dark mode, and takes the increased-contrast colors when the system's contrast setting is medium or high (Android 14 and later).
|
|
256
|
+
2. Use Material 3 components as they are. `MaterialTheme.colorScheme` is filled from the theme: the surfaces are `background.default` and `background.accent100`, `onSurfaceVariant` is `text.secondary`, `error` is `error.text`. `primary` is `accent.main` with `accent.contrast` on it, except in the default and clay themes in light mode: Material draws `primary` as text as well as a fill, and those accents are about 1.6:1 as text, so there `primary` is the neutral strong color (`primary.dark`). The accent is a fill in every theme through `tertiaryContainer`, for example a floating action button's container color.
|
|
257
|
+
3. Read the colors Material has no role for from `OneSlashTheme.colors`, for example `OneSlashTheme.colors.warningFill` or `backgroundAccent300`. The names are the color table's, in camel case.
|
|
258
|
+
4. Shapes and type are Material's defaults. `OdsSpacing`, `OdsRadius` and `OdsDuration` are for our own content.
|
|
259
|
+
5. Parts: `OdsBanner`, `OdsTag`, `OdsAvatar` and `OdsEmptyState`. `OdsAvatar` takes a `Painter`; load the picture with the app's own image library.
|
|
260
|
+
6. Do not use dynamic color (Material You): the theme is the brand.
|
|
261
|
+
|
|
262
|
+
Limits to know:
|
|
263
|
+
|
|
264
|
+
- Material's surface containers stop at `background.accent100`. The lighter ODS surfaces are for our own content, where we choose the text on them: secondary text fails on them in dark mode.
|
|
265
|
+
- Outlined borders (`outline`) are the web's outlined border, which is below 3:1 on the page in light mode and reaches it under increased contrast.
|
|
266
|
+
|
|
237
267
|
### Type roles
|
|
238
268
|
|
|
239
269
|
ODS type roles map to system text styles, so they keep Dynamic Type. No font files ship with the native packages.
|
|
@@ -255,14 +285,14 @@ ODS type roles map to system text styles, so they keep Dynamic Type. No font fil
|
|
|
255
285
|
|
|
256
286
|
### Component mapping
|
|
257
287
|
|
|
258
|
-
For each web component, the table gives the native control to use. System controls keep their standard styles; ODS supplies only tokens.
|
|
288
|
+
For each web component, the table gives the native control to use. System controls keep their standard styles; ODS supplies only tokens. A name starting with `ODS` (Swift) or `Ods` (Compose) is a part ODS ships. "Not applicable: web page pattern" means the web component has no native counterpart; use the note.
|
|
259
289
|
|
|
260
290
|
| ODS | SwiftUI | Compose | Note |
|
|
261
291
|
| --- | --- | --- | --- |
|
|
262
|
-
| alert | `ODSBanner` for an inline message; `.alert` for one that needs a decision |
|
|
292
|
+
| alert | `ODSBanner` for an inline message; `.alert` for one that needs a decision | `OdsBanner` for an inline message; `AlertDialog` for one that needs a decision | ODS has no native toast: on Android use `Snackbar` in a `SnackbarHost`. |
|
|
263
293
|
| button | `Button` with `.odsProminentButton()` for accent (`.odsProminentButton(.glass)` for the glass style), `.bordered` for primary | `Button`, `OutlinedButton` | Tertiary and text-only: `.borderless` / `TextButton`. On Apple, apply `.odsProminentButton()` to every prominent button. Under `odsTheme` the label of a `.borderedProminent` or `.glassProminent` button takes `text.primary`, not the system white, which is below 4.5:1 on the accent in default dark, forest light, forest dark, clay dark, indigo light, indigo dark, wine light, wine dark. In forest light it is the same color as the fill, so the label cannot be seen. The modifier keeps the system style and sets the label to `accent.contrast`. Compose needs nothing: `onPrimary` is `accent.contrast`. |
|
|
264
294
|
| checkBox | `Toggle` (switch on iOS, `.toggleStyle(.checkbox)` on macOS) | `Checkbox` | |
|
|
265
|
-
| emptyBox | `ContentUnavailableView` |
|
|
295
|
+
| emptyBox | `ContentUnavailableView` | `OdsEmptyState` | The system has this control on Apple, so ODS adds no part there. Material has none, so ODS does. |
|
|
266
296
|
| factsRow | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `LabeledContent` rows in a `Form` / `ListItem` rows. |
|
|
267
297
|
| figure | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: an `Image` with a caption `Text` in the caption text style. |
|
|
268
298
|
| heading | `Text` with the type role's text style and `.accessibilityAddTraits(.isHeader)` | `Text` with the type role's `MaterialTheme.typography` style and `Modifier.semantics { heading() }` | |
|
|
@@ -294,12 +324,12 @@ For each web component, the table gives the native control to use. System contro
|
|
|
294
324
|
| tableHeaderCell | A `TableColumn` title | `Text` in the header `Row` | Material 3 has no table. |
|
|
295
325
|
| tableRow | `TableRow` | `Row` | Material 3 has no table. |
|
|
296
326
|
| tabsContainer | `TabView` or segmented `Picker` | `PrimaryTabRow` | `TabRow` is deprecated in Material 3. |
|
|
297
|
-
| tag | `ODSTag` |
|
|
327
|
+
| tag | `ODSTag` | `OdsTag` | A count on a list row or tab stays `.badge` / `Badge`. A tag that acts: wrap `ODSTag` in a `Button` with the plain style; on Android use a Material `AssistChip` or `FilterChip`, which are made to be pressed. |
|
|
298
328
|
| textarea | `TextField(_:text:axis: .vertical)` or `TextEditor` | `OutlinedTextField` with `minLines` | |
|
|
299
329
|
| textField | `TextField` (`SecureField` for passwords) | `OutlinedTextField` or `TextField` | |
|
|
300
330
|
| timeStamp | `Text(_:style:)` (`.relative`) or `Text(_:format:)` (`.dateTime`) | `Text` with `DateUtils.getRelativeTimeSpanString` or `DateTimeFormatter.ofLocalizedDateTime` | |
|
|
301
331
|
| tooltip | `.help` | `TooltipBox` | `.help` shows on pointer hover only. `TooltipBox` needs `@OptIn(ExperimentalMaterial3Api::class)`. |
|
|
302
|
-
| userImage | `ODSAvatar` |
|
|
332
|
+
| userImage | `ODSAvatar` | `OdsAvatar` | Load the picture yourself and pass it as an `Image` / a `Painter`. |
|
|
303
333
|
|
|
304
334
|
### Parts
|
|
305
335
|
|
package/dist/native-mapping.json
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
{
|
|
4
4
|
"ods": "alert",
|
|
5
5
|
"swiftui": "`ODSBanner` for an inline message; `.alert` for one that needs a decision",
|
|
6
|
-
"compose": "
|
|
7
|
-
"note": "ODS has no native toast
|
|
6
|
+
"compose": "`OdsBanner` for an inline message; `AlertDialog` for one that needs a decision",
|
|
7
|
+
"note": "ODS has no native toast: on Android use `Snackbar` in a `SnackbarHost`."
|
|
8
8
|
},
|
|
9
9
|
{
|
|
10
10
|
"ods": "button",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
{
|
|
21
21
|
"ods": "emptyBox",
|
|
22
22
|
"swiftui": "`ContentUnavailableView`",
|
|
23
|
-
"compose": "
|
|
24
|
-
"note": "The system has this control on Apple, so ODS adds no part there.
|
|
23
|
+
"compose": "`OdsEmptyState`",
|
|
24
|
+
"note": "The system has this control on Apple, so ODS adds no part there. Material has none, so ODS does."
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"ods": "factsRow",
|
|
@@ -201,8 +201,8 @@
|
|
|
201
201
|
{
|
|
202
202
|
"ods": "tag",
|
|
203
203
|
"swiftui": "`ODSTag`",
|
|
204
|
-
"compose": "
|
|
205
|
-
"note": "A count on a list row or tab stays `.badge`. A tag that acts: wrap `ODSTag` in a `Button` with the plain style
|
|
204
|
+
"compose": "`OdsTag`",
|
|
205
|
+
"note": "A count on a list row or tab stays `.badge` / `Badge`. A tag that acts: wrap `ODSTag` in a `Button` with the plain style; on Android use a Material `AssistChip` or `FilterChip`, which are made to be pressed."
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
208
|
"ods": "textarea",
|
|
@@ -228,8 +228,8 @@
|
|
|
228
228
|
{
|
|
229
229
|
"ods": "userImage",
|
|
230
230
|
"swiftui": "`ODSAvatar`",
|
|
231
|
-
"compose": "
|
|
232
|
-
"note": "Load the picture yourself and pass it as an `Image
|
|
231
|
+
"compose": "`OdsAvatar`",
|
|
232
|
+
"note": "Load the picture yourself and pass it as an `Image` / a `Painter`."
|
|
233
233
|
}
|
|
234
234
|
],
|
|
235
235
|
"typeRoles": {
|