@loidolt/theme-capacitor 0.13.0 → 0.14.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/README.md +16 -9
- package/dist/device-layout.svelte.d.ts +13 -0
- package/dist/device-layout.svelte.js +41 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +47 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -191,13 +191,15 @@ how far to stay from each edge, not that bars went to the side, nor where the fo
|
|
|
191
191
|
device is partly open. `createDeviceLayout` reads them natively (iOS 27.1, through the plugin
|
|
192
192
|
bundled with this package) and writes them on `<html>`:
|
|
193
193
|
|
|
194
|
-
| Written
|
|
195
|
-
|
|
|
196
|
-
| `data-bar-edge="left"` or `"right"`
|
|
197
|
-
| `--ldt-bar-start`
|
|
198
|
-
| `data-fold="vertical"` or `"horizontal"`
|
|
199
|
-
| `--ldt-fold-start`, `--ldt-fold-end`
|
|
200
|
-
| `data-
|
|
194
|
+
| Written | When |
|
|
195
|
+
| ------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
196
|
+
| `data-bar-edge="left"` or `"right"` | The system puts bars vertically on that side. A physical side, in every text direction. |
|
|
197
|
+
| `--ldt-bar-start` | With it: how far down that strip your controls can start, below the camera and status |
|
|
198
|
+
| `data-fold="vertical"` or `"horizontal"` | The device is partly open |
|
|
199
|
+
| `--ldt-fold-start`, `--ldt-fold-end` | With it: the band across the fold to keep controls out of; taps there may not register |
|
|
200
|
+
| `data-top-cutout="left"` or `"right"` | Bars stay horizontal and the camera and status bar take that top corner |
|
|
201
|
+
| `--ldt-cutout-width`, `--ldt-cutout-height` | With it: the cutout's size, from the screen edge and from the top |
|
|
202
|
+
| `data-hinge` | `closed`, `partially-open` or `fully-open`, on a device with a hinge |
|
|
201
203
|
|
|
202
204
|
`current` holds the whole report, the reserved regions included, for layouts the attributes
|
|
203
205
|
don't cover. `setupCapacitor` turns it on unless `deviceLayout: false`. Nothing is written on
|
|
@@ -213,12 +215,17 @@ system without code of its own:
|
|
|
213
215
|
`AppShell`, `Topbar`, toasts and drawers all clear. `Topbar`'s actions move into the strip
|
|
214
216
|
below the camera and status bar, and the `TabBar` runs down it from the foot, within reach of
|
|
215
217
|
the thumb. `Topbar` stays at the top of the content as a slim header with the brand and
|
|
216
|
-
navigation. The current tab's accent edge faces the content.
|
|
218
|
+
navigation. The current tab's accent edge faces the content. The strip's controls share the
|
|
219
|
+
4.5rem column iOS centres its clock and status icons in, on the content side of the strip, so
|
|
220
|
+
they sit in line under them.
|
|
221
|
+
- **A cutout in a top corner** (the inner screen in portrait). `Topbar` moves up into the band
|
|
222
|
+
beside the camera and status bar, ending where the cutout ends and stopping short of it, so its
|
|
223
|
+
row lines up with the clock instead of starting below a blank strip.
|
|
217
224
|
- **The fold.** Dialogs move to the half before the fold, as the system's alerts do; top and
|
|
218
225
|
bottom drawers cover that half only; side drawers stop short of it; toasts stay in the half
|
|
219
226
|
after it.
|
|
220
227
|
|
|
221
|
-
|
|
228
|
+
Every other device and the browser are unchanged.
|
|
222
229
|
|
|
223
230
|
### Haptics
|
|
224
231
|
|
|
@@ -69,6 +69,17 @@ export declare function foldOf(layout: DeviceLayoutSnapshot): {
|
|
|
69
69
|
* there's no vertical bar.
|
|
70
70
|
*/
|
|
71
71
|
export declare function barStartOf(layout: DeviceLayoutSnapshot): number;
|
|
72
|
+
/**
|
|
73
|
+
* The camera's cutout in a top corner, while the bars stay horizontal: iPhone Duo's inner screen
|
|
74
|
+
* in portrait keeps the camera and status bar in a block at the top of one side, and the rest of
|
|
75
|
+
* that band is free. Its width from the screen edge and its height from the top; `null` when
|
|
76
|
+
* there's a vertical bar, or no occlusion touches a top corner, as with a Dynamic Island.
|
|
77
|
+
*/
|
|
78
|
+
export declare function topCutoutOf(layout: DeviceLayoutSnapshot): {
|
|
79
|
+
side: 'left' | 'right';
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
} | null;
|
|
72
83
|
/**
|
|
73
84
|
* Follows the native layout and tells the stylesheet about it, so a page that draws its own bars
|
|
74
85
|
* can follow the system's on devices like iPhone Duo:
|
|
@@ -77,6 +88,8 @@ export declare function barStartOf(layout: DeviceLayoutSnapshot): number;
|
|
|
77
88
|
* side, with `--ldt-bar-start`, how far down the strip the page's controls can begin.
|
|
78
89
|
* - `data-fold="vertical"` (or `"horizontal"`) while the device is partly open, with
|
|
79
90
|
* `--ldt-fold-start` and `--ldt-fold-end`, the band to keep controls out of.
|
|
91
|
+
* - `data-top-cutout="left"` or `"right"` while the camera and status bar take one top corner and
|
|
92
|
+
* the bars stay horizontal, with `--ldt-cutout-width` and `--ldt-cutout-height`, its size.
|
|
80
93
|
* - `data-hinge`, the hinge status, where the device has one.
|
|
81
94
|
*
|
|
82
95
|
* Needs the iOS plugin bundled with this package (run `cap sync` after installing) and iOS 27.1;
|
|
@@ -25,6 +25,31 @@ export function barStartOf(layout) {
|
|
|
25
25
|
.filter((region) => region.kind === 'occlusion' && inStrip(region))
|
|
26
26
|
.reduce((bottom, rect) => Math.max(bottom, rect.y + rect.height), 0);
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* The camera's cutout in a top corner, while the bars stay horizontal: iPhone Duo's inner screen
|
|
30
|
+
* in portrait keeps the camera and status bar in a block at the top of one side, and the rest of
|
|
31
|
+
* that band is free. Its width from the screen edge and its height from the top; `null` when
|
|
32
|
+
* there's a vertical bar, or no occlusion touches a top corner, as with a Dynamic Island.
|
|
33
|
+
*/
|
|
34
|
+
export function topCutoutOf(layout) {
|
|
35
|
+
if (layout.barEdge)
|
|
36
|
+
return null;
|
|
37
|
+
const corner = layout.regions.filter((region) => region.kind === 'occlusion' && region.y <= 1 && region.width < layout.width / 2);
|
|
38
|
+
const right = corner.filter((region) => region.x + region.width >= layout.width - 1);
|
|
39
|
+
const left = corner.filter((region) => region.x <= 1);
|
|
40
|
+
// One corner only: with both taken there's no free run of the band to put a header in.
|
|
41
|
+
if (right.length && left.length)
|
|
42
|
+
return null;
|
|
43
|
+
const side = right.length ? 'right' : left.length ? 'left' : null;
|
|
44
|
+
if (!side)
|
|
45
|
+
return null;
|
|
46
|
+
const regions = side === 'right' ? right : left;
|
|
47
|
+
return {
|
|
48
|
+
side,
|
|
49
|
+
width: Math.max(...regions.map((region) => side === 'right' ? layout.width - region.x : region.x + region.width)),
|
|
50
|
+
height: Math.max(...regions.map((region) => region.y + region.height)),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
28
53
|
const px = (value) => `${Math.round(value * 100) / 100}px`;
|
|
29
54
|
/**
|
|
30
55
|
* Follows the native layout and tells the stylesheet about it, so a page that draws its own bars
|
|
@@ -34,6 +59,8 @@ const px = (value) => `${Math.round(value * 100) / 100}px`;
|
|
|
34
59
|
* side, with `--ldt-bar-start`, how far down the strip the page's controls can begin.
|
|
35
60
|
* - `data-fold="vertical"` (or `"horizontal"`) while the device is partly open, with
|
|
36
61
|
* `--ldt-fold-start` and `--ldt-fold-end`, the band to keep controls out of.
|
|
62
|
+
* - `data-top-cutout="left"` or `"right"` while the camera and status bar take one top corner and
|
|
63
|
+
* the bars stay horizontal, with `--ldt-cutout-width` and `--ldt-cutout-height`, its size.
|
|
37
64
|
* - `data-hinge`, the hinge status, where the device has one.
|
|
38
65
|
*
|
|
39
66
|
* Needs the iOS plugin bundled with this package (run `cap sync` after installing) and iOS 27.1;
|
|
@@ -49,7 +76,14 @@ export function createDeviceLayout(options = {}) {
|
|
|
49
76
|
delete root.dataset.barEdge;
|
|
50
77
|
delete root.dataset.fold;
|
|
51
78
|
delete root.dataset.hinge;
|
|
52
|
-
|
|
79
|
+
delete root.dataset.topCutout;
|
|
80
|
+
for (const name of [
|
|
81
|
+
'--ldt-bar-start',
|
|
82
|
+
'--ldt-fold-start',
|
|
83
|
+
'--ldt-fold-end',
|
|
84
|
+
'--ldt-cutout-width',
|
|
85
|
+
'--ldt-cutout-height',
|
|
86
|
+
]) {
|
|
53
87
|
root.style.removeProperty(name);
|
|
54
88
|
}
|
|
55
89
|
};
|
|
@@ -66,6 +100,12 @@ export function createDeviceLayout(options = {}) {
|
|
|
66
100
|
root.style.setProperty('--ldt-fold-start', px(fold.start));
|
|
67
101
|
root.style.setProperty('--ldt-fold-end', px(fold.end));
|
|
68
102
|
}
|
|
103
|
+
const cutout = topCutoutOf(layout);
|
|
104
|
+
if (cutout) {
|
|
105
|
+
root.dataset.topCutout = cutout.side;
|
|
106
|
+
root.style.setProperty('--ldt-cutout-width', px(cutout.width));
|
|
107
|
+
root.style.setProperty('--ldt-cutout-height', px(cutout.height));
|
|
108
|
+
}
|
|
69
109
|
if (layout.hinge && layout.hinge.status !== 'unknown') {
|
|
70
110
|
root.dataset.hinge = layout.hinge.status;
|
|
71
111
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { syncNativeAppearance, systemBarStyleFor } from './appearance.js';
|
|
|
6
6
|
export type { NativeAppearanceOptions, SystemBarStyle } from './appearance.js';
|
|
7
7
|
export { closeTopLayer, handleBackButton } from './back-button.js';
|
|
8
8
|
export type { BackButtonEvent, BackButtonOptions } from './back-button.js';
|
|
9
|
-
export { barStartOf, createDeviceLayout, foldOf } from './device-layout.svelte.js';
|
|
9
|
+
export { barStartOf, createDeviceLayout, foldOf, topCutoutOf } from './device-layout.svelte.js';
|
|
10
10
|
export type { DeviceLayout, DeviceLayoutOptions, DeviceLayoutPlugin, DeviceLayoutSnapshot, DeviceRect, DeviceRegion, HingeStatus, } from './device-layout.svelte.js';
|
|
11
11
|
export { createNativeKeyboard } from './keyboard.svelte.js';
|
|
12
12
|
export type { NativeKeyboard, NativeKeyboardOptions } from './keyboard.svelte.js';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { isNativePlatform, markNativePlatform, nativePlatform } from './platform
|
|
|
2
2
|
export { setupCapacitor } from './setup.js';
|
|
3
3
|
export { syncNativeAppearance, systemBarStyleFor } from './appearance.js';
|
|
4
4
|
export { closeTopLayer, handleBackButton } from './back-button.js';
|
|
5
|
-
export { barStartOf, createDeviceLayout, foldOf } from './device-layout.svelte.js';
|
|
5
|
+
export { barStartOf, createDeviceLayout, foldOf, topCutoutOf } from './device-layout.svelte.js';
|
|
6
6
|
export { createNativeKeyboard } from './keyboard.svelte.js';
|
|
7
7
|
export { createHaptics, SELECTION_TARGETS, withHaptics } from './haptics.js';
|
|
8
8
|
export { persistTheme } from './theme-storage.svelte.js';
|
package/dist/styles.css
CHANGED
|
@@ -54,13 +54,20 @@
|
|
|
54
54
|
* and every `--ldt-safe-*` reader (AppShell, Topbar, toasts, drawers) then clears it as a whole.
|
|
55
55
|
* Top to bottom it holds what the system reserves (`--ldt-bar-start`), Topbar's actions, and the
|
|
56
56
|
* TabBar at the foot, within reach of the thumb. Topbar stays as a slim header in the content.
|
|
57
|
+
*
|
|
58
|
+
* iOS lines its own items (the clock, the status icons) up in a 4.5rem column on the content side
|
|
59
|
+
* of the strip, and leaves what's left of a wider strip as margin at the bezel; on iPhone Duo the
|
|
60
|
+
* strip is 84pt and the column's centre 48pt in from the edge. The page's controls share that
|
|
61
|
+
* column (`--ldt-bar-outer` is the margin), so they sit in line under the clock.
|
|
57
62
|
*/
|
|
58
63
|
:where(:root[data-bar-edge='right']) {
|
|
59
64
|
--ldt-bar-width: max(var(--safe-area-inset-right, env(safe-area-inset-right, 0px)), 4.5rem);
|
|
65
|
+
--ldt-bar-outer: calc(var(--ldt-bar-width) - 4.5rem);
|
|
60
66
|
--ldt-safe-right: var(--ldt-bar-width);
|
|
61
67
|
}
|
|
62
68
|
:where(:root[data-bar-edge='left']) {
|
|
63
69
|
--ldt-bar-width: max(var(--safe-area-inset-left, env(safe-area-inset-left, 0px)), 4.5rem);
|
|
70
|
+
--ldt-bar-outer: calc(var(--ldt-bar-width) - 4.5rem);
|
|
64
71
|
--ldt-safe-left: var(--ldt-bar-width);
|
|
65
72
|
}
|
|
66
73
|
/* The strip's surface, full height, under the system's items and the page's own. */
|
|
@@ -93,9 +100,11 @@
|
|
|
93
100
|
}
|
|
94
101
|
:where([data-bar-edge='right'] .ldt-topbar__actions) {
|
|
95
102
|
right: 0;
|
|
103
|
+
padding-right: var(--ldt-bar-outer);
|
|
96
104
|
}
|
|
97
105
|
:where([data-bar-edge='left'] .ldt-topbar__actions) {
|
|
98
106
|
left: 0;
|
|
107
|
+
padding-left: var(--ldt-bar-outer);
|
|
99
108
|
}
|
|
100
109
|
:where([data-bar-edge] .ldt-app-shell > .ldt-tab-bar) {
|
|
101
110
|
position: fixed;
|
|
@@ -107,15 +116,16 @@
|
|
|
107
116
|
overflow-y: auto;
|
|
108
117
|
flex-direction: column;
|
|
109
118
|
justify-content: flex-end;
|
|
110
|
-
padding: 0 0 var(--ldt-safe-bottom);
|
|
111
119
|
border-top: 0;
|
|
112
120
|
background: transparent;
|
|
113
121
|
}
|
|
114
122
|
:where([data-bar-edge='right'] .ldt-app-shell > .ldt-tab-bar) {
|
|
115
123
|
right: 0;
|
|
124
|
+
padding: 0 var(--ldt-bar-outer) var(--ldt-safe-bottom) 0;
|
|
116
125
|
}
|
|
117
126
|
:where([data-bar-edge='left'] .ldt-app-shell > .ldt-tab-bar) {
|
|
118
127
|
left: 0;
|
|
128
|
+
padding: 0 0 var(--ldt-safe-bottom) var(--ldt-bar-outer);
|
|
119
129
|
}
|
|
120
130
|
:where([data-bar-edge] .ldt-tab-bar__item) {
|
|
121
131
|
flex: none;
|
|
@@ -133,6 +143,42 @@
|
|
|
133
143
|
padding-bottom: var(--ldt-safe-bottom, env(safe-area-inset-bottom, 0px));
|
|
134
144
|
}
|
|
135
145
|
|
|
146
|
+
/*
|
|
147
|
+
* A camera cutout in one top corner (`data-top-cutout`, with `--ldt-cutout-width` and
|
|
148
|
+
* `--ldt-cutout-height`): iPhone Duo's inner screen in portrait. The status bar lives in the
|
|
149
|
+
* cutout, so the top inset spans the whole width though only that corner is taken. Topbar moves
|
|
150
|
+
* up into the band beside it, ending where the cutout ends and stopping short of it at the side,
|
|
151
|
+
* rather than starting below a blank strip; its row then lines up with the clock. Only Topbar:
|
|
152
|
+
* overlays still clear the band. The cutout comes with a phone-width screen, where Topbar pads a
|
|
153
|
+
* row of 44px touch targets by `space-3` above and below.
|
|
154
|
+
*/
|
|
155
|
+
:where([data-top-cutout] .ldt-topbar) {
|
|
156
|
+
--ldt-safe-top: max(0px, calc(var(--ldt-cutout-height) - 2 * var(--loidolt-space-3) - 44px));
|
|
157
|
+
}
|
|
158
|
+
:where([data-top-cutout='right'] .ldt-topbar) {
|
|
159
|
+
--ldt-safe-right: max(
|
|
160
|
+
var(--safe-area-inset-right, env(safe-area-inset-right, 0px)),
|
|
161
|
+
calc(var(--ldt-cutout-width) - var(--loidolt-pad-bar-x))
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
:where([data-top-cutout='left'] .ldt-topbar) {
|
|
165
|
+
--ldt-safe-left: max(
|
|
166
|
+
var(--safe-area-inset-left, env(safe-area-inset-left, 0px)),
|
|
167
|
+
calc(var(--ldt-cutout-width) - var(--loidolt-pad-bar-x))
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
/* The status bar backdrop covers the cutout only, not the header beside it. */
|
|
171
|
+
:where([data-native-platform][data-top-cutout] body)::before {
|
|
172
|
+
width: var(--ldt-cutout-width);
|
|
173
|
+
height: var(--ldt-cutout-height);
|
|
174
|
+
}
|
|
175
|
+
:where([data-native-platform][data-top-cutout='right'] body)::before {
|
|
176
|
+
left: auto;
|
|
177
|
+
}
|
|
178
|
+
:where([data-native-platform][data-top-cutout='left'] body)::before {
|
|
179
|
+
right: auto;
|
|
180
|
+
}
|
|
181
|
+
|
|
136
182
|
/*
|
|
137
183
|
* The fold (`data-fold`, with `--ldt-fold-start` and `--ldt-fold-end`), while the device is partly
|
|
138
184
|
* open. Taps over it may not register, so what the theme centres on the screen moves to one side
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loidolt/theme-capacitor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Capacitor adapters that carry the Loidolt theme into native iOS and Android apps",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"clean": "rimraf dist"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@loidolt/theme-svelte": "^0.
|
|
45
|
-
"@loidolt/theme-tokens": "^0.
|
|
44
|
+
"@loidolt/theme-svelte": "^0.14.0",
|
|
45
|
+
"@loidolt/theme-tokens": "^0.14.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@capacitor/app": "^8.0.0",
|