@revenuecat/purchases-ui-js 0.0.14 → 0.0.16
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/image/Image.svelte +1 -1
- package/dist/components/image/image-utils.js +12 -7
- package/dist/components/package/Package.svelte +6 -2
- package/dist/components/paywall/Paywall.stories.svelte +57 -0
- package/dist/components/paywall/Paywall.svelte +48 -3
- package/dist/components/paywall/paywall-utils.d.ts +7 -0
- package/dist/components/paywall/paywall-utils.js +21 -0
- package/dist/components/stack/stack-utils.js +9 -4
- package/dist/components/text/Text.svelte +3 -2
- package/dist/components/text/TextNode.stories.svelte +118 -1
- package/dist/components/text/TextNode.svelte +34 -4
- package/dist/components/text/text-utils.d.ts +4 -2
- package/dist/components/text/text-utils.js +6 -5
- package/dist/data/entities.d.ts +36 -5
- package/dist/stories/fixtures.d.ts +3 -0
- package/dist/stories/fixtures.js +4760 -35
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utils/style-utils.d.ts +4 -7
- package/dist/utils/style-utils.js +43 -13
- package/package.json +13 -3
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { getGradientStyle, getMaskStyle, getSizeStyle, } from "../../utils/style-utils";
|
|
1
|
+
import { getActiveStateProps, getGradientStyle, getMaskStyle, getSizeStyle, } from "../../utils/style-utils";
|
|
2
2
|
/**
|
|
3
3
|
* Generates comprehensive styles for image components by combining gradient and size styles
|
|
4
4
|
* @param props - Image component properties including gradient, mask and size
|
|
5
5
|
* @returns Object containing image style variables and gradient style variables
|
|
6
6
|
*/
|
|
7
7
|
export const getImageComponentStyles = (props) => {
|
|
8
|
-
const { gradient_colors, colorMode, mask_shape, size,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
8
|
+
const { gradient_colors, colorMode, mask_shape, size,
|
|
9
|
+
// max_height, // TODO: implement this. still waiting on spec
|
|
10
|
+
// override_source_lid, // TODO: Implement this once structure is defined
|
|
11
|
+
overrides, componentState, } = props;
|
|
12
|
+
const activeStateProps = getActiveStateProps(overrides, componentState);
|
|
13
|
+
const gradientStyles = getGradientStyle(colorMode, activeStateProps?.gradient_colors || gradient_colors);
|
|
14
|
+
const sizeStyles = getSizeStyle({ ...size, ...activeStateProps });
|
|
15
|
+
const maskStyles = getMaskStyle({
|
|
16
|
+
...mask_shape,
|
|
17
|
+
...activeStateProps,
|
|
18
|
+
});
|
|
14
19
|
const imageStylesObject = {
|
|
15
20
|
...sizeStyles,
|
|
16
21
|
...maskStyles,
|
|
@@ -24,12 +24,15 @@
|
|
|
24
24
|
const packageVariables = $derived(
|
|
25
25
|
purchaseState.variablesPerPackage?.[package_id] || variableDictionary,
|
|
26
26
|
);
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
const componentState = $derived({
|
|
29
|
+
selected: purchaseState?.selectedPackageId === package_id,
|
|
30
|
+
});
|
|
28
31
|
</script>
|
|
29
32
|
|
|
30
33
|
<button
|
|
31
34
|
class="package"
|
|
32
|
-
class:selected={
|
|
35
|
+
class:selected={componentState.selected}
|
|
33
36
|
{id}
|
|
34
37
|
onclick={onPackageClick}
|
|
35
38
|
>
|
|
@@ -38,6 +41,7 @@
|
|
|
38
41
|
{labels}
|
|
39
42
|
{onAction}
|
|
40
43
|
{purchaseState}
|
|
44
|
+
{componentState}
|
|
41
45
|
variableDictionary={packageVariables}
|
|
42
46
|
/>
|
|
43
47
|
</button>
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
paywallData,
|
|
11
11
|
gradientPaywallData,
|
|
12
12
|
variablesPastaPaywallData,
|
|
13
|
+
stateTemplate,
|
|
14
|
+
posterMakerTemplate,
|
|
13
15
|
} from "../../stories/fixtures";
|
|
14
16
|
import { fn } from "@storybook/test";
|
|
15
17
|
|
|
@@ -132,3 +134,58 @@
|
|
|
132
134
|
onRestorePurchasesClicked: fn(),
|
|
133
135
|
}}
|
|
134
136
|
/>
|
|
137
|
+
|
|
138
|
+
<Story
|
|
139
|
+
name="Dynamic state style overrides"
|
|
140
|
+
args={{
|
|
141
|
+
paywallData: stateTemplate,
|
|
142
|
+
onPurchaseClicked: fn(),
|
|
143
|
+
onBackClicked: fn(),
|
|
144
|
+
onNavigateToClicked: fn(),
|
|
145
|
+
onRestorePurchasesClicked: fn(),
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
148
|
+
|
|
149
|
+
<Story
|
|
150
|
+
name="Dynamic state style overrides with background image"
|
|
151
|
+
args={{
|
|
152
|
+
paywallData: {
|
|
153
|
+
...stateTemplate,
|
|
154
|
+
components_config: {
|
|
155
|
+
...stateTemplate.components_config,
|
|
156
|
+
base: {
|
|
157
|
+
...stateTemplate.components_config.base,
|
|
158
|
+
background: {
|
|
159
|
+
type: "image",
|
|
160
|
+
value: {
|
|
161
|
+
light: {
|
|
162
|
+
heic: "https://assets.pawwalls.com/1005820_1732028636.heic",
|
|
163
|
+
heic_low_res:
|
|
164
|
+
"https://assets.pawwalls.com/1005820_low_res_1732028636.heic",
|
|
165
|
+
original: "https://assets.pawwalls.com/1005820_1732028636.jpeg",
|
|
166
|
+
webp: "https://assets.pawwalls.com/1005820_1732028636.webp",
|
|
167
|
+
webp_low_res:
|
|
168
|
+
"https://assets.pawwalls.com/1005820_low_res_1732028636.webp",
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
onPurchaseClicked: fn(),
|
|
176
|
+
onBackClicked: fn(),
|
|
177
|
+
onNavigateToClicked: fn(),
|
|
178
|
+
onRestorePurchasesClicked: fn(),
|
|
179
|
+
}}
|
|
180
|
+
/>
|
|
181
|
+
|
|
182
|
+
<Story
|
|
183
|
+
name="Poster Maker"
|
|
184
|
+
args={{
|
|
185
|
+
paywallData: posterMakerTemplate,
|
|
186
|
+
onPurchaseClicked: fn(),
|
|
187
|
+
onBackClicked: fn(),
|
|
188
|
+
onNavigateToClicked: fn(),
|
|
189
|
+
onRestorePurchasesClicked: fn(),
|
|
190
|
+
}}
|
|
191
|
+
/>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type {
|
|
3
|
+
BaseNodeBackgroundImage,
|
|
3
4
|
Extra,
|
|
4
5
|
NavigateToAction,
|
|
5
6
|
PaywallData,
|
|
@@ -10,6 +11,11 @@
|
|
|
10
11
|
import type { PurchaseState } from "../../data/state";
|
|
11
12
|
import { findSelectedPackageId, getLabelById } from "../../utils/style-utils";
|
|
12
13
|
import { type VariableDictionary } from "../../utils/variable-utils";
|
|
14
|
+
import {
|
|
15
|
+
getBackgroundImageSource,
|
|
16
|
+
getBackgroundStyles,
|
|
17
|
+
} from "./paywall-utils";
|
|
18
|
+
import { prefersDarkMode } from "../../stores/theme";
|
|
13
19
|
|
|
14
20
|
interface Props {
|
|
15
21
|
paywallData: PaywallData;
|
|
@@ -107,6 +113,17 @@
|
|
|
107
113
|
break;
|
|
108
114
|
}
|
|
109
115
|
};
|
|
116
|
+
const colorMode = $derived($prefersDarkMode ? "dark" : "light");
|
|
117
|
+
|
|
118
|
+
const backgroundStyles = $derived(
|
|
119
|
+
getBackgroundStyles({
|
|
120
|
+
background: paywallData.components_config.base?.background,
|
|
121
|
+
colorMode,
|
|
122
|
+
}),
|
|
123
|
+
);
|
|
124
|
+
const backgroundImgSource = $derived(
|
|
125
|
+
getBackgroundImageSource(paywallData, $prefersDarkMode ? "dark" : "light"),
|
|
126
|
+
);
|
|
110
127
|
</script>
|
|
111
128
|
|
|
112
129
|
<div class="paywall">
|
|
@@ -117,6 +134,13 @@
|
|
|
117
134
|
{purchaseState}
|
|
118
135
|
{variableDictionary}
|
|
119
136
|
/>
|
|
137
|
+
{#if paywallData.components_config.base.background?.type === "color"}
|
|
138
|
+
<div class="paywall-background" style={backgroundStyles}></div>
|
|
139
|
+
{:else if paywallData.components_config.base.background?.type === "image"}
|
|
140
|
+
<div class="paywall-background image-container">
|
|
141
|
+
<img class="image" src={backgroundImgSource} alt="" />
|
|
142
|
+
</div>
|
|
143
|
+
{/if}
|
|
120
144
|
</div>
|
|
121
145
|
|
|
122
146
|
<style>
|
|
@@ -125,11 +149,32 @@
|
|
|
125
149
|
*::before,
|
|
126
150
|
*::after {
|
|
127
151
|
box-sizing: border-box;
|
|
152
|
+
margin: 0;
|
|
128
153
|
}
|
|
129
154
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
155
|
+
.paywall {
|
|
156
|
+
position: relative;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.paywall-background {
|
|
160
|
+
position: absolute;
|
|
161
|
+
top: 0;
|
|
162
|
+
left: 0;
|
|
163
|
+
width: 100%;
|
|
164
|
+
height: 100%;
|
|
165
|
+
background: var(--background, none);
|
|
166
|
+
z-index: -1;
|
|
167
|
+
}
|
|
168
|
+
.image-container {
|
|
169
|
+
overflow: hidden;
|
|
170
|
+
background: none;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.image {
|
|
174
|
+
width: 100%;
|
|
175
|
+
height: 100%;
|
|
176
|
+
object-fit: cover;
|
|
177
|
+
display: block;
|
|
133
178
|
}
|
|
134
179
|
|
|
135
180
|
body {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BaseNodeBackgroundType, PaywallData } from "../../data/entities";
|
|
2
|
+
import type { ColorMode } from "../../types";
|
|
3
|
+
export declare function getBackgroundStyles({ background, colorMode, }: {
|
|
4
|
+
background?: BaseNodeBackgroundType;
|
|
5
|
+
colorMode: ColorMode;
|
|
6
|
+
}): string | undefined;
|
|
7
|
+
export declare function getBackgroundImageSource(paywallData: PaywallData, colorMode: ColorMode): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getColor } from "../../utils/style-utils";
|
|
2
|
+
export function getBackgroundStyles({ background, colorMode, }) {
|
|
3
|
+
if (!background)
|
|
4
|
+
return "";
|
|
5
|
+
if (background.type === "color") {
|
|
6
|
+
const style = getColor({
|
|
7
|
+
colorMap: background.value,
|
|
8
|
+
colorMode,
|
|
9
|
+
fallback: "transparent",
|
|
10
|
+
});
|
|
11
|
+
return `--background: ${style};`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function getBackgroundImageSource(paywallData, colorMode) {
|
|
15
|
+
if (paywallData.components_config.base?.background?.type !== "image")
|
|
16
|
+
return "";
|
|
17
|
+
const backgroundObject = paywallData.components_config.base
|
|
18
|
+
.background;
|
|
19
|
+
return (backgroundObject.value[colorMode]?.original ||
|
|
20
|
+
backgroundObject.value["light"]?.original);
|
|
21
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { getComponentStyles, getDimensionStyle, getSizeStyle, } from "../../utils/style-utils";
|
|
1
|
+
import { getActiveStateProps, getComponentStyles, getDimensionStyle, getSizeStyle, } from "../../utils/style-utils";
|
|
2
2
|
/**
|
|
3
3
|
* Generates comprehensive styles for stack components by combining component, dimension and size styles
|
|
4
4
|
* @param props - Stack component properties including background, spacing, size, border etc.
|
|
5
5
|
* @returns CSS style variables object with all stack-specific styles
|
|
6
6
|
*/
|
|
7
7
|
export const getStackComponentStyles = (props) => {
|
|
8
|
-
const { background_color, margin, padding, spacing, size, border, shape, colorMode, shadow, dimension, } = props;
|
|
8
|
+
const { background_color, margin, padding, spacing, size, border, shape, colorMode, shadow, dimension, componentState, overrides, } = props;
|
|
9
|
+
const activeStateProps = getActiveStateProps(overrides, componentState);
|
|
9
10
|
const componentStyles = getComponentStyles({
|
|
10
11
|
backgroundColor: background_color,
|
|
11
12
|
margin,
|
|
@@ -14,9 +15,13 @@ export const getStackComponentStyles = (props) => {
|
|
|
14
15
|
colorMode,
|
|
15
16
|
shape,
|
|
16
17
|
shadow,
|
|
18
|
+
...activeStateProps,
|
|
17
19
|
});
|
|
18
|
-
const dimensionStyles = getDimensionStyle(
|
|
19
|
-
|
|
20
|
+
const dimensionStyles = getDimensionStyle({
|
|
21
|
+
...dimension,
|
|
22
|
+
...activeStateProps,
|
|
23
|
+
});
|
|
24
|
+
const sizeStyles = getSizeStyle({ ...size, ...activeStateProps });
|
|
20
25
|
return {
|
|
21
26
|
...sizeStyles,
|
|
22
27
|
...dimensionStyles,
|
|
@@ -36,8 +36,9 @@
|
|
|
36
36
|
font-size: var(--font-size, 1rem);
|
|
37
37
|
font-weight: var(--font-weight, normal);
|
|
38
38
|
text-align: var(--text-align, center);
|
|
39
|
-
height: var(--height, unset);
|
|
40
|
-
width: var(--width, unset);
|
|
41
39
|
font-family: var(--font-family, sans-serif);
|
|
40
|
+
-webkit-background-clip: var(--background-clip, initial);
|
|
41
|
+
background-clip: var(--background-clip, initial);
|
|
42
|
+
-webkit-text-fill-color: var(--text-fill-color, initial);
|
|
42
43
|
}
|
|
43
44
|
</style>
|
|
@@ -39,7 +39,12 @@
|
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
args: {
|
|
42
|
-
labels: {
|
|
42
|
+
labels: {
|
|
43
|
+
en_US: {
|
|
44
|
+
lb123:
|
|
45
|
+
"Do not allow people to dim your shine because they are blinded. Tell them to put some sunglasses on.",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
43
48
|
text_lid: "lb123",
|
|
44
49
|
size: {
|
|
45
50
|
width: { type: "fill" },
|
|
@@ -102,6 +107,118 @@
|
|
|
102
107
|
name: "hello world!",
|
|
103
108
|
}}
|
|
104
109
|
/>
|
|
110
|
+
|
|
111
|
+
<!-- Linear Gradient Color text story -->
|
|
112
|
+
<Story
|
|
113
|
+
name="LinearGradientColor"
|
|
114
|
+
args={{
|
|
115
|
+
font_weight: "regular",
|
|
116
|
+
text_style: "normal",
|
|
117
|
+
horizontal_alignment: "start",
|
|
118
|
+
size: { width: { type: "fixed", value: 200 }, height: { type: "fixed" } },
|
|
119
|
+
padding: { top: 20, trailing: 20, bottom: 20, leading: 20 },
|
|
120
|
+
color: {
|
|
121
|
+
dark: {
|
|
122
|
+
degrees: 90,
|
|
123
|
+
points: [
|
|
124
|
+
{
|
|
125
|
+
color: "#9f009f",
|
|
126
|
+
percent: 100,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
color: "#090979ff",
|
|
130
|
+
percent: 35,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
color: "#53d6ec",
|
|
134
|
+
percent: 0,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
type: "linear",
|
|
138
|
+
},
|
|
139
|
+
light: {
|
|
140
|
+
degrees: 45,
|
|
141
|
+
points: [
|
|
142
|
+
{
|
|
143
|
+
color: "#9f009f",
|
|
144
|
+
percent: 0,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
color: "#090979ff",
|
|
148
|
+
percent: 50,
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
{
|
|
152
|
+
color: "#53d6ec",
|
|
153
|
+
percent: 100,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
type: "linear",
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
background_color: {
|
|
160
|
+
dark: { type: "hex", value: "#000000" },
|
|
161
|
+
light: { type: "hex", value: "#000000" },
|
|
162
|
+
},
|
|
163
|
+
name: "hello world!",
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
166
|
+
|
|
167
|
+
<!-- Radial Gradient Color text story -->
|
|
168
|
+
<Story
|
|
169
|
+
name="RadialGradientColor"
|
|
170
|
+
args={{
|
|
171
|
+
font_weight: "regular",
|
|
172
|
+
text_style: "normal",
|
|
173
|
+
horizontal_alignment: "start",
|
|
174
|
+
size: { width: { type: "fixed", value: 200 }, height: { type: "fixed" } },
|
|
175
|
+
padding: { top: 20, trailing: 20, bottom: 20, leading: 20 },
|
|
176
|
+
color: {
|
|
177
|
+
dark: {
|
|
178
|
+
degrees: 90,
|
|
179
|
+
points: [
|
|
180
|
+
{
|
|
181
|
+
color: "#9f009f",
|
|
182
|
+
percent: 100,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
color: "#090979ff",
|
|
186
|
+
percent: 35,
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
color: "#53d6ec",
|
|
190
|
+
percent: 0,
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
type: "radial",
|
|
194
|
+
},
|
|
195
|
+
light: {
|
|
196
|
+
points: [
|
|
197
|
+
{
|
|
198
|
+
color: "#53d6ec",
|
|
199
|
+
percent: 0,
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
color: "#090979ff",
|
|
203
|
+
percent: 30,
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
{
|
|
207
|
+
color: "#9f009f",
|
|
208
|
+
percent: 50,
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
type: "radial",
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
background_color: {
|
|
215
|
+
dark: { type: "hex", value: "#000000" },
|
|
216
|
+
light: { type: "hex", value: "#000000" },
|
|
217
|
+
},
|
|
218
|
+
name: "hello world!",
|
|
219
|
+
}}
|
|
220
|
+
/>
|
|
221
|
+
|
|
105
222
|
<!-- Text with spacing story -->
|
|
106
223
|
<Story
|
|
107
224
|
name="With Spacing"
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
import { getTextComponentStyles } from "./text-utils";
|
|
3
3
|
import Text from "./Text.svelte";
|
|
4
4
|
import type { TextNodeProps } from "../../data/entities";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getComponentStyles,
|
|
7
|
+
getLabelById,
|
|
8
|
+
getSizeStyle,
|
|
9
|
+
stringifyStyles,
|
|
10
|
+
} from "../../utils/style-utils";
|
|
6
11
|
import { replaceVariables } from "../../utils/variable-utils";
|
|
7
12
|
|
|
8
13
|
const {
|
|
@@ -11,6 +16,8 @@
|
|
|
11
16
|
text_lid,
|
|
12
17
|
purchaseState,
|
|
13
18
|
variableDictionary,
|
|
19
|
+
background_color,
|
|
20
|
+
size,
|
|
14
21
|
...restProps
|
|
15
22
|
}: TextNodeProps = $props();
|
|
16
23
|
|
|
@@ -20,9 +27,20 @@
|
|
|
20
27
|
labels,
|
|
21
28
|
text_lid,
|
|
22
29
|
purchaseState,
|
|
30
|
+
background_color,
|
|
31
|
+
size,
|
|
23
32
|
...restProps,
|
|
24
33
|
}),
|
|
25
34
|
);
|
|
35
|
+
const wrapperStyles = $derived(
|
|
36
|
+
stringifyStyles({
|
|
37
|
+
...getComponentStyles({
|
|
38
|
+
backgroundColor: background_color,
|
|
39
|
+
...restProps,
|
|
40
|
+
}),
|
|
41
|
+
...getSizeStyle(size),
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
26
44
|
const styles = $derived(stringifyStyles(textStyles));
|
|
27
45
|
|
|
28
46
|
const label = $derived(
|
|
@@ -41,6 +59,18 @@
|
|
|
41
59
|
);
|
|
42
60
|
</script>
|
|
43
61
|
|
|
44
|
-
<
|
|
45
|
-
{
|
|
46
|
-
|
|
62
|
+
<span style={wrapperStyles} class="text-wrapper">
|
|
63
|
+
<Text styleVariables={styles} component={tagToRender} {id}>
|
|
64
|
+
{parsedLabel}
|
|
65
|
+
</Text>
|
|
66
|
+
</span>
|
|
67
|
+
|
|
68
|
+
<style>
|
|
69
|
+
.text-wrapper {
|
|
70
|
+
display: block;
|
|
71
|
+
|
|
72
|
+
height: var(--height, unset);
|
|
73
|
+
width: var(--width, unset);
|
|
74
|
+
background: var(--background, none);
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
@@ -7,6 +7,8 @@ type TextStyleVariables = {
|
|
|
7
7
|
"--font-weight": number | string;
|
|
8
8
|
"--font-size": string;
|
|
9
9
|
"--font-family": string;
|
|
10
|
+
"--background-clip": string;
|
|
11
|
+
"--text-fill-color": string;
|
|
10
12
|
};
|
|
11
13
|
/**
|
|
12
14
|
* Generates comprehensive styles for text components by combining text, component and size styles
|
|
@@ -14,7 +16,7 @@ type TextStyleVariables = {
|
|
|
14
16
|
* @returns Object containing text style variables and the appropriate HTML tag to render
|
|
15
17
|
*/
|
|
16
18
|
export declare const getTextComponentStyles: (props: TextNodeProps) => {
|
|
17
|
-
textStyles: TextStyleVariables
|
|
18
|
-
tagToRender: TextComponentTags
|
|
19
|
+
textStyles: Partial<TextStyleVariables>;
|
|
20
|
+
tagToRender: Partial<TextComponentTags>;
|
|
19
21
|
};
|
|
20
22
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getSizeStyle, getTextComponentTag, getTextStyles, } from "../../utils/style-utils";
|
|
2
|
-
import { getComponentStyles } from "../../utils/style-utils";
|
|
1
|
+
import { getActiveStateProps, getComponentStyles, getSizeStyle, getTextComponentTag, getTextStyles, } from "../../utils/style-utils";
|
|
3
2
|
/**
|
|
4
3
|
* Generates comprehensive styles for text components by combining text, component and size styles
|
|
5
4
|
* @param props - Text component properties including font, color, background, spacing etc.
|
|
@@ -13,20 +12,22 @@ export const getTextComponentStyles = (props) => {
|
|
|
13
12
|
dark: { type: "hex", value: "#FFFFFF" },
|
|
14
13
|
light: { type: "hex", value: "#FFFFFF" },
|
|
15
14
|
}, padding, margin, colorMode, size, } = props;
|
|
15
|
+
const activeStateProps = getActiveStateProps(props.overrides, props.componentState);
|
|
16
16
|
const tagToRender = getTextComponentTag(font_size);
|
|
17
|
-
const textStyles = getTextStyles(props);
|
|
17
|
+
const textStyles = getTextStyles({ ...props, ...activeStateProps }, colorMode);
|
|
18
18
|
const componentStyles = getComponentStyles({
|
|
19
19
|
backgroundColor: background_color,
|
|
20
20
|
textColor: color,
|
|
21
21
|
margin,
|
|
22
22
|
padding,
|
|
23
23
|
colorMode,
|
|
24
|
+
...activeStateProps,
|
|
24
25
|
});
|
|
25
|
-
const sizeStyles = getSizeStyle(size);
|
|
26
|
+
const sizeStyles = getSizeStyle({ ...size, ...activeStateProps });
|
|
26
27
|
return {
|
|
27
28
|
textStyles: {
|
|
28
|
-
...textStyles,
|
|
29
29
|
...componentStyles,
|
|
30
|
+
...textStyles,
|
|
30
31
|
...sizeStyles,
|
|
31
32
|
},
|
|
32
33
|
tagToRender,
|
package/dist/data/entities.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { BorderType, ColorMode, ColorType, CornerRadiusType, DimensionType,
|
|
|
2
2
|
import type { PurchaseState } from "./state";
|
|
3
3
|
import type { VariableDictionary } from "../utils/variable-utils";
|
|
4
4
|
export interface Extra {
|
|
5
|
-
[key: string]:
|
|
5
|
+
[key: string]: unknown;
|
|
6
6
|
}
|
|
7
7
|
export type ComponentTypes = "stack" | "text" | "image" | "button" | "purchase_button" | "footer" | "package";
|
|
8
8
|
export interface PaywallComponent extends Extra {
|
|
@@ -10,14 +10,32 @@ export interface PaywallComponent extends Extra {
|
|
|
10
10
|
id: string;
|
|
11
11
|
name: string;
|
|
12
12
|
}
|
|
13
|
-
export interface Text extends PaywallComponent {
|
|
14
|
-
}
|
|
15
13
|
export interface Stack extends PaywallComponent {
|
|
16
14
|
spacing: number;
|
|
17
15
|
components: PaywallComponent[];
|
|
18
16
|
}
|
|
17
|
+
type BaseNodeBackgroundColor = {
|
|
18
|
+
type: "color";
|
|
19
|
+
value: ColorType;
|
|
20
|
+
};
|
|
21
|
+
export type BaseNodeBackgroundImage = {
|
|
22
|
+
type: "image";
|
|
23
|
+
value: ImageSourceType;
|
|
24
|
+
};
|
|
25
|
+
export type BaseNodeBackgroundType = BaseNodeBackgroundColor | BaseNodeBackgroundImage;
|
|
19
26
|
export interface ComponentConfig {
|
|
27
|
+
colors?: Record<string, string>;
|
|
28
|
+
fonts?: {
|
|
29
|
+
[fontName: string]: {
|
|
30
|
+
ios: string;
|
|
31
|
+
android: string;
|
|
32
|
+
web: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
asset_base_url?: string;
|
|
20
36
|
base: {
|
|
37
|
+
default_font_name?: string;
|
|
38
|
+
background?: BaseNodeBackgroundType;
|
|
21
39
|
stack: Stack;
|
|
22
40
|
sticky_footer?: {
|
|
23
41
|
stack: {
|
|
@@ -28,8 +46,8 @@ export interface ComponentConfig {
|
|
|
28
46
|
};
|
|
29
47
|
}
|
|
30
48
|
export interface ComponentLocalizations extends Extra {
|
|
31
|
-
|
|
32
|
-
[
|
|
49
|
+
[locale: string]: {
|
|
50
|
+
[label_id: string]: string;
|
|
33
51
|
};
|
|
34
52
|
}
|
|
35
53
|
export interface PaywallData extends Extra {
|
|
@@ -43,12 +61,16 @@ export interface ActionsProps {
|
|
|
43
61
|
export interface PurchaseStateProps {
|
|
44
62
|
purchaseState: PurchaseState;
|
|
45
63
|
}
|
|
64
|
+
export type ComponentState = {
|
|
65
|
+
[state: string]: boolean;
|
|
66
|
+
};
|
|
46
67
|
interface SharedComponentProps extends PaywallComponent, ActionsProps, PurchaseStateProps {
|
|
47
68
|
labels: ComponentLocalizations;
|
|
48
69
|
id: string;
|
|
49
70
|
colorMode: ColorMode;
|
|
50
71
|
name: string;
|
|
51
72
|
variableDictionary?: VariableDictionary;
|
|
73
|
+
componentState?: ComponentState;
|
|
52
74
|
}
|
|
53
75
|
interface Action {
|
|
54
76
|
type: "restore_purchases" | "navigate_to" | "navigate_back" | "purchase" | "select_package";
|
|
@@ -105,6 +127,9 @@ export interface StackProps extends SharedComponentProps {
|
|
|
105
127
|
size: SizeType;
|
|
106
128
|
spacing?: number;
|
|
107
129
|
type: "stack";
|
|
130
|
+
overrides?: {
|
|
131
|
+
[state: string]: StackProps;
|
|
132
|
+
};
|
|
108
133
|
}
|
|
109
134
|
export interface TextNodeProps extends SharedComponentProps {
|
|
110
135
|
background_color?: ColorType;
|
|
@@ -120,6 +145,9 @@ export interface TextNodeProps extends SharedComponentProps {
|
|
|
120
145
|
type: "text";
|
|
121
146
|
size: SizeType;
|
|
122
147
|
variableDictionary?: VariableDictionary;
|
|
148
|
+
overrides?: {
|
|
149
|
+
[state: string]: TextNodeProps;
|
|
150
|
+
};
|
|
123
151
|
}
|
|
124
152
|
type ImageSourceDictionaryType = Record<"original" | "heic" | "heic_low_res" | "webp" | "webp_low_res", string>;
|
|
125
153
|
type ImageSourceType = {
|
|
@@ -139,5 +167,8 @@ export interface ImageProps extends SharedComponentProps {
|
|
|
139
167
|
mask_shape?: ImageMaskShapeType;
|
|
140
168
|
max_height?: number;
|
|
141
169
|
override_source_lid?: string;
|
|
170
|
+
overrides?: {
|
|
171
|
+
[state: string]: ImageProps;
|
|
172
|
+
};
|
|
142
173
|
}
|
|
143
174
|
export {};
|
|
@@ -6,6 +6,9 @@ export declare const pastaPaywallData: PaywallData;
|
|
|
6
6
|
export declare const variablesPastaPaywallData: PaywallData;
|
|
7
7
|
export declare const gradientPaywallData: PaywallData;
|
|
8
8
|
export declare const calmPaywallData: PaywallData;
|
|
9
|
+
export declare const stateTemplate: PaywallData;
|
|
10
|
+
export declare const posterMakerTemplate: PaywallData;
|
|
11
|
+
export declare const testTemplate: PaywallData;
|
|
9
12
|
export declare const labelsData: {
|
|
10
13
|
en_US: {
|
|
11
14
|
id1: string;
|