@stapel/listings-react 0.15.1 → 0.17.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 +66 -0
- package/dist/default/GateReasonPopover.d.ts +24 -0
- package/dist/default/GateReasonPopover.d.ts.map +1 -0
- package/dist/default/GateReasonPopover.js +45 -0
- package/dist/default/GateReasonPopover.js.map +1 -0
- package/dist/default/ListingCard.d.ts +26 -5
- package/dist/default/ListingCard.d.ts.map +1 -1
- package/dist/default/ListingCard.js +14 -5
- package/dist/default/ListingCard.js.map +1 -1
- package/dist/default/ListingComposerPage.d.ts.map +1 -1
- package/dist/default/ListingComposerPage.js +7 -1
- package/dist/default/ListingComposerPage.js.map +1 -1
- package/dist/default/ListingDetailPane.d.ts +60 -1
- package/dist/default/ListingDetailPane.d.ts.map +1 -1
- package/dist/default/ListingDetailPane.js +135 -38
- package/dist/default/ListingDetailPane.js.map +1 -1
- package/dist/default/index.d.ts +1 -1
- package/dist/default/index.d.ts.map +1 -1
- package/dist/default/index.js +4 -1
- package/dist/default/index.js.map +1 -1
- package/dist/headless/ListingDetail.d.ts +11 -0
- package/dist/headless/ListingDetail.d.ts.map +1 -1
- package/dist/headless/ListingDetail.js +7 -0
- package/dist/headless/ListingDetail.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +4 -1
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/keys.d.ts +11 -0
- package/dist/i18n/keys.d.ts.map +1 -1
- package/dist/i18n/keys.js +15 -1
- package/dist/i18n/keys.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +4 -1
- package/dist/i18n/ru.js.map +1 -1
- package/llms.txt +1 -1
- package/manifest.json +4 -1
- package/nav-manifest.json +1 -1
- package/package.json +8 -8
- package/src/analytics/generated/events.json +1 -1
- package/src/default/GateReasonPopover.tsx +95 -0
- package/src/default/ListingCard.tsx +100 -43
- package/src/default/ListingComposerPage.tsx +12 -2
- package/src/default/ListingDetailPane.tsx +362 -114
- package/src/default/index.ts +9 -1
- package/src/headless/ListingDetail.tsx +19 -0
- package/src/i18n/es.ts +5 -1
- package/src/i18n/keys.ts +16 -1
- package/src/i18n/ru.ts +5 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `<ListingDetailPane>` — the listing page, and the page a marketplace makes
|
|
3
3
|
* its money on.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Five distinct absences, five distinct sentences, and the whole point of the
|
|
6
6
|
* component is that none of them collapses into another:
|
|
7
7
|
*
|
|
8
8
|
* loading — we are asking
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* not found — no listing ever had this id
|
|
11
11
|
* removed — one did, and it is gone (the AllowAny status probe
|
|
12
12
|
* is the only read that can still say so)
|
|
13
|
+
* withdrawn — one did, and its owner took it off the shelf: the
|
|
14
|
+
* detail 404s while the probe still answers "not
|
|
15
|
+
* deleted". NO retry — nothing a retry could change.
|
|
13
16
|
*
|
|
14
17
|
* On top of that, a listing that IS returned may still not be on sale: the
|
|
15
18
|
* detail endpoint has no `published()` filter, so a draft answers 200 to
|
|
@@ -32,6 +35,20 @@
|
|
|
32
35
|
* L2 pairs do not import each other. Unfilled it renders `<SlotPlaceholder>`,
|
|
33
36
|
* so an app wired without a chat is a named gap in a dev build rather than a
|
|
34
37
|
* page whose only verb is "save".
|
|
38
|
+
*
|
|
39
|
+
* ── The page has a DESKTOP, when the host says so ──────────────────────────
|
|
40
|
+
*
|
|
41
|
+
* Measured on a live classified deployment at 1440×900: the whole listing
|
|
42
|
+
* page was a ~930px single column hugging the start edge, the price a 22px
|
|
43
|
+
* line UNDER the title and smaller than it, and the right half of the screen
|
|
44
|
+
* empty — while the reference design for this page is two columns: gallery +
|
|
45
|
+
* description + specs on the left, a sticky buy column on the right with the
|
|
46
|
+
* price LARGE at its top, then the actions, then the seller block.
|
|
47
|
+
*
|
|
48
|
+
* `layout="split"` is that design. The HOST states the axis — the same rule
|
|
49
|
+
* as CategoryPage's `subcategories`: a decision taken once by the component
|
|
50
|
+
* that knows the viewport it granted, never a media query guessed in a leaf —
|
|
51
|
+
* and the default `"column"` renders exactly what existing hosts already get.
|
|
35
52
|
*/
|
|
36
53
|
import type { ReactElement, ReactNode } from "react";
|
|
37
54
|
import { Button, Descriptions, Divider, Flex, Typography } from "antd";
|
|
@@ -45,6 +62,7 @@ import {
|
|
|
45
62
|
import {
|
|
46
63
|
SlotPlaceholder,
|
|
47
64
|
matchLoad,
|
|
65
|
+
useActionGate,
|
|
48
66
|
useI18n,
|
|
49
67
|
useT,
|
|
50
68
|
} from "@stapel/core";
|
|
@@ -56,6 +74,7 @@ import { useListingDetail } from "../headless/ListingDetail.js";
|
|
|
56
74
|
import { useListingActions } from "../headless/ListingActions.js";
|
|
57
75
|
import { asFeatureDaoList, featureValuesForDisplay } from "../model/features.js";
|
|
58
76
|
import { LISTINGS_I18N_KEYS } from "../i18n/keys.js";
|
|
77
|
+
import { GateReasonPopover } from "./GateReasonPopover.js";
|
|
59
78
|
import { SignInLink } from "./SignInLink.js";
|
|
60
79
|
import { HeartIcon } from "./icons.js";
|
|
61
80
|
import { ListingPhoto } from "./ListingPhoto.js";
|
|
@@ -68,6 +87,24 @@ import type { CategoryFeaturesProp, ThemeModeProp } from "./types.js";
|
|
|
68
87
|
* a 2560px pane. */
|
|
69
88
|
export const DETAIL_MEASURE = "60rem";
|
|
70
89
|
|
|
90
|
+
/**
|
|
91
|
+
* The split layout's measure. {@link DETAIL_MEASURE} is a ONE-COLUMN reading
|
|
92
|
+
* measure; in the split the same prose shares the row with a fixed buy
|
|
93
|
+
* column and a gap, so the pane must be wider for the reading half to keep
|
|
94
|
+
* its line — 75rem puts the left column back at roughly the width the
|
|
95
|
+
* one-column page reads at, with the buy column beside it instead of the
|
|
96
|
+
* empty half-screen the 1440×900 walk measured.
|
|
97
|
+
*/
|
|
98
|
+
export const DETAIL_SPLIT_MEASURE = "75rem";
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The buy column's fixed track. A width, not a fraction: a price, a row of
|
|
102
|
+
* buttons and a seller block do not improve with width, and every pixel they
|
|
103
|
+
* took would come out of the reading column — so the reading column is the
|
|
104
|
+
* `1fr` and this is not.
|
|
105
|
+
*/
|
|
106
|
+
export const DETAIL_SPLIT_ASIDE = "380px";
|
|
107
|
+
|
|
71
108
|
/** The narrowest a gallery tile may get before the grid drops a column. A
|
|
72
109
|
* measure rather than a pixel: the tiles then fill whatever the ELEMENT is,
|
|
73
110
|
* which is §83's geometry rule — one photo per row on a phone, three on a
|
|
@@ -83,6 +120,24 @@ export interface ListingDetailPaneProps
|
|
|
83
120
|
* the only place the moderation axis is shown, because it is the only
|
|
84
121
|
* person it concerns. */
|
|
85
122
|
readonly viewerId?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Which desktop the page renders: the single reading column it has always
|
|
125
|
+
* been (default `"column"`, byte-compatible for existing hosts), or the
|
|
126
|
+
* reference design's two-column split — see this file's header for the
|
|
127
|
+
* measurement that earned it. The host states the axis; the pane never
|
|
128
|
+
* reads the viewport.
|
|
129
|
+
*/
|
|
130
|
+
readonly layout?: "column" | "split";
|
|
131
|
+
/**
|
|
132
|
+
* The host's seller block (a profile card, ratings, "member since" — a
|
|
133
|
+
* different pair's data, so it arrives as a node). In `"split"` it renders
|
|
134
|
+
* inside the sticky buy column, under the actions, where the reference
|
|
135
|
+
* design keeps it. In `"column"` there is no buy column to live in, so it
|
|
136
|
+
* joins the end of the reading flow directly ABOVE `footer` — the flow
|
|
137
|
+
* position the footer already holds, so a host passing both gets seller
|
|
138
|
+
* block then footer, in that order.
|
|
139
|
+
*/
|
|
140
|
+
readonly aside?: ReactNode;
|
|
86
141
|
/**
|
|
87
142
|
* THE primary action for a buyer: "message the seller", filled by the
|
|
88
143
|
* container from `@stapel/chat-react`. Rendered first, before favouriting,
|
|
@@ -105,6 +160,14 @@ export interface ListingDetailPaneProps
|
|
|
105
160
|
* cards. Absent: the reason stands alone, as before.
|
|
106
161
|
*/
|
|
107
162
|
readonly signIn?: SignInCta;
|
|
163
|
+
/**
|
|
164
|
+
* How the favourite's blocked reason speaks: `"text"` (default) keeps the
|
|
165
|
+
* standing sentence + door beside the heart; `"popover"` moves both into a
|
|
166
|
+
* disclosure on the heart itself — the cards' third arm, same argument and
|
|
167
|
+
* same accessibility floor (see `ListingCardBlockedReason`), for a host
|
|
168
|
+
* whose chrome already carries a standing sign-in door.
|
|
169
|
+
*/
|
|
170
|
+
readonly blockedReason?: "text" | "popover";
|
|
108
171
|
readonly footer?: ReactNode;
|
|
109
172
|
}
|
|
110
173
|
|
|
@@ -120,6 +183,10 @@ export function ListingDetailPane(props: ListingDetailPaneProps): ReactElement {
|
|
|
120
183
|
const owner = bag.viewerIsOwner === true;
|
|
121
184
|
const actions = useListingActions(props.id, bag.status?.lifecycle.status);
|
|
122
185
|
const editGate = actions.editGate(props.onEdit !== undefined);
|
|
186
|
+
// The gate VIEW (localized reason), for the popover arm — the "text" arm
|
|
187
|
+
// leaves rendering the reason to `<GatedControl>`, which computes its own.
|
|
188
|
+
const favoriteView = useActionGate(bag.favoriteGate);
|
|
189
|
+
const split = props.layout === "split";
|
|
123
190
|
|
|
124
191
|
const favoriteLabel = t(
|
|
125
192
|
bag.isFavorited === true
|
|
@@ -130,7 +197,10 @@ export function ListingDetailPane(props: ListingDetailPaneProps): ReactElement {
|
|
|
130
197
|
return (
|
|
131
198
|
<SkinTheme
|
|
132
199
|
surface="base"
|
|
133
|
-
style={{
|
|
200
|
+
style={{
|
|
201
|
+
maxWidth: split ? DETAIL_SPLIT_MEASURE : DETAIL_MEASURE,
|
|
202
|
+
padding: spacing[4],
|
|
203
|
+
}}
|
|
134
204
|
{...(props.mode !== undefined ? { mode: props.mode } : {})}
|
|
135
205
|
>
|
|
136
206
|
<Flex vertical gap={spacing[4]} data-testid="listings-detail">
|
|
@@ -151,12 +221,22 @@ export function ListingDetailPane(props: ListingDetailPaneProps): ReactElement {
|
|
|
151
221
|
data-stapel-load-state="loading"
|
|
152
222
|
/>
|
|
153
223
|
),
|
|
224
|
+
// The failed arm, most specific sentence first: removed (the banner
|
|
225
|
+
// above already says it) → not found → withdrawn → the generic
|
|
226
|
+
// retry. `withdrawn` carries no retry control on purpose — the row
|
|
227
|
+
// is gone by its owner's choice, and a retry that can never help is
|
|
228
|
+
// what this arm replaces.
|
|
154
229
|
failed: (error) =>
|
|
155
230
|
bag.removed ? null : bag.notFound ? (
|
|
156
231
|
<EmptyState
|
|
157
232
|
testId="listings-detail-error"
|
|
158
233
|
title={t(LISTINGS_I18N_KEYS.detailNotFound)}
|
|
159
234
|
/>
|
|
235
|
+
) : bag.withdrawn ? (
|
|
236
|
+
<EmptyState
|
|
237
|
+
testId="listings-detail-withdrawn"
|
|
238
|
+
title={t(LISTINGS_I18N_KEYS.detailWithdrawn)}
|
|
239
|
+
/>
|
|
160
240
|
) : (
|
|
161
241
|
<ErrorAlert
|
|
162
242
|
testId="listings-detail-error"
|
|
@@ -166,33 +246,39 @@ export function ListingDetailPane(props: ListingDetailPaneProps): ReactElement {
|
|
|
166
246
|
retryLabel={t(LISTINGS_I18N_KEYS.detailRetry)}
|
|
167
247
|
/>
|
|
168
248
|
),
|
|
169
|
-
ready: (listing) =>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
249
|
+
ready: (listing) => {
|
|
250
|
+
/* The moderation axis is the OWNER's business and nobody
|
|
251
|
+
else's: a buyer has no use for "changes under review", and
|
|
252
|
+
showing a stranger that a listing was refused would leak a
|
|
253
|
+
verdict about someone else's content. Rendered above the
|
|
254
|
+
split, full width — a verdict is about the PAGE, not about
|
|
255
|
+
either of its columns. */
|
|
256
|
+
const statusBlocks = (
|
|
257
|
+
<>
|
|
258
|
+
{owner && bag.status !== undefined ? (
|
|
259
|
+
<Flex vertical gap={spacing[2]} data-testid="listings-detail-owner-view">
|
|
260
|
+
<ListingStatusBlock status={bag.status} />
|
|
261
|
+
{!bag.publiclyVisible ? (
|
|
262
|
+
<Typography.Text type="secondary">
|
|
263
|
+
{t(LISTINGS_I18N_KEYS.detailOwnerOnlyView)}
|
|
264
|
+
</Typography.Text>
|
|
265
|
+
) : null}
|
|
266
|
+
</Flex>
|
|
267
|
+
) : null}
|
|
185
268
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
269
|
+
{!owner && !bag.publiclyVisible ? (
|
|
270
|
+
<ErrorAlert
|
|
271
|
+
testId="listings-detail-not-published"
|
|
272
|
+
message={t(LISTINGS_I18N_KEYS.detailNotPublished)}
|
|
273
|
+
variant="inline"
|
|
274
|
+
/>
|
|
275
|
+
) : null}
|
|
276
|
+
</>
|
|
277
|
+
);
|
|
193
278
|
|
|
194
|
-
|
|
195
|
-
|
|
279
|
+
/* Element-width tiles: the grid decides how many fit, the
|
|
280
|
+
photos fill them. */
|
|
281
|
+
const gallery = (
|
|
196
282
|
<div
|
|
197
283
|
data-testid="listings-detail-gallery"
|
|
198
284
|
style={{
|
|
@@ -219,33 +305,47 @@ export function ListingDetailPane(props: ListingDetailPaneProps): ReactElement {
|
|
|
219
305
|
))
|
|
220
306
|
)}
|
|
221
307
|
</div>
|
|
308
|
+
);
|
|
222
309
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
310
|
+
const heading = (
|
|
311
|
+
<>
|
|
312
|
+
<Typography.Title level={3} data-testid="listings-detail-title">
|
|
313
|
+
{listing.title ?? ""}
|
|
314
|
+
</Typography.Title>
|
|
226
315
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
316
|
+
{/* The `show_at_title` projection, formatted from the stored
|
|
317
|
+
DAOs — no category read needed (see model/features.ts). */}
|
|
318
|
+
{bag.titleFeatures.length > 0 ? (
|
|
319
|
+
<Typography.Text type="secondary" data-testid="listings-detail-title-features">
|
|
320
|
+
{bag.titleFeatures
|
|
321
|
+
// A hidden value is never part of a title: the server
|
|
322
|
+
// keeps one out of `features_title` entirely, and
|
|
323
|
+
// `formatFeatureValue` refuses a stub besides (it carries
|
|
324
|
+
// no value, so there is nothing to format). The filter is
|
|
325
|
+
// the third belt, and it is here rather than at the
|
|
326
|
+
// formatter's edge because THIS is the line where a
|
|
327
|
+
// leaked identifier would be read out loud.
|
|
328
|
+
.filter((view) => !isRedactedValue(view.value))
|
|
329
|
+
.map((view) =>
|
|
330
|
+
formatFeatureValue(view.feature, view.value, { t, locale })
|
|
331
|
+
)
|
|
332
|
+
.filter((text): text is string => text !== undefined)
|
|
333
|
+
.join(" · ")}
|
|
334
|
+
</Typography.Text>
|
|
335
|
+
) : null}
|
|
336
|
+
</>
|
|
337
|
+
);
|
|
247
338
|
|
|
248
|
-
|
|
339
|
+
/* In the split the price leads the buy column at level 2 — the
|
|
340
|
+
measured page had it at 22px UNDER the title, smaller than the
|
|
341
|
+
thing it prices, which is backwards on the one line a buyer
|
|
342
|
+
came to read. In the column it stays the level-4 line it has
|
|
343
|
+
always been. */
|
|
344
|
+
const price = (
|
|
345
|
+
<Typography.Title
|
|
346
|
+
level={split ? 2 : 4}
|
|
347
|
+
data-testid="listings-detail-price"
|
|
348
|
+
>
|
|
249
349
|
<ListingPrice
|
|
250
350
|
amount={listing.price}
|
|
251
351
|
{...(listing.currency !== undefined
|
|
@@ -253,9 +353,11 @@ export function ListingDetailPane(props: ListingDetailPaneProps): ReactElement {
|
|
|
253
353
|
: {})}
|
|
254
354
|
/>
|
|
255
355
|
</Typography.Title>
|
|
356
|
+
);
|
|
256
357
|
|
|
257
|
-
|
|
258
|
-
|
|
358
|
+
/* The buy box. One primary, and which one depends on who is
|
|
359
|
+
reading this page. */
|
|
360
|
+
const buyBox = (
|
|
259
361
|
<Flex
|
|
260
362
|
wrap
|
|
261
363
|
gap={spacing[3]}
|
|
@@ -295,19 +397,23 @@ export function ListingDetailPane(props: ListingDetailPaneProps): ReactElement {
|
|
|
295
397
|
|
|
296
398
|
{/* Favouriting your own listing is not a thing anyone does;
|
|
297
399
|
for everyone else it is the secondary it always was. */}
|
|
298
|
-
{owner ? null :
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
400
|
+
{owner ? null : props.blockedReason === "popover" &&
|
|
401
|
+
favoriteView.reason !== undefined ? (
|
|
402
|
+
/* The cards' third volume, verbatim: nothing standing, the
|
|
403
|
+
reason and the door disclosed on the heart. `aria-disabled`
|
|
404
|
+
rather than `disabled`, so the disclosure's hover, focus
|
|
405
|
+
and tap all arrive — and the click is a safe no-op, because
|
|
406
|
+
`toggleFavorite` refuses while the gate is blocked. */
|
|
407
|
+
<GateReasonPopover
|
|
408
|
+
reason={favoriteView.reason}
|
|
409
|
+
cta={props.signIn}
|
|
410
|
+
testId="listings-detail-favorite-reason"
|
|
411
|
+
signInTestId="listings-detail-sign-in"
|
|
303
412
|
>
|
|
304
413
|
{(bind) => (
|
|
305
414
|
<Button
|
|
306
|
-
disabled
|
|
307
|
-
|
|
308
|
-
{...(bind["aria-describedby"] !== undefined
|
|
309
|
-
? { "aria-describedby": bind["aria-describedby"] }
|
|
310
|
-
: {})}
|
|
415
|
+
aria-disabled
|
|
416
|
+
{...bind}
|
|
311
417
|
aria-label={favoriteLabel}
|
|
312
418
|
aria-pressed={bag.isFavorited === true}
|
|
313
419
|
icon={<HeartIcon filled={bag.isFavorited === true} />}
|
|
@@ -319,77 +425,146 @@ export function ListingDetailPane(props: ListingDetailPaneProps): ReactElement {
|
|
|
319
425
|
{favoriteLabel}
|
|
320
426
|
</Button>
|
|
321
427
|
)}
|
|
322
|
-
</
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
type="secondary"
|
|
329
|
-
data-testid="listings-detail-favorite-blocked"
|
|
428
|
+
</GateReasonPopover>
|
|
429
|
+
) : (
|
|
430
|
+
<Flex vertical gap={spacing[1]}>
|
|
431
|
+
<GatedControl
|
|
432
|
+
gate={bag.favoriteGate}
|
|
433
|
+
testId="listings-detail-favorite-gate"
|
|
330
434
|
>
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
435
|
+
{(bind) => (
|
|
436
|
+
<Button
|
|
437
|
+
disabled={bind.disabled}
|
|
438
|
+
data-disabled-reason="the enclosing <GatedControl> renders the gate's reason beside this button"
|
|
439
|
+
{...(bind["aria-describedby"] !== undefined
|
|
440
|
+
? { "aria-describedby": bind["aria-describedby"] }
|
|
441
|
+
: {})}
|
|
442
|
+
aria-label={favoriteLabel}
|
|
443
|
+
aria-pressed={bag.isFavorited === true}
|
|
444
|
+
icon={<HeartIcon filled={bag.isFavorited === true} />}
|
|
445
|
+
data-testid="listings-detail-favorite"
|
|
446
|
+
data-analytics="none"
|
|
447
|
+
data-analytics-reason="business action — host app wraps with its own tracked()"
|
|
448
|
+
onClick={bag.toggleFavorite}
|
|
449
|
+
>
|
|
450
|
+
{favoriteLabel}
|
|
451
|
+
</Button>
|
|
452
|
+
)}
|
|
453
|
+
</GatedControl>
|
|
454
|
+
{/* The door. `GatedControl` prints the reason; where a
|
|
455
|
+
visitor signs in is the container's, and arrives as
|
|
456
|
+
`signIn` — the cards' own pattern, verbatim. */}
|
|
457
|
+
{bag.favoriteGate.available ? null : (
|
|
458
|
+
<Typography.Text
|
|
459
|
+
type="secondary"
|
|
460
|
+
data-testid="listings-detail-favorite-blocked"
|
|
461
|
+
>
|
|
462
|
+
<SignInLink cta={props.signIn} testId="listings-detail-sign-in" />
|
|
463
|
+
</Typography.Text>
|
|
464
|
+
)}
|
|
334
465
|
</Flex>
|
|
335
466
|
)}
|
|
336
467
|
|
|
337
468
|
{props.actions}
|
|
338
469
|
</Flex>
|
|
470
|
+
);
|
|
339
471
|
|
|
340
|
-
|
|
472
|
+
const actionError =
|
|
473
|
+
actions.error !== undefined && actions.error !== null ? (
|
|
341
474
|
<ErrorAlert
|
|
342
475
|
testId="listings-detail-action-error"
|
|
343
476
|
thrown={actions.error}
|
|
344
477
|
variant="inline"
|
|
345
478
|
/>
|
|
346
|
-
) : null
|
|
479
|
+
) : null;
|
|
347
480
|
|
|
348
|
-
|
|
481
|
+
const description = (
|
|
482
|
+
<>
|
|
483
|
+
<Typography.Title level={5}>
|
|
484
|
+
{t(LISTINGS_I18N_KEYS.detailDescription)}
|
|
485
|
+
</Typography.Title>
|
|
486
|
+
<Typography.Paragraph data-testid="listings-detail-description">
|
|
487
|
+
{listing.description ?? ""}
|
|
488
|
+
</Typography.Paragraph>
|
|
489
|
+
</>
|
|
490
|
+
);
|
|
349
491
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
{
|
|
359
|
-
|
|
360
|
-
|
|
492
|
+
/* The DISPLAY envelope, not the edit one: a redacted row keeps
|
|
493
|
+
its place in the table and says the seller supplied the value.
|
|
494
|
+
`featuresDtoFromDaoList` deliberately drops a stub, because it
|
|
495
|
+
is what seeds a composer. */
|
|
496
|
+
const specValues = featureValuesForDisplay(
|
|
497
|
+
asFeatureDaoList(listing.features),
|
|
498
|
+
props.categoryFeatures !== undefined
|
|
499
|
+
? { categoryFeatures: props.categoryFeatures }
|
|
500
|
+
: {}
|
|
501
|
+
);
|
|
502
|
+
/* Two spec columns in the split, split by ROW COUNT and not by
|
|
503
|
+
`<FeatureValueList>` — the halves are cut HERE so the category's
|
|
504
|
+
declaration order survives: the first (larger) half fills the
|
|
505
|
+
left list, and the table reads top-to-bottom, left column
|
|
506
|
+
first, exactly as the one-column table read. */
|
|
507
|
+
const specHalf = Math.ceil(bag.features.length / 2);
|
|
508
|
+
const specs =
|
|
509
|
+
bag.features.length === 0 ? (
|
|
361
510
|
<Typography.Text type="secondary" data-testid="listings-detail-no-specs">
|
|
362
511
|
{t(LISTINGS_I18N_KEYS.detailNoSpecs)}
|
|
363
512
|
</Typography.Text>
|
|
513
|
+
) : split ? (
|
|
514
|
+
<div
|
|
515
|
+
data-testid="listings-detail-specs-split"
|
|
516
|
+
style={{
|
|
517
|
+
display: "grid",
|
|
518
|
+
gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
|
|
519
|
+
gap: spacing[4],
|
|
520
|
+
alignItems: "start",
|
|
521
|
+
}}
|
|
522
|
+
>
|
|
523
|
+
<FeatureValueList
|
|
524
|
+
features={bag.features
|
|
525
|
+
.slice(0, specHalf)
|
|
526
|
+
.map((view) => view.feature)}
|
|
527
|
+
values={specValues}
|
|
528
|
+
/>
|
|
529
|
+
{bag.features.length > specHalf ? (
|
|
530
|
+
<FeatureValueList
|
|
531
|
+
features={bag.features
|
|
532
|
+
.slice(specHalf)
|
|
533
|
+
.map((view) => view.feature)}
|
|
534
|
+
values={specValues}
|
|
535
|
+
/>
|
|
536
|
+
) : null}
|
|
537
|
+
</div>
|
|
364
538
|
) : (
|
|
365
539
|
<FeatureValueList
|
|
366
540
|
features={bag.features.map((view) => view.feature)}
|
|
367
|
-
|
|
368
|
-
// keeps its place in the table and says the seller supplied
|
|
369
|
-
// the value. `featuresDtoFromDaoList` deliberately drops a
|
|
370
|
-
// stub, because it is what seeds a composer.
|
|
371
|
-
values={featureValuesForDisplay(
|
|
372
|
-
asFeatureDaoList(listing.features),
|
|
373
|
-
props.categoryFeatures !== undefined
|
|
374
|
-
? { categoryFeatures: props.categoryFeatures }
|
|
375
|
-
: {}
|
|
376
|
-
)}
|
|
541
|
+
values={specValues}
|
|
377
542
|
/>
|
|
378
|
-
)
|
|
543
|
+
);
|
|
379
544
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
>
|
|
387
|
-
{t(LISTINGS_I18N_KEYS.detailUnreadableFeatures, {
|
|
388
|
-
count: bag.unreadableFeatures,
|
|
389
|
-
})}
|
|
390
|
-
</Typography.Text>
|
|
391
|
-
) : null}
|
|
545
|
+
const specsSection = (
|
|
546
|
+
<>
|
|
547
|
+
<Typography.Title level={5}>
|
|
548
|
+
{t(LISTINGS_I18N_KEYS.detailSpecs)}
|
|
549
|
+
</Typography.Title>
|
|
550
|
+
{specs}
|
|
392
551
|
|
|
552
|
+
{/* Counted, not rounded to zero: a stored attribute this build
|
|
553
|
+
cannot key is a gap in what the buyer is being told. */}
|
|
554
|
+
{bag.unreadableFeatures > 0 ? (
|
|
555
|
+
<Typography.Text
|
|
556
|
+
type="warning"
|
|
557
|
+
data-testid="listings-detail-unreadable"
|
|
558
|
+
>
|
|
559
|
+
{t(LISTINGS_I18N_KEYS.detailUnreadableFeatures, {
|
|
560
|
+
count: bag.unreadableFeatures,
|
|
561
|
+
})}
|
|
562
|
+
</Typography.Text>
|
|
563
|
+
) : null}
|
|
564
|
+
</>
|
|
565
|
+
);
|
|
566
|
+
|
|
567
|
+
const meta = (
|
|
393
568
|
<Descriptions size="small" column={1}>
|
|
394
569
|
{/* Label cell and value cell, which is what a `<Descriptions>`
|
|
395
570
|
row IS: the label key carries no `{count}` (it did, and the
|
|
@@ -410,10 +585,83 @@ export function ListingDetailPane(props: ListingDetailPaneProps): ReactElement {
|
|
|
410
585
|
</Descriptions.Item>
|
|
411
586
|
) : null}
|
|
412
587
|
</Descriptions>
|
|
588
|
+
);
|
|
413
589
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
590
|
+
const aside =
|
|
591
|
+
props.aside !== undefined ? (
|
|
592
|
+
<div data-testid="listings-detail-aside">{props.aside}</div>
|
|
593
|
+
) : null;
|
|
594
|
+
|
|
595
|
+
if (!split) {
|
|
596
|
+
// The single column, in the order it has always read — the
|
|
597
|
+
// host's aside joins where the footer's flow already is.
|
|
598
|
+
return (
|
|
599
|
+
<>
|
|
600
|
+
{statusBlocks}
|
|
601
|
+
{gallery}
|
|
602
|
+
{heading}
|
|
603
|
+
{price}
|
|
604
|
+
{buyBox}
|
|
605
|
+
{actionError}
|
|
606
|
+
<Divider />
|
|
607
|
+
{description}
|
|
608
|
+
{specsSection}
|
|
609
|
+
{meta}
|
|
610
|
+
{aside}
|
|
611
|
+
{props.footer}
|
|
612
|
+
</>
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
return (
|
|
617
|
+
<>
|
|
618
|
+
{statusBlocks}
|
|
619
|
+
<div
|
|
620
|
+
data-testid="listings-detail-split"
|
|
621
|
+
style={{
|
|
622
|
+
display: "grid",
|
|
623
|
+
// The reading column takes what is left and may shrink
|
|
624
|
+
// (`minmax(0, …)`, or a long unbroken title widens the
|
|
625
|
+
// track past the pane); the buy column's track is fixed —
|
|
626
|
+
// see DETAIL_SPLIT_ASIDE for why it is not a fraction.
|
|
627
|
+
gridTemplateColumns: `minmax(0, 1fr) ${DETAIL_SPLIT_ASIDE}`,
|
|
628
|
+
gap: spacing[5],
|
|
629
|
+
alignItems: "start",
|
|
630
|
+
}}
|
|
631
|
+
>
|
|
632
|
+
<Flex vertical gap={spacing[4]}>
|
|
633
|
+
{gallery}
|
|
634
|
+
{heading}
|
|
635
|
+
<Divider />
|
|
636
|
+
{description}
|
|
637
|
+
{specsSection}
|
|
638
|
+
{meta}
|
|
639
|
+
{props.footer}
|
|
640
|
+
</Flex>
|
|
641
|
+
{/* Sticky, so the actions ride along a page whose left
|
|
642
|
+
column is as tall as the seller's photo set. `alignSelf:
|
|
643
|
+
"start"` is load-bearing: a grid item stretches to the
|
|
644
|
+
row's height by default, and an element as tall as its
|
|
645
|
+
scroll container has nowhere to stick. */}
|
|
646
|
+
<Flex
|
|
647
|
+
vertical
|
|
648
|
+
gap={spacing[3]}
|
|
649
|
+
data-testid="listings-detail-buy-column"
|
|
650
|
+
style={{
|
|
651
|
+
position: "sticky",
|
|
652
|
+
top: spacing[4],
|
|
653
|
+
alignSelf: "start",
|
|
654
|
+
}}
|
|
655
|
+
>
|
|
656
|
+
{price}
|
|
657
|
+
{buyBox}
|
|
658
|
+
{actionError}
|
|
659
|
+
{aside}
|
|
660
|
+
</Flex>
|
|
661
|
+
</div>
|
|
662
|
+
</>
|
|
663
|
+
);
|
|
664
|
+
},
|
|
417
665
|
})}
|
|
418
666
|
</Flex>
|
|
419
667
|
</SkinTheme>
|
package/src/default/index.ts
CHANGED
|
@@ -59,7 +59,15 @@ export type {
|
|
|
59
59
|
} from "./ListingFeedCard.js";
|
|
60
60
|
export { FeedGrid, FEED_GRID_COLUMNS } from "./FeedGrid.js";
|
|
61
61
|
export type { FeedGridProps } from "./FeedGrid.js";
|
|
62
|
-
export {
|
|
62
|
+
export {
|
|
63
|
+
ListingDetailPane,
|
|
64
|
+
DETAIL_MEASURE,
|
|
65
|
+
// The split layout's two geometry constants, for a container laying out
|
|
66
|
+
// against the same tracks (and for a test that measures them).
|
|
67
|
+
DETAIL_SPLIT_MEASURE,
|
|
68
|
+
DETAIL_SPLIT_ASIDE,
|
|
69
|
+
DETAIL_PHOTO_MIN,
|
|
70
|
+
} from "./ListingDetailPane.js";
|
|
63
71
|
export type { ListingDetailPaneProps } from "./ListingDetailPane.js";
|
|
64
72
|
export {
|
|
65
73
|
ListingComposerPage,
|