@pradip1995/segment-powerhouse-cart 0.1.2 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pradip1995/segment-powerhouse-cart",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@pradip1995/segment-analytics": "^0.2.4",
29
29
  "@pradip1995/segment-login-popup": "^0.1.3",
30
- "@pradip1995/segment-primitives": "^0.4.0"
30
+ "@pradip1995/segment-primitives": "^0.4.11"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@medusajs/types": "^2.0.0",
package/src/cart.css CHANGED
@@ -412,79 +412,155 @@
412
412
  }
413
413
  }
414
414
 
415
+ @keyframes powerhouseModalFadeIn {
416
+ from {
417
+ opacity: 0;
418
+ transform: scale(0.95) translateY(10px);
419
+ }
420
+ to {
421
+ opacity: 1;
422
+ transform: scale(1) translateY(0);
423
+ }
424
+ }
425
+
426
+ @keyframes powerhouseBackdropFade {
427
+ from { opacity: 0; }
428
+ to { opacity: 1; }
429
+ }
430
+
415
431
  .powerhouse-cart-confirm {
416
432
  position: fixed;
417
433
  inset: 0;
418
- z-index: 80;
434
+ z-index: 99999;
419
435
  display: flex;
420
436
  align-items: center;
421
437
  justify-content: center;
422
- padding: 1rem;
438
+ padding: 1.25rem;
423
439
  }
424
440
 
425
441
  .powerhouse-cart-confirm__backdrop {
426
442
  position: absolute;
427
443
  inset: 0;
428
444
  border: 0;
429
- background: rgba(10, 10, 10, 0.45);
445
+ background: rgba(15, 10, 25, 0.55);
446
+ backdrop-filter: blur(6px);
447
+ -webkit-backdrop-filter: blur(6px);
448
+ animation: powerhouseBackdropFade 0.2s ease-out forwards;
430
449
  }
431
450
 
432
451
  .powerhouse-cart-confirm__panel {
433
452
  position: relative;
434
- width: min(26rem, 100%);
435
- padding: 1.5rem;
453
+ width: min(25.5rem, 100%);
454
+ padding: 2.25rem 2rem 1.75rem;
436
455
  background: #ffffff;
437
- border: 1px solid #e8e8e8;
456
+ border-radius: 1.25rem;
457
+ border: 1px solid rgba(59, 31, 78, 0.1);
458
+ box-shadow:
459
+ 0 20px 40px -10px rgba(30, 15, 45, 0.25),
460
+ 0 2px 10px rgba(0, 0, 0, 0.05);
461
+ text-align: center;
462
+ animation: powerhouseModalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
463
+ }
464
+
465
+ .powerhouse-cart-confirm__close {
466
+ position: absolute;
467
+ top: 1rem;
468
+ right: 1rem;
469
+ display: flex;
470
+ align-items: center;
471
+ justify-content: center;
472
+ width: 2rem;
473
+ height: 2rem;
474
+ padding: 0;
475
+ border: none;
476
+ border-radius: 9999px;
477
+ background: rgba(59, 31, 78, 0.05);
478
+ color: #6b7280;
479
+ font-size: 0.875rem;
480
+ line-height: 1;
481
+ cursor: pointer;
482
+ transition: all 0.2s ease;
483
+ }
484
+
485
+ .powerhouse-cart-confirm__close:hover {
486
+ background: rgba(59, 31, 78, 0.12);
487
+ color: #111827;
438
488
  }
439
489
 
440
490
  .powerhouse-cart-confirm__title {
441
491
  margin: 0 0 0.5rem;
442
492
  font-family: var(--font-heading, Georgia, serif);
443
- font-size: 1.35rem;
444
- color: #1d1d1d;
493
+ font-size: 1.4rem;
494
+ font-weight: 500;
495
+ letter-spacing: -0.01em;
496
+ color: #111827;
445
497
  }
446
498
 
447
499
  .powerhouse-cart-confirm__text {
448
- margin: 0 0 1.25rem;
500
+ margin: 0 0 1.5rem;
449
501
  font-size: 0.875rem;
450
- color: #6b6b6b;
502
+ line-height: 1.5;
503
+ color: #4b5563;
451
504
  }
452
505
 
453
506
  .powerhouse-cart-confirm__actions {
454
507
  display: flex;
455
508
  flex-direction: column;
456
- gap: 0.5rem;
509
+ gap: 0.625rem;
457
510
  }
458
511
 
459
512
  .powerhouse-cart-confirm__btn {
460
- min-height: 2.6rem;
461
- padding: 0.65rem 1rem;
513
+ display: inline-flex;
514
+ align-items: center;
515
+ justify-content: center;
516
+ min-height: 2.75rem;
517
+ padding: 0.7rem 1.25rem;
518
+ border-radius: 9999px;
462
519
  font-size: 0.75rem;
463
520
  font-weight: 600;
464
- letter-spacing: 0.06em;
521
+ letter-spacing: 0.09em;
465
522
  text-transform: uppercase;
466
523
  cursor: pointer;
524
+ transition: all 0.2s ease;
467
525
  }
468
526
 
469
527
  .powerhouse-cart-confirm__btn--primary {
470
- border: 0;
471
- background: #1d1d1d;
528
+ border: 1px solid #362447;
529
+ background: #362447;
472
530
  color: #ffffff;
531
+ box-shadow: 0 4px 14px rgba(54, 36, 71, 0.25);
532
+ }
533
+
534
+ .powerhouse-cart-confirm__btn--primary:hover:not(:disabled) {
535
+ background: #4a3260;
536
+ border-color: #4a3260;
537
+ box-shadow: 0 6px 18px rgba(54, 36, 71, 0.35);
473
538
  }
474
539
 
475
540
  .powerhouse-cart-confirm__btn--danger {
476
- border: 1px solid #c1272d;
541
+ border: 1px solid #dc2626;
477
542
  background: #ffffff;
478
- color: #c1272d;
543
+ color: #dc2626;
544
+ }
545
+
546
+ .powerhouse-cart-confirm__btn--danger:hover:not(:disabled) {
547
+ background: #fef2f2;
548
+ border-color: #b91c1c;
549
+ color: #b91c1c;
479
550
  }
480
551
 
481
552
  .powerhouse-cart-confirm__btn--ghost {
482
- border: 0;
553
+ border: 1px solid transparent;
483
554
  background: transparent;
484
- color: #6b6b6b;
555
+ color: #6b7280;
556
+ }
557
+
558
+ .powerhouse-cart-confirm__btn--ghost:hover:not(:disabled) {
559
+ background: rgba(59, 31, 78, 0.05);
560
+ color: #111827;
485
561
  }
486
562
 
487
563
  .powerhouse-cart-confirm__btn:disabled {
488
- opacity: 0.6;
564
+ opacity: 0.75;
489
565
  cursor: not-allowed;
490
566
  }
package/src/segment.tsx CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  import Image from "next/image"
4
4
  import { useRouter } from "next/navigation"
5
- import { useState, useTransition } from "react"
5
+ import { useEffect, useState, useTransition } from "react"
6
+ import { createPortal } from "react-dom"
6
7
  import type { HttpTypes } from "@medusajs/types"
7
8
  import { deleteLineItem, updateLineItem } from "@pradip1995/commerce-core/client/actions/cart"
8
9
  import { addToWishlist } from "@pradip1995/commerce-core/client/actions/wishlist"
@@ -135,10 +136,15 @@ function LineItemRow({
135
136
  const [pending, startTransition] = useTransition()
136
137
  const [confirmOpen, setConfirmOpen] = useState(false)
137
138
  const [loginRequired, setLoginRequired] = useState(false)
139
+ const [mounted, setMounted] = useState(false)
138
140
  const thumbnail = lineItemImage(item)
139
141
  const variantLabel = item.variant?.title
140
142
  const showVariant = Boolean(variantLabel && !isPlaceholderVariant(variantLabel))
141
143
 
144
+ useEffect(() => {
145
+ setMounted(true)
146
+ }, [])
147
+
142
148
  function changeQty(next: number) {
143
149
  if (next < 1 || !item.id) return
144
150
  const previousQuantity = item.quantity ?? 1
@@ -241,48 +247,59 @@ function LineItemRow({
241
247
  </div>
242
248
  <p className="powerhouse-cart__total">{formatPrice(lineTotal(item), currency)}</p>
243
249
 
244
- {confirmOpen ? (
245
- <div className="powerhouse-cart-confirm">
246
- <button
247
- type="button"
248
- className="powerhouse-cart-confirm__backdrop"
249
- aria-label="Close"
250
- onClick={() => setConfirmOpen(false)}
251
- />
252
- <div className="powerhouse-cart-confirm__panel" role="dialog" aria-modal="true">
253
- <h3 className="powerhouse-cart-confirm__title">Remove this item?</h3>
254
- <p className="powerhouse-cart-confirm__text">
255
- Move it to your wishlist to save it for later, or remove it from your cart.
256
- </p>
257
- <div className="powerhouse-cart-confirm__actions">
250
+ {confirmOpen && mounted
251
+ ? createPortal(
252
+ <div className="powerhouse-cart-confirm">
258
253
  <button
259
254
  type="button"
260
- className="powerhouse-cart-confirm__btn powerhouse-cart-confirm__btn--primary"
261
- disabled={pending}
262
- onClick={moveToWishlist}
263
- >
264
- {pending ? "Saving…" : "Move to Wishlist"}
265
- </button>
266
- <button
267
- type="button"
268
- className="powerhouse-cart-confirm__btn powerhouse-cart-confirm__btn--danger"
269
- disabled={pending}
270
- onClick={removeFromCart}
271
- >
272
- Remove the Product
273
- </button>
274
- <button
275
- type="button"
276
- className="powerhouse-cart-confirm__btn powerhouse-cart-confirm__btn--ghost"
277
- disabled={pending}
255
+ className="powerhouse-cart-confirm__backdrop"
256
+ aria-label="Close"
278
257
  onClick={() => setConfirmOpen(false)}
279
- >
280
- Keep in cart
281
- </button>
282
- </div>
283
- </div>
284
- </div>
285
- ) : null}
258
+ />
259
+ <div className="powerhouse-cart-confirm__panel" role="dialog" aria-modal="true">
260
+ <button
261
+ type="button"
262
+ className="powerhouse-cart-confirm__close"
263
+ aria-label="Close dialog"
264
+ onClick={() => setConfirmOpen(false)}
265
+ >
266
+
267
+ </button>
268
+ <h3 className="powerhouse-cart-confirm__title">Remove this item?</h3>
269
+ <p className="powerhouse-cart-confirm__text">
270
+ Move it to your wishlist to save it for later, or remove it from your cart.
271
+ </p>
272
+ <div className="powerhouse-cart-confirm__actions">
273
+ <button
274
+ type="button"
275
+ className="powerhouse-cart-confirm__btn powerhouse-cart-confirm__btn--primary"
276
+ disabled={pending}
277
+ onClick={moveToWishlist}
278
+ >
279
+ {pending ? "Saving…" : "Move to Wishlist"}
280
+ </button>
281
+ <button
282
+ type="button"
283
+ className="powerhouse-cart-confirm__btn powerhouse-cart-confirm__btn--danger"
284
+ disabled={pending}
285
+ onClick={removeFromCart}
286
+ >
287
+ Remove the Product
288
+ </button>
289
+ <button
290
+ type="button"
291
+ className="powerhouse-cart-confirm__btn powerhouse-cart-confirm__btn--ghost"
292
+ disabled={pending}
293
+ onClick={() => setConfirmOpen(false)}
294
+ >
295
+ Keep in cart
296
+ </button>
297
+ </div>
298
+ </div>
299
+ </div>,
300
+ document.body
301
+ )
302
+ : null}
286
303
 
287
304
  <LoginRequiredModal
288
305
  isOpen={loginRequired}