@foldjs/svelte 0.1.1 → 0.3.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 +177 -39
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/package.json +22 -5
package/README.md
CHANGED
|
@@ -1,33 +1,49 @@
|
|
|
1
|
-
# fold.js
|
|
1
|
+
# fold.js: foldable phone support for React, Vue, Svelte and the web
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/foldjs)
|
|
4
4
|
[](https://bundlejs.com/?q=foldjs)
|
|
5
5
|
[](LICENSE)
|
|
6
|
+
[](https://christophe77.github.io/foldjs/)
|
|
6
7
|
|
|
7
|
-
**
|
|
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.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
> 📊 **New study:** [94% of popular websites split a button across a foldable's hinge](https://christophe77.github.io/foldjs/study.html) (79 sites audited on a Galaxy Z Fold, including Google, Amazon and Facebook, plus a run at the leaked iPhone Fold size: 88%).
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
### [▶ Try the live demo](https://christophe77.github.io/foldjs/) (works on desktop: the simulator is built in) · [See an existing site fixed in one line](https://christophe77.github.io/foldjs/legacy.html)
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
```bash
|
|
15
|
+
npx foldjs audit https://your-site.com # how foldable-ready is your site? Score out of 100 + HTML report
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
## Why fold.js?
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
Most web apps treat a foldable phone as one big rectangle. Once the device is folded or spanned, text and buttons land under the hinge, and the half-folded "tabletop" posture is ignored. Chromium now exposes the right web standards ([CSS Viewport Segments](https://developer.mozilla.org/en-US/docs/Web/API/Viewport_segments_API) and the [Device Posture API](https://developer.mozilla.org/en-US/docs/Web/API/Device_Posture_API)), but using them directly means pixel math, event wiring, SSR guards and no way to test without hardware. Microsoft's earlier dual-screen libraries (`react-foldable`, `react-native-dualscreen`) are archived.
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
fold.js wraps all of that in one small, framework-agnostic API.
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- 🪟 **Two-pane layouts**: each pane on its own side of the hinge, stacked (or one hidden) on regular phones
|
|
29
|
+
- 📐 **Posture detection**: `flat`, `book` (vertical hinge), `tabletop` (horizontal hinge), `folded`
|
|
30
|
+
- 📏 **Hinge geometry**: exact position and size of the hinge and of each screen segment, in JS and as CSS variables
|
|
31
|
+
- 🧪 **Built-in foldable simulator**: switch postures from a floating panel or with Alt+Shift+F, on any desktop browser, with live outlines of everything under the hinge
|
|
32
|
+
- 🔍 **Audit CLI**: `npx foldjs audit <url>` scores any site out of 100 on Galaxy Z Fold and Pixel Fold, with an HTML report, a README badge and a CI mode
|
|
33
|
+
- 🪄 **foldjs/auto**: one script tag retrofits an existing mobile site (modals, tab bars, videos, text columns), no rewrite needed
|
|
34
|
+
- 🧩 **Every framework**: React, Vue, Svelte, Solid adapters, Web Components for everything else, and a CSS-only layer
|
|
35
|
+
- 🪶 **Tiny and safe**: about 2 kB min+gzip, zero dependencies, SSR-safe (Next.js, Nuxt, SvelteKit, Astro), TypeScript types included
|
|
22
36
|
|
|
23
37
|
## Install
|
|
24
38
|
|
|
25
39
|
```bash
|
|
26
|
-
npm i foldjs # core, CSS, Web Components, simulator
|
|
40
|
+
npm i foldjs # core, CSS layer, Web Components, simulator
|
|
27
41
|
npm i @foldjs/react # or @foldjs/vue, @foldjs/svelte, @foldjs/solid
|
|
28
42
|
```
|
|
29
43
|
|
|
30
|
-
##
|
|
44
|
+
## Quick start
|
|
45
|
+
|
|
46
|
+
### React (and Next.js)
|
|
31
47
|
|
|
32
48
|
```tsx
|
|
33
49
|
import { TwoPane, FoldWhen, FoldDevtools, useFold } from "@foldjs/react";
|
|
@@ -45,13 +61,15 @@ export function Inbox() {
|
|
|
45
61
|
<FoldWhen posture="tabletop">
|
|
46
62
|
<PlayerControls />
|
|
47
63
|
</FoldWhen>
|
|
48
|
-
{
|
|
64
|
+
{process.env.NODE_ENV === "development" && <FoldDevtools initial="book" />}
|
|
49
65
|
</>
|
|
50
66
|
);
|
|
51
67
|
}
|
|
52
68
|
```
|
|
53
69
|
|
|
54
|
-
|
|
70
|
+
`@foldjs/react` is marked `"use client"`, so it works in the Next.js App Router out of the box.
|
|
71
|
+
|
|
72
|
+
### Vue (and Nuxt)
|
|
55
73
|
|
|
56
74
|
```vue
|
|
57
75
|
<script setup>
|
|
@@ -67,7 +85,7 @@ const fold = useFold(); // fold.value.posture
|
|
|
67
85
|
</template>
|
|
68
86
|
```
|
|
69
87
|
|
|
70
|
-
|
|
88
|
+
### Svelte (and SvelteKit)
|
|
71
89
|
|
|
72
90
|
```svelte
|
|
73
91
|
<script>
|
|
@@ -83,7 +101,7 @@ const fold = useFold(); // fold.value.posture
|
|
|
83
101
|
<div use:foldWhen={"tabletop"}>Tabletop only</div>
|
|
84
102
|
```
|
|
85
103
|
|
|
86
|
-
|
|
104
|
+
### Solid
|
|
87
105
|
|
|
88
106
|
```tsx
|
|
89
107
|
import { createFold, twoPane } from "@foldjs/solid";
|
|
@@ -96,7 +114,7 @@ const fold = createFold(); // fold().posture
|
|
|
96
114
|
</div>
|
|
97
115
|
```
|
|
98
116
|
|
|
99
|
-
|
|
117
|
+
### Web Components (Angular, Lit, Astro, htmx, plain HTML)
|
|
100
118
|
|
|
101
119
|
```html
|
|
102
120
|
<script type="module">import "foldjs/elements";</script>
|
|
@@ -109,7 +127,7 @@ const fold = createFold(); // fold().posture
|
|
|
109
127
|
<fold-when posture="tabletop book">Only on a split screen</fold-when>
|
|
110
128
|
```
|
|
111
129
|
|
|
112
|
-
|
|
130
|
+
### CSS only
|
|
113
131
|
|
|
114
132
|
```js
|
|
115
133
|
import "foldjs/css";
|
|
@@ -125,23 +143,103 @@ init(); // optional: enables the simulator and non-native browsers
|
|
|
125
143
|
<div class="fold-only-tabletop">Tabletop only</div>
|
|
126
144
|
```
|
|
127
145
|
|
|
128
|
-
|
|
129
|
-
Attributes
|
|
146
|
+
CSS variables on `<html>`: `--fold-hinge-x|y|width|height`, `--fold-segment-0-width|height`, `--fold-segment-1-width|height`.
|
|
147
|
+
Attributes on `<html>`: `data-fold-posture`, `data-fold-spanning`.
|
|
130
148
|
|
|
131
|
-
##
|
|
149
|
+
## Test foldable layouts without a device
|
|
132
150
|
|
|
133
151
|
```js
|
|
134
152
|
import { mountDevtools } from "foldjs/devtools";
|
|
135
153
|
mountDevtools({ initial: "book", position: "bottom-right", hingeSize: 24 });
|
|
136
154
|
```
|
|
137
155
|
|
|
138
|
-
|
|
139
|
-
|
|
156
|
+
A floating panel lets you switch between **Device / Flat / Book / Tabletop** and draws the simulated hinge on screen. Press **Alt + Shift + F** to cycle postures. In tests, demos or Storybook, drive it from code: `simulate({ posture: "tabletop" })`, then `simulate(null)` to go back to the real device.
|
|
157
|
+
|
|
158
|
+
The panel also shows a live **foldable score** and outlines every element under the hinge: red for split buttons and form fields, orange for text, modals, fixed elements and videos, yellow for images. Click the score to toggle the outlines and log each issue, with a suggested fix, to the console. Pass `highlight: false` to turn it off.
|
|
159
|
+
|
|
160
|
+
## Audit any website: `npx foldjs audit`
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npx foldjs audit https://christophe77.github.io/foldjs/legacy.html
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
70 Samsung Galaxy Z Fold · book 2 critical, 6 warnings
|
|
168
|
+
94 Samsung Galaxy Z Fold · tabletop 0 critical, 2 warnings
|
|
169
|
+
70 Google Pixel Fold · book 2 critical, 6 warnings
|
|
170
|
+
97 Google Pixel Fold · tabletop 0 critical, 1 warnings
|
|
171
|
+
|
|
172
|
+
Top issues
|
|
173
|
+
● Button is split by the hinge #book
|
|
174
|
+
● Link is split by the hinge nav.bottom-nav > a:nth-of-type(3)
|
|
175
|
+
● Text crosses the hinge main > article > p:nth-of-type(1)
|
|
176
|
+
|
|
177
|
+
Foldable score: 83/100
|
|
178
|
+
Report: ./foldjs-report/report.html
|
|
179
|
+
```
|
|
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/foldjs)
|
|
182
|
+
|
|
183
|
+
| Option | Default | |
|
|
184
|
+
|---|---|---|
|
|
185
|
+
| `--device` | `all` | `galaxy-z-fold`, `pixel-fold`, `iphone-fold` or `all`. `iphone-fold` uses leaked specs (904×640 CSS px, iPhone user agent) and is not part of `all`. |
|
|
186
|
+
| `--posture` | `all` | `book`, `tabletop` or `all` |
|
|
187
|
+
| `--out` | `foldjs-report` | Report folder (`report.html` + `report.json`) |
|
|
188
|
+
| `--min-score` | | Exit with code 1 below this score, for CI |
|
|
189
|
+
| `--dismiss-consent` | | Close cookie banners (rejecting when possible) before the audit |
|
|
190
|
+
| `--json` | | Print the result as JSON |
|
|
191
|
+
| `--browser` | auto | Chrome, Edge or Chromium path (or `CHROME_PATH`). No browser is downloaded. |
|
|
192
|
+
|
|
193
|
+
In CI (GitHub Actions runners ship with Chrome):
|
|
194
|
+
|
|
195
|
+
```yaml
|
|
196
|
+
- run: npx foldjs audit http://localhost:3000 --min-score 90
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The audit checks the first screen of the page. It runs `findHingeCollisions()` from the core, so you can also call it yourself in a browser or in Playwright tests.
|
|
200
|
+
|
|
201
|
+
## Retrofit an existing site: `foldjs/auto`
|
|
202
|
+
|
|
203
|
+
One line, no build step, no rewrite:
|
|
204
|
+
|
|
205
|
+
```html
|
|
206
|
+
<script src="https://unpkg.com/foldjs/dist/auto.global.js"></script>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Or from your bundle: `import { autoFix } from "foldjs/auto"; const undo = autoFix();`
|
|
210
|
+
|
|
211
|
+
On a foldable (and in the simulator), it applies safe, reversible fixes as inline styles, and removes them as soon as the device is flat again:
|
|
212
|
+
|
|
213
|
+
| Fix | Automatic | Option |
|
|
214
|
+
|---|---|---|
|
|
215
|
+
| Open dialogs and modals move to a single screen (right screen in book, top half in tabletop) | ✅ | `modals` |
|
|
216
|
+
| Fixed tab bars and toolbars get an empty slot under the hinge, so no item is split | ✅ | `bars` |
|
|
217
|
+
| Videos and iframes stay on one screen (top half in tabletop) | ✅ | `media` |
|
|
218
|
+
| Text blocks flow into two columns around the hinge | add `data-fold-columns` | `columns` |
|
|
219
|
+
| Any element is pushed off the hinge (titles, call-to-action buttons) | add `data-fold-avoid` | `avoid` |
|
|
220
|
+
| An element and its children are never touched | add `data-fold-ignore` | |
|
|
221
|
+
|
|
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/foldjs/legacy.html): the foldable score goes from 70 to 100 in book posture.
|
|
223
|
+
|
|
224
|
+
## iPhone Fold: the virtual fold
|
|
225
|
+
|
|
226
|
+
Safari does not implement the foldable web APIs, so a page cannot know where the iPhone Fold folds. fold.js handles it anyway: when an Apple touch screen measures 600 to 720px on its short side (regular iPhones are under 450px, iPads at least 744px, so only an unfolded iPhone Fold fits) and is held in landscape, it splits the viewport at its center line. `<TwoPane>`, `use:twoPane`, `<fold-two-pane>` and the CSS layer then show list and detail side by side, like on an iPad. In portrait, nothing changes.
|
|
227
|
+
|
|
228
|
+
It is on by default and only affects that case. `getFold().virtual` tells you when it is active. Change it with `configure()`:
|
|
229
|
+
|
|
230
|
+
```js
|
|
231
|
+
import { configure } from "foldjs"; // also exported by every adapter
|
|
232
|
+
configure({ virtualFold: "auto" }); // default: unfolded iPhone Fold only
|
|
233
|
+
configure({ virtualFold: true }); // any landscape screen at least 600px tall (tablets, desktop testing)
|
|
234
|
+
configure({ virtualFold: false }); // never
|
|
235
|
+
```
|
|
236
|
+
|
|
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/foldjs/?virtual=1), and audit a site at the leaked iPhone Fold size with `npx foldjs audit <url> --device iphone-fold`.
|
|
140
238
|
|
|
141
239
|
## Core API
|
|
142
240
|
|
|
143
241
|
```ts
|
|
144
|
-
import { getFold, subscribe, simulate, twoPaneLayout, bindTwoPane } from "foldjs";
|
|
242
|
+
import { getFold, subscribe, simulate, twoPaneLayout, bindTwoPane, findHingeCollisions, foldScore } from "foldjs";
|
|
145
243
|
|
|
146
244
|
getFold();
|
|
147
245
|
// {
|
|
@@ -156,28 +254,66 @@ getFold();
|
|
|
156
254
|
// }
|
|
157
255
|
|
|
158
256
|
const off = subscribe((state) => console.log(state.posture));
|
|
257
|
+
|
|
258
|
+
// What sits under the hinge right now (real or simulated)?
|
|
259
|
+
const issues = findHingeCollisions(); // [{ severity, kind, message, suggestion, selector, rect, element }, …]
|
|
260
|
+
foldScore(issues); // 0 to 100
|
|
159
261
|
```
|
|
160
262
|
|
|
161
|
-
Writing an adapter for another framework? `subscribe`
|
|
263
|
+
Writing an adapter for another framework? `subscribe` and `getFold` are all you need, and `twoPaneLayout(state)` returns the styles every built-in adapter uses.
|
|
264
|
+
|
|
265
|
+
## FAQ
|
|
266
|
+
|
|
267
|
+
### How do I check if my website works on foldable phones?
|
|
268
|
+
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
|
+
### 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
|
+
|
|
273
|
+
### How do I detect a foldable phone in JavaScript?
|
|
274
|
+
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.
|
|
275
|
+
|
|
276
|
+
### How do I keep content away from the hinge in CSS?
|
|
277
|
+
Use the `fold-two-pane` class from `foldjs/css`, or the `--fold-hinge-*` and `--fold-segment-*` variables. On supporting browsers the CSS layer also uses the native `env(viewport-segment-*)` values and the `horizontal-viewport-segments` / `vertical-viewport-segments` media queries.
|
|
278
|
+
|
|
279
|
+
### What is the difference between book and tabletop posture?
|
|
280
|
+
**Book** means the hinge is vertical and the two screens are side by side, like an open book: ideal for list and detail. **Tabletop** means the hinge is horizontal, like a half-open laptop: ideal for a video or camera on top and controls at the bottom.
|
|
281
|
+
|
|
282
|
+
### Can I build for foldables without owning one?
|
|
283
|
+
Yes. The built-in simulator (`<FoldDevtools />`, `<FoldDevtools>` in Vue, or `mountDevtools()` anywhere) fakes the segments and posture on any desktop browser. Chrome DevTools device emulation (Galaxy Z Fold, Surface Duo) also works with fold.js.
|
|
284
|
+
|
|
285
|
+
### Does fold.js work on the iPhone Fold?
|
|
286
|
+
Yes, with a virtual fold. Safari exposes no foldable API, so fold.js detects an unfolded iPhone Fold from its screen size and splits the viewport at its center in landscape. Two-pane layouts work out of the box; posture detection (book or tabletop angle) is not possible on iOS until WebKit ships the Device Posture and Viewport Segments APIs.
|
|
287
|
+
|
|
288
|
+
### Which devices and browsers are supported?
|
|
289
|
+
Chrome and Edge on Android foldables (Samsung Galaxy Z Fold, Google Pixel Fold, Honor, Oppo, Vivo, Surface Duo) support the native APIs. On every other browser, including Samsung Internet, Firefox and Safari on iOS, fold.js falls back to a normal single-screen layout and the simulator still works.
|
|
290
|
+
|
|
291
|
+
### Does fold.js work with server-side rendering?
|
|
292
|
+
Yes. On the server the state is a flat, unsplit screen, and it updates on the client after hydration. It works with Next.js, Nuxt, SvelteKit, Remix and Astro.
|
|
293
|
+
|
|
294
|
+
### Is fold.js a replacement for react-foldable or react-native-dualscreen?
|
|
295
|
+
For the web, yes. Those Microsoft packages are archived and rely on the deprecated `spanning` media query and `getWindowSegments()`. fold.js uses the current standards and supports more frameworks. It does not target React Native.
|
|
162
296
|
|
|
163
297
|
## Browser support
|
|
164
298
|
|
|
165
|
-
| | Native | With
|
|
299
|
+
| | Native APIs | With fold.js |
|
|
166
300
|
|---|---|---|
|
|
167
|
-
| Chrome / Edge on Android foldables | ✅ Viewport Segments + Device Posture | ✅ |
|
|
168
|
-
| Samsung Internet,
|
|
169
|
-
| Desktop |
|
|
301
|
+
| Chrome / Edge on Android foldables | ✅ Viewport Segments + Device Posture | ✅ Full support |
|
|
302
|
+
| Samsung Internet, Firefox, Safari | ❌ | ✅ Single-screen fallback, simulator |
|
|
303
|
+
| Desktop browsers | ❌ | ✅ Simulator |
|
|
170
304
|
|
|
171
|
-
##
|
|
305
|
+
## Packages
|
|
172
306
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
307
|
+
| Package | Description |
|
|
308
|
+
|---|---|
|
|
309
|
+
| [`foldjs`](https://www.npmjs.com/package/foldjs) | Core API, CSS layer (`foldjs/css`), Web Components (`foldjs/elements`), simulator (`foldjs/devtools`), retrofit script (`foldjs/auto`) |
|
|
310
|
+
| [`@foldjs/react`](https://www.npmjs.com/package/@foldjs/react) | `useFold`, `<TwoPane>`, `<FoldWhen>`, `<FoldDevtools>` |
|
|
311
|
+
| [`@foldjs/vue`](https://www.npmjs.com/package/@foldjs/vue) | `useFold`, `<TwoPane>`, `<FoldWhen>`, `<FoldDevtools>` |
|
|
312
|
+
| [`@foldjs/svelte`](https://www.npmjs.com/package/@foldjs/svelte) | `fold` store, `use:twoPane`, `use:foldWhen` |
|
|
313
|
+
| [`@foldjs/solid`](https://www.npmjs.com/package/@foldjs/solid) | `createFold`, `use:twoPane` |
|
|
314
|
+
| [`@foldjs/cli`](https://www.npmjs.com/package/@foldjs/cli) | `foldjs audit` command (run it with `npx foldjs audit`) |
|
|
315
|
+
|
|
316
|
+
## Contributing
|
|
181
317
|
|
|
182
318
|
```bash
|
|
183
319
|
npm install
|
|
@@ -186,6 +322,8 @@ npm test
|
|
|
186
322
|
npm run build
|
|
187
323
|
```
|
|
188
324
|
|
|
325
|
+
Issues and pull requests are welcome, especially reports from people testing on real foldable devices.
|
|
326
|
+
|
|
189
327
|
## License
|
|
190
328
|
|
|
191
329
|
MIT
|
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
configure: () => import_foldjs2.configure,
|
|
23
24
|
fold: () => fold,
|
|
24
25
|
foldWhen: () => foldWhen,
|
|
25
26
|
mountDevtools: () => import_devtools.mountDevtools,
|
|
@@ -56,6 +57,7 @@ function foldWhen(node, posture) {
|
|
|
56
57
|
}
|
|
57
58
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
59
|
0 && (module.exports = {
|
|
60
|
+
configure,
|
|
59
61
|
fold,
|
|
60
62
|
foldWhen,
|
|
61
63
|
mountDevtools,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'svelte/store';
|
|
2
2
|
import { FoldState, Posture, TwoPaneOptions } from 'foldjs';
|
|
3
|
-
export { FoldState, Posture, Rect, Spanning, simulate } from 'foldjs';
|
|
3
|
+
export { FoldState, Posture, Rect, Spanning, configure, simulate } from 'foldjs';
|
|
4
4
|
export { mountDevtools } from 'foldjs/devtools';
|
|
5
5
|
|
|
6
6
|
/** Live foldable state: `$fold.posture`, `$fold.hinge`… */
|
|
@@ -15,7 +15,7 @@ declare function twoPane(node: HTMLElement, options?: TwoPaneOptions): {
|
|
|
15
15
|
update(next?: TwoPaneOptions): void;
|
|
16
16
|
destroy: () => void;
|
|
17
17
|
};
|
|
18
|
-
/** <div use:foldWhen={"tabletop"}>…</div
|
|
18
|
+
/** <div use:foldWhen={"tabletop"}>…</div>: hidden unless the posture matches. */
|
|
19
19
|
declare function foldWhen(node: HTMLElement, posture: Posture | Posture[]): {
|
|
20
20
|
update(next: Posture | Posture[]): void;
|
|
21
21
|
destroy: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'svelte/store';
|
|
2
2
|
import { FoldState, Posture, TwoPaneOptions } from 'foldjs';
|
|
3
|
-
export { FoldState, Posture, Rect, Spanning, simulate } from 'foldjs';
|
|
3
|
+
export { FoldState, Posture, Rect, Spanning, configure, simulate } from 'foldjs';
|
|
4
4
|
export { mountDevtools } from 'foldjs/devtools';
|
|
5
5
|
|
|
6
6
|
/** Live foldable state: `$fold.posture`, `$fold.hinge`… */
|
|
@@ -15,7 +15,7 @@ declare function twoPane(node: HTMLElement, options?: TwoPaneOptions): {
|
|
|
15
15
|
update(next?: TwoPaneOptions): void;
|
|
16
16
|
destroy: () => void;
|
|
17
17
|
};
|
|
18
|
-
/** <div use:foldWhen={"tabletop"}>…</div
|
|
18
|
+
/** <div use:foldWhen={"tabletop"}>…</div>: hidden unless the posture matches. */
|
|
19
19
|
declare function foldWhen(node: HTMLElement, posture: Posture | Posture[]): {
|
|
20
20
|
update(next: Posture | Posture[]): void;
|
|
21
21
|
destroy: () => void;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { readable } from "svelte/store";
|
|
3
3
|
import { bindTwoPane, getFold, subscribe } from "foldjs";
|
|
4
|
-
import { simulate } from "foldjs";
|
|
4
|
+
import { configure, simulate } from "foldjs";
|
|
5
5
|
import { mountDevtools } from "foldjs/devtools";
|
|
6
6
|
var fold = readable(getFold(), (set) => {
|
|
7
7
|
set(getFold());
|
|
@@ -27,6 +27,7 @@ function foldWhen(node, posture) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
export {
|
|
30
|
+
configure,
|
|
30
31
|
fold,
|
|
31
32
|
foldWhen,
|
|
32
33
|
mountDevtools,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foldjs/svelte",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Svelte
|
|
3
|
+
"version": "0.3.0",
|
|
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": {
|
|
@@ -28,14 +28,31 @@
|
|
|
28
28
|
],
|
|
29
29
|
"sideEffects": false,
|
|
30
30
|
"keywords": [
|
|
31
|
-
"foldable",
|
|
32
31
|
"svelte",
|
|
32
|
+
"sveltejs",
|
|
33
|
+
"sveltekit",
|
|
34
|
+
"svelte-action",
|
|
35
|
+
"store",
|
|
36
|
+
"foldable",
|
|
37
|
+
"foldable-phone",
|
|
38
|
+
"foldables",
|
|
33
39
|
"dual-screen",
|
|
34
40
|
"hinge",
|
|
35
|
-
"
|
|
41
|
+
"viewport-segments",
|
|
42
|
+
"device-posture",
|
|
43
|
+
"galaxy-fold",
|
|
44
|
+
"pixel-fold",
|
|
45
|
+
"surface-duo",
|
|
46
|
+
"two-pane",
|
|
47
|
+
"responsive",
|
|
48
|
+
"responsive-design",
|
|
49
|
+
"layout",
|
|
50
|
+
"tabletop-mode",
|
|
51
|
+
"foldjs",
|
|
52
|
+
"iphone-fold"
|
|
36
53
|
],
|
|
37
54
|
"peerDependencies": {
|
|
38
|
-
"foldjs": "^0.
|
|
55
|
+
"foldjs": "^0.3.0",
|
|
39
56
|
"svelte": ">=4"
|
|
40
57
|
},
|
|
41
58
|
"scripts": {
|