You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+64Lines changed: 64 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,7 @@ Building a chat widget, floating toolbar, debug panel, or side dock? You want th
32
32
|[`<ResizableSplitPane>`](#resizablesplitter)| An N-pane resizable split layout with draggable handles, min/max constraints, and localStorage-persisted ratios. |
33
33
|[`<InspectorBubble>`](#inspectorbubble)| A Chrome-DevTools-style element picker overlay for design QA — hover to see tag, selector, dimensions, font, colors + WCAG contrast, box model, ARIA role, and accessible name. |
34
34
|[`<ZoomLens>`](#zoomlens)| A draggable magnifier circle that zooms into whatever it hovers — free-drag over the whole page or scope it to one element (product-image-zoom style). Wheel to zoom, hotkey or Escape to dismiss. |
35
+
|[`<FlickDeck>`](#flickdeck)| A stack of cards where each back card peeks from one edge. Click the peek to flick that card to the front, or optionally swipe the front card off to dismiss it. |
35
36
36
37
## Installation
37
38
@@ -56,6 +57,21 @@ bun add react-driftkit
56
57
57
58
</details>
58
59
60
+
## Importing
61
+
62
+
Every component is available two ways — both tree-shake to the same code.
63
+
64
+
```tsx
65
+
// 1. Barrel import — grab multiple components at once
Subpath imports are handy when you only need one component and want the import line to be explicit about bundle cost (your bundler will tree-shake the barrel import down to the same output either way, as long as `sideEffects` is respected — which it is here).
74
+
59
75
## Quick Start
60
76
61
77
```tsx
@@ -67,6 +83,7 @@ import {
67
83
ResizableSplitPane,
68
84
InspectorBubble,
69
85
ZoomLens,
86
+
FlickDeck,
70
87
} from'react-driftkit';
71
88
72
89
function App() {
@@ -104,6 +121,13 @@ function App() {
104
121
{/* Magnifier scoped to one element — hover to zoom. */}
@@ -225,6 +259,8 @@ A draggable magnifier circle that zooms into whatever it hovers. Great for desig
225
259
-**Ignore rules** — strip elements from the clone via `behavior.ignoreSelector` or `[data-zoom-lens-ignore]`
226
260
227
261
```tsx
262
+
importZoomLensfrom'react-driftkit/ZoomLens';
263
+
228
264
<ZoomLens
229
265
defaultActive
230
266
target={imageRef}// omit for a free-drag whole-page lens
@@ -237,6 +273,30 @@ A draggable magnifier circle that zooms into whatever it hovers. Great for desig
237
273
238
274
---
239
275
276
+
## FlickDeck
277
+
278
+
A stack of cards where each back card peeks from one edge — receding into depth for `top`/`bottom` peek, fanning out at an angle for `left`/`right`. Click the peek to flick that card to the front, or optionally swipe the front card off to dismiss it. Great for toggles between views, tip stacks, onboarding cards, and side-by-side comparisons.
279
+
280
+
-**Four peek edges** — `top`, `bottom`, `left`, `right`; each child's React `key` is its card id
281
+
-**Depth cues you can tune** — `depthScale` shrinks back cards, `fanAngle` rotates them, `depthFade` dims them, or set any to `0` for a flat stack
282
+
-**Controlled or uncontrolled** — drive the front card via `frontId` + `on.frontChange`, or just pass `defaultFrontId`
283
+
-**Optional swipe-to-dismiss** — drag the front card off in the opposite direction of the peek to fire `on.dismiss(id)`
284
+
-**Unstyled** — `data-flick-deck-front`, `data-flick-deck-depth`, and `data-flick-deck-active` attributes let you drive CSS without re-rendering
**Full API, more examples, and live demo →**<https://react-driftkit.saktichourasia.dev/flick-deck>
297
+
298
+
---
299
+
240
300
## Use Cases
241
301
242
302
-**Chat widgets** — floating support buttons that stay accessible
@@ -254,6 +314,8 @@ A draggable magnifier circle that zooms into whatever it hovers. Great for desig
254
314
-**In-house devtools** — a built-in element picker for style audits, a11y audits, or click-to-log workflows
255
315
-**Product image zoom** — magnifier scoped to a single image, follows the cursor, hides on leave
256
316
-**Data table inspection** — drag a magnifier over dense tables, charts, or heatmaps to read small values without re-flowing the page
317
+
-**Tip / onboarding stacks** — a deck of coachmark cards the user can flick through and swipe off one by one
318
+
-**Comparison decks** — toggle between product plans, chart variants, or before/after states with a single click on the peek
257
319
258
320
## How it works
259
321
@@ -267,6 +329,8 @@ Under the hood all components use the [Pointer Events API](https://developer.moz
267
329
268
330
`ZoomLens` live-clones either `document.body` (free mode) or a target element (target mode) into a portalled host, then applies a `translate()` + `scale()` transform so the point under the lens center maps to target-local — or document — coords. A `MutationObserver` rebuilds the clone when the real DOM changes, debounced to 150 ms and skipped during drag. In target mode, pointer tracking attaches directly to the target, and the lens overlay is `pointer-events: none` so hover state keeps passing through to the real element underneath.
269
331
332
+
`FlickDeck` lays every card in a single CSS grid cell so the container auto-sizes to the largest card, then offsets back cards with pure `transform` — `translate` along the peek axis, plus `scale` (top/bottom peek) or `rotate` around the attached edge (left/right peek). Depth fade uses `opacity`. The front card's `key` is its id; a click or keyboard activation on a peek swaps ids with a CSS transition. Swipe-to-dismiss tracks pointer movement on the front card and fires `on.dismiss(id)` once the drag crosses `dismissThreshold` in the direction opposite the peek, leaving the consumer to remove that child.
333
+
270
334
## Contributing
271
335
272
336
Contributions are welcome. Open an issue or send a pull request.
0 commit comments