@pushwoosh/dumb-components 1.1.175 → 1.1.176
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/NativeRichMediaPreview/NativeRichMediaPreview.d.ts +8 -5
- package/NativeRichMediaPreview/NativeRichMediaPreview.js +21 -14
- package/NativeRichMediaPreview/styles.d.ts +3 -0
- package/NativeRichMediaPreview/styles.js +14 -4
- package/NativeRichMediaPreview/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -3,13 +3,16 @@ import type { NativeRichMediaPreviewProps } from './types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Preview of a native rich media (modal, banner, stories, spinwheel, …)
|
|
5
5
|
* rendered from its JSON config; lays out with plain CSS in the real pixels
|
|
6
|
-
* of the given width/height box
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* of the given width/height box, with no fidelity to any phone's pt-metrics
|
|
7
|
+
* since this is a preview and devices vary. Content flows inside a scrollable
|
|
8
|
+
* layer above a static backdrop (the dim overlay or, for
|
|
9
9
|
* `fullscreen`/`video`/`stories`, the full-bleed background image or poster):
|
|
10
10
|
* content taller than the box scrolls, shorter content aligns per display
|
|
11
|
-
* type while the backdrop stays put.
|
|
12
|
-
*
|
|
11
|
+
* type while the backdrop stays put. Pass `scale` to lay the content out on a
|
|
12
|
+
* larger (or smaller) reference viewport and scale the whole preview to fill
|
|
13
|
+
* the box — the way to cram a phone-sized layout into a small preview box
|
|
14
|
+
* while keeping its proportions. Shows an invalid-config placeholder when the
|
|
15
|
+
* config cannot be parsed or misses required contract fields.
|
|
13
16
|
*
|
|
14
17
|
* @example
|
|
15
18
|
* <NativeRichMediaPreview
|
|
@@ -9,7 +9,7 @@ import { NativeRichMediaMuteChip } from './components/NativeRichMediaMuteChip';
|
|
|
9
9
|
import { EDGE_INSET, clampIndex } from './helpers';
|
|
10
10
|
import { parseNativeRichMediaConfig } from './parseNativeRichMediaConfig';
|
|
11
11
|
import { resolveLocalization } from './resolveLocalization';
|
|
12
|
-
import { BackdropLayer, ContentFlow, PreviewHost, ScrollLayer, SpinnerLayer } from './styles';
|
|
12
|
+
import { BackdropLayer, ContentFlow, PreviewHost, ScaleViewport, ScrollLayer, SpinnerLayer } from './styles';
|
|
13
13
|
import { NativeRichMediaBannerView, NativeRichMediaCarouselView, NativeRichMediaFullscreenView, NativeRichMediaInvalidView, NativeRichMediaModalView, NativeRichMediaPipView, NativeRichMediaScratchcardView, NativeRichMediaSheetView, NativeRichMediaSpinwheelView, NativeRichMediaStoriesView, NativeRichMediaVideoView } from './views';
|
|
14
14
|
function dimsScreen(config) {
|
|
15
15
|
if (!config) {
|
|
@@ -153,13 +153,16 @@ function renderConfig(config, activeIndex) {
|
|
|
153
153
|
/**
|
|
154
154
|
* Preview of a native rich media (modal, banner, stories, spinwheel, …)
|
|
155
155
|
* rendered from its JSON config; lays out with plain CSS in the real pixels
|
|
156
|
-
* of the given width/height box
|
|
157
|
-
*
|
|
158
|
-
*
|
|
156
|
+
* of the given width/height box, with no fidelity to any phone's pt-metrics
|
|
157
|
+
* since this is a preview and devices vary. Content flows inside a scrollable
|
|
158
|
+
* layer above a static backdrop (the dim overlay or, for
|
|
159
159
|
* `fullscreen`/`video`/`stories`, the full-bleed background image or poster):
|
|
160
160
|
* content taller than the box scrolls, shorter content aligns per display
|
|
161
|
-
* type while the backdrop stays put.
|
|
162
|
-
*
|
|
161
|
+
* type while the backdrop stays put. Pass `scale` to lay the content out on a
|
|
162
|
+
* larger (or smaller) reference viewport and scale the whole preview to fill
|
|
163
|
+
* the box — the way to cram a phone-sized layout into a small preview box
|
|
164
|
+
* while keeping its proportions. Shows an invalid-config placeholder when the
|
|
165
|
+
* config cannot be parsed or misses required contract fields.
|
|
163
166
|
*
|
|
164
167
|
* @example
|
|
165
168
|
* <NativeRichMediaPreview
|
|
@@ -184,6 +187,7 @@ export function NativeRichMediaPreview(props) {
|
|
|
184
187
|
language,
|
|
185
188
|
width,
|
|
186
189
|
height,
|
|
190
|
+
scale = 1,
|
|
187
191
|
activeIndex = 0,
|
|
188
192
|
isLoading = false,
|
|
189
193
|
withBackground = true
|
|
@@ -200,18 +204,21 @@ export function NativeRichMediaPreview(props) {
|
|
|
200
204
|
width: width,
|
|
201
205
|
height: height,
|
|
202
206
|
"$withBackground": withBackground,
|
|
203
|
-
children: [_jsxs(
|
|
204
|
-
|
|
207
|
+
children: [_jsxs(ScaleViewport, {
|
|
208
|
+
"$scale": scale,
|
|
209
|
+
children: [_jsxs(BackdropLayer, {
|
|
210
|
+
children: [shouldDim && _jsx(NativeRichMediaDim, {}), !isLoading && config && renderBackdrop(config, activeIndex)]
|
|
211
|
+
}), !isLoading && config && _jsx(ScrollLayer, {
|
|
212
|
+
children: _jsx(ContentFlow, {
|
|
213
|
+
"$justify": justifyFor(config),
|
|
214
|
+
children: renderConfig(config, activeIndex)
|
|
215
|
+
})
|
|
216
|
+
}, config.displayType), !isLoading && config && renderChrome(config)]
|
|
205
217
|
}), isLoading && _jsx(SpinnerLayer, {
|
|
206
218
|
children: _jsx(Spinner, {
|
|
207
219
|
size: "medium",
|
|
208
220
|
color: Color.LOCKED
|
|
209
221
|
})
|
|
210
|
-
}), !isLoading && !config && _jsx(NativeRichMediaInvalidView, {})
|
|
211
|
-
children: _jsx(ContentFlow, {
|
|
212
|
-
"$justify": justifyFor(config),
|
|
213
|
-
children: renderConfig(config, activeIndex)
|
|
214
|
-
})
|
|
215
|
-
}, config.displayType), !isLoading && config && renderChrome(config)]
|
|
222
|
+
}), !isLoading && !config && _jsx(NativeRichMediaInvalidView, {})]
|
|
216
223
|
});
|
|
217
224
|
}
|
|
@@ -11,6 +11,9 @@ export declare const PreviewHost: import("styled-components").StyledComponent<"d
|
|
|
11
11
|
height: string | number;
|
|
12
12
|
$withBackground: boolean;
|
|
13
13
|
}, never>;
|
|
14
|
+
export declare const ScaleViewport: import("styled-components").StyledComponent<"div", any, {
|
|
15
|
+
$scale: number;
|
|
16
|
+
}, never>;
|
|
14
17
|
export declare const BackdropLayer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
15
18
|
export declare const ScrollLayer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
19
|
export declare const ContentFlow: import("styled-components").StyledComponent<"div", any, {
|
|
@@ -27,21 +27,31 @@ export const PreviewHost = styled.div.withConfig({
|
|
|
27
27
|
}) => toCssValue(width), ({
|
|
28
28
|
height
|
|
29
29
|
}) => toCssValue(height), FontFamily.MAIN);
|
|
30
|
+
export const ScaleViewport = styled.div.withConfig({
|
|
31
|
+
displayName: "ScaleViewport",
|
|
32
|
+
componentId: "sc-mc9ykd-2"
|
|
33
|
+
})(["position:absolute;top:0;left:0;width:", "%;height:", "%;transform:scale(", ");transform-origin:top left;"], ({
|
|
34
|
+
$scale
|
|
35
|
+
}) => 100 / $scale, ({
|
|
36
|
+
$scale
|
|
37
|
+
}) => 100 / $scale, ({
|
|
38
|
+
$scale
|
|
39
|
+
}) => $scale);
|
|
30
40
|
export const BackdropLayer = styled.div.withConfig({
|
|
31
41
|
displayName: "BackdropLayer",
|
|
32
|
-
componentId: "sc-mc9ykd-
|
|
42
|
+
componentId: "sc-mc9ykd-3"
|
|
33
43
|
})(["position:absolute;inset:0;"]);
|
|
34
44
|
export const ScrollLayer = styled.div.withConfig({
|
|
35
45
|
displayName: "ScrollLayer",
|
|
36
|
-
componentId: "sc-mc9ykd-
|
|
46
|
+
componentId: "sc-mc9ykd-4"
|
|
37
47
|
})(["position:absolute;inset:0;overflow-y:auto;overflow-x:hidden;"]);
|
|
38
48
|
export const ContentFlow = styled.div.withConfig({
|
|
39
49
|
displayName: "ContentFlow",
|
|
40
|
-
componentId: "sc-mc9ykd-
|
|
50
|
+
componentId: "sc-mc9ykd-5"
|
|
41
51
|
})(["position:relative;min-height:100%;width:100%;display:flex;flex-direction:column;justify-content:", ";"], ({
|
|
42
52
|
$justify
|
|
43
53
|
}) => $justify);
|
|
44
54
|
export const SpinnerLayer = styled.div.withConfig({
|
|
45
55
|
displayName: "SpinnerLayer",
|
|
46
|
-
componentId: "sc-mc9ykd-
|
|
56
|
+
componentId: "sc-mc9ykd-6"
|
|
47
57
|
})(["position:absolute;inset:0;display:flex;align-items:center;justify-content:center;"]);
|
|
@@ -301,6 +301,8 @@ export type NativeRichMediaPreviewProps = {
|
|
|
301
301
|
width: string | number;
|
|
302
302
|
/** Preview box height; number is treated as px. */
|
|
303
303
|
height: string | number;
|
|
304
|
+
/** Zoom of the rendered preview relative to the `width`/`height` box (default `1`). The content is laid out on a `box / scale` reference viewport and scaled to fill the box, so `0.5` fits a phone twice the box's size — the whole preview looks half as large while still filling the box. Use it to cram the layout into a small preview box without cramping its phone-sized proportions. Must be greater than `0`. */
|
|
305
|
+
scale?: number;
|
|
304
306
|
/** Index of the slide shown for `carousel`/`stories` (clamped to the items range, default `0`); ignored by other display types. */
|
|
305
307
|
activeIndex?: number;
|
|
306
308
|
/** Show a spinner instead of the content. */
|