@revenuecat/purchases-ui-js 2.0.2 → 2.0.4
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/dist/components/button/ButtonNode.stories.svelte +66 -102
- package/dist/components/button/ButtonNode.svelte +18 -26
- package/dist/components/carousel/Carousel.stories.svelte +1039 -0
- package/dist/components/carousel/Carousel.stories.svelte.d.ts +19 -0
- package/dist/components/carousel/Carousel.svelte +298 -0
- package/dist/components/carousel/Carousel.svelte.d.ts +4 -0
- package/dist/components/carousel/CarouselPage.svelte +39 -0
- package/dist/components/carousel/CarouselPage.svelte.d.ts +11 -0
- package/dist/components/carousel/PageControl.svelte +93 -0
- package/dist/components/carousel/PageControl.svelte.d.ts +4 -0
- package/dist/components/carousel/carousel-utils.d.ts +4 -0
- package/dist/components/carousel/carousel-utils.js +21 -0
- package/dist/components/footer/Footer.stories.svelte +112 -102
- package/dist/components/footer/Footer.svelte +8 -4
- package/dist/components/icon/Icon.stories.svelte +100 -0
- package/dist/components/icon/Icon.stories.svelte.d.ts +19 -0
- package/dist/components/icon/Icon.svelte +73 -0
- package/dist/components/icon/Icon.svelte.d.ts +4 -0
- package/dist/components/image/ClipPath.svelte +49 -0
- package/dist/components/image/ClipPath.svelte.d.ts +9 -0
- package/dist/components/image/Image.stories.svelte +83 -188
- package/dist/components/image/Image.svelte +152 -136
- package/dist/components/image/Image.svelte.d.ts +1 -1
- package/dist/components/image/Overlay.svelte +36 -0
- package/dist/components/image/Overlay.svelte.d.ts +8 -0
- package/dist/components/package/Package.stories.svelte +10 -21
- package/dist/components/package/Package.svelte +8 -35
- package/dist/components/paywall/Node.svelte +25 -32
- package/dist/components/paywall/Node.svelte.d.ts +4 -6
- package/dist/components/paywall/Paywall.stories.svelte +36 -140
- package/dist/components/paywall/Paywall.svelte +23 -7
- package/dist/components/paywall/Paywall.svelte.d.ts +4 -2
- package/dist/components/paywall/fixtures/override-paywall.d.ts +2 -0
- package/dist/components/paywall/fixtures/override-paywall.js +1310 -0
- package/dist/components/paywall/fixtures/stack-paywall.d.ts +2 -0
- package/dist/components/paywall/fixtures/stack-paywall.js +5223 -0
- package/dist/components/paywall/fixtures/variables.d.ts +261 -0
- package/dist/components/paywall/fixtures/variables.js +262 -0
- package/dist/components/paywall/paywall-utils.d.ts +1 -1
- package/dist/components/purchase-button/PurchaseButton.stories.svelte +10 -21
- package/dist/components/purchase-button/PurchaseButton.svelte +2 -27
- package/dist/components/stack/Stack.stories.svelte +2354 -978
- package/dist/components/stack/Stack.svelte +116 -134
- package/dist/components/stack/Stack.svelte.d.ts +8 -2
- package/dist/components/stack/stack-utils.d.ts +10 -30
- package/dist/components/stack/stack-utils.js +77 -255
- package/dist/components/text/Text.svelte +3 -37
- package/dist/components/text/Text.svelte.d.ts +1 -2
- package/dist/components/text/TextNode.stories.svelte +10 -36
- package/dist/components/text/TextNode.svelte +25 -28
- package/dist/components/text/TextNode.svelte.d.ts +1 -1
- package/dist/components/text/text-utils.d.ts +4 -9
- package/dist/components/text/text-utils.js +32 -117
- package/dist/components/timeline/Timeline.stories.svelte +640 -251
- package/dist/components/timeline/Timeline.svelte +42 -28
- package/dist/components/timeline/Timeline.svelte.d.ts +1 -1
- package/dist/components/timeline/TimelineItem.svelte +80 -112
- package/dist/components/timeline/TimelineItem.svelte.d.ts +6 -2
- package/dist/components/timeline/timeline-utils.d.ts +24 -6
- package/dist/components/timeline/timeline-utils.js +21 -113
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/stores/color-mode.d.ts +1 -1
- package/dist/stores/paywall.d.ts +5 -2
- package/dist/stores/selected.d.ts +5 -0
- package/dist/stores/selected.js +12 -0
- package/dist/stores/variables.d.ts +1 -1
- package/dist/stores/variables.js +0 -1
- package/dist/stories/component-decorator.d.ts +2 -0
- package/dist/stories/component-decorator.js +12 -0
- package/dist/stories/fixtures.d.ts +6 -3
- package/dist/stories/fixtures.js +5214 -4422
- package/dist/stories/paywall-decorator.js +6 -0
- package/dist/stories/variables-decorator.d.ts +1 -1
- package/dist/stories/viewport-decorator.d.ts +2 -0
- package/dist/stories/viewport-decorator.js +8 -0
- package/dist/stories/viewport-wrapper.svelte +55 -0
- package/dist/stories/viewport-wrapper.svelte.d.ts +10 -0
- package/dist/stories/with-layout.d.ts +2 -10
- package/dist/stories/with-layout.js +3 -5
- package/dist/types/alignment.d.ts +5 -3
- package/dist/types/background.d.ts +6 -5
- package/dist/types/base.d.ts +7 -0
- package/dist/types/colors.d.ts +4 -4
- package/dist/types/component.d.ts +7 -2
- package/dist/types/components/button.d.ts +6 -1
- package/dist/types/components/carousel.d.ts +51 -0
- package/dist/types/components/carousel.js +1 -0
- package/dist/types/components/footer.d.ts +2 -1
- package/dist/types/components/icon.d.ts +28 -0
- package/dist/types/components/icon.js +1 -0
- package/dist/types/components/image.d.ts +20 -0
- package/dist/types/components/image.js +1 -0
- package/dist/types/components/package.d.ts +2 -1
- package/dist/types/components/purchase-button.d.ts +2 -1
- package/dist/types/components/stack.d.ts +32 -0
- package/dist/types/components/stack.js +1 -0
- package/dist/types/components/text.d.ts +20 -0
- package/dist/types/components/text.js +1 -0
- package/dist/types/components/timeline.d.ts +35 -0
- package/dist/types/components/timeline.js +1 -0
- package/dist/types/localization.d.ts +2 -1
- package/dist/types/media.d.ts +4 -3
- package/dist/types/overrides.d.ts +48 -0
- package/dist/types/overrides.js +1 -0
- package/dist/types/paywall.d.ts +27 -0
- package/dist/types/paywall.js +1 -0
- package/dist/types/ui-config.d.ts +20 -0
- package/dist/types/ui-config.js +1 -0
- package/dist/types/variables.d.ts +13 -0
- package/dist/types/variables.js +10 -0
- package/dist/types.d.ts +17 -9
- package/dist/ui/atoms/typography.stories.svelte +1 -27
- package/dist/ui/molecules/button.stories.svelte +3 -8
- package/dist/ui/theme/colors.d.ts +0 -6
- package/dist/ui/theme/colors.js +1 -1
- package/dist/ui/theme/text.d.ts +3 -4
- package/dist/ui/theme/utils.d.ts +0 -10
- package/dist/ui/theme/utils.js +5 -5
- package/dist/utils/background-utils.d.ts +4 -0
- package/dist/utils/background-utils.js +39 -0
- package/dist/utils/base-utils.d.ts +18 -0
- package/dist/utils/base-utils.js +124 -0
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.js +6 -1
- package/dist/utils/font-utils.d.ts +4 -0
- package/dist/utils/font-utils.js +47 -0
- package/dist/utils/style-utils.d.ts +7 -120
- package/dist/utils/style-utils.js +29 -304
- package/dist/utils/variable-utils.d.ts +1 -22
- package/dist/utils/variable-utils.js +28 -24
- package/dist/web-components/index.css +1 -1
- package/dist/web-components/index.js +1435 -980
- package/package.json +36 -26
- package/dist/components/button/button-utils.d.ts +0 -2
- package/dist/components/button/button-utils.js +0 -19
- package/dist/components/image/image-utils.d.ts +0 -19
- package/dist/components/image/image-utils.js +0 -33
- package/dist/components/purchase-button/purchase-button-utils.d.ts +0 -2
- package/dist/components/purchase-button/purchase-button-utils.js +0 -20
- package/dist/data/entities.d.ts +0 -162
- package/dist/stories/meta-templates.d.ts +0 -12
- package/dist/stories/meta-templates.js +0 -155
- /package/dist/{data/entities.js → types/base.js} +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ColorGradientInfo } from "../../types/colors";
|
|
3
|
+
|
|
4
|
+
interface OverlayProps {
|
|
5
|
+
id: string;
|
|
6
|
+
overlay: ColorGradientInfo | null | undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { id, overlay }: OverlayProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#if overlay?.type === "hex"}
|
|
13
|
+
<linearGradient {id} x1="0" y1="0" x2="100%" y2="100%">
|
|
14
|
+
<stop offset="0%" stop-color={overlay.value} />
|
|
15
|
+
<stop offset="100%" stop-color={overlay.value} />
|
|
16
|
+
</linearGradient>
|
|
17
|
+
{/if}
|
|
18
|
+
|
|
19
|
+
{#if overlay?.type === "linear"}
|
|
20
|
+
<linearGradient
|
|
21
|
+
{id}
|
|
22
|
+
gradientTransform={`rotate(${overlay.degrees - 90}, 0.5, 0.5)`}
|
|
23
|
+
>
|
|
24
|
+
{#each overlay.points as point}
|
|
25
|
+
<stop offset={`${point.percent}%`} stop-color={point.color} />
|
|
26
|
+
{/each}
|
|
27
|
+
</linearGradient>
|
|
28
|
+
{/if}
|
|
29
|
+
|
|
30
|
+
{#if overlay?.type === "radial"}
|
|
31
|
+
<radialGradient {id}>
|
|
32
|
+
{#each overlay.points as point}
|
|
33
|
+
<stop offset={`${point.percent}%`} stop-color={point.color} />
|
|
34
|
+
{/each}
|
|
35
|
+
</radialGradient>
|
|
36
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ColorGradientInfo } from "../../types/colors";
|
|
2
|
+
interface OverlayProps {
|
|
3
|
+
id: string;
|
|
4
|
+
overlay: ColorGradientInfo | null | undefined;
|
|
5
|
+
}
|
|
6
|
+
declare const Overlay: import("svelte").Component<OverlayProps, {}, "">;
|
|
7
|
+
type Overlay = ReturnType<typeof Overlay>;
|
|
8
|
+
export default Overlay;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import Package from "./Package.svelte";
|
|
3
|
+
import { componentDecorator } from "../../stories/component-decorator";
|
|
3
4
|
import { localizationDecorator } from "../../stories/localization-decorator";
|
|
5
|
+
import type { PackageProps } from "../../types/components/package";
|
|
4
6
|
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
5
7
|
|
|
6
8
|
const defaultLocale = "en_US";
|
|
@@ -10,8 +12,8 @@
|
|
|
10
12
|
const { Story } = defineMeta({
|
|
11
13
|
title: "Components/Package",
|
|
12
14
|
component: Package,
|
|
13
|
-
tags: ["autodocs"],
|
|
14
15
|
decorators: [
|
|
16
|
+
componentDecorator(),
|
|
15
17
|
localizationDecorator({
|
|
16
18
|
defaultLocale,
|
|
17
19
|
localizations: {
|
|
@@ -22,30 +24,21 @@
|
|
|
22
24
|
},
|
|
23
25
|
}),
|
|
24
26
|
],
|
|
25
|
-
argTypes: {
|
|
26
|
-
stack: {
|
|
27
|
-
control: { type: "object" },
|
|
28
|
-
description: "Stack configuration for package content",
|
|
29
|
-
table: {
|
|
30
|
-
type: {
|
|
31
|
-
summary: "object",
|
|
32
|
-
detail: "StackProps",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
27
|
});
|
|
38
28
|
</script>
|
|
39
29
|
|
|
40
|
-
<!-- Default -->
|
|
41
30
|
<Story
|
|
42
31
|
name="Default Package"
|
|
43
32
|
args={{
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
type: "package",
|
|
34
|
+
id: "package",
|
|
46
35
|
name: "Package - Monthly",
|
|
47
36
|
package_id: "$rc_monthly",
|
|
37
|
+
is_selected_by_default: true,
|
|
48
38
|
stack: {
|
|
39
|
+
type: "stack",
|
|
40
|
+
id: "stack",
|
|
41
|
+
name: "Stack",
|
|
49
42
|
background_color: {
|
|
50
43
|
light: {
|
|
51
44
|
type: "hex",
|
|
@@ -208,14 +201,12 @@
|
|
|
208
201
|
distribution: "space_between",
|
|
209
202
|
type: "horizontal",
|
|
210
203
|
},
|
|
211
|
-
id: "u0KZLUZTQT",
|
|
212
204
|
margin: {
|
|
213
205
|
bottom: 0,
|
|
214
206
|
leading: 16,
|
|
215
207
|
top: 16,
|
|
216
208
|
trailing: 16,
|
|
217
209
|
},
|
|
218
|
-
name: "Stack",
|
|
219
210
|
padding: {
|
|
220
211
|
bottom: 16,
|
|
221
212
|
leading: 16,
|
|
@@ -241,9 +232,7 @@
|
|
|
241
232
|
},
|
|
242
233
|
},
|
|
243
234
|
spacing: 8,
|
|
244
|
-
type: "stack",
|
|
245
235
|
shadow: null,
|
|
246
236
|
},
|
|
247
|
-
|
|
248
|
-
}}
|
|
237
|
+
} satisfies PackageProps}
|
|
249
238
|
/>
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import Stack from "../stack/Stack.svelte";
|
|
3
3
|
import { getPaywallContext } from "../../stores/paywall";
|
|
4
|
+
import { setSelectedStateContext } from "../../stores/selected";
|
|
4
5
|
import {
|
|
5
6
|
getVariablesContext,
|
|
6
7
|
setVariablesContext,
|
|
7
8
|
} from "../../stores/variables";
|
|
8
9
|
import type { PackageProps } from "../../types/components/package";
|
|
9
|
-
import { prefixObject, stringifyStyles } from "../../utils/style-utils";
|
|
10
10
|
import { derived } from "svelte/store";
|
|
11
11
|
|
|
12
|
-
const { stack, package_id
|
|
12
|
+
const { stack, package_id }: PackageProps = $props();
|
|
13
13
|
|
|
14
14
|
const { selectedPackageId, variablesPerPackage } = getPaywallContext();
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
setSelectedStateContext(package_id);
|
|
17
|
+
|
|
18
|
+
const onPackageClick = () => {
|
|
19
|
+
$selectedPackageId = package_id;
|
|
20
|
+
};
|
|
17
21
|
|
|
18
22
|
const fallbackVariables = getVariablesContext();
|
|
19
23
|
const variables = derived(
|
|
@@ -21,37 +25,6 @@
|
|
|
21
25
|
(fallback) => $variablesPerPackage?.[package_id] ?? fallback,
|
|
22
26
|
);
|
|
23
27
|
setVariablesContext(variables);
|
|
24
|
-
|
|
25
|
-
const componentState = $derived({
|
|
26
|
-
selected: $selectedPackageId === package_id,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const styles = $derived(
|
|
30
|
-
stringifyStyles(prefixObject(zStackChildStyles, "package")),
|
|
31
|
-
);
|
|
32
28
|
</script>
|
|
33
29
|
|
|
34
|
-
<
|
|
35
|
-
class="rc-pw-package"
|
|
36
|
-
class:selected={componentState.selected}
|
|
37
|
-
{id}
|
|
38
|
-
onclick={onPackageClick}
|
|
39
|
-
style={styles}
|
|
40
|
-
>
|
|
41
|
-
<Stack {...stack} {componentState} />
|
|
42
|
-
</button>
|
|
43
|
-
|
|
44
|
-
<style>
|
|
45
|
-
.rc-pw-package {
|
|
46
|
-
width: 100%;
|
|
47
|
-
display: flex;
|
|
48
|
-
margin: 0;
|
|
49
|
-
padding: 0;
|
|
50
|
-
background: initial;
|
|
51
|
-
border: initial;
|
|
52
|
-
text-align: initial;
|
|
53
|
-
position: var(--package-position, relative);
|
|
54
|
-
inset: var(--package-inset, 0);
|
|
55
|
-
transform: var(--package-transform, initial);
|
|
56
|
-
}
|
|
57
|
-
</style>
|
|
30
|
+
<Stack {...stack} onclick={onPackageClick} />
|
|
@@ -8,37 +8,38 @@
|
|
|
8
8
|
Timeline,
|
|
9
9
|
} from "../..";
|
|
10
10
|
import ButtonNode from "../button/ButtonNode.svelte";
|
|
11
|
-
import type { ZStackChildStyles } from "../stack/stack-utils";
|
|
12
11
|
import TextNode from "../text/TextNode.svelte";
|
|
13
|
-
import type { ComponentState } from "../../data/entities";
|
|
14
12
|
import type { Component } from "../../types/component";
|
|
15
13
|
import type { Component as SvelteComponent } from "svelte";
|
|
16
|
-
import
|
|
14
|
+
import Carousel from "../carousel/Carousel.svelte";
|
|
15
|
+
import Icon from "../icon/Icon.svelte";
|
|
17
16
|
|
|
18
17
|
type SupportedComponents =
|
|
19
|
-
| TextNode
|
|
20
|
-
| Stack
|
|
21
|
-
| Image
|
|
22
18
|
| ButtonNode
|
|
23
|
-
|
|
|
24
|
-
| Package
|
|
19
|
+
| Carousel
|
|
25
20
|
| Footer
|
|
21
|
+
| Icon
|
|
22
|
+
| Image
|
|
23
|
+
| Package
|
|
24
|
+
| PurchaseButton
|
|
25
|
+
| Stack
|
|
26
|
+
| TextNode
|
|
26
27
|
| Timeline;
|
|
27
28
|
|
|
28
29
|
interface Props {
|
|
29
30
|
nodeData: Component;
|
|
30
|
-
zStackChildStyles?: ZStackChildStyles;
|
|
31
|
-
componentState?: ComponentState;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
const ComponentTypes = {
|
|
35
|
-
stack: Stack,
|
|
36
|
-
text: TextNode,
|
|
37
|
-
image: Image,
|
|
38
34
|
button: ButtonNode,
|
|
39
|
-
|
|
40
|
-
package: Package,
|
|
35
|
+
carousel: Carousel,
|
|
41
36
|
footer: Footer,
|
|
37
|
+
icon: Icon,
|
|
38
|
+
image: Image,
|
|
39
|
+
package: Package,
|
|
40
|
+
purchase_button: PurchaseButton,
|
|
41
|
+
stack: Stack,
|
|
42
|
+
text: TextNode,
|
|
42
43
|
timeline: Timeline,
|
|
43
44
|
} satisfies {
|
|
44
45
|
[key in Component["type"]]: SvelteComponent<
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
*/
|
|
58
59
|
export const getComponentClass: (
|
|
59
60
|
nodeData: Component,
|
|
60
|
-
) => [SvelteComponent<SupportedComponents>, Component] = (
|
|
61
|
+
) => [SvelteComponent<SupportedComponents>, Component] | undefined = (
|
|
61
62
|
nodeData: Component,
|
|
62
63
|
) => {
|
|
63
64
|
if (ComponentTypes[nodeData.type]) {
|
|
@@ -75,26 +76,18 @@
|
|
|
75
76
|
];
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
//
|
|
79
|
+
// Manually throwing error for this specific case until
|
|
79
80
|
// it's handled with fallback components
|
|
80
|
-
throw new Error(`Invalid component type: ${nodeData.type}`);
|
|
81
|
+
// throw new Error(`Invalid component type: ${nodeData.type}`);
|
|
81
82
|
};
|
|
82
83
|
|
|
83
|
-
const { nodeData,
|
|
84
|
-
|
|
85
|
-
const [ComponentToRender, dataToUse] = $derived(getComponentClass(nodeData));
|
|
84
|
+
const { nodeData, ...restProps }: Props = $props();
|
|
86
85
|
|
|
87
|
-
const
|
|
88
|
-
(
|
|
86
|
+
const [ComponentToRender, dataToUse] = $derived(
|
|
87
|
+
getComponentClass(nodeData) ?? [],
|
|
89
88
|
);
|
|
90
89
|
</script>
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
{...(dataToUse as any) || {}}
|
|
94
|
-
|
|
95
|
-
{...restProps}
|
|
96
|
-
>
|
|
97
|
-
{#each components as childData}
|
|
98
|
-
<Self nodeData={childData} {...restProps} />
|
|
99
|
-
{/each}
|
|
100
|
-
</ComponentToRender>
|
|
91
|
+
{#if ComponentToRender}
|
|
92
|
+
<ComponentToRender {...(dataToUse as any) || {}} {...restProps} />
|
|
93
|
+
{/if}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
import { Footer, Image, Package, PurchaseButton, Stack, Timeline } from "../..";
|
|
3
3
|
import ButtonNode from "../button/ButtonNode.svelte";
|
|
4
|
-
import type { ZStackChildStyles } from "../stack/stack-utils";
|
|
5
4
|
import TextNode from "../text/TextNode.svelte";
|
|
6
|
-
import type { ComponentState } from "../../data/entities";
|
|
7
5
|
import type { Component } from "../../types/component";
|
|
8
|
-
|
|
6
|
+
import Carousel from "../carousel/Carousel.svelte";
|
|
7
|
+
import Icon from "../icon/Icon.svelte";
|
|
8
|
+
type SupportedComponents = ButtonNode | Carousel | Footer | Icon | Image | Package | PurchaseButton | Stack | TextNode | Timeline;
|
|
9
9
|
interface Props {
|
|
10
10
|
nodeData: Component;
|
|
11
|
-
zStackChildStyles?: ZStackChildStyles;
|
|
12
|
-
componentState?: ComponentState;
|
|
13
11
|
}
|
|
14
12
|
declare const Node: import("svelte").Component<Props, {
|
|
15
13
|
/**
|
|
@@ -20,7 +18,7 @@ declare const Node: import("svelte").Component<Props, {
|
|
|
20
18
|
* @param nodeData:Component - the Component object representing a Node in the paywall
|
|
21
19
|
* @returns [Component<SupportedComponents>, Component] - a tuple containing the component class and the node data
|
|
22
20
|
* @throws Error - if the component type and the fallback component type are not supported
|
|
23
|
-
*/ getComponentClass: (nodeData: Component) => [SvelteComponent<SupportedComponents>, Component];
|
|
21
|
+
*/ getComponentClass: (nodeData: Component) => [SvelteComponent<SupportedComponents>, Component] | undefined;
|
|
24
22
|
}, "">;
|
|
25
23
|
type Node = ReturnType<typeof Node>;
|
|
26
24
|
export default Node;
|
|
@@ -6,25 +6,26 @@
|
|
|
6
6
|
alignmentPaywallData,
|
|
7
7
|
calmPaywallData,
|
|
8
8
|
colorModeOverrideTemplate,
|
|
9
|
-
e2eTestTemplate,
|
|
10
9
|
errorPaywallData,
|
|
11
10
|
fallbackPaywallData,
|
|
12
11
|
fontsPaywallData,
|
|
13
12
|
gradientPaywallData,
|
|
13
|
+
listTemplate,
|
|
14
14
|
pastaPaywallData,
|
|
15
15
|
paywallData,
|
|
16
16
|
paywallWithFooter,
|
|
17
17
|
posterMakerTemplate,
|
|
18
|
-
|
|
18
|
+
timelineTemplate,
|
|
19
|
+
uiConfigData,
|
|
19
20
|
zStackTemplate,
|
|
20
21
|
} from "../../stories/fixtures";
|
|
21
|
-
import
|
|
22
|
+
import { OVERRIDE_PAYWALL } from "./fixtures/override-paywall";
|
|
23
|
+
import { STACK_PAYWALL } from "./fixtures/stack-paywall";
|
|
24
|
+
import { VARIABLES } from "./fixtures/variables";
|
|
22
25
|
|
|
23
26
|
const { Story } = defineMeta({
|
|
24
27
|
title: "Example/Paywall",
|
|
25
28
|
component: Paywall,
|
|
26
|
-
tags: ["autodocs"],
|
|
27
|
-
argTypes: {},
|
|
28
29
|
args: {
|
|
29
30
|
onPurchaseClicked: (selectedPackageId: string) =>
|
|
30
31
|
alert(`Purchase package ${selectedPackageId}`),
|
|
@@ -32,11 +33,26 @@
|
|
|
32
33
|
onVisitCustomerCenterClicked: () => alert("Visit customer center"),
|
|
33
34
|
onRestorePurchasesClicked: () => alert("Restore purchases"),
|
|
34
35
|
onNavigateToUrlClicked: (url: string) => alert(`Navigate to ${url}`),
|
|
36
|
+
uiConfig: uiConfigData,
|
|
37
|
+
variablesPerPackage: VARIABLES,
|
|
35
38
|
},
|
|
36
39
|
});
|
|
37
40
|
</script>
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
<Story
|
|
43
|
+
name="Stack paywall"
|
|
44
|
+
args={{
|
|
45
|
+
paywallData: STACK_PAYWALL,
|
|
46
|
+
}}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<Story
|
|
50
|
+
name="Override paywall"
|
|
51
|
+
args={{
|
|
52
|
+
paywallData: OVERRIDE_PAYWALL,
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
|
|
40
56
|
<Story
|
|
41
57
|
name="Primary"
|
|
42
58
|
args={{
|
|
@@ -75,30 +91,6 @@
|
|
|
75
91
|
selectedLocale: "en_US",
|
|
76
92
|
}}
|
|
77
93
|
/>
|
|
78
|
-
<Story
|
|
79
|
-
name="Pasta paywall example(with variables)"
|
|
80
|
-
args={{
|
|
81
|
-
paywallData: variablesPastaPaywallData,
|
|
82
|
-
selectedLocale: "en_US",
|
|
83
|
-
variablesPerPackage: {
|
|
84
|
-
trial: {
|
|
85
|
-
product_name: "This was a variable: Product A",
|
|
86
|
-
price: "$19.99",
|
|
87
|
-
price_per_period: "$19.99/yr",
|
|
88
|
-
} as VariableDictionary,
|
|
89
|
-
$rc_weekly: {
|
|
90
|
-
product_name: "This was a variable: Product B",
|
|
91
|
-
price: "$29.99",
|
|
92
|
-
price_per_period: "$29.99/yr",
|
|
93
|
-
} as VariableDictionary,
|
|
94
|
-
$rc_daily: {
|
|
95
|
-
product_name: "This was a variable: Product C",
|
|
96
|
-
price: "$39.99",
|
|
97
|
-
price_per_period: "$19.99/yr",
|
|
98
|
-
} as VariableDictionary,
|
|
99
|
-
},
|
|
100
|
-
}}
|
|
101
|
-
/>
|
|
102
94
|
|
|
103
95
|
<Story
|
|
104
96
|
name="Calm paywall example"
|
|
@@ -115,47 +107,6 @@
|
|
|
115
107
|
}}
|
|
116
108
|
/>
|
|
117
109
|
|
|
118
|
-
<Story
|
|
119
|
-
name="Dynamic state style overrides"
|
|
120
|
-
args={{
|
|
121
|
-
paywallData: e2eTestTemplate,
|
|
122
|
-
}}
|
|
123
|
-
/>
|
|
124
|
-
|
|
125
|
-
<Story
|
|
126
|
-
name="Dynamic state style overrides with background image"
|
|
127
|
-
args={{
|
|
128
|
-
paywallData: {
|
|
129
|
-
...e2eTestTemplate,
|
|
130
|
-
components_config: {
|
|
131
|
-
...e2eTestTemplate.components_config,
|
|
132
|
-
base: {
|
|
133
|
-
...e2eTestTemplate.components_config.base,
|
|
134
|
-
background: {
|
|
135
|
-
type: "image",
|
|
136
|
-
fit_mode: "fit",
|
|
137
|
-
color_overlay: null,
|
|
138
|
-
value: {
|
|
139
|
-
light: {
|
|
140
|
-
width: 1792,
|
|
141
|
-
height: 1024,
|
|
142
|
-
original: "https://assets.pawwalls.com/1005820_1732028636.jpeg",
|
|
143
|
-
heic: "https://assets.pawwalls.com/1005820_1732028636.heic",
|
|
144
|
-
heic_low_res:
|
|
145
|
-
"https://assets.pawwalls.com/1005820_low_res_1732028636.heic",
|
|
146
|
-
webp: "https://assets.pawwalls.com/1005820_1732028636.webp",
|
|
147
|
-
webp_low_res:
|
|
148
|
-
"https://assets.pawwalls.com/1005820_low_res_1732028636.webp",
|
|
149
|
-
},
|
|
150
|
-
dark: null,
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
}}
|
|
157
|
-
/>
|
|
158
|
-
|
|
159
110
|
<Story
|
|
160
111
|
name="Poster Maker"
|
|
161
112
|
args={{
|
|
@@ -163,75 +114,6 @@
|
|
|
163
114
|
}}
|
|
164
115
|
/>
|
|
165
116
|
|
|
166
|
-
<Story
|
|
167
|
-
name="E2E Test with variables"
|
|
168
|
-
args={{
|
|
169
|
-
paywallData: e2eTestTemplate,
|
|
170
|
-
variablesPerPackage: {
|
|
171
|
-
$rc_annual: {
|
|
172
|
-
product_name: "Yearly sub",
|
|
173
|
-
price: "$19.99",
|
|
174
|
-
price_per_period: "$19.99/1yr",
|
|
175
|
-
price_per_period_full: "$19.99/1year",
|
|
176
|
-
total_price_and_per_month: "$19.99/1yr($1.67/mo)",
|
|
177
|
-
total_price_and_per_month_full: "$19.99/1year($1.67/month)",
|
|
178
|
-
sub_price_per_month: "$1.67",
|
|
179
|
-
sub_price_per_week: "$0.42",
|
|
180
|
-
sub_duration: "1 year",
|
|
181
|
-
sub_duration_in_months: "12 months",
|
|
182
|
-
sub_period: "yearly",
|
|
183
|
-
sub_period_length: "year",
|
|
184
|
-
sub_period_abbreviated: "yr",
|
|
185
|
-
sub_relative_discount: "33% off",
|
|
186
|
-
sub_offer_duration: "undefined",
|
|
187
|
-
sub_offer_duration_2: "undefined",
|
|
188
|
-
sub_offer_price: "undefined",
|
|
189
|
-
sub_offer_price_2: "undefined",
|
|
190
|
-
},
|
|
191
|
-
$rc_monthly: {
|
|
192
|
-
product_name: "Monthly sub",
|
|
193
|
-
price: "$30.00",
|
|
194
|
-
price_per_period: "$30.00/1mo",
|
|
195
|
-
price_per_period_full: "$30.00/1month",
|
|
196
|
-
total_price_and_per_month: "$30.00",
|
|
197
|
-
total_price_and_per_month_full: "$30.00",
|
|
198
|
-
sub_price_per_month: "$30.00",
|
|
199
|
-
sub_price_per_week: "$30.00",
|
|
200
|
-
sub_duration: "1 month",
|
|
201
|
-
sub_duration_in_months: "1 month",
|
|
202
|
-
sub_period: "monthly",
|
|
203
|
-
sub_period_length: "month",
|
|
204
|
-
sub_period_abbreviated: "mo",
|
|
205
|
-
sub_relative_discount: "",
|
|
206
|
-
sub_offer_duration: "undefined",
|
|
207
|
-
sub_offer_duration_2: "undefined",
|
|
208
|
-
sub_offer_price: "undefined",
|
|
209
|
-
sub_offer_price_2: "undefined",
|
|
210
|
-
},
|
|
211
|
-
$rc_weekly: {
|
|
212
|
-
product_name: "Weekly no trial",
|
|
213
|
-
price: "$1.25",
|
|
214
|
-
price_per_period: "$1.25/1wk",
|
|
215
|
-
price_per_period_full: "$1.25/1week",
|
|
216
|
-
total_price_and_per_month: "$1.25/1wk($5.00/mo)",
|
|
217
|
-
total_price_and_per_month_full: "$1.25/1week($5.00/month)",
|
|
218
|
-
sub_price_per_month: "$5.00",
|
|
219
|
-
sub_price_per_week: "$1.25",
|
|
220
|
-
sub_duration: "1 week",
|
|
221
|
-
sub_duration_in_months: "1 week",
|
|
222
|
-
sub_period: "weekly",
|
|
223
|
-
sub_period_length: "week",
|
|
224
|
-
sub_period_abbreviated: "wk",
|
|
225
|
-
sub_relative_discount: "96% off",
|
|
226
|
-
sub_offer_duration: "undefined",
|
|
227
|
-
sub_offer_duration_2: "undefined",
|
|
228
|
-
sub_offer_price: "undefined",
|
|
229
|
-
sub_offer_price_2: "undefined",
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
}}
|
|
233
|
-
/>
|
|
234
|
-
|
|
235
117
|
<Story
|
|
236
118
|
name="Z Stack"
|
|
237
119
|
args={{
|
|
@@ -271,3 +153,17 @@
|
|
|
271
153
|
paywallData: paywallWithFooter,
|
|
272
154
|
}}
|
|
273
155
|
/>
|
|
156
|
+
|
|
157
|
+
<Story
|
|
158
|
+
name="Timeline"
|
|
159
|
+
args={{
|
|
160
|
+
paywallData: timelineTemplate,
|
|
161
|
+
}}
|
|
162
|
+
/>
|
|
163
|
+
|
|
164
|
+
<Story
|
|
165
|
+
name="List"
|
|
166
|
+
args={{
|
|
167
|
+
paywallData: listTemplate,
|
|
168
|
+
}}
|
|
169
|
+
/>
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { PaywallData, StackProps } from "../../data/entities";
|
|
3
|
-
|
|
4
2
|
import Footer from "../footer/Footer.svelte";
|
|
5
3
|
import Node from "./Node.svelte";
|
|
6
4
|
import {
|
|
@@ -16,14 +14,19 @@
|
|
|
16
14
|
} from "../../stores/variables";
|
|
17
15
|
import type { ColorMode } from "../../types";
|
|
18
16
|
import type { Action } from "../../types/components/button";
|
|
17
|
+
import type { PaywallData } from "../../types/paywall";
|
|
18
|
+
import type { UIConfig } from "../../types/ui-config";
|
|
19
|
+
import type { VariableDictionary } from "../../types/variables";
|
|
20
|
+
import { registerFonts } from "../../utils/font-utils";
|
|
19
21
|
import { findSelectedPackageId } from "../../utils/style-utils";
|
|
20
|
-
import {
|
|
22
|
+
import { onMount } from "svelte";
|
|
21
23
|
import { derived, readable, writable } from "svelte/store";
|
|
22
24
|
|
|
23
25
|
interface Props {
|
|
24
26
|
paywallData: PaywallData;
|
|
25
27
|
selectedLocale?: string;
|
|
26
28
|
variablesPerPackage?: Record<string, VariableDictionary>;
|
|
29
|
+
uiConfig: UIConfig;
|
|
27
30
|
preferredColorMode?: ColorMode;
|
|
28
31
|
onPurchaseClicked?: (selectedPackageId: string) => void;
|
|
29
32
|
onBackClicked?: () => void;
|
|
@@ -44,6 +47,7 @@
|
|
|
44
47
|
onRestorePurchasesClicked,
|
|
45
48
|
onNavigateToUrlClicked,
|
|
46
49
|
onError,
|
|
50
|
+
uiConfig,
|
|
47
51
|
}: Props = $props();
|
|
48
52
|
|
|
49
53
|
const getColorMode = setColorModeContext(() => preferredColorMode);
|
|
@@ -101,6 +105,7 @@
|
|
|
101
105
|
variablesPerPackage: readable(variablesPerPackage),
|
|
102
106
|
onPurchase,
|
|
103
107
|
onButtonAction,
|
|
108
|
+
uiConfig,
|
|
104
109
|
});
|
|
105
110
|
|
|
106
111
|
const variables: VariablesStore = derived(
|
|
@@ -119,6 +124,10 @@
|
|
|
119
124
|
const backgroundImgSource = $derived(
|
|
120
125
|
getBackgroundImageSource(paywallData, colorMode),
|
|
121
126
|
);
|
|
127
|
+
|
|
128
|
+
onMount(() => {
|
|
129
|
+
registerFonts(uiConfig);
|
|
130
|
+
});
|
|
122
131
|
</script>
|
|
123
132
|
|
|
124
133
|
<svelte:boundary onerror={onError}>
|
|
@@ -128,8 +137,7 @@
|
|
|
128
137
|
{#if paywallData.components_config.base.sticky_footer}
|
|
129
138
|
<Footer
|
|
130
139
|
{...paywallData.components_config.base.sticky_footer}
|
|
131
|
-
stack={paywallData.components_config.base.sticky_footer
|
|
132
|
-
.stack as StackProps}
|
|
140
|
+
stack={paywallData.components_config.base.sticky_footer.stack}
|
|
133
141
|
/>
|
|
134
142
|
{/if}
|
|
135
143
|
{#if paywallData.components_config.base.background?.type === "color"}
|
|
@@ -145,8 +153,16 @@
|
|
|
145
153
|
<style>
|
|
146
154
|
.rc-pw-paywall {
|
|
147
155
|
position: relative;
|
|
148
|
-
display:
|
|
149
|
-
|
|
156
|
+
display: flex;
|
|
157
|
+
flex-direction: column;
|
|
158
|
+
align-items: stretch;
|
|
159
|
+
height: 100%;
|
|
160
|
+
overflow: hidden;
|
|
161
|
+
|
|
162
|
+
& > :global(*:first-child) {
|
|
163
|
+
flex-grow: 1;
|
|
164
|
+
overflow-y: auto;
|
|
165
|
+
}
|
|
150
166
|
}
|
|
151
167
|
|
|
152
168
|
.rc-pw-paywall-background {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { PaywallData } from "../../data/entities";
|
|
2
1
|
import type { ColorMode } from "../../types";
|
|
3
|
-
import {
|
|
2
|
+
import type { PaywallData } from "../../types/paywall";
|
|
3
|
+
import type { UIConfig } from "../../types/ui-config";
|
|
4
|
+
import type { VariableDictionary } from "../../types/variables";
|
|
4
5
|
interface Props {
|
|
5
6
|
paywallData: PaywallData;
|
|
6
7
|
selectedLocale?: string;
|
|
7
8
|
variablesPerPackage?: Record<string, VariableDictionary>;
|
|
9
|
+
uiConfig: UIConfig;
|
|
8
10
|
preferredColorMode?: ColorMode;
|
|
9
11
|
onPurchaseClicked?: (selectedPackageId: string) => void;
|
|
10
12
|
onBackClicked?: () => void;
|