@foldjs/svelte 0.3.0 โ 0.4.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 +11 -10
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/foldjs)
|
|
4
4
|
[](https://bundlejs.com/?q=foldjs)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](https://christophe77.github.io/
|
|
6
|
+
[](https://christophe77.github.io/fold.js/)
|
|
7
7
|
|
|
8
8
|
**fold.js is an open-source JavaScript library that makes web apps work properly on foldable phones** such as the Samsung Galaxy Z Fold, Google Pixel Fold, Honor Magic V or Microsoft Surface Duo. It detects the hinge and the device posture (flat, book, tabletop), and gives you two-pane layouts that never put content under the hinge. It works with React, Vue, Svelte, Solid, Angular, Astro or plain HTML, weighs about 2 kB, and ships with a built-in foldable simulator so you can build without owning a device.
|
|
9
9
|
|
|
10
|
-
> ๐ **New study:** [94% of popular websites split a button across a foldable's hinge](https://christophe77.github.io/
|
|
10
|
+
> ๐ **New study:** [94% of popular websites split a button across a foldable's hinge](https://christophe77.github.io/fold.js/study.html) (77 sites audited on a Galaxy Z Fold, including Google, Amazon and Facebook, plus a run at the leaked iPhone Fold size: 86%).
|
|
11
11
|
|
|
12
|
-
### [โถ Try the live demo](https://christophe77.github.io/
|
|
12
|
+
### [โถ Try the live demo](https://christophe77.github.io/fold.js/) (works on desktop: the simulator is built in) ยท [See an existing site fixed in one line](https://christophe77.github.io/fold.js/legacy.html)
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
15
|
npx foldjs audit https://your-site.com # how foldable-ready is your site? Score out of 100 + HTML report
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-

|
|
19
19
|
|
|
20
20
|
## Why fold.js?
|
|
21
21
|
|
|
@@ -160,7 +160,7 @@ The panel also shows a live **foldable score** and outlines every element under
|
|
|
160
160
|
## Audit any website: `npx foldjs audit`
|
|
161
161
|
|
|
162
162
|
```bash
|
|
163
|
-
npx foldjs audit https://christophe77.github.io/
|
|
163
|
+
npx foldjs audit https://christophe77.github.io/fold.js/legacy.html
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
```
|
|
@@ -178,7 +178,7 @@ npx foldjs audit https://christophe77.github.io/foldjs/legacy.html
|
|
|
178
178
|
Report: ./foldjs-report/report.html
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
It opens the page in headless Chrome at the real inner-screen sizes of the Samsung Galaxy Z Fold and Google Pixel Fold, in book and tabletop postures, and lists every element under the hinge. The HTML report shows annotated screenshots and a fix for each issue, plus a badge for your README: [](https://github.com/christophe77/
|
|
181
|
+
It opens the page in headless Chrome at the real inner-screen sizes of the Samsung Galaxy Z Fold and Google Pixel Fold, in book and tabletop postures, and lists every element under the hinge. The HTML report shows annotated screenshots and a fix for each issue, plus a badge for your README: [](https://github.com/christophe77/fold.js)
|
|
182
182
|
|
|
183
183
|
| Option | Default | |
|
|
184
184
|
|---|---|---|
|
|
@@ -186,7 +186,7 @@ It opens the page in headless Chrome at the real inner-screen sizes of the Samsu
|
|
|
186
186
|
| `--posture` | `all` | `book`, `tabletop` or `all` |
|
|
187
187
|
| `--out` | `foldjs-report` | Report folder (`report.html` + `report.json`) |
|
|
188
188
|
| `--min-score` | | Exit with code 1 below this score, for CI |
|
|
189
|
-
| `--dismiss-consent` | | Close cookie banners (
|
|
189
|
+
| `--dismiss-consent` | | Close cookie banners (accepting, like most visitors) before the audit |
|
|
190
190
|
| `--json` | | Print the result as JSON |
|
|
191
191
|
| `--browser` | auto | Chrome, Edge or Chromium path (or `CHROME_PATH`). No browser is downloaded. |
|
|
192
192
|
|
|
@@ -213,13 +213,14 @@ On a foldable (and in the simulator), it applies safe, reversible fixes as inlin
|
|
|
213
213
|
| Fix | Automatic | Option |
|
|
214
214
|
|---|---|---|
|
|
215
215
|
| Open dialogs and modals move to a single screen (right screen in book, top half in tabletop) | โ
| `modals` |
|
|
216
|
+
| Cookie and consent banners move to a single screen (OneTrust, Didomi, Axeptio, Cookiebot, Quantcast, Usercentrics, Sourcepoint, tarteaucitron and homemade ones) | โ
| `consent` |
|
|
216
217
|
| Fixed tab bars and toolbars get an empty slot under the hinge, so no item is split | โ
| `bars` |
|
|
217
218
|
| Videos and iframes stay on one screen (top half in tabletop) | โ
| `media` |
|
|
218
219
|
| Text blocks flow into two columns around the hinge | add `data-fold-columns` | `columns` |
|
|
219
220
|
| Any element is pushed off the hinge (titles, call-to-action buttons) | add `data-fold-avoid` | `avoid` |
|
|
220
221
|
| An element and its children are never touched | add `data-fold-ignore` | |
|
|
221
222
|
|
|
222
|
-
Turn a fix off with `autoFix({ bars: false })` or `<script src="โฆ/auto.global.js" data-bars="false">`. [See it on a typical mobile site](https://christophe77.github.io/
|
|
223
|
+
Turn a fix off with `autoFix({ bars: false })` or `<script src="โฆ/auto.global.js" data-bars="false">`. [See it on a typical mobile site](https://christophe77.github.io/fold.js/legacy.html): the foldable score goes from 76 to 100 in book posture, cookie banner included.
|
|
223
224
|
|
|
224
225
|
## iPhone Fold: the virtual fold
|
|
225
226
|
|
|
@@ -234,7 +235,7 @@ configure({ virtualFold: true }); // any landscape screen at least 600px tall
|
|
|
234
235
|
configure({ virtualFold: false }); // never
|
|
235
236
|
```
|
|
236
237
|
|
|
237
|
-
The iPhone Fold crease is reportedly much shallower than on earlier foldables, so content on the fold stays readable. The virtual fold is about using the wide inner screen well, not about hiding a gap. Preview it in the [demo](https://christophe77.github.io/
|
|
238
|
+
The iPhone Fold crease is reportedly much shallower than on earlier foldables, so content on the fold stays readable. The virtual fold is about using the wide inner screen well, not about hiding a gap. Preview it in the [demo](https://christophe77.github.io/fold.js/?virtual=1), and audit a site at the leaked iPhone Fold size with `npx foldjs audit <url> --device iphone-fold`.
|
|
238
239
|
|
|
239
240
|
## Core API
|
|
240
241
|
|
|
@@ -268,7 +269,7 @@ Writing an adapter for another framework? `subscribe` and `getFold` are all you
|
|
|
268
269
|
Run `npx foldjs audit https://your-site.com`. It tests the page on the Samsung Galaxy Z Fold and Google Pixel Fold in book and tabletop postures, gives a score out of 100 and an HTML report with screenshots of every element under the hinge. While developing, the fold.js simulator shows the same issues live.
|
|
269
270
|
|
|
270
271
|
### Can I make an existing mobile site foldable-friendly without rewriting it?
|
|
271
|
-
Yes. Add `<script src="https://unpkg.com/foldjs/dist/auto.global.js"></script>`. It moves modals, tab bars and videos off the hinge automatically, and you can mark text blocks with `data-fold-columns` or elements with `data-fold-avoid` for more. For new screens, `<TwoPane>` gives the best result.
|
|
272
|
+
Yes. Add `<script src="https://unpkg.com/foldjs/dist/auto.global.js"></script>`. It moves cookie banners, modals, tab bars and videos off the hinge automatically, and you can mark text blocks with `data-fold-columns` or elements with `data-fold-avoid` for more. For new screens, `<TwoPane>` gives the best result.
|
|
272
273
|
|
|
273
274
|
### How do I detect a foldable phone in JavaScript?
|
|
274
275
|
Call `getFold()` from `foldjs` (or `useFold()` in React and Vue). `isSpanned` tells you whether the viewport is split by a hinge, `posture` tells you how the device is held, and `hinge` gives the hinge rectangle in CSS pixels. Under the hood fold.js reads `window.viewport.segments` and `navigator.devicePosture`, with a fallback for older Edge builds.
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foldjs/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Svelte store and actions for foldable phones: $fold, use:twoPane, use:foldWhen and a built-in foldable simulator. Works with SvelteKit.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "christophe77",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/christophe77/
|
|
9
|
+
"url": "git+https://github.com/christophe77/fold.js.git",
|
|
10
10
|
"directory": "packages/svelte"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://christophe77.github.io/
|
|
13
|
-
"bugs": "https://github.com/christophe77/
|
|
12
|
+
"homepage": "https://christophe77.github.io/fold.js/",
|
|
13
|
+
"bugs": "https://github.com/christophe77/fold.js/issues",
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "./dist/index.cjs",
|
|
16
16
|
"module": "./dist/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"iphone-fold"
|
|
53
53
|
],
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"foldjs": "^0.
|
|
55
|
+
"foldjs": "^0.4.0",
|
|
56
56
|
"svelte": ">=4"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|