openguessr-ui 0.3.6 → 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 CHANGED
@@ -343,7 +343,8 @@ The loading spinner component can be displayed while large content loads, such a
343
343
 
344
344
  The notification component is used for short messages at the top of the screen, optionally with an action. It needs to be mounted. It takes the following props:
345
345
 
346
- - `top`: Distance from the top of the viewport, defaults to `--layout-margin`
346
+ - `top`: Distance from the top of the viewport, defaults to `--box-margin`
347
+ - `offsetSafeArea`: Whether the top position should be offset by the safe area inset, defaults to true
347
348
  - `onaccept`: Called when the accept button is used
348
349
  - `ondismiss`: Called when the dismiss button is used
349
350
 
@@ -3,7 +3,7 @@
3
3
  import { Check, SquareArrowOutUpRight, X } from "@lucide/svelte";
4
4
  import { fly } from "svelte/transition";
5
5
 
6
- let { top = "var(--box-margin)", onaccept, ondismiss } = $props();
6
+ let { top = "var(--box-margin)", offsetSafeArea = true, onaccept, ondismiss } = $props();
7
7
 
8
8
  function accept() {
9
9
  if (notification.acceptFunction) {
@@ -36,7 +36,7 @@
36
36
  );
37
37
  </script>
38
38
 
39
- <div class="notification-holder" style:top>
39
+ <div class="notification-holder" style:top style:margin-top={offsetSafeArea ? "env(safe-area-inset-top)" : ""}>
40
40
  {#if notification.visible}
41
41
  <div id="notification-bar" transition:fly={{ y: -20, duration: 250 }}>
42
42
  <p id="notification-text">
@@ -103,7 +103,6 @@
103
103
  position: fixed;
104
104
  left: var(--box-margin);
105
105
  right: var(--box-margin);
106
- margin-top: env(safe-area-inset-top);
107
106
  display: flex;
108
107
  justify-content: center;
109
108
  pointer-events: none;
@@ -122,7 +122,7 @@
122
122
 
123
123
  if (isScrollingHorizontally || isScrollingDown) {
124
124
  dragStartY = null;
125
- return animateDrawerOpen(); // Touch could've stopped the drawer during open, since it's a content scroll not a drag, resume
125
+ return animateDrawerOpen(); // Touch could've stopped the drawer during open, since it's a content scroll not a drag, resume
126
126
  }
127
127
  }
128
128
 
@@ -140,7 +140,7 @@
140
140
  };
141
141
 
142
142
  const dragEnd = (event) => {
143
- if (dragStartY == null || !findDragTouch(event.changedTouches)) return; // Only the dragging finger ends the drag
143
+ if (dragStartY == null || !findDragTouch(event.changedTouches)) return; // Only the dragging finger can end the drag
144
144
  dragStartY = null;
145
145
 
146
146
  if (!isDragging) return animateDrawerOpen(); // Single tap without drag, resume opening if it was caught mid-animation
@@ -149,14 +149,14 @@
149
149
  // Calculate velocity
150
150
  const first = velocitySamples[0];
151
151
  const last = velocitySamples.at(-1);
152
- const velocity = last.time > first.time ? (last.y - first.y) / (last.time - first.time) : 0; // Pixels per ms (time is ms)
152
+ const velocity = last.time > first.time ? (last.y - first.y) / (last.time - first.time) : 0; // Pixels per ms
153
153
 
154
154
  // If swiped with enough velocity or past 35%, animate it shut, otherwise open fully again
155
155
  if (velocity > 0.4 || drawerVerticalOffset > uiWindowHeight * 0.35) {
156
156
  const duration = clamp((closedOffset - drawerVerticalOffset) / Math.max(velocity, 1.5), 180, 420); // Faster drag velocity means lower duration
157
157
  closeTiming = { duration, easing: cubicBezier(0.45, 0.55, 0.4, 0.92) };
158
158
  close();
159
- } else animateDrawerOpen(); // Too little drag, snap back to fully open state
159
+ } else animateDrawerOpen();
160
160
  };
161
161
 
162
162
  // Automatic z-indexing ---------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openguessr-ui",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite example"