fix(web,widget): embed checkout styles and no silent host fallback - #171
Open
Mamavee001 wants to merge 1 commit into
Open
fix(web,widget): embed checkout styles and no silent host fallback#171Mamavee001 wants to merge 1 commit into
Mamavee001 wants to merge 1 commit into
Conversation
…ssue 5.10) - globals.css: real .shell--embed / .panel--embed rules - no page-level max-width/centering/32-80px padding inside the widget's 440x680 iframe (the outer modal <div> in packages/widget/src/modal.ts already supplies the rounded corners/border/shadow, so the page inside only needs to fill the frame). Added .checkout--embed overrides tightening heading scale, QR wrap margins, memo-note spacing, and the status-rail/icon sizes specifically for the narrower embed context - checked against the "active - waiting for payment" render, the tallest of the states. - CheckoutClient now takes an `embed` prop (threaded from pay/[id]/page.tsx's existing isEmbed flag) so it can apply the .checkout--embed class and use a smaller QR size (140px vs 180px) - the one thing CSS alone can't resize, since it's a real prop on QRCodeSVG, not a stylable dimension. - packages/widget/src/modal.ts: deleted the DEFAULT_HOST fallback (https://quay-web.vercel.app - the maintainer's own deployment). openModal() now resolves the host via an explicit `host` option or the widget's own <script src="...widget.js"> tag; if neither works, it throws a clear error naming both ways to fix it, rather than silently pointing a self-hoster's integration at someone else's backend. Also moved host resolution to the very top of openModal(), before any state mutation, so a failed call is a true no-op - it doesn't close (and fail to replace) a modal that was already open. - README.md: added the `host` option to the widget quickstart snippet for self-hosters, with the new fail-loud behavior stated explicitly. - packages/widget/test/widget.test.ts: updated the existing tests to supply a host (they'd have hit the new throw otherwise, since none of them had a real host to detect), and added new coverage for the throw case, script-tag inference, explicit-host precedence, and the no-op-on-failure guarantee. No Node.js/npm/pnpm/vitest runtime is available in the environment this was authored in, so none of this - including the updated and new widget tests - has actually been executed. The CSS sizing was checked by reasoning through the actual component markup and existing style rules (qr-wrap padding, amount-hero font sizes, the existing <=560px breakpoint) against a 440x680 frame, not by rendering it - please verify visually at that exact size before merging.
|
@Mamavee001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@Mamavee001 is attempting to deploy a commit to the determined's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #156
What changed
1. Real
.shell--embed/.panel--embedrules (apps/web/app/globals.css) - previously neither class existed, so only the full-page.shellrules applied (max-width centering + 32-80px page padding) inside the widget's 440x680 iframe. The widget's own outer<div>(packages/widget/src/modal.ts) already supplies the rounded corners/border/shadow around the iframe, so the page rendered inside it only needs to fill the frame - it shouldn't also look like a card floating inside a card.2. Checked the embed rendering at that exact size and tightened what assumed a full page -
CheckoutClientnow takes anembedprop (threaded frompay/[id]/page.tsx's existingisEmbedflag) so it can:.checkout--embedclass (tighter heading scale, QR-wrap margins, memo-note spacing, and status-rail/icon sizing -globals.css), andsizeis a real prop onQRCodeSVG, not a stylable dimension.I sized/checked this against the "active - waiting for payment" render specifically, since it's the tallest of the checkout states (title + amount + QR + memo note + status rail, no masthead since that's already hidden in embed mode).
3.
packages/widget/src/modal.ts: deleted theDEFAULT_HOSTfallback (https://quay-web.vercel.app- the maintainer's own deployment).openModal()now resolves the host via an explicithostoption or the widget's own<script src="...widget.js">tag; if neither works, it throws a clear error naming both fixes, rather than silently pointing a self-hoster's integration at someone else's backend. I also moved host resolution to the very top ofopenModal(), before any state mutation - a failed call is now a true no-op, rather than one that closes (and fails to replace) whatever modal was already open.4. Updated the widget quickstart in
README.mdto show thehostoption for self-hosters, stating the new fail-loud behavior explicitly.A real, necessary test update
The existing widget tests (
packages/widget/test/widget.test.ts) calledQuay.open("lnk_test_123")with no host and no script tag in the DOM - under the old code this silently succeeded via thewindow.location.originfallback (itself removed too, since it's just a different flavor of the same "guess a host" problem - a third-party site embedding the widget would havewindow.location.originresolve to their own origin, not Quay's, which is just as wrong as the hardcoded fallback). Under the new code these calls would throw. I updated them to supply an explicithost(or a real script tag, for the button-binding test), and added new coverage for: the throw case, script-tag inference, explicit-host-overrides-script-tag precedence, and the no-op-on-failure guarantee.Test plan
No Node.js/npm/pnpm/vitest runtime is available in the environment this was authored in, so none of this - including the updated and new widget tests - has actually been executed. The CSS sizing was checked by reasoning through the actual component markup and existing style rules (real
qr-wrappadding values,amount-herofont sizes, the existing<=560pxmedia query) against a 440x680 frame, not by rendering it in a browser. Please:pnpm --filter @checkout/widget testandpnpm --filter @checkout/web buildbefore merging.