@akinon/projectzero 2.0.43 → 2.0.45-beta.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/CHANGELOG.md +12 -0
- package/app-template/CHANGELOG.md +66 -1
- package/app-template/package.json +29 -29
- package/app-template/src/app/[pz]/orders/checkout/layout.tsx +30 -11
- package/app-template/src/app/[pz]/orders/checkout/page.tsx +31 -18
- package/app-template/src/components/checkbox.tsx +21 -2
- package/app-template/src/views/checkout/__tests__/part-style-reachability.test.ts +121 -0
- package/app-template/src/views/checkout/step-button.tsx +13 -2
- package/app-template/src/views/checkout/step-list.tsx +5 -1
- package/app-template/src/views/checkout/steps/payment/agreements.tsx +9 -1
- package/app-template/src/views/checkout/steps/payment/index.tsx +10 -2
- package/app-template/src/views/checkout/steps/payment/options/credit-card/index.tsx +2 -0
- package/app-template/src/views/checkout/steps/payment/options/funds-transfer.tsx +2 -0
- package/app-template/src/views/checkout/steps/payment/payment-header.tsx +5 -1
- package/app-template/src/views/checkout/steps/payment/payment-option-buttons.tsx +16 -4
- package/app-template/src/views/checkout/steps/shipping/addresses.tsx +2 -1
- package/app-template/src/views/checkout/steps/shipping/index.tsx +2 -0
- package/app-template/src/views/checkout/steps/shipping/shipping-options.tsx +2 -0
- package/app-template/src/views/checkout/summary.tsx +56 -18
- package/app-template/src/views/checkout/variants/__tests__/registry.test.tsx +82 -0
- package/app-template/src/views/checkout/variants/__tests__/use-resolved-config.test.tsx +208 -0
- package/app-template/src/views/checkout/variants/basket-and-checkout/index.tsx +7 -4
- package/app-template/src/views/checkout/variants/multi-step/index.tsx +7 -2
- package/app-template/src/views/checkout/variants/one-page/accordion-section.tsx +22 -0
- package/app-template/src/views/checkout/variants/one-page/index.tsx +7 -4
- package/app-template/src/views/checkout/variants/one-page/one-page-summary.tsx +80 -18
- package/app-template/src/views/checkout/variants/one-page/payment-options-grid.tsx +34 -22
- package/app-template/src/views/checkout/variants/one-page/sections/address-section.tsx +2 -0
- package/app-template/src/views/checkout/variants/one-page/sections/payment-section.tsx +2 -0
- package/app-template/src/views/checkout/variants/one-page/sections/shipping-section.tsx +2 -0
- package/app-template/src/views/checkout/variants/registry.ts +13 -2
- package/app-template/src/views/checkout/variants/use-resolved-config.ts +77 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
# @akinon/projectzero
|
|
2
2
|
|
|
3
|
+
## 2.0.45-beta.0
|
|
4
|
+
|
|
5
|
+
## 2.0.44
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- 867e7873: ZERO-4731: Ship the composable checkout wiring in the CLI scaffold. 2.0.43 published the renderer half before the scaffold port merged, so a generated project still referenced the removed checkout summary placeholder and could not type-check.
|
|
10
|
+
|
|
3
11
|
## 2.0.43
|
|
4
12
|
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- c44604f6a: ZERO-4731: Wire the composable checkout into the CLI scaffold's checkout route
|
|
16
|
+
|
|
5
17
|
## 2.0.42
|
|
6
18
|
|
|
7
19
|
## 2.0.41
|
|
@@ -1,10 +1,75 @@
|
|
|
1
1
|
# projectzeronext
|
|
2
2
|
|
|
3
|
+
## 2.0.45-beta.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [cbbbfd75]
|
|
8
|
+
- @akinon/next@2.0.45-beta.0
|
|
9
|
+
- @akinon/pz-theme@2.0.45-beta.0
|
|
10
|
+
- @akinon/pz-virtual-try-on@2.0.45-beta.0
|
|
11
|
+
- @akinon/pz-akifast@2.0.45-beta.0
|
|
12
|
+
- @akinon/pz-apple-pay@2.0.45-beta.0
|
|
13
|
+
- @akinon/pz-b2b@2.0.45-beta.0
|
|
14
|
+
- @akinon/pz-basket-gift-pack@2.0.45-beta.0
|
|
15
|
+
- @akinon/pz-bkm@2.0.45-beta.0
|
|
16
|
+
- @akinon/pz-checkout-gift-pack@2.0.45-beta.0
|
|
17
|
+
- @akinon/pz-click-collect@2.0.45-beta.0
|
|
18
|
+
- @akinon/pz-credit-payment@2.0.45-beta.0
|
|
19
|
+
- @akinon/pz-cybersource-uc@2.0.45-beta.0
|
|
20
|
+
- @akinon/pz-flow-payment@2.0.45-beta.0
|
|
21
|
+
- @akinon/pz-google-pay@2.0.45-beta.0
|
|
22
|
+
- @akinon/pz-gpay@2.0.45-beta.0
|
|
23
|
+
- @akinon/pz-haso@2.0.45-beta.0
|
|
24
|
+
- @akinon/pz-hepsipay@2.0.45-beta.0
|
|
25
|
+
- @akinon/pz-masterpass@2.0.45-beta.0
|
|
26
|
+
- @akinon/pz-masterpass-rest@2.0.45-beta.0
|
|
27
|
+
- @akinon/pz-multi-basket@2.0.45-beta.0
|
|
28
|
+
- @akinon/pz-one-click-checkout@2.0.45-beta.0
|
|
29
|
+
- @akinon/pz-otp@2.0.45-beta.0
|
|
30
|
+
- @akinon/pz-pay-on-delivery@2.0.45-beta.0
|
|
31
|
+
- @akinon/pz-saved-card@2.0.45-beta.0
|
|
32
|
+
- @akinon/pz-similar-products@2.0.45-beta.0
|
|
33
|
+
- @akinon/pz-tabby-extension@2.0.45-beta.0
|
|
34
|
+
- @akinon/pz-tamara-extension@2.0.45-beta.0
|
|
35
|
+
|
|
36
|
+
## 2.0.44
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- @akinon/next@2.0.44
|
|
41
|
+
- @akinon/pz-akifast@2.0.44
|
|
42
|
+
- @akinon/pz-apple-pay@2.0.44
|
|
43
|
+
- @akinon/pz-b2b@2.0.44
|
|
44
|
+
- @akinon/pz-basket-gift-pack@2.0.44
|
|
45
|
+
- @akinon/pz-bkm@2.0.44
|
|
46
|
+
- @akinon/pz-checkout-gift-pack@2.0.44
|
|
47
|
+
- @akinon/pz-click-collect@2.0.44
|
|
48
|
+
- @akinon/pz-credit-payment@2.0.44
|
|
49
|
+
- @akinon/pz-cybersource-uc@2.0.44
|
|
50
|
+
- @akinon/pz-flow-payment@2.0.44
|
|
51
|
+
- @akinon/pz-google-pay@2.0.44
|
|
52
|
+
- @akinon/pz-gpay@2.0.44
|
|
53
|
+
- @akinon/pz-haso@2.0.44
|
|
54
|
+
- @akinon/pz-hepsipay@2.0.44
|
|
55
|
+
- @akinon/pz-masterpass@2.0.44
|
|
56
|
+
- @akinon/pz-masterpass-rest@2.0.44
|
|
57
|
+
- @akinon/pz-multi-basket@2.0.44
|
|
58
|
+
- @akinon/pz-one-click-checkout@2.0.44
|
|
59
|
+
- @akinon/pz-otp@2.0.44
|
|
60
|
+
- @akinon/pz-pay-on-delivery@2.0.44
|
|
61
|
+
- @akinon/pz-saved-card@2.0.44
|
|
62
|
+
- @akinon/pz-similar-products@2.0.44
|
|
63
|
+
- @akinon/pz-tabby-extension@2.0.44
|
|
64
|
+
- @akinon/pz-tamara-extension@2.0.44
|
|
65
|
+
- @akinon/pz-theme@2.0.44
|
|
66
|
+
- @akinon/pz-virtual-try-on@2.0.44
|
|
67
|
+
|
|
3
68
|
## 2.0.43
|
|
4
69
|
|
|
5
70
|
### Patch Changes
|
|
6
71
|
|
|
7
|
-
- Updated dependencies [
|
|
72
|
+
- Updated dependencies [0e384d73c]
|
|
8
73
|
- @akinon/pz-theme@2.0.43
|
|
9
74
|
- @akinon/next@2.0.43
|
|
10
75
|
- @akinon/pz-akifast@2.0.43
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "projectzeronext",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.45-beta.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -24,33 +24,33 @@
|
|
|
24
24
|
"test:middleware": "jest middleware-matcher.test.ts --bail"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@akinon/next": "2.0.
|
|
28
|
-
"@akinon/pz-akifast": "2.0.
|
|
29
|
-
"@akinon/pz-apple-pay": "2.0.
|
|
30
|
-
"@akinon/pz-b2b": "2.0.
|
|
31
|
-
"@akinon/pz-basket-gift-pack": "2.0.
|
|
32
|
-
"@akinon/pz-bkm": "2.0.
|
|
33
|
-
"@akinon/pz-checkout-gift-pack": "2.0.
|
|
34
|
-
"@akinon/pz-click-collect": "2.0.
|
|
35
|
-
"@akinon/pz-credit-payment": "2.0.
|
|
36
|
-
"@akinon/pz-cybersource-uc": "2.0.
|
|
37
|
-
"@akinon/pz-flow-payment": "2.0.
|
|
38
|
-
"@akinon/pz-google-pay": "2.0.
|
|
39
|
-
"@akinon/pz-gpay": "2.0.
|
|
40
|
-
"@akinon/pz-haso": "2.0.
|
|
41
|
-
"@akinon/pz-hepsipay": "2.0.
|
|
42
|
-
"@akinon/pz-masterpass": "2.0.
|
|
43
|
-
"@akinon/pz-masterpass-rest": "2.0.
|
|
44
|
-
"@akinon/pz-multi-basket": "2.0.
|
|
45
|
-
"@akinon/pz-one-click-checkout": "2.0.
|
|
46
|
-
"@akinon/pz-otp": "2.0.
|
|
47
|
-
"@akinon/pz-pay-on-delivery": "2.0.
|
|
48
|
-
"@akinon/pz-saved-card": "2.0.
|
|
49
|
-
"@akinon/pz-similar-products": "2.0.
|
|
50
|
-
"@akinon/pz-tabby-extension": "2.0.
|
|
51
|
-
"@akinon/pz-tamara-extension": "2.0.
|
|
52
|
-
"@akinon/pz-theme": "2.0.
|
|
53
|
-
"@akinon/pz-virtual-try-on": "2.0.
|
|
27
|
+
"@akinon/next": "2.0.45-beta.0",
|
|
28
|
+
"@akinon/pz-akifast": "2.0.45-beta.0",
|
|
29
|
+
"@akinon/pz-apple-pay": "2.0.45-beta.0",
|
|
30
|
+
"@akinon/pz-b2b": "2.0.45-beta.0",
|
|
31
|
+
"@akinon/pz-basket-gift-pack": "2.0.45-beta.0",
|
|
32
|
+
"@akinon/pz-bkm": "2.0.45-beta.0",
|
|
33
|
+
"@akinon/pz-checkout-gift-pack": "2.0.45-beta.0",
|
|
34
|
+
"@akinon/pz-click-collect": "2.0.45-beta.0",
|
|
35
|
+
"@akinon/pz-credit-payment": "2.0.45-beta.0",
|
|
36
|
+
"@akinon/pz-cybersource-uc": "2.0.45-beta.0",
|
|
37
|
+
"@akinon/pz-flow-payment": "2.0.45-beta.0",
|
|
38
|
+
"@akinon/pz-google-pay": "2.0.45-beta.0",
|
|
39
|
+
"@akinon/pz-gpay": "2.0.45-beta.0",
|
|
40
|
+
"@akinon/pz-haso": "2.0.45-beta.0",
|
|
41
|
+
"@akinon/pz-hepsipay": "2.0.45-beta.0",
|
|
42
|
+
"@akinon/pz-masterpass": "2.0.45-beta.0",
|
|
43
|
+
"@akinon/pz-masterpass-rest": "2.0.45-beta.0",
|
|
44
|
+
"@akinon/pz-multi-basket": "2.0.45-beta.0",
|
|
45
|
+
"@akinon/pz-one-click-checkout": "2.0.45-beta.0",
|
|
46
|
+
"@akinon/pz-otp": "2.0.45-beta.0",
|
|
47
|
+
"@akinon/pz-pay-on-delivery": "2.0.45-beta.0",
|
|
48
|
+
"@akinon/pz-saved-card": "2.0.45-beta.0",
|
|
49
|
+
"@akinon/pz-similar-products": "2.0.45-beta.0",
|
|
50
|
+
"@akinon/pz-tabby-extension": "2.0.45-beta.0",
|
|
51
|
+
"@akinon/pz-tamara-extension": "2.0.45-beta.0",
|
|
52
|
+
"@akinon/pz-theme": "2.0.45-beta.0",
|
|
53
|
+
"@akinon/pz-virtual-try-on": "2.0.45-beta.0",
|
|
54
54
|
"@hookform/resolvers": "2.9.0",
|
|
55
55
|
"@next/third-parties": "16.2.6",
|
|
56
56
|
"@react-google-maps/api": "2.17.1",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"yup": "0.32.11"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@akinon/eslint-plugin-projectzero": "2.0.
|
|
77
|
+
"@akinon/eslint-plugin-projectzero": "2.0.45-beta.0",
|
|
78
78
|
"@semantic-release/changelog": "6.0.2",
|
|
79
79
|
"@semantic-release/exec": "6.0.3",
|
|
80
80
|
"@semantic-release/git": "10.0.1",
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
|
|
3
|
-
import
|
|
3
|
+
import ComposableRegion from '@akinon/pz-theme/src/chrome/composable-region';
|
|
4
4
|
import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
|
|
5
5
|
import { LiveCheckoutPageContext } from '@akinon/pz-theme/src/chrome/live-checkout-page-context';
|
|
6
|
+
import { CheckoutPiecesProvider } from '@akinon/pz-theme/src/chrome/checkout-pieces-provider';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
* Checkout
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Checkout internals are sealed, checkout placement is composable. The body
|
|
10
|
+
* slot's composition positions the real flow, steps and summary through
|
|
11
|
+
* checkout outlet blocks; the flow itself always renders — in an outlet when
|
|
12
|
+
* one claims it, in its default place below otherwise. No slot takes the
|
|
13
|
+
* flow as its fallback: a composition may move the payment steps, never
|
|
14
|
+
* replace them. Ordering is load-bearing: the body slot mounts BEFORE
|
|
15
|
+
* `children`, so outlet targets register before the flow's first paint.
|
|
16
|
+
*
|
|
17
|
+
* The body's takeover is offered on the flow itself, by the region wrapping
|
|
18
|
+
* it: the designer hovers the real checkout content and gets the same
|
|
19
|
+
* affordance every other page has, instead of a dashed band above content
|
|
20
|
+
* that answers a hover with nothing. Starting a composition that way is why
|
|
21
|
+
* the body slot's own band is suppressed — one slug, one CTA.
|
|
12
22
|
*/
|
|
13
23
|
export default function CheckoutLayout({
|
|
14
24
|
children
|
|
@@ -17,12 +27,21 @@ export default function CheckoutLayout({
|
|
|
17
27
|
}) {
|
|
18
28
|
return (
|
|
19
29
|
<LiveCheckoutPageContext>
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
<CheckoutPiecesProvider>
|
|
31
|
+
<ChromeSlot slug={PLACEHOLDER_SLUGS.checkoutTop} />
|
|
32
|
+
<ChromeSlot
|
|
33
|
+
slug={PLACEHOLDER_SLUGS.checkoutBody}
|
|
34
|
+
emptyZoneBand={false}
|
|
35
|
+
/>
|
|
36
|
+
<ComposableRegion
|
|
37
|
+
slug={PLACEHOLDER_SLUGS.checkoutBody}
|
|
38
|
+
label="The checkout flow stays code-owned — take this area over to arrange where the flow, steps and summary render"
|
|
39
|
+
composedNote="The checkout flow renders here until a checkout flow outlet places it — it stays code-owned and inert on the canvas"
|
|
40
|
+
>
|
|
41
|
+
{children}
|
|
42
|
+
</ComposableRegion>
|
|
43
|
+
<ChromeSlot slug={PLACEHOLDER_SLUGS.checkoutBottom} />
|
|
44
|
+
</CheckoutPiecesProvider>
|
|
26
45
|
</LiveCheckoutPageContext>
|
|
27
46
|
);
|
|
28
47
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useEffect, useMemo } from 'react';
|
|
3
|
+
import { useEffect, useMemo, type ReactNode } from 'react';
|
|
4
4
|
import dynamic from 'next/dynamic';
|
|
5
|
+
import { CheckoutPiece } from '@akinon/pz-theme/src/chrome/checkout-piece';
|
|
6
|
+
import { isThemeEditorDesigner } from '@akinon/pz-theme/src/chrome/checkout-pieces';
|
|
5
7
|
import { useAppDispatch } from '@akinon/next/redux/hooks';
|
|
6
8
|
import { resetCheckoutState } from '@akinon/next/redux/reducers/checkout';
|
|
7
9
|
import {
|
|
@@ -66,21 +68,31 @@ const Checkout = () => {
|
|
|
66
68
|
UNIFIED_VARIANTS.has(variantId) ||
|
|
67
69
|
UNIFIED_VARIANTS.has(baselineVariant ?? '');
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
// The designer canvas edits the checkout page itself — an empty test basket
|
|
72
|
+
// must never navigate the iframe to the basket page, or the composition
|
|
73
|
+
// being authored disappears mid-edit. Live keeps the redirect untouched.
|
|
74
|
+
if (
|
|
75
|
+
!isUnifiedCheckout &&
|
|
76
|
+
checkoutData?.redirect_url?.includes('basket') &&
|
|
77
|
+
!isThemeEditorDesigner()
|
|
78
|
+
) {
|
|
70
79
|
router.push(ROUTES.BASKET);
|
|
71
80
|
return null;
|
|
72
81
|
}
|
|
73
82
|
|
|
83
|
+
// One stable CheckoutPiece instance hosts every gate below: the latch runs
|
|
84
|
+
// once, and the loading-to-variant transition is a child swap under the same
|
|
85
|
+
// (possibly portaled) position — no remounts mid-session.
|
|
86
|
+
let body: ReactNode;
|
|
87
|
+
|
|
74
88
|
if (checkoutData?.template_name === 'orders/index.html') {
|
|
75
|
-
|
|
89
|
+
body = (
|
|
76
90
|
<section className="container px-4 my-7 md:mt-20 lg:px-0 lg:mx-auto">
|
|
77
91
|
<CheckoutAuth />
|
|
78
92
|
</section>
|
|
79
93
|
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (isError) {
|
|
83
|
-
return (
|
|
94
|
+
} else if (isError) {
|
|
95
|
+
body = (
|
|
84
96
|
<div className="flex flex-col items-center justify-center h-80">
|
|
85
97
|
<div>{t('checkout.error.title')}</div>
|
|
86
98
|
<div className="mt-5">
|
|
@@ -90,19 +102,20 @@ const Checkout = () => {
|
|
|
90
102
|
</div>
|
|
91
103
|
</div>
|
|
92
104
|
);
|
|
105
|
+
} else if (isResetStateLoading || isCheckoutLoading) {
|
|
106
|
+
body =
|
|
107
|
+
variantId === 'multi-step' ? (
|
|
108
|
+
<div className="flex flex-col items-center justify-center h-80">
|
|
109
|
+
<LoaderSpinner />
|
|
110
|
+
</div>
|
|
111
|
+
) : (
|
|
112
|
+
<CheckoutOnePageSkeleton />
|
|
113
|
+
);
|
|
114
|
+
} else {
|
|
115
|
+
body = <CheckoutVariant options={variantOptions} />;
|
|
93
116
|
}
|
|
94
117
|
|
|
95
|
-
|
|
96
|
-
return variantId === 'multi-step' ? (
|
|
97
|
-
<div className="flex flex-col items-center justify-center h-80">
|
|
98
|
-
<LoaderSpinner />
|
|
99
|
-
</div>
|
|
100
|
-
) : (
|
|
101
|
-
<CheckoutOnePageSkeleton />
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return <CheckoutVariant options={variantOptions} />;
|
|
118
|
+
return <CheckoutPiece piece="flow">{body}</CheckoutPiece>;
|
|
106
119
|
};
|
|
107
120
|
|
|
108
121
|
export default Checkout;
|
|
@@ -3,10 +3,29 @@ import { CheckboxProps } from '@theme/components/types';
|
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
|
|
5
5
|
const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
|
|
6
|
-
|
|
6
|
+
// Part styling names the ROW, not the native box: when a caller stamps a
|
|
7
|
+
// checkbox (see `partAttrs`), the attributes ride the label wrapper so the
|
|
8
|
+
// whole line — box, text, links, spacing — is restylable, and the input
|
|
9
|
+
// keeps every other prop it has today. No caller that omits them is
|
|
10
|
+
// affected: both values are simply undefined and React drops them.
|
|
11
|
+
const {
|
|
12
|
+
children,
|
|
13
|
+
checked = false,
|
|
14
|
+
error,
|
|
15
|
+
'data-part': partName,
|
|
16
|
+
'data-state': partState,
|
|
17
|
+
...rest
|
|
18
|
+
} = props as CheckboxProps & {
|
|
19
|
+
'data-part'?: string;
|
|
20
|
+
'data-state'?: string;
|
|
21
|
+
};
|
|
7
22
|
|
|
8
23
|
return (
|
|
9
|
-
<label
|
|
24
|
+
<label
|
|
25
|
+
className={twMerge('flex flex-col text-xs', props.className)}
|
|
26
|
+
data-part={partName}
|
|
27
|
+
data-state={partState}
|
|
28
|
+
>
|
|
10
29
|
<div className="flex items-center">
|
|
11
30
|
<input
|
|
12
31
|
data-testid="checkbox"
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Part styling only works by INHERITANCE, and inheritance loses to any
|
|
6
|
+
* declaration on the element itself.
|
|
7
|
+
*
|
|
8
|
+
* A checkout part rule lands on the element the part is stamped on:
|
|
9
|
+
*
|
|
10
|
+
* [data-block-id="…"] [data-part="payment-option"] { color: #fff !important }
|
|
11
|
+
*
|
|
12
|
+
* If the text inside that element sits in a child that declares its own
|
|
13
|
+
* `text-…` colour, size or weight, the inherited value never reaches it —
|
|
14
|
+
* `!important` does not help, because the child is not competing for the same
|
|
15
|
+
* declaration, it simply has one of its own. Every typography control the
|
|
16
|
+
* panel offers for that part is then a silent no-op: the designer sets Text
|
|
17
|
+
* Color to white, nothing moves, and there is no error to explain it.
|
|
18
|
+
*
|
|
19
|
+
* That is exactly how a starter template painted a near-black selected
|
|
20
|
+
* payment card behind a near-black method name (contrast ≈ 1:1), and how
|
|
21
|
+
* "Font Weight" on the grand total row did nothing.
|
|
22
|
+
*
|
|
23
|
+
* The rule this file locks: on these elements the typography lives on the
|
|
24
|
+
* STAMPED element, and a child either carries none of its own or is a part in
|
|
25
|
+
* its own right. Where two children genuinely differ (a totals row's label and
|
|
26
|
+
* its amount), each gets its own part instead of the row pretending to control
|
|
27
|
+
* both.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const checkoutDir = path.resolve(__dirname, '..');
|
|
31
|
+
|
|
32
|
+
const read = (relative: string): string =>
|
|
33
|
+
fs.readFileSync(path.join(checkoutDir, relative), 'utf8');
|
|
34
|
+
|
|
35
|
+
/** Utilities that would out-declare an inherited part rule. */
|
|
36
|
+
const TYPOGRAPHY_UTILITY =
|
|
37
|
+
/\btext-(?:xs|sm|base|lg|xl|\d?xl|black-\d+|gray-\d+|primary-\d+|secondary)\b|\bfont-(?:light|normal|medium|semibold|bold)\b/;
|
|
38
|
+
|
|
39
|
+
describe('one-page payment cards keep their typography on the stamped button', () => {
|
|
40
|
+
const source = read('variants/one-page/payment-options-grid.tsx');
|
|
41
|
+
|
|
42
|
+
it('declares the text styles on the button that carries the part', () => {
|
|
43
|
+
const button = source.slice(
|
|
44
|
+
source.indexOf('<button'),
|
|
45
|
+
source.indexOf('<Icon')
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect(button).toContain("partAttrs('payment-option'");
|
|
49
|
+
expect(button).toMatch(/text-sm font-medium leading-tight/);
|
|
50
|
+
expect(button).toMatch(/text-black-800/);
|
|
51
|
+
expect(button).toMatch(/text-gray-700/);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('leaves the method name span with layout classes only', () => {
|
|
55
|
+
expect(source).toContain('<span className="flex-1">{option.name}</span>');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('never re-colours the icon with fill utilities', () => {
|
|
59
|
+
// `Icon` renders an icon FONT, so `fill-*` coloured nothing at all; the
|
|
60
|
+
// glyph follows `color`, which now comes from the button.
|
|
61
|
+
expect(source).not.toMatch(/\bfill-(?:black|gray)-\d+\b/);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('multi-step payment options keep their typography on the stamped element', () => {
|
|
66
|
+
const source = read('steps/payment/payment-option-buttons.tsx');
|
|
67
|
+
|
|
68
|
+
it('puts the mobile row styles on the label that carries the part', () => {
|
|
69
|
+
const label = source.slice(
|
|
70
|
+
source.indexOf('<label'),
|
|
71
|
+
source.indexOf('</label>')
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
expect(label).toContain("partAttrs('payment-option'");
|
|
75
|
+
expect(label).toMatch(/text-primary-800 font-light text-lg/);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('leaves the method name span with layout classes only', () => {
|
|
79
|
+
expect(source).toContain('<span className="flex">{option.name}</span>');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('summary rows expose their label and amount as parts', () => {
|
|
84
|
+
it.each([
|
|
85
|
+
['variants/one-page/one-page-summary.tsx'],
|
|
86
|
+
['summary.tsx']
|
|
87
|
+
])('%s stamps both cells of every totals row and the grand total', file => {
|
|
88
|
+
const source = read(file);
|
|
89
|
+
|
|
90
|
+
for (const part of [
|
|
91
|
+
'summary-row-label',
|
|
92
|
+
'summary-row-value',
|
|
93
|
+
'summary-total-label',
|
|
94
|
+
'summary-total-value'
|
|
95
|
+
]) {
|
|
96
|
+
expect(source).toContain(`partAttrs('${part}')`);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('gives the one-page grand total row a baseline its label can inherit', () => {
|
|
101
|
+
const source = read('variants/one-page/one-page-summary.tsx');
|
|
102
|
+
const total = source.slice(
|
|
103
|
+
source.indexOf("partAttrs('summary-total')") - 400,
|
|
104
|
+
source.indexOf("partAttrs('summary-total-value')")
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// The row owns the label's treatment; the label span declares nothing.
|
|
108
|
+
expect(total).toMatch(/text-sm font-medium uppercase/);
|
|
109
|
+
expect(total).toContain(
|
|
110
|
+
"<span {...partAttrs('summary-total-label')}>"
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('keeps a stamped cell free to declare its own look', () => {
|
|
115
|
+
// The amount is allowed to differ — it answers to summary-*-value.
|
|
116
|
+
const source = read('variants/one-page/one-page-summary.tsx');
|
|
117
|
+
|
|
118
|
+
expect(source).toMatch(TYPOGRAPHY_UTILITY);
|
|
119
|
+
expect(source).toContain("partAttrs('summary-total-value')");
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useAppDispatch } from '@akinon/next/redux/hooks';
|
|
3
3
|
import { setCurrentStep } from '@akinon/next/redux/reducers/checkout';
|
|
4
|
+
import { partAttrs } from '@akinon/pz-theme/src/utils/part-styles';
|
|
4
5
|
import { Icon } from '@theme/components';
|
|
5
6
|
import clsx from 'clsx';
|
|
6
7
|
import { CheckoutStep } from '@akinon/next/types';
|
|
@@ -40,6 +41,7 @@ export const CheckoutStepButton = ({
|
|
|
40
41
|
{ 'mr-6': completed }
|
|
41
42
|
)}
|
|
42
43
|
onClick={handleClick}
|
|
44
|
+
{...partAttrs('step', { selected, completed, disabled })}
|
|
43
45
|
>
|
|
44
46
|
<span
|
|
45
47
|
className={clsx(
|
|
@@ -50,10 +52,18 @@ export const CheckoutStepButton = ({
|
|
|
50
52
|
{ 'text-black': selected }
|
|
51
53
|
)}
|
|
52
54
|
>
|
|
53
|
-
<span
|
|
55
|
+
<span
|
|
56
|
+
className="order-1 flex-1 md:mr-1 md:order-none md:flex-none"
|
|
57
|
+
{...partAttrs('step-number', { selected, completed })}
|
|
58
|
+
>
|
|
54
59
|
{number} {number && `.`}
|
|
55
60
|
</span>
|
|
56
|
-
<span
|
|
61
|
+
<span
|
|
62
|
+
className="order-3 uppercase md:order-none"
|
|
63
|
+
{...partAttrs('step-label', { selected, completed })}
|
|
64
|
+
>
|
|
65
|
+
{label}
|
|
66
|
+
</span>
|
|
57
67
|
<Icon
|
|
58
68
|
name="check"
|
|
59
69
|
size={12}
|
|
@@ -62,6 +72,7 @@ export const CheckoutStepButton = ({
|
|
|
62
72
|
{ 'opacity-0 scale-x-0': !completed },
|
|
63
73
|
{ 'opacity-100 scale-x-100': completed }
|
|
64
74
|
)}
|
|
75
|
+
{...partAttrs('step-icon')}
|
|
65
76
|
/>
|
|
66
77
|
</span>
|
|
67
78
|
</button>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useAppSelector } from '@akinon/next/redux/hooks';
|
|
2
|
+
import { partAttrs } from '@akinon/pz-theme/src/utils/part-styles';
|
|
2
3
|
import { RootState } from '@theme/redux/store';
|
|
3
4
|
import { Icon } from '@theme/components';
|
|
4
5
|
import { CheckoutStepButton } from './step-button';
|
|
@@ -19,7 +20,10 @@ export const CheckoutStepList = () => {
|
|
|
19
20
|
);
|
|
20
21
|
|
|
21
22
|
return (
|
|
22
|
-
<div
|
|
23
|
+
<div
|
|
24
|
+
className="w-full flex items-center justify-center py-5 md:pl-1 md:justify-start md:py-8 lg:py-11"
|
|
25
|
+
{...partAttrs('steps')}
|
|
26
|
+
>
|
|
23
27
|
<CheckoutStepButton
|
|
24
28
|
number="1"
|
|
25
29
|
label={t('checkout.step.shipping')}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import useContract from '../../../../hooks/use-contract';
|
|
2
2
|
import { Controller } from 'react-hook-form';
|
|
3
3
|
import { Checkbox } from '@theme/components';
|
|
4
|
+
import { partAttrs } from '@akinon/pz-theme/src/utils/part-styles';
|
|
4
5
|
import { useLocalization } from '@akinon/next/hooks';
|
|
5
6
|
import { Trans } from '@akinon/next/components/trans';
|
|
6
7
|
|
|
@@ -22,7 +23,14 @@ const CheckoutAgreements = ({ control, fieldId, error }) => {
|
|
|
22
23
|
control={control}
|
|
23
24
|
defaultValue={false}
|
|
24
25
|
render={({ field }) => (
|
|
25
|
-
|
|
26
|
+
// The stamp addresses the agreement ROW (Checkbox routes it to its
|
|
27
|
+
// label wrapper): LOOK only — the consent itself is untouchable.
|
|
28
|
+
<Checkbox
|
|
29
|
+
{...field}
|
|
30
|
+
error={error}
|
|
31
|
+
data-testid="checkout-agreement"
|
|
32
|
+
{...partAttrs('agreement')}
|
|
33
|
+
>
|
|
26
34
|
<Trans
|
|
27
35
|
i18nKey="checkout.agreement.content"
|
|
28
36
|
components={{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import SelectedPaymentOptionView from '@akinon/next/components/selected-payment-option-view';
|
|
2
2
|
import { useAppSelector } from '@akinon/next/redux/hooks';
|
|
3
3
|
import { CheckoutPaymentOption } from '@akinon/next/types';
|
|
4
|
+
import { partAttrs } from '@akinon/pz-theme/src/utils/part-styles';
|
|
4
5
|
import clsx from 'clsx';
|
|
5
6
|
import { RootState } from '@theme/redux/store';
|
|
6
7
|
import PaymentOptionButtons from './payment-option-buttons';
|
|
@@ -17,11 +18,18 @@ const PaymentStep = () => {
|
|
|
17
18
|
className={clsx('flex flex-wrap w-full', {
|
|
18
19
|
'pointer-events-none opacity-30': isPaymentStepBusy
|
|
19
20
|
})}
|
|
21
|
+
{...partAttrs('section')}
|
|
20
22
|
>
|
|
21
|
-
<div
|
|
23
|
+
<div
|
|
24
|
+
className="w-full mt-4 flex justify-start border border-gray-400 -mb-px z-10 md:mt-0 md:border-r-0 md:border-b-0 md:w-auto order-2 md:order-none overflow-x-auto"
|
|
25
|
+
{...partAttrs('payment-options')}
|
|
26
|
+
>
|
|
22
27
|
<PaymentOptionButtons />
|
|
23
28
|
</div>
|
|
24
|
-
<div
|
|
29
|
+
<div
|
|
30
|
+
className="w-full border border-solid border-gray-400 bg-white"
|
|
31
|
+
{...partAttrs('payment-panel')}
|
|
32
|
+
>
|
|
25
33
|
<SelectedPaymentOptionView />
|
|
26
34
|
</div>
|
|
27
35
|
</div>
|
|
@@ -18,6 +18,7 @@ import { useLocalization } from '@akinon/next/hooks';
|
|
|
18
18
|
import { Image } from '@akinon/next/components/image';
|
|
19
19
|
import { getPosError, checkPaymentWillRedirect } from '@akinon/next/utils';
|
|
20
20
|
import PluginModule, { Component } from '@akinon/next/components/plugin-module';
|
|
21
|
+
import { partAttrs } from '@akinon/pz-theme/src/utils/part-styles';
|
|
21
22
|
import { PaymentOption } from '@akinon/next/types';
|
|
22
23
|
|
|
23
24
|
const creditCardFormSchema = (
|
|
@@ -409,6 +410,7 @@ const CheckoutCreditCard = () => {
|
|
|
409
410
|
type="submit"
|
|
410
411
|
disabled={isButtonDisabled}
|
|
411
412
|
data-testid="checkout-credit-card-place-order"
|
|
413
|
+
{...partAttrs('place-order-button')}
|
|
412
414
|
>
|
|
413
415
|
<span>{t('checkout.payment.credit_card.form.button')}</span>
|
|
414
416
|
<Icon
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
useSetFundsTransferOptionMutation
|
|
9
9
|
} from '@akinon/next/data/client/checkout';
|
|
10
10
|
import { Button, Icon, Price, Radio } from '@theme/components';
|
|
11
|
+
import { partAttrs } from '@akinon/pz-theme/src/utils/part-styles';
|
|
11
12
|
import * as yup from 'yup';
|
|
12
13
|
import CheckoutAgreements from '../agreements';
|
|
13
14
|
import PaymentHeader from '../payment-header';
|
|
@@ -176,6 +177,7 @@ const CheckoutFundsTransfer = () => {
|
|
|
176
177
|
type="submit"
|
|
177
178
|
disabled={isButtonDisabled}
|
|
178
179
|
data-testid="checkout-bank-account-place-order"
|
|
180
|
+
{...partAttrs('place-order-button')}
|
|
179
181
|
>
|
|
180
182
|
<span> {t('checkout.payment.fund_transfer.button')}</span>
|
|
181
183
|
<Icon
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { partAttrs } from '@akinon/pz-theme/src/utils/part-styles';
|
|
2
3
|
|
|
3
4
|
export type PaymentHeaderProps = {
|
|
4
5
|
title: string;
|
|
@@ -7,7 +8,10 @@ export type PaymentHeaderProps = {
|
|
|
7
8
|
const PaymentHeader = ({ title }: PaymentHeaderProps) => {
|
|
8
9
|
return (
|
|
9
10
|
<div className="flex justify-start items-center border-solid border-gray-400 px-4 py-2 sm:px-6 sm:py-3 sm:min-h-15">
|
|
10
|
-
<span
|
|
11
|
+
<span
|
|
12
|
+
className="text-black-800 text-lg font-medium sm:text-2xl"
|
|
13
|
+
{...partAttrs('section-title')}
|
|
14
|
+
>
|
|
11
15
|
{title}
|
|
12
16
|
</span>
|
|
13
17
|
</div>
|