@revenuecat/purchases-ui-js 0.0.13 → 0.0.15
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/Button.svelte +1 -1
- package/dist/components/button/ButtonNode.svelte +9 -3
- package/dist/components/footer/Footer.svelte +3 -3
- package/dist/components/image/Image.svelte +4 -2
- package/dist/components/image/image-utils.js +9 -5
- package/dist/components/package/Package.svelte +28 -8
- package/dist/components/paywall/Node.svelte +17 -2
- package/dist/components/paywall/Node.svelte.d.ts +2 -0
- package/dist/components/paywall/Paywall.stories.svelte +99 -1
- package/dist/components/paywall/Paywall.svelte +60 -3
- package/dist/components/paywall/Paywall.svelte.d.ts +2 -0
- package/dist/components/paywall/paywall-utils.d.ts +7 -0
- package/dist/components/paywall/paywall-utils.js +21 -0
- package/dist/components/purchase-button/PurchaseButton.svelte +9 -4
- package/dist/components/stack/Stack.svelte +9 -2
- package/dist/components/stack/stack-utils.d.ts +1 -1
- package/dist/components/stack/stack-utils.js +9 -4
- package/dist/components/text/Text.svelte +4 -3
- package/dist/components/text/TextNode.stories.svelte +118 -1
- package/dist/components/text/TextNode.svelte +35 -5
- package/dist/components/text/text-utils.d.ts +2 -0
- package/dist/components/text/text-utils.js +6 -5
- package/dist/data/entities.d.ts +40 -0
- package/dist/data/state.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/stories/fixtures.d.ts +4 -0
- package/dist/stories/fixtures.js +7840 -585
- package/dist/types.d.ts +9 -3
- package/dist/types.js +1 -1
- package/dist/utils/style-utils.d.ts +15 -8
- package/dist/utils/style-utils.js +61 -11
- package/dist/utils/variable-utils.d.ts +23 -3
- package/dist/utils/variable-utils.js +1 -1
- package/package.json +13 -3
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
import type { ButtonNodeProps } from "../../data/entities";
|
|
4
4
|
import Stack from "../stack/Stack.svelte";
|
|
5
5
|
|
|
6
|
-
const {
|
|
7
|
-
|
|
6
|
+
const {
|
|
7
|
+
stack,
|
|
8
|
+
action,
|
|
9
|
+
onAction,
|
|
10
|
+
labels,
|
|
11
|
+
purchaseState,
|
|
12
|
+
variableDictionary,
|
|
13
|
+
}: ButtonNodeProps = $props();
|
|
8
14
|
const onClick = () => {
|
|
9
15
|
onAction && onAction(action);
|
|
10
16
|
};
|
|
11
17
|
</script>
|
|
12
18
|
|
|
13
19
|
<Button onclick={onClick}>
|
|
14
|
-
<Stack {...stack} {labels} {purchaseState} />
|
|
20
|
+
<Stack {...stack} {labels} {purchaseState} {variableDictionary} />
|
|
15
21
|
</Button>
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import type { FooterProps } from "../../data/entities";
|
|
3
3
|
import Stack from "../stack/Stack.svelte";
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const { stack, id, labels, purchaseState, variableDictionary }: FooterProps =
|
|
6
|
+
$props();
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<div class="footer" {id}>
|
|
10
|
-
<Stack {...stack} {labels} />
|
|
10
|
+
<Stack {...stack} {labels} {purchaseState} {variableDictionary} />
|
|
11
11
|
</div>
|
|
@@ -30,17 +30,19 @@
|
|
|
30
30
|
border-radius: var(--corner-radius, unset);
|
|
31
31
|
clip-path: var(--clip-path, unset);
|
|
32
32
|
display: flex;
|
|
33
|
-
flex: var(--flex, 1
|
|
33
|
+
flex: var(--flex, 1 1 auto);
|
|
34
34
|
}
|
|
35
|
+
|
|
35
36
|
.image {
|
|
36
37
|
width: 100%;
|
|
37
38
|
height: 100%;
|
|
38
39
|
object-fit: cover;
|
|
39
40
|
display: block;
|
|
40
41
|
}
|
|
42
|
+
|
|
41
43
|
.image-overlay {
|
|
42
44
|
position: absolute;
|
|
43
45
|
inset: 0;
|
|
44
|
-
background: var(--background,
|
|
46
|
+
background: var(--background, none);
|
|
45
47
|
}
|
|
46
48
|
</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
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
|
|
@@ -7,10 +7,14 @@ import { getGradientStyle, getMaskStyle, getSizeStyle, } from "../../utils/style
|
|
|
7
7
|
export const getImageComponentStyles = (props) => {
|
|
8
8
|
const { gradient_colors, colorMode, mask_shape, size, max_height, // TODO: implement this. still waiting on spec
|
|
9
9
|
override_source_lid, // TODO: Implement this once structure is defined
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
10
|
+
overrides, componentState, } = props;
|
|
11
|
+
const activeStateProps = getActiveStateProps(overrides, componentState);
|
|
12
|
+
const gradientStyles = getGradientStyle(colorMode, activeStateProps?.gradient_colors || gradient_colors);
|
|
13
|
+
const sizeStyles = getSizeStyle({ ...size, ...activeStateProps });
|
|
14
|
+
const maskStyles = getMaskStyle({
|
|
15
|
+
...mask_shape,
|
|
16
|
+
...activeStateProps,
|
|
17
|
+
});
|
|
14
18
|
const imageStylesObject = {
|
|
15
19
|
...sizeStyles,
|
|
16
20
|
...maskStyles,
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
id,
|
|
10
10
|
onAction,
|
|
11
11
|
purchaseState,
|
|
12
|
+
variableDictionary,
|
|
12
13
|
}: PackageProps = $props();
|
|
13
14
|
|
|
14
15
|
const onPackageClick = (evt: MouseEvent) => {
|
|
@@ -20,20 +21,39 @@
|
|
|
20
21
|
});
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
const
|
|
24
|
+
const packageVariables = $derived(
|
|
25
|
+
purchaseState.variablesPerPackage?.[package_id] || variableDictionary,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const componentState = $derived({
|
|
29
|
+
selected: purchaseState?.selectedPackageId === package_id,
|
|
30
|
+
});
|
|
24
31
|
</script>
|
|
25
32
|
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
<button
|
|
34
|
+
class="package"
|
|
35
|
+
class:selected={componentState.selected}
|
|
36
|
+
{id}
|
|
37
|
+
onclick={onPackageClick}
|
|
38
|
+
>
|
|
39
|
+
<Stack
|
|
40
|
+
{...stack}
|
|
41
|
+
{labels}
|
|
42
|
+
{onAction}
|
|
43
|
+
{purchaseState}
|
|
44
|
+
{componentState}
|
|
45
|
+
variableDictionary={packageVariables}
|
|
46
|
+
/>
|
|
47
|
+
</button>
|
|
29
48
|
|
|
30
49
|
<style>
|
|
31
50
|
.package {
|
|
32
51
|
width: 100%;
|
|
33
52
|
display: flex;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
margin: 0;
|
|
54
|
+
padding: 0;
|
|
55
|
+
background: unset;
|
|
56
|
+
border: unset;
|
|
57
|
+
text-align: unset;
|
|
38
58
|
}
|
|
39
59
|
</style>
|
|
@@ -12,14 +12,22 @@
|
|
|
12
12
|
import { prefersDarkMode } from "../../stores/theme";
|
|
13
13
|
import ButtonNode from "../button/ButtonNode.svelte";
|
|
14
14
|
import TextNode from "../text/TextNode.svelte";
|
|
15
|
+
import type { VariableDictionary } from "../../utils/variable-utils";
|
|
15
16
|
|
|
16
17
|
interface Props extends ActionsProps, PurchaseStateProps {
|
|
17
18
|
nodeData: PaywallComponent;
|
|
18
19
|
labels: ComponentLocalizations;
|
|
19
20
|
onAction?: (action: SupportedActions, data?: Extra) => void;
|
|
21
|
+
variableDictionary?: VariableDictionary;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
nodeData,
|
|
26
|
+
labels,
|
|
27
|
+
onAction,
|
|
28
|
+
purchaseState,
|
|
29
|
+
variableDictionary,
|
|
30
|
+
}: Props = $props();
|
|
23
31
|
|
|
24
32
|
const ComponentTypes = {
|
|
25
33
|
text: TextNode,
|
|
@@ -39,8 +47,15 @@
|
|
|
39
47
|
prefersDarkMode={$prefersDarkMode}
|
|
40
48
|
{onAction}
|
|
41
49
|
{purchaseState}
|
|
50
|
+
{variableDictionary}
|
|
42
51
|
>
|
|
43
52
|
{#each nodeData.components as childData}
|
|
44
|
-
<Self
|
|
53
|
+
<Self
|
|
54
|
+
nodeData={childData}
|
|
55
|
+
{labels}
|
|
56
|
+
{onAction}
|
|
57
|
+
{purchaseState}
|
|
58
|
+
{variableDictionary}
|
|
59
|
+
/>
|
|
45
60
|
{/each}
|
|
46
61
|
</MyComponent>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type ActionsProps, type ComponentLocalizations, type Extra, type PaywallComponent, type PurchaseStateProps, type SupportedActions } from "../../data/entities";
|
|
2
|
+
import type { VariableDictionary } from "../../utils/variable-utils";
|
|
2
3
|
declare const Node: import("svelte").Component<ActionsProps & PurchaseStateProps & {
|
|
3
4
|
nodeData: PaywallComponent;
|
|
4
5
|
labels: ComponentLocalizations;
|
|
5
6
|
onAction?: (action: SupportedActions, data?: Extra) => void;
|
|
7
|
+
variableDictionary?: VariableDictionary;
|
|
6
8
|
}, {}, "">;
|
|
7
9
|
export default Node;
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
fontsPaywallData,
|
|
9
9
|
pastaPaywallData,
|
|
10
10
|
paywallData,
|
|
11
|
+
gradientPaywallData,
|
|
12
|
+
variablesPastaPaywallData,
|
|
13
|
+
stateTemplate,
|
|
14
|
+
posterMakerTemplate,
|
|
11
15
|
} from "../../stories/fixtures";
|
|
12
16
|
import { fn } from "@storybook/test";
|
|
13
17
|
|
|
@@ -31,7 +35,7 @@
|
|
|
31
35
|
onRestorePurchasesClicked: fn(),
|
|
32
36
|
}}
|
|
33
37
|
/>
|
|
34
|
-
|
|
38
|
+
|
|
35
39
|
<Story
|
|
36
40
|
name="Italian Missing Labels"
|
|
37
41
|
args={{
|
|
@@ -79,6 +83,34 @@
|
|
|
79
83
|
onRestorePurchasesClicked: fn(),
|
|
80
84
|
}}
|
|
81
85
|
/>
|
|
86
|
+
<Story
|
|
87
|
+
name="Pasta paywall example(with variables)"
|
|
88
|
+
args={{
|
|
89
|
+
paywallData: variablesPastaPaywallData,
|
|
90
|
+
selectedLocale: "en_US",
|
|
91
|
+
onPurchaseClicked: fn(),
|
|
92
|
+
onBackClicked: fn(),
|
|
93
|
+
onNavigateToClicked: fn(),
|
|
94
|
+
onRestorePurchasesClicked: fn(),
|
|
95
|
+
variablesPerPackage: {
|
|
96
|
+
trial: {
|
|
97
|
+
product_name: "This was a variable: Product A",
|
|
98
|
+
price: "$19.99",
|
|
99
|
+
price_per_period: "$19.99/yr",
|
|
100
|
+
},
|
|
101
|
+
$rc_weekly: {
|
|
102
|
+
product_name: "This was a variable: Product B",
|
|
103
|
+
price: "$29.99",
|
|
104
|
+
price_per_period: "$29.99/yr",
|
|
105
|
+
},
|
|
106
|
+
$rc_daily: {
|
|
107
|
+
product_name: "This was a variable: Product C",
|
|
108
|
+
price: "$39.99",
|
|
109
|
+
price_per_period: "$39.99/yr",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
82
114
|
|
|
83
115
|
<Story
|
|
84
116
|
name="Calm paywall example"
|
|
@@ -91,3 +123,69 @@
|
|
|
91
123
|
onRestorePurchasesClicked: fn(),
|
|
92
124
|
}}
|
|
93
125
|
/>
|
|
126
|
+
|
|
127
|
+
<Story
|
|
128
|
+
name="Healthy Cat (Gradient)"
|
|
129
|
+
args={{
|
|
130
|
+
paywallData: gradientPaywallData,
|
|
131
|
+
onPurchaseClicked: fn(),
|
|
132
|
+
onBackClicked: fn(),
|
|
133
|
+
onNavigateToClicked: fn(),
|
|
134
|
+
onRestorePurchasesClicked: fn(),
|
|
135
|
+
}}
|
|
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,
|
|
@@ -9,6 +10,12 @@
|
|
|
9
10
|
import Node from "./Node.svelte";
|
|
10
11
|
import type { PurchaseState } from "../../data/state";
|
|
11
12
|
import { findSelectedPackageId, getLabelById } from "../../utils/style-utils";
|
|
13
|
+
import { type VariableDictionary } from "../../utils/variable-utils";
|
|
14
|
+
import {
|
|
15
|
+
getBackgroundImageSource,
|
|
16
|
+
getBackgroundStyles,
|
|
17
|
+
} from "./paywall-utils";
|
|
18
|
+
import { prefersDarkMode } from "../../stores/theme";
|
|
12
19
|
|
|
13
20
|
interface Props {
|
|
14
21
|
paywallData: PaywallData;
|
|
@@ -18,6 +25,7 @@
|
|
|
18
25
|
onRestorePurchasesClicked?: () => void;
|
|
19
26
|
onNavigateToUrlClicked?: (url: string) => void;
|
|
20
27
|
selectedLocale?: string;
|
|
28
|
+
variablesPerPackage?: Record<string, VariableDictionary>;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
const {
|
|
@@ -28,14 +36,20 @@
|
|
|
28
36
|
onBackClicked,
|
|
29
37
|
onVisitCustomerCenterClicked,
|
|
30
38
|
selectedLocale,
|
|
39
|
+
variablesPerPackage = {},
|
|
31
40
|
}: Props = $props();
|
|
32
41
|
|
|
33
42
|
let purchaseState: PurchaseState = $state({
|
|
34
43
|
selectedPackageId: findSelectedPackageId(paywallData),
|
|
35
44
|
locale: selectedLocale || paywallData.default_locale,
|
|
36
45
|
defaultLocale: paywallData.default_locale,
|
|
46
|
+
variablesPerPackage,
|
|
37
47
|
});
|
|
38
48
|
|
|
49
|
+
let variableDictionary = $state(
|
|
50
|
+
variablesPerPackage[purchaseState.selectedPackageId || ""],
|
|
51
|
+
);
|
|
52
|
+
|
|
39
53
|
const onRestorePurchasesAction = (_: SupportedActions, _2?: Extra) => {
|
|
40
54
|
onRestorePurchasesClicked?.();
|
|
41
55
|
};
|
|
@@ -68,6 +82,9 @@
|
|
|
68
82
|
|
|
69
83
|
const onSelectPackageAction = (_: SupportedActions, data?: Extra) => {
|
|
70
84
|
purchaseState.selectedPackageId = data?.packageId;
|
|
85
|
+
if (data?.packageId) {
|
|
86
|
+
variableDictionary = variablesPerPackage[data.packageId];
|
|
87
|
+
}
|
|
71
88
|
};
|
|
72
89
|
|
|
73
90
|
const onPurchaseAction = (_: SupportedActions, _2?: Extra) => {
|
|
@@ -96,6 +113,17 @@
|
|
|
96
113
|
break;
|
|
97
114
|
}
|
|
98
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
|
+
);
|
|
99
127
|
</script>
|
|
100
128
|
|
|
101
129
|
<div class="paywall">
|
|
@@ -104,7 +132,15 @@
|
|
|
104
132
|
nodeData={paywallData.components_config.base.stack}
|
|
105
133
|
labels={paywallData.components_localizations}
|
|
106
134
|
{purchaseState}
|
|
135
|
+
{variableDictionary}
|
|
107
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}
|
|
108
144
|
</div>
|
|
109
145
|
|
|
110
146
|
<style>
|
|
@@ -113,11 +149,32 @@
|
|
|
113
149
|
*::before,
|
|
114
150
|
*::after {
|
|
115
151
|
box-sizing: border-box;
|
|
152
|
+
margin: 0;
|
|
116
153
|
}
|
|
117
154
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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;
|
|
121
178
|
}
|
|
122
179
|
|
|
123
180
|
body {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PaywallData } from "../../data/entities";
|
|
2
|
+
import { type VariableDictionary } from "../../utils/variable-utils";
|
|
2
3
|
declare const Paywall: import("svelte").Component<{
|
|
3
4
|
paywallData: PaywallData;
|
|
4
5
|
onPurchaseClicked?: (selectedPackageId: string) => void;
|
|
@@ -7,5 +8,6 @@ declare const Paywall: import("svelte").Component<{
|
|
|
7
8
|
onRestorePurchasesClicked?: () => void;
|
|
8
9
|
onNavigateToUrlClicked?: (url: string) => void;
|
|
9
10
|
selectedLocale?: string;
|
|
11
|
+
variablesPerPackage?: Record<string, VariableDictionary>;
|
|
10
12
|
}, {}, "">;
|
|
11
13
|
export default Paywall;
|
|
@@ -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
|
+
}
|
|
@@ -3,22 +3,27 @@
|
|
|
3
3
|
import Stack from "../stack/Stack.svelte";
|
|
4
4
|
import { Button } from "../../index";
|
|
5
5
|
|
|
6
|
-
const {
|
|
7
|
-
|
|
6
|
+
const {
|
|
7
|
+
stack,
|
|
8
|
+
labels,
|
|
9
|
+
onAction,
|
|
10
|
+
purchaseState,
|
|
11
|
+
variableDictionary,
|
|
12
|
+
}: PurchaseButtonProps = $props();
|
|
8
13
|
const handleClick = () => {
|
|
9
14
|
onAction && onAction({ type: "purchase" });
|
|
10
15
|
};
|
|
11
16
|
</script>
|
|
12
17
|
|
|
13
18
|
<Button onclick={handleClick} class="purchase-button">
|
|
14
|
-
<Stack {...stack} {labels} {purchaseState} />
|
|
19
|
+
<Stack {...stack} {labels} {purchaseState} {variableDictionary} />
|
|
15
20
|
</Button>
|
|
16
21
|
|
|
17
22
|
<style>
|
|
18
23
|
.purchase-button {
|
|
19
24
|
border: none;
|
|
20
25
|
cursor: pointer;
|
|
21
|
-
background
|
|
26
|
+
background: transparent;
|
|
22
27
|
padding: 0;
|
|
23
28
|
width: 100%;
|
|
24
29
|
display: flex;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
labels,
|
|
11
11
|
onAction,
|
|
12
12
|
purchaseState,
|
|
13
|
+
variableDictionary,
|
|
13
14
|
...restProps
|
|
14
15
|
}: StackProps = $props();
|
|
15
16
|
|
|
@@ -29,7 +30,13 @@
|
|
|
29
30
|
|
|
30
31
|
<div {id} style={stackStyles} class="stack">
|
|
31
32
|
{#each components as component}
|
|
32
|
-
<Node
|
|
33
|
+
<Node
|
|
34
|
+
nodeData={component}
|
|
35
|
+
{labels}
|
|
36
|
+
{onAction}
|
|
37
|
+
{purchaseState}
|
|
38
|
+
{variableDictionary}
|
|
39
|
+
/>
|
|
33
40
|
{/each}
|
|
34
41
|
</div>
|
|
35
42
|
|
|
@@ -41,7 +48,7 @@
|
|
|
41
48
|
width: var(--width, unset);
|
|
42
49
|
height: var(--height, unset);
|
|
43
50
|
gap: var(--spacing, 0);
|
|
44
|
-
background
|
|
51
|
+
background: var(--background, none);
|
|
45
52
|
border: var(--border, none);
|
|
46
53
|
border-radius: var(--border-radius, 0);
|
|
47
54
|
box-shadow: var(--shadow, none);
|
|
@@ -15,7 +15,7 @@ type StackStyleVariables = {
|
|
|
15
15
|
"--padding-inline-end": string;
|
|
16
16
|
"--padding-block-end": string;
|
|
17
17
|
"--padding-inline-start": string;
|
|
18
|
-
"--background
|
|
18
|
+
"--background": string;
|
|
19
19
|
"--text-color": string;
|
|
20
20
|
"--border": string;
|
|
21
21
|
"--border-radius": string;
|
|
@@ -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,
|
|
@@ -32,12 +32,13 @@
|
|
|
32
32
|
margin-block-end: var(--margin-block-end, unset);
|
|
33
33
|
margin-inline-start: var(--margin-inline-start, unset);
|
|
34
34
|
color: var(--text-color, #ffffff);
|
|
35
|
-
background
|
|
35
|
+
background: var(--background, none);
|
|
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>
|