@revenuecat/purchases-ui-js 0.0.8
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/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/components/button/Button.svelte +33 -0
- package/dist/components/button/Button.svelte.d.ts +8 -0
- package/dist/components/button/ButtonNode.stories.svelte +204 -0
- package/dist/components/button/ButtonNode.stories.svelte.d.ts +27 -0
- package/dist/components/button/ButtonNode.svelte +15 -0
- package/dist/components/button/ButtonNode.svelte.d.ts +3 -0
- package/dist/components/footer/Footer.stories.svelte +237 -0
- package/dist/components/footer/Footer.stories.svelte.d.ts +25 -0
- package/dist/components/footer/Footer.svelte +11 -0
- package/dist/components/footer/Footer.svelte.d.ts +3 -0
- package/dist/components/image/Image.stories.svelte +165 -0
- package/dist/components/image/Image.stories.svelte.d.ts +19 -0
- package/dist/components/image/Image.svelte +45 -0
- package/dist/components/image/Image.svelte.d.ts +3 -0
- package/dist/components/image/image-utils.d.ts +20 -0
- package/dist/components/image/image-utils.js +19 -0
- package/dist/components/package/Package.stories.svelte +243 -0
- package/dist/components/package/Package.stories.svelte.d.ts +25 -0
- package/dist/components/package/Package.svelte +39 -0
- package/dist/components/package/Package.svelte.d.ts +3 -0
- package/dist/components/paywall/Node.svelte +55 -0
- package/dist/components/paywall/Node.svelte.d.ts +9 -0
- package/dist/components/paywall/Paywall.stories.svelte +24 -0
- package/dist/components/paywall/Paywall.stories.svelte.d.ts +19 -0
- package/dist/components/paywall/Paywall.svelte +122 -0
- package/dist/components/paywall/Paywall.svelte.d.ts +6 -0
- package/dist/components/paywall/global-styles.css +9 -0
- package/dist/components/purchase-button/PurchaseButton.stories.svelte +133 -0
- package/dist/components/purchase-button/PurchaseButton.stories.svelte.d.ts +24 -0
- package/dist/components/purchase-button/PurchaseButton.svelte +28 -0
- package/dist/components/purchase-button/PurchaseButton.svelte.d.ts +3 -0
- package/dist/components/stack/Stack.stories.svelte +306 -0
- package/dist/components/stack/Stack.stories.svelte.d.ts +19 -0
- package/dist/components/stack/Stack.svelte +61 -0
- package/dist/components/stack/Stack.svelte.d.ts +3 -0
- package/dist/components/stack/stack-utils.d.ts +29 -0
- package/dist/components/stack/stack-utils.js +26 -0
- package/dist/components/text/Text.stories.svelte +101 -0
- package/dist/components/text/Text.stories.svelte.d.ts +19 -0
- package/dist/components/text/Text.svelte +40 -0
- package/dist/components/text/Text.svelte.d.ts +3 -0
- package/dist/components/text/text-utils.d.ts +20 -0
- package/dist/components/text/text-utils.js +34 -0
- package/dist/data/entities.d.ts +139 -0
- package/dist/data/entities.js +1 -0
- package/dist/data/state.d.ts +3 -0
- package/dist/data/state.js +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +11 -0
- package/dist/stores/theme.d.ts +1 -0
- package/dist/stores/theme.js +17 -0
- package/dist/stories/fixtures.d.ts +12 -0
- package/dist/stories/fixtures.js +6855 -0
- package/dist/stories/meta-templates.d.ts +13 -0
- package/dist/stories/meta-templates.js +156 -0
- package/dist/types.d.ts +125 -0
- package/dist/types.js +61 -0
- package/dist/utils.d.ts +93 -0
- package/dist/utils.js +227 -0
- package/package.json +91 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
|
+
import Image from "./Image.svelte";
|
|
4
|
+
import { colorModeStoryMeta } from "../../stories/meta-templates";
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
title: "Components/Image",
|
|
8
|
+
component: Image,
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
argTypes: {
|
|
11
|
+
id: { control: "text", description: "Unique identifier for the image" },
|
|
12
|
+
gradient_colors: {
|
|
13
|
+
control: "object",
|
|
14
|
+
description: "Gradient colors for the overlay",
|
|
15
|
+
},
|
|
16
|
+
colorMode: colorModeStoryMeta,
|
|
17
|
+
size: {
|
|
18
|
+
control: "object",
|
|
19
|
+
description: "Size configuration for the image",
|
|
20
|
+
},
|
|
21
|
+
max_height: {
|
|
22
|
+
control: "number",
|
|
23
|
+
description: "Maximum height of the image",
|
|
24
|
+
},
|
|
25
|
+
override_source_lid: {
|
|
26
|
+
control: "text",
|
|
27
|
+
description: "Override source lid",
|
|
28
|
+
},
|
|
29
|
+
fit_mode: {
|
|
30
|
+
control: { type: "select" },
|
|
31
|
+
options: ["fit", "fill"],
|
|
32
|
+
description: "Fit mode for the image",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<!-- Rectangle story -->
|
|
39
|
+
<Story
|
|
40
|
+
name="Rectangle"
|
|
41
|
+
args={{
|
|
42
|
+
id: "example-id",
|
|
43
|
+
fit_mode: "fit",
|
|
44
|
+
size: {
|
|
45
|
+
width: { type: "fill" },
|
|
46
|
+
height: { type: "fill" },
|
|
47
|
+
},
|
|
48
|
+
source: {
|
|
49
|
+
light: {
|
|
50
|
+
original: "https://placehold.co/600x400",
|
|
51
|
+
heic: "https://placehold.co/600x400",
|
|
52
|
+
heic_low_res: "https://placehold.co/600x400",
|
|
53
|
+
webp: "https://placehold.co/600x400",
|
|
54
|
+
webp_low_res: "https://placehold.co/600x400",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
colorMode: "light",
|
|
58
|
+
mask_shape: { type: "rectangle" },
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
<!-- Circle story -->
|
|
62
|
+
<Story
|
|
63
|
+
name="Circle"
|
|
64
|
+
args={{
|
|
65
|
+
id: "example-id",
|
|
66
|
+
fit_mode: "fit",
|
|
67
|
+
size: {
|
|
68
|
+
width: { type: "fill" },
|
|
69
|
+
height: { type: "fill" },
|
|
70
|
+
},
|
|
71
|
+
source: {
|
|
72
|
+
light: {
|
|
73
|
+
original: "https://placehold.co/600x400",
|
|
74
|
+
heic: "https://placehold.co/600x400",
|
|
75
|
+
heic_low_res: "https://placehold.co/600x400",
|
|
76
|
+
webp: "https://placehold.co/600x400",
|
|
77
|
+
webp_low_res: "https://placehold.co/600x400",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
colorMode: "light",
|
|
81
|
+
mask_shape: { type: "circle" },
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
<!-- Concave story -->
|
|
85
|
+
<Story
|
|
86
|
+
name="Concave"
|
|
87
|
+
args={{
|
|
88
|
+
id: "example-id",
|
|
89
|
+
fit_mode: "fit",
|
|
90
|
+
size: {
|
|
91
|
+
width: { type: "fill" },
|
|
92
|
+
height: { type: "fill" },
|
|
93
|
+
},
|
|
94
|
+
source: {
|
|
95
|
+
light: {
|
|
96
|
+
original: "https://placehold.co/600x400",
|
|
97
|
+
heic: "https://placehold.co/600x400",
|
|
98
|
+
heic_low_res: "https://placehold.co/600x400",
|
|
99
|
+
webp: "https://placehold.co/600x400",
|
|
100
|
+
webp_low_res: "https://placehold.co/600x400",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
colorMode: "light",
|
|
104
|
+
mask_shape: { type: "concave" },
|
|
105
|
+
}}
|
|
106
|
+
/>
|
|
107
|
+
<!-- Convex story -->
|
|
108
|
+
<Story
|
|
109
|
+
name="Convex"
|
|
110
|
+
args={{
|
|
111
|
+
id: "example-id",
|
|
112
|
+
fit_mode: "fit",
|
|
113
|
+
size: {
|
|
114
|
+
width: { type: "fill" },
|
|
115
|
+
height: { type: "fill" },
|
|
116
|
+
},
|
|
117
|
+
source: {
|
|
118
|
+
light: {
|
|
119
|
+
original: "https://placehold.co/600x400",
|
|
120
|
+
heic: "https://placehold.co/600x400",
|
|
121
|
+
heic_low_res: "https://placehold.co/600x400",
|
|
122
|
+
webp: "https://placehold.co/600x400",
|
|
123
|
+
webp_low_res: "https://placehold.co/600x400",
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
colorMode: "light",
|
|
127
|
+
mask_shape: { type: "convex" },
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
<!-- Gradient story -->
|
|
131
|
+
<Story
|
|
132
|
+
name="Background Gradient"
|
|
133
|
+
args={{
|
|
134
|
+
id: "example-id",
|
|
135
|
+
fit_mode: "fit",
|
|
136
|
+
size: {
|
|
137
|
+
width: { type: "fill" },
|
|
138
|
+
height: { type: "fill" },
|
|
139
|
+
},
|
|
140
|
+
source: {
|
|
141
|
+
light: {
|
|
142
|
+
original: "https://placehold.co/600x400",
|
|
143
|
+
heic: "https://placehold.co/600x400",
|
|
144
|
+
heic_low_res: "https://placehold.co/600x400",
|
|
145
|
+
webp: "https://placehold.co/600x400",
|
|
146
|
+
webp_low_res: "https://placehold.co/600x400",
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
colorMode: "light",
|
|
150
|
+
gradient_colors: [
|
|
151
|
+
{
|
|
152
|
+
dark: { type: "hex", value: "#FFFFFF80" },
|
|
153
|
+
light: { type: "hex", value: "#FFFFFF80" },
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
dark: { type: "hex", value: "#FFFFFF80" },
|
|
157
|
+
light: { type: "hex", value: "#FFFFFF80" },
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
dark: { type: "hex", value: "#000000" },
|
|
161
|
+
light: { type: "hex", value: "#000000" },
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Image from "./Image.svelte";
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Image: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Image = InstanceType<typeof Image>;
|
|
19
|
+
export default Image;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getImageComponentStyles } from "./image-utils";
|
|
3
|
+
import { stringifyStyles } from "../../utils";
|
|
4
|
+
import type { ImageProps } from "../../data/entities";
|
|
5
|
+
|
|
6
|
+
const { id, colorMode, source, ...restProps }: ImageProps = $props();
|
|
7
|
+
|
|
8
|
+
const { gradientStyles, imageStyles } = $derived(
|
|
9
|
+
getImageComponentStyles({ id, colorMode, source, ...restProps }),
|
|
10
|
+
);
|
|
11
|
+
const gradientStylesString = $derived(stringifyStyles(gradientStyles));
|
|
12
|
+
const imageStylesString = $derived(stringifyStyles(imageStyles));
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div
|
|
16
|
+
class="image-container"
|
|
17
|
+
id={`image-container-${id}`}
|
|
18
|
+
style={imageStylesString}
|
|
19
|
+
>
|
|
20
|
+
<img class="image" src={source[colorMode || "light"]?.original} alt="" {id} />
|
|
21
|
+
<span class="image-overlay" style={gradientStylesString}></span>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
.image-container {
|
|
26
|
+
position: relative;
|
|
27
|
+
height: var(--height, unset);
|
|
28
|
+
width: var(--width, unset);
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
border-radius: var(--corner-radius, unset);
|
|
31
|
+
clip-path: var(--clip-path, unset);
|
|
32
|
+
display: flex;
|
|
33
|
+
flex: 1 0 auto;
|
|
34
|
+
}
|
|
35
|
+
.image {
|
|
36
|
+
width: 100%;
|
|
37
|
+
height: 100%;
|
|
38
|
+
object-fit: cover;
|
|
39
|
+
}
|
|
40
|
+
.image-overlay {
|
|
41
|
+
position: absolute;
|
|
42
|
+
inset: 0;
|
|
43
|
+
background: var(--background, unset);
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ImageProps } from "../../data/entities";
|
|
2
|
+
type ImageStyleVariables = {
|
|
3
|
+
"--height": string;
|
|
4
|
+
"--width": string;
|
|
5
|
+
"--clip-path": string;
|
|
6
|
+
"--corner-radius": string;
|
|
7
|
+
};
|
|
8
|
+
type GradientStyleVariables = {
|
|
9
|
+
"--background": string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Generates comprehensive styles for image components by combining gradient and size styles
|
|
13
|
+
* @param props - Image component properties including gradient, mask and size
|
|
14
|
+
* @returns Object containing image style variables and gradient style variables
|
|
15
|
+
*/
|
|
16
|
+
export declare const getImageComponentStyles: (props: ImageProps) => {
|
|
17
|
+
imageStyles: ImageStyleVariables;
|
|
18
|
+
gradientStyles: GradientStyleVariables;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getGradientStyle, getMaskStyle, getSizeStyle } from "../../utils";
|
|
2
|
+
/**
|
|
3
|
+
* Generates comprehensive styles for image components by combining gradient and size styles
|
|
4
|
+
* @param props - Image component properties including gradient, mask and size
|
|
5
|
+
* @returns Object containing image style variables and gradient style variables
|
|
6
|
+
*/
|
|
7
|
+
export const getImageComponentStyles = (props) => {
|
|
8
|
+
const { gradient_colors, colorMode, mask_shape, size, max_height, // TODO: implement this. still waiting on spec
|
|
9
|
+
override_source_lid, // TODO: Implement this once structure is defined
|
|
10
|
+
} = props;
|
|
11
|
+
const gradientStyles = getGradientStyle(colorMode, gradient_colors);
|
|
12
|
+
const sizeStyles = getSizeStyle(size);
|
|
13
|
+
const maskStyles = getMaskStyle(mask_shape);
|
|
14
|
+
const imageStylesObject = {
|
|
15
|
+
...sizeStyles,
|
|
16
|
+
...maskStyles,
|
|
17
|
+
};
|
|
18
|
+
return { imageStyles: imageStylesObject, gradientStyles };
|
|
19
|
+
};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
|
+
import Package from "./Package.svelte";
|
|
4
|
+
import { colorModeStoryMeta } from "../../stories/meta-templates";
|
|
5
|
+
import type { Extra, SupportedActions } from "../../data/entities";
|
|
6
|
+
|
|
7
|
+
const onAction = (action: SupportedActions, data: Extra) => {
|
|
8
|
+
alert(`${action.type} ${JSON.stringify(data)}`);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const { Story } = defineMeta({
|
|
12
|
+
title: "Components/Package",
|
|
13
|
+
component: Package,
|
|
14
|
+
tags: ["autodocs"],
|
|
15
|
+
argTypes: {
|
|
16
|
+
colorMode: colorModeStoryMeta,
|
|
17
|
+
stack: {
|
|
18
|
+
control: { type: "object" },
|
|
19
|
+
description: "Stack configuration for package content",
|
|
20
|
+
table: {
|
|
21
|
+
type: {
|
|
22
|
+
summary: "object",
|
|
23
|
+
detail: "StackProps",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const labelsData = {
|
|
31
|
+
en_US: {
|
|
32
|
+
"BcX-6YwhoV": "Monthly",
|
|
33
|
+
QZ4ZmYsqjN: "$1.99",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<!-- Default -->
|
|
39
|
+
<Story
|
|
40
|
+
name="Default Package"
|
|
41
|
+
args={{
|
|
42
|
+
id: "6rQSD5e2Kz",
|
|
43
|
+
is_selected_by_default: false,
|
|
44
|
+
name: "Package - Monthly",
|
|
45
|
+
package_id: "$rc_annual",
|
|
46
|
+
stack: {
|
|
47
|
+
background_color: {
|
|
48
|
+
light: {
|
|
49
|
+
type: "hex",
|
|
50
|
+
value: "#09090b",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
labels: labelsData,
|
|
54
|
+
border: {
|
|
55
|
+
color: {
|
|
56
|
+
light: {
|
|
57
|
+
type: "hex",
|
|
58
|
+
value: "#3b393f",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
width: 1,
|
|
62
|
+
},
|
|
63
|
+
components: [
|
|
64
|
+
{
|
|
65
|
+
background_color: null,
|
|
66
|
+
color: {
|
|
67
|
+
light: {
|
|
68
|
+
type: "hex",
|
|
69
|
+
value: "#ffffff",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
labels: labelsData,
|
|
73
|
+
components: [],
|
|
74
|
+
font_name: null,
|
|
75
|
+
font_size: "heading_s",
|
|
76
|
+
font_weight: "bold",
|
|
77
|
+
horizontal_alignment: "center",
|
|
78
|
+
id: "aSK4Jf1zd4",
|
|
79
|
+
margin: {
|
|
80
|
+
bottom: 0,
|
|
81
|
+
leading: 0,
|
|
82
|
+
top: 0,
|
|
83
|
+
trailing: 0,
|
|
84
|
+
},
|
|
85
|
+
name: "Text",
|
|
86
|
+
padding: {
|
|
87
|
+
bottom: 0,
|
|
88
|
+
leading: 0,
|
|
89
|
+
top: 0,
|
|
90
|
+
trailing: 0,
|
|
91
|
+
},
|
|
92
|
+
size: {
|
|
93
|
+
height: {
|
|
94
|
+
type: "fit",
|
|
95
|
+
value: null,
|
|
96
|
+
},
|
|
97
|
+
width: {
|
|
98
|
+
type: "fit",
|
|
99
|
+
value: null,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
text_lid: "BcX-6YwhoV",
|
|
103
|
+
type: "text",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
background_color: {
|
|
107
|
+
light: {
|
|
108
|
+
type: "hex",
|
|
109
|
+
value: "#292631",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
labels: labelsData,
|
|
113
|
+
border: null,
|
|
114
|
+
components: [
|
|
115
|
+
{
|
|
116
|
+
background_color: null,
|
|
117
|
+
color: {
|
|
118
|
+
light: {
|
|
119
|
+
type: "hex",
|
|
120
|
+
value: "#ffffff",
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
components: [],
|
|
124
|
+
font_name: null,
|
|
125
|
+
font_size: "body_m",
|
|
126
|
+
font_weight: "extra_bold",
|
|
127
|
+
horizontal_alignment: "center",
|
|
128
|
+
id: "unosKAXGp4",
|
|
129
|
+
margin: {
|
|
130
|
+
bottom: 0,
|
|
131
|
+
leading: 0,
|
|
132
|
+
top: 0,
|
|
133
|
+
trailing: 0,
|
|
134
|
+
},
|
|
135
|
+
name: "Text",
|
|
136
|
+
padding: {
|
|
137
|
+
bottom: 8,
|
|
138
|
+
leading: 16,
|
|
139
|
+
top: 8,
|
|
140
|
+
trailing: 16,
|
|
141
|
+
},
|
|
142
|
+
size: {
|
|
143
|
+
height: {
|
|
144
|
+
type: "fit",
|
|
145
|
+
value: null,
|
|
146
|
+
},
|
|
147
|
+
width: {
|
|
148
|
+
type: "fit",
|
|
149
|
+
value: null,
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
text_lid: "QZ4ZmYsqjN",
|
|
153
|
+
type: "text",
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
dimension: {
|
|
157
|
+
alignment: "leading",
|
|
158
|
+
distribution: "space_between",
|
|
159
|
+
type: "vertical",
|
|
160
|
+
},
|
|
161
|
+
id: "-41AkrT2Ha",
|
|
162
|
+
margin: {
|
|
163
|
+
bottom: 0,
|
|
164
|
+
leading: 0,
|
|
165
|
+
top: 0,
|
|
166
|
+
trailing: 0,
|
|
167
|
+
},
|
|
168
|
+
name: "Stack",
|
|
169
|
+
padding: {
|
|
170
|
+
bottom: 0,
|
|
171
|
+
leading: 0,
|
|
172
|
+
top: 0,
|
|
173
|
+
trailing: 0,
|
|
174
|
+
},
|
|
175
|
+
shape: {
|
|
176
|
+
corners: {
|
|
177
|
+
bottom_leading: 8,
|
|
178
|
+
bottom_trailing: 8,
|
|
179
|
+
top_leading: 8,
|
|
180
|
+
top_trailing: 8,
|
|
181
|
+
},
|
|
182
|
+
type: "rectangle",
|
|
183
|
+
},
|
|
184
|
+
size: {
|
|
185
|
+
height: {
|
|
186
|
+
type: "fit",
|
|
187
|
+
value: null,
|
|
188
|
+
},
|
|
189
|
+
width: {
|
|
190
|
+
type: "fit",
|
|
191
|
+
value: null,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
spacing: 8,
|
|
195
|
+
type: "stack",
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
dimension: {
|
|
199
|
+
alignment: "center",
|
|
200
|
+
distribution: "space_between",
|
|
201
|
+
type: "horizontal",
|
|
202
|
+
},
|
|
203
|
+
id: "u0KZLUZTQT",
|
|
204
|
+
margin: {
|
|
205
|
+
bottom: 0,
|
|
206
|
+
leading: 16,
|
|
207
|
+
top: 16,
|
|
208
|
+
trailing: 16,
|
|
209
|
+
},
|
|
210
|
+
name: "Stack",
|
|
211
|
+
padding: {
|
|
212
|
+
bottom: 16,
|
|
213
|
+
leading: 16,
|
|
214
|
+
top: 16,
|
|
215
|
+
trailing: 16,
|
|
216
|
+
},
|
|
217
|
+
shape: {
|
|
218
|
+
corners: {
|
|
219
|
+
bottom_leading: 0,
|
|
220
|
+
bottom_trailing: 0,
|
|
221
|
+
top_leading: 8,
|
|
222
|
+
top_trailing: 8,
|
|
223
|
+
},
|
|
224
|
+
type: "rectangle",
|
|
225
|
+
},
|
|
226
|
+
size: {
|
|
227
|
+
height: {
|
|
228
|
+
type: "fit",
|
|
229
|
+
value: null,
|
|
230
|
+
},
|
|
231
|
+
width: {
|
|
232
|
+
type: "fixed",
|
|
233
|
+
value: 500,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
spacing: 8,
|
|
237
|
+
type: "stack",
|
|
238
|
+
},
|
|
239
|
+
onAction,
|
|
240
|
+
labels: labelsData,
|
|
241
|
+
type: "package",
|
|
242
|
+
}}
|
|
243
|
+
/>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Package from "./Package.svelte";
|
|
2
|
+
export declare const labelsData: {
|
|
3
|
+
en_US: {
|
|
4
|
+
"BcX-6YwhoV": string;
|
|
5
|
+
QZ4ZmYsqjN: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
9
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
10
|
+
$$bindings?: Bindings;
|
|
11
|
+
} & Exports;
|
|
12
|
+
(internal: unknown, props: {
|
|
13
|
+
$$events?: Events;
|
|
14
|
+
$$slots?: Slots;
|
|
15
|
+
}): Exports & {
|
|
16
|
+
$set?: any;
|
|
17
|
+
$on?: any;
|
|
18
|
+
};
|
|
19
|
+
z_$$bindings?: Bindings;
|
|
20
|
+
}
|
|
21
|
+
declare const Package: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
22
|
+
[evt: string]: CustomEvent<any>;
|
|
23
|
+
}, {}, {}, string>;
|
|
24
|
+
type Package = InstanceType<typeof Package>;
|
|
25
|
+
export default Package;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PackageProps, SelectPackageAction } from "../../data/entities";
|
|
3
|
+
import Stack from "../stack/Stack.svelte";
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
stack,
|
|
7
|
+
package_id,
|
|
8
|
+
labels,
|
|
9
|
+
id,
|
|
10
|
+
onAction,
|
|
11
|
+
purchaseState,
|
|
12
|
+
}: PackageProps = $props();
|
|
13
|
+
|
|
14
|
+
const onPackageClick = (evt: MouseEvent) => {
|
|
15
|
+
evt.preventDefault();
|
|
16
|
+
evt.stopPropagation();
|
|
17
|
+
onAction &&
|
|
18
|
+
onAction({ type: "select_package" } as SelectPackageAction, {
|
|
19
|
+
packageId: package_id,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const isSelected = $derived(purchaseState?.selectedPackageId === package_id);
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<div class="package" class:selected={isSelected} {id} onclick={onPackageClick}>
|
|
27
|
+
<Stack {...stack} {labels} {onAction} {purchaseState} />
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<style>
|
|
31
|
+
.package {
|
|
32
|
+
width: 100%;
|
|
33
|
+
display: flex;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.selected {
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Stack,
|
|
4
|
+
Text,
|
|
5
|
+
Button,
|
|
6
|
+
Image,
|
|
7
|
+
PurchaseButton,
|
|
8
|
+
Package,
|
|
9
|
+
Footer,
|
|
10
|
+
} from "../..";
|
|
11
|
+
import Self from "./Node.svelte";
|
|
12
|
+
import {
|
|
13
|
+
type ActionsProps,
|
|
14
|
+
type ComponentLocalizations,
|
|
15
|
+
type Extra,
|
|
16
|
+
type PaywallComponent,
|
|
17
|
+
type PurchaseStateProps,
|
|
18
|
+
type SupportedActions,
|
|
19
|
+
} from "../../data/entities";
|
|
20
|
+
import { prefersDarkMode } from "../../stores/theme";
|
|
21
|
+
import ButtonNode from "../button/ButtonNode.svelte";
|
|
22
|
+
import type { PurchaseState } from "../../data/state";
|
|
23
|
+
|
|
24
|
+
interface Props extends ActionsProps, PurchaseStateProps {
|
|
25
|
+
nodeData: PaywallComponent;
|
|
26
|
+
labels: ComponentLocalizations;
|
|
27
|
+
onAction?: (action: SupportedActions, data?: Extra) => void;
|
|
28
|
+
purchaseState?: PurchaseState;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { nodeData, labels, onAction, purchaseState }: Props = $props();
|
|
32
|
+
|
|
33
|
+
const ComponentTypes = {
|
|
34
|
+
text: Text,
|
|
35
|
+
stack: Stack,
|
|
36
|
+
image: Image,
|
|
37
|
+
button: ButtonNode,
|
|
38
|
+
purchase_button: PurchaseButton,
|
|
39
|
+
package: Package,
|
|
40
|
+
footer: Footer,
|
|
41
|
+
};
|
|
42
|
+
const MyComponent = $derived(ComponentTypes[nodeData.type]);
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<MyComponent
|
|
46
|
+
{...(nodeData as any) || {}}
|
|
47
|
+
{labels}
|
|
48
|
+
prefersDarkMode={$prefersDarkMode}
|
|
49
|
+
{onAction}
|
|
50
|
+
{purchaseState}
|
|
51
|
+
>
|
|
52
|
+
{#each nodeData.components as childData}
|
|
53
|
+
<Self nodeData={childData} {labels} {onAction} {purchaseState} />
|
|
54
|
+
{/each}
|
|
55
|
+
</MyComponent>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ActionsProps, type ComponentLocalizations, type Extra, type PaywallComponent, type PurchaseStateProps, type SupportedActions } from "../../data/entities";
|
|
2
|
+
import type { PurchaseState } from "../../data/state";
|
|
3
|
+
declare const Node: import("svelte").Component<ActionsProps & PurchaseStateProps & {
|
|
4
|
+
nodeData: PaywallComponent;
|
|
5
|
+
labels: ComponentLocalizations;
|
|
6
|
+
onAction?: (action: SupportedActions, data?: Extra) => void;
|
|
7
|
+
purchaseState?: PurchaseState;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
export default Node;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
|
+
|
|
4
|
+
import Paywall from "./Paywall.svelte";
|
|
5
|
+
import { paywallData } from "../../stories/fixtures";
|
|
6
|
+
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
title: "Example/Paywall",
|
|
9
|
+
component: Paywall,
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
argTypes: {},
|
|
12
|
+
args: {},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const onPurchaseClicked = (selectedPackageId: string) => {
|
|
16
|
+
alert(`Purchasing: ${selectedPackageId}`);
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<!-- Default story -->
|
|
21
|
+
<Story
|
|
22
|
+
name="Primary"
|
|
23
|
+
args={{ data: paywallData, onPurchaseClicked: onPurchaseClicked }}
|
|
24
|
+
/>
|