@revenuecat/purchases-ui-js 2.0.0 → 2.0.2

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.
Files changed (105) hide show
  1. package/dist/components/button/Button.svelte +1 -5
  2. package/dist/components/button/ButtonNode.stories.svelte +57 -71
  3. package/dist/components/button/ButtonNode.stories.svelte.d.ts +0 -8
  4. package/dist/components/button/ButtonNode.svelte +10 -21
  5. package/dist/components/button/ButtonNode.svelte.d.ts +2 -2
  6. package/dist/components/button/button-utils.d.ts +2 -2
  7. package/dist/components/footer/Footer.stories.svelte +26 -22
  8. package/dist/components/footer/Footer.stories.svelte.d.ts +0 -5
  9. package/dist/components/footer/Footer.svelte +3 -10
  10. package/dist/components/footer/Footer.svelte.d.ts +1 -1
  11. package/dist/components/image/Image.stories.svelte +27 -19
  12. package/dist/components/image/Image.svelte +18 -17
  13. package/dist/components/image/image-utils.d.ts +2 -1
  14. package/dist/components/image/image-utils.js +2 -2
  15. package/dist/components/package/Package.stories.svelte +31 -31
  16. package/dist/components/package/Package.stories.svelte.d.ts +0 -6
  17. package/dist/components/package/Package.svelte +19 -30
  18. package/dist/components/package/Package.svelte.d.ts +1 -1
  19. package/dist/components/paywall/Node.svelte +26 -50
  20. package/dist/components/paywall/Node.svelte.d.ts +11 -14
  21. package/dist/components/paywall/Paywall.stories.svelte +21 -78
  22. package/dist/components/paywall/Paywall.svelte +75 -100
  23. package/dist/components/paywall/Paywall.svelte.d.ts +4 -4
  24. package/dist/components/paywall/paywall-utils.d.ts +3 -2
  25. package/dist/components/paywall/paywall-utils.js +5 -5
  26. package/dist/components/purchase-button/PurchaseButton.stories.svelte +29 -31
  27. package/dist/components/purchase-button/PurchaseButton.stories.svelte.d.ts +0 -5
  28. package/dist/components/purchase-button/PurchaseButton.svelte +9 -20
  29. package/dist/components/purchase-button/PurchaseButton.svelte.d.ts +1 -1
  30. package/dist/components/purchase-button/purchase-button-utils.d.ts +1 -1
  31. package/dist/components/stack/Stack.stories.svelte +17 -94
  32. package/dist/components/stack/Stack.svelte +18 -48
  33. package/dist/components/stack/stack-utils.d.ts +4 -3
  34. package/dist/components/stack/stack-utils.js +7 -10
  35. package/dist/components/text/TextNode.stories.svelte +45 -152
  36. package/dist/components/text/TextNode.svelte +15 -23
  37. package/dist/components/text/text-utils.d.ts +7 -6
  38. package/dist/components/text/text-utils.js +7 -7
  39. package/dist/components/timeline/Timeline.stories.svelte +37 -48
  40. package/dist/components/timeline/Timeline.svelte +0 -2
  41. package/dist/components/timeline/TimelineItem.svelte +28 -11
  42. package/dist/components/timeline/timeline-utils.d.ts +3 -3
  43. package/dist/components/timeline/timeline-utils.js +7 -17
  44. package/dist/data/entities.d.ts +54 -145
  45. package/dist/index.d.ts +10 -10
  46. package/dist/index.js +10 -10
  47. package/dist/stores/color-mode.d.ts +6 -0
  48. package/dist/stores/color-mode.js +15 -0
  49. package/dist/stores/localization.d.ts +13 -0
  50. package/dist/stores/localization.js +26 -0
  51. package/dist/stores/paywall.d.ts +11 -0
  52. package/dist/stores/paywall.js +13 -0
  53. package/dist/stores/variables.d.ts +5 -0
  54. package/dist/stores/variables.js +14 -0
  55. package/dist/stories/fixtures.d.ts +1 -1
  56. package/dist/stories/fixtures.js +30 -135
  57. package/dist/stories/localization-decorator.d.ts +3 -0
  58. package/dist/stories/localization-decorator.js +7 -0
  59. package/dist/stories/paywall-decorator.d.ts +2 -0
  60. package/dist/stories/paywall-decorator.js +19 -0
  61. package/dist/stories/variables-decorator.d.ts +3 -0
  62. package/dist/stories/variables-decorator.js +9 -0
  63. package/dist/stories/with-layout.svelte +4 -4
  64. package/dist/types/alignment.d.ts +19 -0
  65. package/dist/types/background.d.ts +18 -0
  66. package/dist/types/background.js +1 -0
  67. package/dist/types/colors.d.ts +34 -0
  68. package/dist/types/colors.js +1 -0
  69. package/dist/types/component.d.ts +6 -0
  70. package/dist/types/component.js +1 -0
  71. package/dist/types/components/button.d.ts +36 -0
  72. package/dist/types/components/button.js +1 -0
  73. package/dist/types/components/footer.d.ts +5 -0
  74. package/dist/types/components/footer.js +1 -0
  75. package/dist/types/components/package.d.ts +8 -0
  76. package/dist/types/components/package.js +1 -0
  77. package/dist/types/components/purchase-button.d.ts +5 -0
  78. package/dist/types/components/purchase-button.js +1 -0
  79. package/dist/types/localization.d.ts +4 -0
  80. package/dist/types/localization.js +1 -0
  81. package/dist/types/media.d.ts +18 -0
  82. package/dist/types/media.js +1 -0
  83. package/dist/types.d.ts +5 -35
  84. package/dist/ui/atoms/typography.stories.svelte +7 -13
  85. package/dist/ui/atoms/typography.stories.svelte.d.ts +1 -1
  86. package/dist/ui/atoms/typography.svelte +1 -1
  87. package/dist/ui/layout/main-block.svelte +2 -2
  88. package/dist/ui/molecules/button.stories.svelte +8 -15
  89. package/dist/ui/molecules/button.svelte +3 -2
  90. package/dist/ui/molecules/button.svelte.d.ts +2 -26
  91. package/dist/ui/molecules/types.d.ts +2 -1
  92. package/dist/ui/theme/theme.d.ts +2 -2
  93. package/dist/ui/theme/theme.js +2 -2
  94. package/dist/ui/theme/utils.d.ts +2 -2
  95. package/dist/utils/style-utils.d.ts +13 -11
  96. package/dist/utils/style-utils.js +21 -27
  97. package/dist/utils/variable-utils.d.ts +1 -38
  98. package/dist/utils/variable-utils.js +6 -48
  99. package/dist/web-components/index.css +1 -1
  100. package/dist/web-components/index.js +610 -657
  101. package/package.json +33 -36
  102. package/dist/data/state.d.ts +0 -9
  103. package/dist/stores/theme.d.ts +0 -1
  104. package/dist/stores/theme.js +0 -17
  105. /package/dist/{data/state.js → types/alignment.js} +0 -0
@@ -5,8 +5,8 @@ import { getActiveStateProps, getComponentStyles, getDimensionStyle, getInsetSty
5
5
  * @param props - Stack component properties including background, spacing, size, border etc.
6
6
  * @returns CSS style variables object with all stack-specific styles
7
7
  */
8
- export const getStackComponentStyles = (props) => {
9
- const { background_color, margin, padding, spacing, size, border, shape, shadow, dimension, componentState, overrides, purchaseState, zStackChildStyles, } = props;
8
+ export const getStackComponentStyles = (colorMode, props) => {
9
+ const { background_color, margin, padding, spacing, size, border, shape, shadow, dimension, componentState, overrides, zStackChildStyles, } = props;
10
10
  const stackStyles = {
11
11
  "--flex": "0 1 auto",
12
12
  "--height": "initial",
@@ -41,7 +41,7 @@ export const getStackComponentStyles = (props) => {
41
41
  margin,
42
42
  padding,
43
43
  border,
44
- colorMode: purchaseState.colorMode,
44
+ colorMode,
45
45
  shape,
46
46
  shadow,
47
47
  ...activeStateProps,
@@ -58,7 +58,7 @@ export const getStackComponentStyles = (props) => {
58
58
  * @param props - Stack component properties containing badge configuration
59
59
  * @returns CSS style object with badge-specific styles including positioning, dimensions and appearance
60
60
  */
61
- export function getBadgeStyles(props) {
61
+ export function getBadgeStyles(colorMode, props) {
62
62
  const { badge } = props;
63
63
  if (!badge)
64
64
  return "";
@@ -93,7 +93,7 @@ export function getBadgeStyles(props) {
93
93
  ...badge,
94
94
  background_color: badge.background_color,
95
95
  color: badge.color,
96
- colorMode: props.purchaseState.colorMode,
96
+ colorMode,
97
97
  }));
98
98
  if (badge.style === "overlay") {
99
99
  // Disable vertical margin for nested & center aligned badges
@@ -211,16 +211,13 @@ function getBadgeTransformStyles(badge, verticalOffset = 0, horizontalOffset = 0
211
211
  * - tagToRender: HTML tag to use for the badge text
212
212
  * - textStyles: CSS styles string for the badge text
213
213
  */
214
- export function getStackBadgeTextStyles(props) {
214
+ export function getStackBadgeTextStyles(colorMode, props) {
215
215
  const { badge } = props;
216
216
  if (!badge)
217
217
  return { tagToRender: "", textStyles: "" };
218
- const { tagToRender, textStyles } = getTextComponentStyles({
218
+ const { tagToRender, textStyles } = getTextComponentStyles(colorMode, {
219
219
  id: props.id,
220
- labels: props.labels,
221
- purchaseState: props.purchaseState,
222
220
  ...badge,
223
- components: [],
224
221
  type: "text",
225
222
  size: {
226
223
  width: { type: "fit" },
@@ -1,6 +1,6 @@
1
1
  <script module lang="ts">
2
- import { defineMeta } from "@storybook/addon-svelte-csf";
3
2
  import TextNode from "./TextNode.svelte";
3
+ import { localizationDecorator } from "../../stories/localization-decorator";
4
4
  import {
5
5
  fontSizeStoryMeta,
6
6
  fontWeightStoryMeta,
@@ -9,17 +9,38 @@
9
9
  getTextControlStoryMeta,
10
10
  horizontalAlignmentStoryMeta,
11
11
  } from "../../stories/meta-templates";
12
+ import { variablesDecorator } from "../../stories/variables-decorator";
13
+ import type { Localizations } from "../../types/localization";
12
14
  import type { VariableDictionary } from "../../utils/variable-utils";
13
- import { DEFAULT_COLOR_MODE, DEFAULT_TEXT_COLOR } from "../../utils/constants";
15
+ import { defineMeta } from "@storybook/addon-svelte-csf";
14
16
 
15
17
  /*
16
18
  * Documentation for this component can be found in https://www.notion.so/revenuecat/Text-e257cb046e104351861f8364ede617be?pvs=4
17
19
  */
18
20
 
21
+ const defaultLocale = "en_US";
22
+ const text_lid = "lb123";
23
+
19
24
  const { Story } = defineMeta({
20
25
  title: "Components/Text",
21
26
  component: TextNode,
22
27
  tags: ["autodocs"],
28
+ decorators: [
29
+ (Story, context) => {
30
+ const localizations = context.parameters.localizations as Localizations;
31
+ return localizationDecorator({
32
+ defaultLocale: Object.keys(localizations)[0],
33
+ localizations,
34
+ })(Story, context);
35
+ },
36
+ ],
37
+ args: {
38
+ text_lid,
39
+ size: {
40
+ width: { type: "fill" },
41
+ height: { type: "fill" },
42
+ },
43
+ },
23
44
  argTypes: {
24
45
  name: getTextControlStoryMeta("Content of the text to render"),
25
46
  font_name: getTextControlStoryMeta(
@@ -32,29 +53,14 @@
32
53
  horizontal_alignment: horizontalAlignmentStoryMeta,
33
54
  padding: getSpacingStoryMeta("Padding values in pixels"),
34
55
  margin: getSpacingStoryMeta("Margin values in pixels"),
35
- variableDictionary: {
36
- description: "Dictionary containing the values for the variables",
37
- control: { type: "object" },
38
- defaultValue: {},
39
- },
40
56
  },
41
- args: {
42
- labels: {
43
- en_US: {
44
- lb123:
57
+ parameters: {
58
+ localizations: {
59
+ [defaultLocale]: {
60
+ [text_lid]:
45
61
  "Do not allow people to dim your shine because they are blinded. Tell them to put some sunglasses on.",
46
62
  },
47
- },
48
- text_lid: "lb123",
49
- size: {
50
- width: { type: "fill" },
51
- height: { type: "fill" },
52
- },
53
- purchaseState: {
54
- locale: "en_US",
55
- defaultLocale: "en_US",
56
- colorMode: DEFAULT_COLOR_MODE,
57
- },
63
+ } satisfies Localizations,
58
64
  },
59
65
  });
60
66
 
@@ -62,7 +68,7 @@
62
68
  product_name: "CatGPT",
63
69
  price: "$39.99",
64
70
  price_per_period: "$39.99/yr",
65
- };
71
+ } as VariableDictionary;
66
72
  </script>
67
73
 
68
74
  <!-- Default story -->
@@ -73,7 +79,6 @@
73
79
  name="Font Weight"
74
80
  args={{
75
81
  font_weight: "bold",
76
- text_style: "normal",
77
82
  horizontal_alignment: "leading",
78
83
  name: "hello world!",
79
84
  }}
@@ -84,7 +89,6 @@
84
89
  name="Text Alignment"
85
90
  args={{
86
91
  font_weight: "regular",
87
- text_style: "normal",
88
92
  horizontal_alignment: "center",
89
93
  name: "hello world!",
90
94
  }}
@@ -95,7 +99,6 @@
95
99
  name="Color"
96
100
  args={{
97
101
  font_weight: "regular",
98
- text_style: "normal",
99
102
  horizontal_alignment: "leading",
100
103
  color: {
101
104
  dark: { type: "hex", value: "#3471eb" },
@@ -109,123 +112,11 @@
109
112
  }}
110
113
  />
111
114
 
112
- <!-- Linear Gradient Color text story -->
113
- <Story
114
- name="LinearGradientColor"
115
- args={{
116
- font_weight: "regular",
117
- text_style: "normal",
118
- horizontal_alignment: "leading",
119
- size: { width: { type: "fixed", value: 200 }, height: { type: "fit" } },
120
- padding: { top: 20, trailing: 20, bottom: 20, leading: 20 },
121
- color: {
122
- dark: {
123
- degrees: 90,
124
- points: [
125
- {
126
- color: "#9f009f",
127
- percent: 100,
128
- },
129
- {
130
- color: "#090979ff",
131
- percent: 35,
132
- },
133
- {
134
- color: "#53d6ec",
135
- percent: 0,
136
- },
137
- ],
138
- type: "linear",
139
- },
140
- light: {
141
- degrees: 45,
142
- points: [
143
- {
144
- color: "#9f009f",
145
- percent: 0,
146
- },
147
- {
148
- color: "#090979ff",
149
- percent: 50,
150
- },
151
-
152
- {
153
- color: "#53d6ec",
154
- percent: 100,
155
- },
156
- ],
157
- type: "linear",
158
- },
159
- },
160
- background_color: {
161
- dark: { type: "hex", value: DEFAULT_TEXT_COLOR },
162
- light: { type: "hex", value: DEFAULT_TEXT_COLOR },
163
- },
164
- name: "hello world!",
165
- }}
166
- />
167
-
168
- <!-- Radial Gradient Color text story -->
169
- <Story
170
- name="RadialGradientColor"
171
- args={{
172
- font_weight: "regular",
173
- text_style: "normal",
174
- horizontal_alignment: "leading",
175
- size: { width: { type: "fixed", value: 200 }, height: { type: "fit" } },
176
- padding: { top: 20, trailing: 20, bottom: 20, leading: 20 },
177
- color: {
178
- dark: {
179
- degrees: 90,
180
- points: [
181
- {
182
- color: "#9f009f",
183
- percent: 100,
184
- },
185
- {
186
- color: "#090979ff",
187
- percent: 35,
188
- },
189
- {
190
- color: "#53d6ec",
191
- percent: 0,
192
- },
193
- ],
194
- type: "radial",
195
- },
196
- light: {
197
- points: [
198
- {
199
- color: "#53d6ec",
200
- percent: 0,
201
- },
202
- {
203
- color: "#090979ff",
204
- percent: 30,
205
- },
206
-
207
- {
208
- color: "#9f009f",
209
- percent: 50,
210
- },
211
- ],
212
- type: "radial",
213
- },
214
- },
215
- background_color: {
216
- dark: { type: "hex", value: DEFAULT_TEXT_COLOR },
217
- light: { type: "hex", value: DEFAULT_TEXT_COLOR },
218
- },
219
- name: "hello world!",
220
- }}
221
- />
222
-
223
115
  <!-- Text with spacing story -->
224
116
  <Story
225
117
  name="With Spacing"
226
118
  args={{
227
119
  font_weight: "regular",
228
- text_style: "normal",
229
120
  horizontal_alignment: "leading",
230
121
  padding: { top: 16, trailing: 24, bottom: 16, leading: 24 },
231
122
  margin: { top: 8, trailing: 0, bottom: 8, leading: 0 },
@@ -238,19 +129,20 @@
238
129
  name="With variable dictionary"
239
130
  args={{
240
131
  font_weight: "regular",
241
- text_style: "normal",
242
132
  horizontal_alignment: "leading",
243
133
  padding: { top: 16, trailing: 24, bottom: 16, leading: 24 },
244
134
  margin: { top: 8, trailing: 0, bottom: 8, leading: 0 },
245
135
  name: "hello world!",
246
- variableDictionary: mockVariableDictionary as VariableDictionary,
247
- labels: {
248
- en_US: {
249
- lb123:
136
+ text_lid,
137
+ }}
138
+ decorators={[variablesDecorator(mockVariableDictionary)]}
139
+ parameters={{
140
+ localizations: {
141
+ [defaultLocale]: {
142
+ [text_lid]:
250
143
  "This is a text that contains variables: {{ product_name }} for {{ price }} per {{ price_per_period }}",
251
144
  },
252
- },
253
- text_lid: "lb123",
145
+ } satisfies Localizations,
254
146
  }}
255
147
  />
256
148
  <!-- Text with missing variable in dictionary story -->
@@ -258,18 +150,19 @@
258
150
  name="With missing variable in dictionary"
259
151
  args={{
260
152
  font_weight: "regular",
261
- text_style: "normal",
262
153
  horizontal_alignment: "leading",
263
154
  padding: { top: 16, trailing: 24, bottom: 16, leading: 24 },
264
155
  margin: { top: 8, trailing: 0, bottom: 8, leading: 0 },
265
156
  name: "hello world!",
266
- variableDictionary: mockVariableDictionary as VariableDictionary,
267
- labels: {
268
- en_US: {
269
- lb123:
157
+ text_lid,
158
+ }}
159
+ decorators={[variablesDecorator(mockVariableDictionary)]}
160
+ parameters={{
161
+ localizations: {
162
+ [defaultLocale]: {
163
+ [text_lid]:
270
164
  "This is a text with variables: {{ product_name }} for {{ price }} per {{ price_per_period }} and a missing variable: {{ sub_period_abbreviated }}",
271
165
  },
272
- },
273
- text_lid: "lb123",
166
+ } satisfies Localizations,
274
167
  }}
275
168
  />
@@ -6,25 +6,21 @@
6
6
  } from "./text-utils";
7
7
  import Text from "./Text.svelte";
8
8
  import type { TextNodeProps } from "../../data/entities";
9
- import { getLabelAndReplaceVariables } from "../../utils/variable-utils";
9
+ import { getColorModeContext } from "../../stores/color-mode";
10
+ import { getLocalizationContext } from "../../stores/localization";
11
+ import { getVariablesContext } from "../../stores/variables";
12
+ import { replaceVariables } from "../../utils/variable-utils";
10
13
 
11
- const {
12
- id,
13
- labels,
14
- text_lid,
15
- purchaseState,
16
- variableDictionary,
17
- background_color,
18
- size,
19
- ...restProps
20
- }: TextNodeProps = $props();
14
+ const { id, text_lid, background_color, size, ...restProps }: TextNodeProps =
15
+ $props();
16
+
17
+ const getColorMode = getColorModeContext();
18
+ const colorMode = $derived(getColorMode());
21
19
 
22
20
  const { tagToRender, textStyles } = $derived(
23
- getTextNodeStyles({
21
+ getTextNodeStyles(colorMode, {
24
22
  id,
25
- labels,
26
23
  text_lid,
27
- purchaseState,
28
24
  background_color,
29
25
  size,
30
26
  ...restProps,
@@ -35,16 +31,12 @@
35
31
  getTextWrapperStyles(restProps, size, background_color),
36
32
  );
37
33
 
38
- const parsedLabel = $derived(
39
- getLabelAndReplaceVariables({
40
- text_lid,
41
- locale: purchaseState.locale,
42
- defaultLocale: purchaseState.defaultLocale,
43
- labels,
44
- variableDictionary,
45
- }),
34
+ const variables = getVariablesContext();
35
+ const { getLocalizedString } = getLocalizationContext();
36
+ const label = $derived(
37
+ replaceVariables(getLocalizedString(text_lid), $variables),
46
38
  );
47
- const markdownParsed = $derived(getHtmlFromMarkdown(parsedLabel));
39
+ const markdownParsed = $derived(getHtmlFromMarkdown(label));
48
40
  </script>
49
41
 
50
42
  <span style={wrapperStyles} class="rc-pw-text-wrapper">
@@ -1,18 +1,19 @@
1
1
  import type { TextNodeProps } from "../../data/entities";
2
- import type { ColorType, SizeType } from "../../types";
3
- export declare const defaultColor: ColorType;
4
- export declare const defaultBackgroundColor: ColorType;
2
+ import type { ColorMode, SizeType } from "../../types";
3
+ import type { ColorGradientScheme, ColorScheme } from "../../types/colors";
4
+ export declare const defaultColor: ColorScheme;
5
+ export declare const defaultBackgroundColor: ColorGradientScheme;
5
6
  /**
6
7
  * Generates comprehensive styles for text components by combining text, component and size styles
7
8
  * @param props - Text component properties including font, color, background, spacing etc.
8
9
  * @returns Object containing text style variables and the appropriate HTML tag to render
9
10
  */
10
- export declare const getTextComponentStyles: (props: TextNodeProps) => {
11
+ export declare const getTextComponentStyles: (colorMode: ColorMode, props: TextNodeProps) => {
11
12
  textStyles: Record<string, string | number>;
12
13
  tagToRender: import("../../utils/style-utils").TextComponentTags;
13
14
  };
14
- export declare function getTextWrapperStyles(restProps: Partial<TextNodeProps>, size: SizeType, background_color?: ColorType): string;
15
- export declare function getTextNodeStyles(props: TextNodeProps): {
15
+ export declare function getTextWrapperStyles(restProps: Partial<TextNodeProps>, size: SizeType, background_color?: ColorGradientScheme | null): string;
16
+ export declare function getTextNodeStyles(colorMode: ColorMode, props: TextNodeProps): {
16
17
  tagToRender: import("../../utils/style-utils").TextComponentTags;
17
18
  textStyles: string;
18
19
  };
@@ -1,5 +1,5 @@
1
- import { getActiveStateProps, getComponentStyles, getSizeStyle, getTextComponentTag, getTextStyles, prefixObject, stringifyStyles, } from "../../utils/style-utils";
2
1
  import { DEFAULT_BACKGROUND_COLOR, DEFAULT_TEXT_COLOR, } from "../../utils/constants";
2
+ import { getActiveStateProps, getComponentStyles, getSizeStyle, getTextComponentTag, getTextStyles, prefixObject, stringifyStyles, } from "../../utils/style-utils";
3
3
  export const defaultColor = {
4
4
  light: { type: "hex", value: DEFAULT_TEXT_COLOR },
5
5
  };
@@ -11,8 +11,8 @@ export const defaultBackgroundColor = {
11
11
  * @param props - Text component properties including font, color, background, spacing etc.
12
12
  * @returns Object containing text style variables and the appropriate HTML tag to render
13
13
  */
14
- export const getTextComponentStyles = (props) => {
15
- const { font_size = "body_m", color = defaultColor, background_color = defaultBackgroundColor, padding, margin, size, purchaseState, } = props;
14
+ export const getTextComponentStyles = (colorMode, props) => {
15
+ const { font_size = "body_m", color = defaultColor, background_color = defaultBackgroundColor, padding, margin, size, } = props;
16
16
  const styles = {
17
17
  "--width": "unset",
18
18
  "--height": "unset",
@@ -42,13 +42,13 @@ export const getTextComponentStyles = (props) => {
42
42
  };
43
43
  const activeStateProps = getActiveStateProps(props.overrides, props.componentState);
44
44
  const tagToRender = getTextComponentTag(font_size);
45
- const textStyles = getTextStyles({ ...props, ...activeStateProps }, purchaseState.colorMode);
45
+ const textStyles = getTextStyles({ ...props, ...activeStateProps });
46
46
  const componentStyles = getComponentStyles({
47
47
  background_color,
48
48
  color,
49
49
  margin,
50
50
  padding,
51
- colorMode: purchaseState.colorMode,
51
+ colorMode,
52
52
  ...activeStateProps,
53
53
  });
54
54
  const sizeStyles = getSizeStyle({ ...size, ...activeStateProps });
@@ -96,7 +96,7 @@ export function getTextWrapperStyles(restProps, size, background_color) {
96
96
  const prefixedStyles = prefixObject(styles, "text");
97
97
  return stringifyStyles(prefixedStyles);
98
98
  }
99
- export function getTextNodeStyles(props) {
99
+ export function getTextNodeStyles(colorMode, props) {
100
100
  const styles = {
101
101
  "--text-margin-block-start": "0px",
102
102
  "--text-margin-inline-end": "0px",
@@ -124,7 +124,7 @@ export function getTextNodeStyles(props) {
124
124
  "--text-height": "unset",
125
125
  "--text-flex": "0 1 auto",
126
126
  };
127
- const { tagToRender, textStyles } = getTextComponentStyles(props);
127
+ const { tagToRender, textStyles } = getTextComponentStyles(colorMode, props);
128
128
  Object.assign(styles, textStyles);
129
129
  return { tagToRender, textStyles: stringifyStyles(styles) };
130
130
  }
@@ -1,48 +1,46 @@
1
1
  <script module lang="ts">
2
- import { defineMeta } from "@storybook/addon-svelte-csf";
3
2
  import { Timeline } from "../..";
4
- import type { PurchaseState } from "../../data/state";
5
3
  import { defaultColor } from "../text/text-utils";
6
- import { type TimelineProps } from "../../data/entities";
7
- import { DEFAULT_COLOR_MODE } from "../../utils/constants";
4
+ import { localizationDecorator } from "../../stories/localization-decorator";
5
+ import { defineMeta } from "@storybook/addon-svelte-csf";
6
+
7
+ const defaultLocale = "en_US";
8
8
 
9
9
  const { Story } = defineMeta({
10
10
  title: "Components/Timeline",
11
11
  component: Timeline,
12
12
  tags: ["autodocs"],
13
+ decorators: [
14
+ localizationDecorator({
15
+ defaultLocale,
16
+ localizations: {
17
+ [defaultLocale]: {
18
+ asd123: "Item 1",
19
+ asd123d: "description 1",
20
+ qwe123: "Item 2",
21
+ qwe123d: "description 2",
22
+ zxc123: "Item 3",
23
+ zxc123d: "description 3",
24
+ rty123: "Item 4",
25
+ rty123d: "description 4",
26
+ fgh123: "Item 5",
27
+ fgh123d: "description 5",
28
+ case1: "Case 1",
29
+ case1d: "No spacing between connector and item",
30
+ case2: "Case 2",
31
+ case2d: "Spacing between connector and item",
32
+ case3: "Case 3",
33
+ case3d: "Spacing at bottom of connector",
34
+ case4: "Case 4",
35
+ case4d: "Spacing at top of connector",
36
+ case5: "Case 5",
37
+ case5d: "No Connector",
38
+ },
39
+ },
40
+ }),
41
+ ],
13
42
  argTypes: {},
14
43
  });
15
-
16
- const purchaseState: PurchaseState = {
17
- locale: "en_US",
18
- defaultLocale: "en_US",
19
- colorMode: DEFAULT_COLOR_MODE,
20
- };
21
-
22
- const labels = {
23
- en_US: {
24
- asd123: "Item 1",
25
- asd123d: "description 1",
26
- qwe123: "Item 2",
27
- qwe123d: "description 2",
28
- zxc123: "Item 3",
29
- zxc123d: "description 3",
30
- rty123: "Item 4",
31
- rty123d: "description 4",
32
- fgh123: "Item 5",
33
- fgh123d: "description 5",
34
- case1: "Case 1",
35
- case1d: "No spacing between connector and item",
36
- case2: "Case 2",
37
- case2d: "Spacing between connector and item",
38
- case3: "Case 3",
39
- case3d: "Spacing at bottom of connector",
40
- case4: "Case 4",
41
- case4d: "Spacing at top of connector",
42
- case5: "Case 5",
43
- case5d: "No Connector",
44
- },
45
- };
46
44
  </script>
47
45
 
48
46
  <!-- Timeline -->
@@ -50,8 +48,6 @@
50
48
  name="Round icon"
51
49
  args={{
52
50
  type: "timeline",
53
- labels,
54
- purchaseState,
55
51
  item_spacing: 32,
56
52
  text_spacing: 16,
57
53
  size: { width: { type: "fill" }, height: { type: "fit" } },
@@ -157,15 +153,13 @@
157
153
  },
158
154
  },
159
155
  ],
160
- } satisfies TimelineProps}
156
+ }}
161
157
  />
162
158
 
163
159
  <Story
164
160
  name="Square icon"
165
161
  args={{
166
162
  type: "timeline",
167
- labels,
168
- purchaseState,
169
163
  item_spacing: 32,
170
164
  text_spacing: 16,
171
165
  size: { width: { type: "fill" }, height: { type: "fit" } },
@@ -295,14 +289,12 @@
295
289
  },
296
290
  },
297
291
  ],
298
- } satisfies TimelineProps}
292
+ }}
299
293
  />
300
294
  <Story
301
295
  name="With connector"
302
296
  args={{
303
297
  type: "timeline",
304
- labels,
305
- purchaseState,
306
298
  item_spacing: 32,
307
299
  text_spacing: 16,
308
300
  size: { width: { type: "fill" }, height: { type: "fit" } },
@@ -427,7 +419,6 @@
427
419
  color: "#d3d3d3",
428
420
  percent: 0,
429
421
  },
430
-
431
422
  {
432
423
  color: "#d3d3d300",
433
424
  percent: 100,
@@ -439,15 +430,13 @@
439
430
  },
440
431
  },
441
432
  ],
442
- } satisfies TimelineProps}
433
+ }}
443
434
  />
444
435
 
445
436
  <Story
446
437
  name="Connector possibilities"
447
438
  args={{
448
439
  type: "timeline",
449
- labels,
450
- purchaseState,
451
440
  item_spacing: 64,
452
441
  text_spacing: 8,
453
442
  size: { width: { type: "fill" }, height: { type: "fit" } },
@@ -637,5 +626,5 @@
637
626
  },
638
627
  },
639
628
  ],
640
- } satisfies TimelineProps}
629
+ }}
641
630
  />
@@ -13,11 +13,9 @@
13
13
  {#each items as item, index}
14
14
  <TimelineItem
15
15
  {...item}
16
- labels={restProps.labels}
17
16
  id={`${restProps.id}-${index}`}
18
17
  name={`${restProps.name}-${index}`}
19
18
  type="timeline"
20
- purchaseState={restProps.purchaseState}
21
19
  text_spacing={restProps.text_spacing}
22
20
  item_spacing={restProps.item_spacing}
23
21
  />