orionplace-react 0.3.1 → 0.5.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.
Files changed (42) hide show
  1. package/README.md +39 -4
  2. package/bin/orionplace-react.mjs +38 -7
  3. package/package.json +1 -1
  4. package/runtime/marketplace.mjs +12 -0
  5. package/src/install.mjs +5 -4
  6. package/src/project-readme.mjs +3 -0
  7. package/src/service.mjs +186 -0
  8. package/templates/app/StorefrontShell.tsx +8 -0
  9. package/templates/app/_storefront/PrivacyPage.tsx +15 -0
  10. package/templates/app/_storefront/storefrontRoutes.tsx +3 -0
  11. package/templates/app/privacy/page.tsx +9 -0
  12. package/templates/components/orionplace/blog/BlogArticle.README.md +16 -0
  13. package/templates/components/orionplace/blog/BlogArticle.module.css +5 -0
  14. package/templates/components/orionplace/blog/BlogArticle.tsx +60 -1
  15. package/templates/components/orionplace/legal/CookieNotice.README.md +42 -0
  16. package/templates/components/orionplace/legal/CookieNotice.module.css +48 -0
  17. package/templates/components/orionplace/legal/CookieNotice.tsx +82 -0
  18. package/templates/components/orionplace/legal/StorefrontPrivacy.README.md +49 -0
  19. package/templates/components/orionplace/legal/StorefrontPrivacy.module.css +166 -0
  20. package/templates/components/orionplace/legal/StorefrontPrivacy.tsx +83 -0
  21. package/templates/components/orionplace/products/ProductReviewImageViewer.README.md +13 -2
  22. package/templates/components/orionplace/products/ProductReviewImageViewer.module.css +10 -1
  23. package/templates/components/orionplace/products/ProductReviewImageViewer.tsx +61 -9
  24. package/templates/components/orionplace/storefront/StorefrontFooter.tsx +3 -0
  25. package/templates/components/orionplace/subscriptions/StorefrontTariff.README.md +13 -0
  26. package/templates/components/orionplace/subscriptions/StorefrontTariff.tsx +17 -6
  27. package/templates/components/orionplace/subscriptions/StorefrontTariffs.README.md +13 -0
  28. package/templates/components/orionplace/subscriptions/StorefrontTariffs.tsx +19 -2
  29. package/templates/components/orionplace/tariffs/TariffCard.tsx +8 -1
  30. package/templates/components/orionplace/tariffs/TariffCardPrices.README.md +10 -2
  31. package/templates/components/orionplace/tariffs/TariffCardPrices.tsx +12 -2
  32. package/templates/hooks/useOrionplaceTariffPurchase.ts +60 -0
  33. package/templates/lib/orionplace/blogImageViewer.ts +84 -0
  34. package/templates/lib/orionplace/blogLabels.ts +4 -0
  35. package/templates/lib/orionplace/footerLabels.ts +2 -0
  36. package/templates/lib/orionplace/pageMetadata.ts +1 -0
  37. package/templates/lib/orionplace/pageSeo.ts +10 -0
  38. package/templates/lib/orionplace/privacyLabels.ts +198 -0
  39. package/templates/lib/orionplace/reviewLabels.ts +4 -0
  40. package/templates/lib/orionplace/tariffLabels.ts +2 -0
  41. package/templates/lib/orionplace/tariffs.ts +49 -0
  42. package/templates/stores/orionplaceCatalog.ts +18 -0
@@ -0,0 +1,42 @@
1
+ # CookieNotice · React
2
+
3
+ ## English
4
+
5
+ `CookieNotice` tells visitors that the site uses only the cookies it needs and
6
+ links the cookies section of the policy. It renders nothing in server HTML;
7
+ after mounting it appears at the bottom of the screen until the visitor presses
8
+ OK, and the choice is kept in local storage under
9
+ `orionplace-cookie-notice-seen` (`COOKIE_NOTICE_STORAGE_KEY` in
10
+ `lib/orionplace/privacyLabels.ts`). The storefront sets only necessary cookies,
11
+ so the notice asks for no consent; a store that adds analytics or advertising
12
+ cookies needs a consent form instead. The supplied shell does not show it in
13
+ the Android app build.
14
+
15
+ Source is maintained in `components/orionplace/legal/CookieNotice.tsx`.
16
+
17
+ ### Props
18
+
19
+ | Prop | Meaning |
20
+ | --------------------------------- | --------------------------------------------------------------------------------------------------------- |
21
+ | `href?: string` | Address of the cookies section with the language, for example `/privacy?locale=ru#cookies`. Default: `/privacy#cookies`. |
22
+ | `onNavigate?: (path: string) => void` | Called on an ordinary click of the link with `href`; the host navigates. Without it the link opens normally. |
23
+
24
+ ## Русский
25
+
26
+ `CookieNotice` сообщает, что сайт использует только необходимые cookie, и
27
+ ведёт в раздел о cookie политики. В серверном HTML его нет; после монтирования
28
+ он показывается внизу экрана, пока посетитель не нажмёт «Понятно», и выбор
29
+ хранится в локальном хранилище под ключом `orionplace-cookie-notice-seen`
30
+ (`COOKIE_NOTICE_STORAGE_KEY` в `lib/orionplace/privacyLabels.ts`). Витрина
31
+ ставит только необходимые cookie, поэтому уведомление не запрашивает согласие;
32
+ магазину, который добавит аналитические или рекламные cookie, нужна форма
33
+ согласия. В сборке приложения для Android оболочка его не показывает.
34
+
35
+ Поддерживаемый исходный файл: `components/orionplace/legal/CookieNotice.tsx`.
36
+
37
+ ### Свойства
38
+
39
+ | Свойство | Назначение |
40
+ | --------------------------------- | ---------------------------------------------------------------------------------------------------------- |
41
+ | `href?: string` | Адрес раздела о cookie с языком, например `/privacy?locale=ru#cookies`. По умолчанию `/privacy#cookies`. |
42
+ | `onNavigate?: (path: string) => void` | Вызывается при обычном щелчке по ссылке с `href`; переход выполняет приложение. Без него ссылка открывается как обычно. |
@@ -0,0 +1,48 @@
1
+ .root {
2
+ position: fixed;
3
+ right: 0.75rem;
4
+ bottom: 0.75rem;
5
+ left: 0.75rem;
6
+ z-index: 40;
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: stretch;
10
+ gap: 0.75rem;
11
+ box-sizing: border-box;
12
+ padding: 1rem;
13
+ border: 1px solid var(--orionplace-border);
14
+ color: var(--orionplace-text);
15
+ background: var(--orionplace-surface);
16
+ box-shadow: 0 10px 15px -3px rgb(0 0 0 / 10%), 0 4px 6px -4px rgb(0 0 0 / 10%);
17
+ font-size: 0.875rem;
18
+ line-height: 1.5rem;
19
+ }
20
+
21
+ .text {
22
+ margin: 0;
23
+ color: var(--orionplace-muted);
24
+ }
25
+
26
+ .text a {
27
+ color: var(--orionplace-text);
28
+ text-decoration: underline;
29
+ text-underline-offset: 2px;
30
+ white-space: nowrap;
31
+ }
32
+
33
+ .button {
34
+ composes: primary from '../shared/features.module.css';
35
+ flex-shrink: 0;
36
+ }
37
+
38
+ @media (min-width: 640px) {
39
+ .root {
40
+ right: 1.25rem;
41
+ bottom: 1.25rem;
42
+ left: auto;
43
+ max-width: 560px;
44
+ flex-direction: row;
45
+ align-items: center;
46
+ gap: 1rem;
47
+ }
48
+ }
@@ -0,0 +1,82 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useState, type MouseEvent } from 'react';
4
+ import { useOrionplaceSelections } from '@/providers/OrionplaceProvider';
5
+ import {
6
+ COOKIE_NOTICE_STORAGE_KEY,
7
+ privacyLabels,
8
+ } from '@/lib/orionplace/privacyLabels';
9
+ import styles from './CookieNotice.module.css';
10
+
11
+ export interface CookieNoticeProps {
12
+ /** Address of the cookies section, with the language and `#cookies`. */
13
+ href?: string;
14
+ /** An ordinary click on the link; the host navigates. */
15
+ onNavigate?: (path: string) => void;
16
+ }
17
+
18
+ // The storefront sets only necessary cookies, so this is a notice, not a
19
+ // consent form. It appears after mounting and stays away once dismissed.
20
+ export function CookieNotice({
21
+ href = '/privacy#cookies',
22
+ onNavigate,
23
+ }: CookieNoticeProps) {
24
+ const locale = useOrionplaceSelections((state) => state.localeCode);
25
+ const labels = privacyLabels(locale).cookie;
26
+ const [visible, setVisible] = useState(false);
27
+
28
+ useEffect(() => {
29
+ try {
30
+ setVisible(localStorage.getItem(COOKIE_NOTICE_STORAGE_KEY) !== '1');
31
+ } catch {
32
+ setVisible(true);
33
+ }
34
+ }, []);
35
+
36
+ function dismiss() {
37
+ setVisible(false);
38
+ try {
39
+ localStorage.setItem(COOKIE_NOTICE_STORAGE_KEY, '1');
40
+ } catch {
41
+ // Without storage the notice comes back on the next visit.
42
+ }
43
+ }
44
+
45
+ function open(event: MouseEvent<HTMLAnchorElement>) {
46
+ if (
47
+ !onNavigate ||
48
+ event.ctrlKey ||
49
+ event.metaKey ||
50
+ event.shiftKey ||
51
+ event.altKey ||
52
+ event.button !== 0
53
+ ) {
54
+ return;
55
+ }
56
+ event.preventDefault();
57
+ onNavigate(href);
58
+ }
59
+
60
+ if (!visible) {
61
+ return null;
62
+ }
63
+
64
+ return (
65
+ <div
66
+ data-feature-part="CookieNotice"
67
+ role="region"
68
+ aria-label={labels.label}
69
+ className={styles.root}
70
+ >
71
+ <p className={styles.text}>
72
+ {labels.text}{' '}
73
+ <a href={href} onClick={open}>
74
+ {labels.link}
75
+ </a>
76
+ </p>
77
+ <button type="button" className={styles.button} onClick={dismiss}>
78
+ {labels.ok}
79
+ </button>
80
+ </div>
81
+ );
82
+ }
@@ -0,0 +1,49 @@
1
+ # StorefrontPrivacy · React
2
+
3
+ ## English
4
+
5
+ `StorefrontPrivacy` is the store's personal data policy at `/privacy`. It has
6
+ no inputs except `className` and sends no requests. It lists which data the
7
+ store receives, why, who receives it, how long it is kept, the customer's
8
+ rights and the cookies the site sets; a contents list links every section, and
9
+ the cookies section has the anchor `#cookies`. The operator block shows the
10
+ company name, tax ID, registration number, address and phone from the
11
+ Application Load contact details; empty values are left out.
12
+
13
+ The texts are in `lib/orionplace/privacyLabels.ts`, in Russian and English. A
14
+ store that adds analytics, chat widgets or other cookies lists them in the
15
+ cookies section.
16
+
17
+ Source is maintained in
18
+ `components/orionplace/legal/StorefrontPrivacy.tsx`; the contact interface is
19
+ `interfaces/orionplace/appBase/appLoadCommon/IAppLoadCommonContact.ts`.
20
+
21
+ ### Props
22
+
23
+ | Prop | Meaning |
24
+ | -------------------- | ---------------------------------------- |
25
+ | `className?: string` | Extra class names for the page section. |
26
+
27
+ ## Русский
28
+
29
+ `StorefrontPrivacy` — политика обработки персональных данных магазина на
30
+ странице `/privacy`. Кроме `className`, свойств нет; запросов компонент не
31
+ отправляет. Он описывает, какие данные получает магазин, зачем, кому
32
+ передаёт, сколько хранит, права покупателя и cookie сайта; оглавление ведёт к
33
+ каждому разделу, у раздела о cookie якорь `#cookies`. Блок оператора
34
+ показывает название компании, ИНН, регистрационный номер, адрес и телефон из
35
+ контактов загрузки приложения; пустые значения не выводятся.
36
+
37
+ Тексты — в `lib/orionplace/privacyLabels.ts`, на русском и английском.
38
+ Магазин, который добавит аналитику, чат или другие cookie, перечисляет их в
39
+ разделе о cookie.
40
+
41
+ Поддерживаемый исходный файл:
42
+ `components/orionplace/legal/StorefrontPrivacy.tsx`; интерфейс контактов —
43
+ `interfaces/orionplace/appBase/appLoadCommon/IAppLoadCommonContact.ts`.
44
+
45
+ ### Свойства
46
+
47
+ | Свойство | Назначение |
48
+ | -------------------- | ------------------------------------------- |
49
+ | `className?: string` | Дополнительные классы для секции страницы. |
@@ -0,0 +1,166 @@
1
+ .root {
2
+ display: grid;
3
+ width: 100%;
4
+ min-width: 0;
5
+ color: var(--orionplace-text);
6
+ font: inherit;
7
+ /* The page's base text, as `op-feature` in the other packages. */
8
+ font-size: 0.875rem;
9
+ line-height: 1.5rem;
10
+ container-type: inline-size;
11
+ }
12
+
13
+ .header {
14
+ display: grid;
15
+ gap: 0.75rem;
16
+ margin-bottom: 2rem;
17
+ padding-bottom: 1.5rem;
18
+ border-bottom: 1px solid var(--orionplace-border);
19
+ }
20
+
21
+ .header h1 {
22
+ margin: 0;
23
+ font-size: 1.5rem;
24
+ font-weight: 500;
25
+ line-height: 1.25;
26
+ text-transform: uppercase;
27
+ letter-spacing: 0.04em;
28
+ }
29
+
30
+ .header p {
31
+ max-width: 42rem;
32
+ margin: 0;
33
+ color: var(--orionplace-muted);
34
+ }
35
+
36
+ .layout {
37
+ display: grid;
38
+ align-items: start;
39
+ gap: 2.5rem;
40
+ min-width: 0;
41
+ }
42
+
43
+ .contents,
44
+ .body,
45
+ .section,
46
+ .operator {
47
+ display: grid;
48
+ min-width: 0;
49
+ }
50
+
51
+ .contents {
52
+ gap: 0.75rem;
53
+ }
54
+
55
+ .contents h2,
56
+ .section h2,
57
+ .operator h2 {
58
+ margin: 0;
59
+ font-size: 0.875rem;
60
+ font-weight: 500;
61
+ line-height: 1.25rem;
62
+ text-transform: uppercase;
63
+ letter-spacing: 0.08em;
64
+ }
65
+
66
+ .contents h2 {
67
+ color: var(--orionplace-muted);
68
+ }
69
+
70
+ .contents ol {
71
+ display: grid;
72
+ gap: 0.5rem;
73
+ margin: 0;
74
+ padding: 0;
75
+ list-style: none;
76
+ }
77
+
78
+ .contents a {
79
+ color: var(--orionplace-text);
80
+ text-decoration: none;
81
+ outline: none;
82
+ }
83
+
84
+ .contents a:focus-visible {
85
+ text-decoration: underline;
86
+ }
87
+
88
+ @media (hover: hover) {
89
+ .contents a:hover {
90
+ text-decoration: underline;
91
+ }
92
+ }
93
+
94
+ .body {
95
+ max-width: 48rem;
96
+ gap: 2rem;
97
+ }
98
+
99
+ .section {
100
+ gap: 0.75rem;
101
+ scroll-margin-top: 1.5rem;
102
+ }
103
+
104
+ .section p,
105
+ .operator p {
106
+ margin: 0;
107
+ }
108
+
109
+ .operator {
110
+ gap: 0.75rem;
111
+ padding: 1.25rem;
112
+ border: 1px solid var(--orionplace-border);
113
+ background: var(--orionplace-surface);
114
+ }
115
+
116
+ .operator p {
117
+ color: var(--orionplace-muted);
118
+ }
119
+
120
+ .operator dl {
121
+ display: grid;
122
+ gap: 0.5rem;
123
+ margin: 0;
124
+ }
125
+
126
+ .detail {
127
+ display: grid;
128
+ gap: 0 1.5rem;
129
+ }
130
+
131
+ .detail dt {
132
+ color: var(--orionplace-muted);
133
+ }
134
+
135
+ .detail dd {
136
+ margin: 0;
137
+ overflow-wrap: anywhere;
138
+ }
139
+
140
+ /* The header's margin spaces the page, so it follows the page's own width. */
141
+ @container (min-width: 592px) {
142
+ .header {
143
+ margin-bottom: 3rem;
144
+ padding-bottom: 2rem;
145
+ }
146
+
147
+ .header h1 {
148
+ font-size: 1.875rem;
149
+ }
150
+
151
+ .detail {
152
+ grid-template-columns: 12rem minmax(0, 1fr);
153
+ }
154
+ }
155
+
156
+ @container (min-width: 960px) {
157
+ .layout {
158
+ grid-template-columns: minmax(0, 3fr) minmax(0, 9fr);
159
+ gap: 4rem;
160
+ }
161
+
162
+ .contents {
163
+ position: sticky;
164
+ top: 1.5rem;
165
+ }
166
+ }
@@ -0,0 +1,83 @@
1
+ 'use client';
2
+
3
+ import { useOrionplace, useOrionplaceSelections } from '@/providers/OrionplaceProvider';
4
+ import { selectInit } from '@/stores/orionplace';
5
+ import { contactLabels } from '@/lib/orionplace/contactLabels';
6
+ import { privacyLabels } from '@/lib/orionplace/privacyLabels';
7
+ import styles from './StorefrontPrivacy.module.css';
8
+
9
+ export interface StorefrontPrivacyProps {
10
+ className?: string;
11
+ }
12
+
13
+ export function StorefrontPrivacy({ className = '' }: StorefrontPrivacyProps) {
14
+ const init = useOrionplace(selectInit);
15
+ const locale = useOrionplaceSelections((state) => state.localeCode);
16
+ const contact = init?.contact;
17
+ const company =
18
+ contact?.company_legal_name?.trim() || contact?.company_name?.trim() || '';
19
+ const labels = privacyLabels(locale, company);
20
+ const fields = contactLabels(locale);
21
+ // The operator's details as the platform sends them; empty rows are left out.
22
+ const details = [
23
+ [fields.legalName, company],
24
+ [fields.taxId, contact?.company_tax_id],
25
+ [fields.registrationNumber, contact?.company_organization_id],
26
+ [fields.address, contact?.company_contact_address],
27
+ [fields.phone, contact?.company_contact_phone],
28
+ ]
29
+ .map(([label, value]) => ({ label: label ?? '', value: value?.trim() ?? '' }))
30
+ .filter((row) => row.value);
31
+
32
+ return (
33
+ <section
34
+ data-feature-part="StorefrontPrivacy"
35
+ className={`${styles.root} ${className}`.trim()}
36
+ >
37
+ <header className={styles.header}>
38
+ <h1>{labels.title}</h1>
39
+ <p>{labels.lead}</p>
40
+ </header>
41
+
42
+ <div className={styles.layout}>
43
+ <nav aria-label={labels.contents} className={styles.contents}>
44
+ <h2>{labels.contents}</h2>
45
+ <ol>
46
+ {labels.sections.map((section) => (
47
+ <li key={section.id}>
48
+ <a href={`#${section.id}`}>{section.title}</a>
49
+ </li>
50
+ ))}
51
+ </ol>
52
+ </nav>
53
+
54
+ <article className={styles.body}>
55
+ {labels.sections.map((section) => (
56
+ <section key={section.id} id={section.id} className={styles.section}>
57
+ <h2>{section.title}</h2>
58
+ {section.text.map((line, index) => (
59
+ <p key={index}>{line}</p>
60
+ ))}
61
+ </section>
62
+ ))}
63
+
64
+ <section id="operator-details" className={styles.operator}>
65
+ <h2>{labels.operator}</h2>
66
+ {details.length ? (
67
+ <dl>
68
+ {details.map((row) => (
69
+ <div key={row.label} className={styles.detail}>
70
+ <dt>{row.label}</dt>
71
+ <dd>{row.value}</dd>
72
+ </div>
73
+ ))}
74
+ </dl>
75
+ ) : (
76
+ <p>{labels.operatorUnknown}</p>
77
+ )}
78
+ </section>
79
+ </article>
80
+ </div>
81
+ </section>
82
+ );
83
+ }
@@ -7,7 +7,11 @@ and public image URLs. `index` chooses the first displayed photo and resets
7
7
  the viewer when it changes. Previous and Next, arrow keys, Home, End and
8
8
  thumbnail buttons change the photo, and so does a sideways swipe on the large
9
9
  photo; `onChange` receives its ID and position. `StorefrontProduct` opens the
10
- product's own photos here with `label` and `alt`.
10
+ product's own photos here with `label` and `alt`. `BlogArticle` opens the
11
+ images of an article with `captions`, a caption under each photo, and `wide`,
12
+ which lets the viewer use up to 1600px of the screen width instead of 960px
13
+ and adds full-size zoom: the magnifier button or a click on the image shows it
14
+ at its own size, scrolling inside the viewer.
11
15
  `onClose` handles the close button, Escape and a click outside the dialog.
12
16
  The component returns keyboard focus to the element that opened it. The
13
17
  dialog's images are mounted when it opens, so an unopened viewer starts no
@@ -21,6 +25,8 @@ image requests.
21
25
  | `index?: number` | Zero-based index of the current item in its collection. |
22
26
  | `label?: string` | Dialog name instead of «Review photos». |
23
27
  | `alt?: string` | Photo text before the photo number instead of «Review photo». |
28
+ | `captions?: string[]` | Caption under each photo, in the order of `images`. |
29
+ | `wide?: boolean` | Up to 1600px wide instead of 960px, with full-size zoom, for detailed images. |
24
30
  | `onChange?: (photo: { id: number; index: number; }) => void` | Called when the visitor confirms a new value. The callback payload is shown in its type. |
25
31
  | `onClose?: () => void` | Called when the visitor closes the panel or dialog. The callback has no payload. |
26
32
 
@@ -32,7 +38,10 @@ image requests.
32
38
  клавиши стрелок, Home, End, миниатюры и смахивание по большой фотографии
33
39
  меняют фотографию; `StorefrontProduct` открывает здесь фотографии товара с
34
40
  `label` и `alt`; `onChange`
35
- получает её ID и номер в списке. `onClose` обрабатывает кнопку закрытия,
41
+ получает её ID и номер в списке. `BlogArticle` открывает изображения статьи с
42
+ `captions` — подписью под каждой фотографией — и `wide`, при котором
43
+ просмотрщик занимает до 1600px ширины экрана вместо 960px, а кнопка с лупой или
44
+ нажатие на изображение показывает его в полный размер с прокруткой. `onClose` обрабатывает кнопку закрытия,
36
45
  Escape и щелчок вне диалога. При закрытии фокус возвращается на элемент,
37
46
  который открыл просмотрщик. Изображения появляются при открытии диалога,
38
47
  поэтому закрытый просмотрщик не начинает их загрузку.
@@ -44,6 +53,8 @@ Escape и щелчок вне диалога. При закрытии фокус
44
53
  | `images: IProductFeedbackImage[]` | Упорядоченные изображения галереи. |
45
54
  | `label?: string` | Название диалога вместо «Фотографии к отзыву». |
46
55
  | `alt?: string` | Текст фотографии перед её номером вместо «Фотография к отзыву». |
56
+ | `captions?: string[]` | Подпись под каждой фотографией в порядке `images`. |
57
+ | `wide?: boolean` | До 1600px ширины вместо 960px и показ в полный размер — для подробных изображений. |
47
58
  | `index?: number` | Индекс текущего элемента в коллекции, начиная с нуля. |
48
59
  | `onChange?: (photo: { id: number; index: number; }) => void` | Вызывается, когда покупатель подтверждает новое значение. Данные обработчика указаны в его типе. |
49
60
  | `onClose?: () => void` | Вызывается, когда покупатель закрывает панель или диалог. Обработчик не получает данные. |
@@ -12,8 +12,9 @@
12
12
  color: var(--orionplace-text);
13
13
  font-family: inherit;
14
14
  }
15
+ .wide { max-width: 1600px; }
15
16
  .viewer::backdrop { background: rgb(0 0 0 / 35%); backdrop-filter: blur(2px); }
16
- .content { display: grid; height: 100%; grid-template-rows: auto minmax(0, 1fr) auto; container: review-image-viewer / inline-size; }
17
+ .content { display: grid; height: 100%; grid-template-rows: auto minmax(0, 1fr) auto auto; container: review-image-viewer / inline-size; }
17
18
  .header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--orionplace-border); }
18
19
  .header p { margin: 0; color: var(--orionplace-muted); font-size: 12px; line-height: 1rem; letter-spacing: 0.08em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
19
20
  .header button { display: grid; flex-shrink: 0; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; outline: none; background: transparent; color: inherit; font-size: 24px; line-height: 2rem; cursor: pointer; transition: background-color 150ms; }
@@ -48,3 +49,11 @@
48
49
  }
49
50
  }
50
51
  .thumbnails img { width: 100%; height: 100%; object-fit: contain; }
52
+ .caption { margin: 0; padding: 4px 16px 12px; color: var(--orionplace-muted); font-size: 14px; line-height: 1.5rem; text-align: center; }
53
+ .zoom { margin-left: auto; }
54
+ .zoom svg { width: 1.25rem; height: 1.25rem; }
55
+ .fitted { display: contents; }
56
+ .zoomed { position: absolute; inset: 0; overflow: auto; }
57
+ .fullImage { display: block; width: auto; height: auto; max-width: none !important; max-height: none !important; margin: auto; }
58
+ .zoomIn { cursor: zoom-in; }
59
+ .zoomOut { cursor: zoom-out; }
@@ -15,11 +15,15 @@ import { OrionplaceImage } from '@/components/orionplace/shared/OrionplaceImage'
15
15
  import styles from './ProductReviewImageViewer.module.css';
16
16
 
17
17
  // `label` and `alt` name the product's own photos on the product page.
18
+ // `captions` are shown under each image (blog article images have them);
19
+ // `wide` lets screenshots and other detailed images use more of the screen.
18
20
  export interface ProductReviewImageViewerProps {
19
21
  images: IProductFeedbackImage[];
20
22
  index?: number;
21
23
  label?: string;
22
24
  alt?: string;
25
+ captions?: string[];
26
+ wide?: boolean;
23
27
  onChange?: (photo: { id: number; index: number }) => void;
24
28
  onClose?: () => void;
25
29
  }
@@ -29,6 +33,8 @@ export function ProductReviewImageViewer({
29
33
  index = 0,
30
34
  label,
31
35
  alt,
36
+ captions,
37
+ wide = false,
32
38
  onChange,
33
39
  onClose,
34
40
  }: ProductReviewImageViewerProps) {
@@ -41,6 +47,10 @@ export function ProductReviewImageViewer({
41
47
  const [active, setActive] = useState(() => validIndex(index, images.length));
42
48
  const current = images[active];
43
49
  const several = images.length > 1;
50
+ const caption = captions?.[active]?.trim() ?? '';
51
+ // A wide viewer can show the image at its own size; the stage then scrolls.
52
+ const [zoomed, setZoomed] = useState(false);
53
+ const toggleZoom = () => setZoomed((value) => wide && !value);
44
54
 
45
55
  useEffect(() => {
46
56
  setMounted(true);
@@ -50,6 +60,11 @@ export function ProductReviewImageViewer({
50
60
  setActive(validIndex(index, images.length));
51
61
  }, [images, index]);
52
62
 
63
+ // Another photo opens fitted to the screen.
64
+ useEffect(() => {
65
+ setZoomed(false);
66
+ }, [active]);
67
+
53
68
  useEffect(() => {
54
69
  const element = dialog.current;
55
70
  if (!mounted || !element) {
@@ -101,7 +116,7 @@ export function ProductReviewImageViewer({
101
116
  const touch = event.changedTouches[0];
102
117
  const start = swipeStart.current;
103
118
  swipeStart.current = undefined;
104
- if (!start || !touch || !several) {
119
+ if (!start || !touch || !several || zoomed) {
105
120
  return;
106
121
  }
107
122
  select(
@@ -150,7 +165,7 @@ export function ProductReviewImageViewer({
150
165
  <dialog
151
166
  data-stable-modal="fixed"
152
167
  ref={dialog}
153
- className={styles.viewer}
168
+ className={wide ? `${styles.viewer} ${styles.wide}` : styles.viewer}
154
169
  aria-label={label || labels.photoViewer}
155
170
  data-feature-part="ProductReviewImageViewer"
156
171
  data-review-image-viewer
@@ -166,6 +181,28 @@ export function ProductReviewImageViewer({
166
181
  <p aria-live="polite" data-review-image-position>
167
182
  {active + 1} / {images.length}
168
183
  </p>
184
+ {wide ? (
185
+ <button
186
+ type="button"
187
+ className={styles.zoom}
188
+ aria-label={zoomed ? labels.zoomOut : labels.zoomIn}
189
+ aria-pressed={zoomed}
190
+ data-review-image-zoom
191
+ onClick={toggleZoom}
192
+ >
193
+ <svg
194
+ viewBox="0 0 24 24"
195
+ fill="none"
196
+ stroke="currentColor"
197
+ strokeWidth="1.5"
198
+ aria-hidden="true"
199
+ >
200
+ <circle cx="10.5" cy="10.5" r="6.5" />
201
+ <path d="m15.5 15.5 5 5M7.5 10.5h6" />
202
+ {zoomed ? null : <path d="M10.5 7.5v6" />}
203
+ </svg>
204
+ </button>
205
+ ) : null}
169
206
  <button
170
207
  type="button"
171
208
  aria-label={common.close}
@@ -176,18 +213,28 @@ export function ProductReviewImageViewer({
176
213
  </button>
177
214
  </header>
178
215
  <div
179
- className={several ? `${styles.stage} ${styles.swipe}` : styles.stage}
216
+ className={several && !zoomed ? `${styles.stage} ${styles.swipe}` : styles.stage}
180
217
  data-review-image-stage
181
218
  onTouchStart={startSwipe}
182
219
  onTouchEnd={endSwipe}
183
220
  >
221
+ {/* At full size the image scrolls inside the stage; the arrows stay in place. */}
184
222
  {current && (
185
- <OrionplaceImage
186
- key={current.id}
187
- src={current.image}
188
- alt={photoLabel(active)}
189
- className={styles.mainImage}
190
- />
223
+ <div
224
+ className={zoomed ? styles.zoomed : styles.fitted}
225
+ data-review-image-zoomed={zoomed || undefined}
226
+ >
227
+ <OrionplaceImage
228
+ key={current.id}
229
+ src={current.image}
230
+ alt={photoLabel(active)}
231
+ className={[
232
+ zoomed ? styles.fullImage : styles.mainImage,
233
+ wide ? (zoomed ? styles.zoomOut : styles.zoomIn) : '',
234
+ ].join(' ').trim()}
235
+ onClick={toggleZoom}
236
+ />
237
+ </div>
191
238
  )}
192
239
  {several && (
193
240
  <>
@@ -228,6 +275,11 @@ export function ProductReviewImageViewer({
228
275
  </>
229
276
  )}
230
277
  </div>
278
+ {caption ? (
279
+ <p className={styles.caption} data-review-image-caption>
280
+ {caption}
281
+ </p>
282
+ ) : null}
231
283
  {several && (
232
284
  <ol className={styles.thumbnails}>
233
285
  {images.map((photo, position) => (