@x33025/sveltely 0.0.53 → 0.0.55

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.
@@ -139,44 +139,44 @@
139
139
  return Number.isFinite(parsed) ? parsed : 0;
140
140
  };
141
141
 
142
- const updateComputedPanelRadius = () => {
142
+ const updateRadiusFromSource = () => {
143
143
  if (!panelEl || !contentEl) {
144
144
  computedPanelRadius = null;
145
145
  return;
146
146
  }
147
147
 
148
- const itemEl =
149
- contentEl.querySelector<HTMLElement>('[data-popover-radius-item]') ||
150
- contentEl.querySelector<HTMLElement>('.popover-item') ||
151
- contentEl.querySelector<HTMLElement>('.dropdown-item');
152
- if (!itemEl) {
148
+ const sourceEl = contentEl.querySelector<HTMLElement>('[data-popover-radius-source]');
149
+ if (!sourceEl) {
153
150
  computedPanelRadius = null;
154
151
  return;
155
152
  }
156
153
 
157
- const itemRect = itemEl.getBoundingClientRect();
158
- const itemStyle = getComputedStyle(itemEl);
159
- const itemRadius = parsePx(itemStyle.borderTopLeftRadius);
160
- const effectiveItemRadius = Math.min(itemRadius, itemRect.height / 2, itemRect.width / 2);
161
-
162
- const panelStyle = getComputedStyle(panelEl);
163
- const panelPadding = Math.min(parsePx(panelStyle.paddingTop), parsePx(panelStyle.paddingLeft));
164
-
154
+ const sourceStyle = getComputedStyle(sourceEl);
155
+ const sourceRadius = parsePx(sourceStyle.borderTopLeftRadius);
156
+ const sourceRect = sourceEl.getBoundingClientRect();
157
+ const effectiveSourceRadius = Math.min(
158
+ sourceRadius,
159
+ sourceRect.height / 2,
160
+ sourceRect.width / 2
161
+ );
165
162
  const panelRect = panelEl.getBoundingClientRect();
166
- const outerRadius = Math.min(
167
- effectiveItemRadius + panelPadding,
163
+ const insetTop = Math.max(0, sourceRect.top - panelRect.top);
164
+ const insetLeft = Math.max(0, sourceRect.left - panelRect.left);
165
+ const sourceInset = Math.min(insetTop, insetLeft);
166
+ const panelRadius = Math.min(
167
+ Math.max(0, effectiveSourceRadius + sourceInset),
168
168
  panelRect.height / 2,
169
169
  panelRect.width / 2
170
170
  );
171
171
 
172
- computedPanelRadius = `${outerRadius}px`;
172
+ computedPanelRadius = `${panelRadius}px`;
173
173
  };
174
174
 
175
175
  const positionAndMeasure = async () => {
176
176
  await tick();
177
177
  await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
178
178
  positionPanel();
179
- updateComputedPanelRadius();
179
+ updateRadiusFromSource();
180
180
  };
181
181
 
182
182
  const getPopoverIdsFromEvent = (event: Event) => {
@@ -256,11 +256,6 @@
256
256
  if (!open) return;
257
257
  void positionAndMeasure();
258
258
  });
259
-
260
- $effect(() => {
261
- if (!open) return;
262
- updateComputedPanelRadius();
263
- });
264
259
  </script>
265
260
 
266
261
  <svelte:window
@@ -297,7 +292,7 @@
297
292
  data-popover-id={popoverId}
298
293
  data-popover-parent-id={parentPopoverId ?? ''}
299
294
  style="top: {panelCoords.top}px; left: {panelCoords.left}px; transform: {panelTransform}; border-radius: {computedPanelRadius ??
300
- '0.375rem'};"
295
+ ''};"
301
296
  role="dialog"
302
297
  aria-modal="false"
303
298
  tabindex="-1"
@@ -95,9 +95,15 @@
95
95
  }
96
96
 
97
97
  .popover {
98
- @apply rounded-md border border-gray-200 bg-white p-1 shadow-md;
98
+ @apply border border-gray-200 bg-white p-1 shadow-md;
99
99
  }
100
100
 
101
+ .popover-item {
102
+ @apply rounded-md px-2 py-1;
103
+ }
104
+ .popover-item:hover {
105
+ @apply bg-zinc-200;
106
+ }
101
107
  .sheet {
102
108
  @apply rounded-md bg-white p-4 shadow-md;
103
109
  }
package/dist/style.css CHANGED
@@ -7,8 +7,11 @@
7
7
  "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
8
8
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
9
9
  "Courier New", monospace;
10
+ --color-red-100: oklch(93.6% 0.032 17.717);
11
+ --color-red-200: oklch(88.5% 0.062 18.334);
10
12
  --color-red-500: oklch(63.7% 0.237 25.331);
11
13
  --color-red-600: oklch(57.7% 0.245 27.325);
14
+ --color-red-700: oklch(50.5% 0.213 27.518);
12
15
  --color-gray-200: oklch(92.8% 0.006 264.531);
13
16
  --color-gray-700: oklch(37.3% 0.034 259.733);
14
17
  --color-gray-900: oklch(21% 0.034 264.665);
@@ -390,12 +393,18 @@
390
393
  .border-zinc-300 {
391
394
  border-color: var(--color-zinc-300);
392
395
  }
396
+ .bg-red-100 {
397
+ background-color: var(--color-red-100);
398
+ }
393
399
  .bg-white {
394
400
  background-color: var(--color-white);
395
401
  }
396
402
  .bg-zinc-50 {
397
403
  background-color: var(--color-zinc-50);
398
404
  }
405
+ .bg-zinc-100 {
406
+ background-color: var(--color-zinc-100);
407
+ }
399
408
  .bg-zinc-900 {
400
409
  background-color: var(--color-zinc-900);
401
410
  }
@@ -456,6 +465,9 @@
456
465
  .text-red-600 {
457
466
  color: var(--color-red-600);
458
467
  }
468
+ .text-red-700 {
469
+ color: var(--color-red-700);
470
+ }
459
471
  .text-white {
460
472
  color: var(--color-white);
461
473
  }
@@ -524,6 +536,13 @@
524
536
  --tw-outline-style: none;
525
537
  outline-style: none;
526
538
  }
539
+ .hover\:bg-red-200 {
540
+ &:hover {
541
+ @media (hover: hover) {
542
+ background-color: var(--color-red-200);
543
+ }
544
+ }
545
+ }
527
546
  .hover\:bg-zinc-100 {
528
547
  &:hover {
529
548
  @media (hover: hover) {
@@ -531,6 +550,13 @@
531
550
  }
532
551
  }
533
552
  }
553
+ .hover\:bg-zinc-200 {
554
+ &:hover {
555
+ @media (hover: hover) {
556
+ background-color: var(--color-zinc-200);
557
+ }
558
+ }
559
+ }
534
560
  .focus\:border-zinc-400 {
535
561
  &:focus {
536
562
  border-color: var(--color-zinc-400);
@@ -686,7 +712,6 @@
686
712
  }
687
713
  }
688
714
  .popover {
689
- border-radius: var(--radius-md);
690
715
  border-style: var(--tw-border-style);
691
716
  border-width: 1px;
692
717
  border-color: var(--color-gray-200);
@@ -695,6 +720,14 @@
695
720
  --tw-shadow: 0 4px 6px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 2px 4px -2px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
696
721
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
697
722
  }
723
+ .popover-item {
724
+ border-radius: var(--radius-md);
725
+ padding-inline: calc(var(--spacing) * 2);
726
+ padding-block: calc(var(--spacing) * 1);
727
+ }
728
+ .popover-item:hover {
729
+ background-color: var(--color-zinc-200);
730
+ }
698
731
  .sheet {
699
732
  border-radius: var(--radius-md);
700
733
  background-color: var(--color-white);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x33025/sveltely",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",