@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.
- package/dist/components/button/Button.svelte +1 -5
- package/dist/components/button/ButtonNode.stories.svelte +57 -71
- package/dist/components/button/ButtonNode.stories.svelte.d.ts +0 -8
- package/dist/components/button/ButtonNode.svelte +10 -21
- package/dist/components/button/ButtonNode.svelte.d.ts +2 -2
- package/dist/components/button/button-utils.d.ts +2 -2
- package/dist/components/footer/Footer.stories.svelte +26 -22
- package/dist/components/footer/Footer.stories.svelte.d.ts +0 -5
- package/dist/components/footer/Footer.svelte +3 -10
- package/dist/components/footer/Footer.svelte.d.ts +1 -1
- package/dist/components/image/Image.stories.svelte +27 -19
- package/dist/components/image/Image.svelte +18 -17
- package/dist/components/image/image-utils.d.ts +2 -1
- package/dist/components/image/image-utils.js +2 -2
- package/dist/components/package/Package.stories.svelte +31 -31
- package/dist/components/package/Package.stories.svelte.d.ts +0 -6
- package/dist/components/package/Package.svelte +19 -30
- package/dist/components/package/Package.svelte.d.ts +1 -1
- package/dist/components/paywall/Node.svelte +26 -50
- package/dist/components/paywall/Node.svelte.d.ts +11 -14
- package/dist/components/paywall/Paywall.stories.svelte +21 -78
- package/dist/components/paywall/Paywall.svelte +75 -100
- package/dist/components/paywall/Paywall.svelte.d.ts +4 -4
- package/dist/components/paywall/paywall-utils.d.ts +3 -2
- package/dist/components/paywall/paywall-utils.js +5 -5
- package/dist/components/purchase-button/PurchaseButton.stories.svelte +29 -31
- package/dist/components/purchase-button/PurchaseButton.stories.svelte.d.ts +0 -5
- package/dist/components/purchase-button/PurchaseButton.svelte +9 -20
- package/dist/components/purchase-button/PurchaseButton.svelte.d.ts +1 -1
- package/dist/components/purchase-button/purchase-button-utils.d.ts +1 -1
- package/dist/components/stack/Stack.stories.svelte +17 -94
- package/dist/components/stack/Stack.svelte +18 -48
- package/dist/components/stack/stack-utils.d.ts +4 -3
- package/dist/components/stack/stack-utils.js +7 -10
- package/dist/components/text/TextNode.stories.svelte +45 -152
- package/dist/components/text/TextNode.svelte +15 -23
- package/dist/components/text/text-utils.d.ts +7 -6
- package/dist/components/text/text-utils.js +7 -7
- package/dist/components/timeline/Timeline.stories.svelte +37 -48
- package/dist/components/timeline/Timeline.svelte +0 -2
- package/dist/components/timeline/TimelineItem.svelte +28 -11
- package/dist/components/timeline/timeline-utils.d.ts +3 -3
- package/dist/components/timeline/timeline-utils.js +7 -17
- package/dist/data/entities.d.ts +54 -145
- package/dist/index.d.ts +10 -10
- package/dist/index.js +10 -10
- package/dist/stores/color-mode.d.ts +6 -0
- package/dist/stores/color-mode.js +15 -0
- package/dist/stores/localization.d.ts +13 -0
- package/dist/stores/localization.js +26 -0
- package/dist/stores/paywall.d.ts +11 -0
- package/dist/stores/paywall.js +13 -0
- package/dist/stores/variables.d.ts +5 -0
- package/dist/stores/variables.js +14 -0
- package/dist/stories/fixtures.d.ts +1 -1
- package/dist/stories/fixtures.js +30 -135
- package/dist/stories/localization-decorator.d.ts +3 -0
- package/dist/stories/localization-decorator.js +7 -0
- package/dist/stories/paywall-decorator.d.ts +2 -0
- package/dist/stories/paywall-decorator.js +19 -0
- package/dist/stories/variables-decorator.d.ts +3 -0
- package/dist/stories/variables-decorator.js +9 -0
- package/dist/stories/with-layout.svelte +4 -4
- package/dist/types/alignment.d.ts +19 -0
- package/dist/types/background.d.ts +18 -0
- package/dist/types/background.js +1 -0
- package/dist/types/colors.d.ts +34 -0
- package/dist/types/colors.js +1 -0
- package/dist/types/component.d.ts +6 -0
- package/dist/types/component.js +1 -0
- package/dist/types/components/button.d.ts +36 -0
- package/dist/types/components/button.js +1 -0
- package/dist/types/components/footer.d.ts +5 -0
- package/dist/types/components/footer.js +1 -0
- package/dist/types/components/package.d.ts +8 -0
- package/dist/types/components/package.js +1 -0
- package/dist/types/components/purchase-button.d.ts +5 -0
- package/dist/types/components/purchase-button.js +1 -0
- package/dist/types/localization.d.ts +4 -0
- package/dist/types/localization.js +1 -0
- package/dist/types/media.d.ts +18 -0
- package/dist/types/media.js +1 -0
- package/dist/types.d.ts +5 -35
- package/dist/ui/atoms/typography.stories.svelte +7 -13
- package/dist/ui/atoms/typography.stories.svelte.d.ts +1 -1
- package/dist/ui/atoms/typography.svelte +1 -1
- package/dist/ui/layout/main-block.svelte +2 -2
- package/dist/ui/molecules/button.stories.svelte +8 -15
- package/dist/ui/molecules/button.svelte +3 -2
- package/dist/ui/molecules/button.svelte.d.ts +2 -26
- package/dist/ui/molecules/types.d.ts +2 -1
- package/dist/ui/theme/theme.d.ts +2 -2
- package/dist/ui/theme/theme.js +2 -2
- package/dist/ui/theme/utils.d.ts +2 -2
- package/dist/utils/style-utils.d.ts +13 -11
- package/dist/utils/style-utils.js +21 -27
- package/dist/utils/variable-utils.d.ts +1 -38
- package/dist/utils/variable-utils.js +6 -48
- package/dist/web-components/index.css +1 -1
- package/dist/web-components/index.js +610 -657
- package/package.json +33 -36
- package/dist/data/state.d.ts +0 -9
- package/dist/stores/theme.d.ts +0 -1
- package/dist/stores/theme.js +0 -17
- /package/dist/{data/state.js → types/alignment.js} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type LocalizationContextProps } from "../stores/localization";
|
|
2
|
+
import type { DecoratorFunction, Renderer } from "storybook/internal/csf";
|
|
3
|
+
export declare function localizationDecorator<TRenderer extends Renderer, TArgs>(props: LocalizationContextProps): DecoratorFunction<TRenderer, TArgs>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { setPaywallContext } from "../stores/paywall";
|
|
2
|
+
import { readable, writable } from "svelte/store";
|
|
3
|
+
export function paywallDecorator() {
|
|
4
|
+
return (Story) => {
|
|
5
|
+
const selectedPackageId = writable(undefined);
|
|
6
|
+
selectedPackageId.subscribe((packageId) => {
|
|
7
|
+
if (packageId !== undefined) {
|
|
8
|
+
window.alert(`Selected package ${packageId}`);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
setPaywallContext({
|
|
12
|
+
selectedPackageId,
|
|
13
|
+
variablesPerPackage: readable(undefined),
|
|
14
|
+
onPurchase: () => window.alert("Purchase clicked"),
|
|
15
|
+
onButtonAction: (action) => window.alert(`Button clicked: ${JSON.stringify(action, undefined, 2)}`),
|
|
16
|
+
});
|
|
17
|
+
return Story();
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { VariableDictionary } from "../utils/variable-utils";
|
|
2
|
+
import type { DecoratorFunction, Renderer } from "storybook/internal/csf";
|
|
3
|
+
export declare function variablesDecorator<TRenderer extends Renderer, TArgs>(variables?: VariableDictionary): DecoratorFunction<TRenderer, TArgs>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { setVariablesContext } from "../stores/variables";
|
|
2
|
+
import { readable } from "svelte/store";
|
|
3
|
+
export function variablesDecorator(variables) {
|
|
4
|
+
const store = readable(variables);
|
|
5
|
+
return (Story) => {
|
|
6
|
+
setVariablesContext(store);
|
|
7
|
+
return Story();
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import {
|
|
3
|
-
import { toProductInfoStyleVar } from "../ui/theme/utils";
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
4
3
|
import Container from "../ui/layout/container.svelte";
|
|
5
4
|
import Layout from "../ui/layout/layout.svelte";
|
|
6
5
|
import Main from "../ui/layout/main-block.svelte";
|
|
7
|
-
import
|
|
6
|
+
import { toProductInfoStyleVar } from "../ui/theme/utils";
|
|
7
|
+
import { brandingAppearances } from "./fixtures";
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
10
|
<script lang="ts">
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Distribution = "start" | "center" | "end" | "space_between" | "space_around" | "space_evenly";
|
|
2
|
+
export type VerticalAlignment = "top" | "center" | "bottom";
|
|
3
|
+
export type HorizontalDimension = {
|
|
4
|
+
type: "horizontal";
|
|
5
|
+
alignment: VerticalAlignment;
|
|
6
|
+
distribution: Distribution;
|
|
7
|
+
};
|
|
8
|
+
export type HorizontalAlignment = "leading" | "center" | "trailing";
|
|
9
|
+
export type VerticalDimension = {
|
|
10
|
+
type: "vertical";
|
|
11
|
+
alignment: HorizontalAlignment;
|
|
12
|
+
distribution: Distribution;
|
|
13
|
+
};
|
|
14
|
+
export type ZAlignment = "top_leading" | "top" | "top_trailing" | "leading" | "center" | "trailing" | "bottom_leading" | "bottom" | "bottom_trailing";
|
|
15
|
+
export type ZDimension = {
|
|
16
|
+
type: "zlayer";
|
|
17
|
+
alignment: ZAlignment;
|
|
18
|
+
};
|
|
19
|
+
export type Dimension = HorizontalDimension | VerticalDimension | ZDimension;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ColorGradientScheme } from "./colors";
|
|
2
|
+
import type { ImageInfo, ImageObjectFit, VideoInfo } from "./media";
|
|
3
|
+
export type BackgroundColor = {
|
|
4
|
+
type: "color";
|
|
5
|
+
value: ColorGradientScheme;
|
|
6
|
+
};
|
|
7
|
+
export type BackgroundImage = {
|
|
8
|
+
type: "image";
|
|
9
|
+
value: ImageInfo;
|
|
10
|
+
color_overlay: ColorGradientScheme | null;
|
|
11
|
+
fit_mode: ImageObjectFit;
|
|
12
|
+
};
|
|
13
|
+
export type BackgroundVideo = {
|
|
14
|
+
type: "video";
|
|
15
|
+
value: VideoInfo;
|
|
16
|
+
color_overlay: ColorGradientScheme | null;
|
|
17
|
+
};
|
|
18
|
+
export type Background = BackgroundColor | BackgroundImage | BackgroundVideo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type GradientPoint = {
|
|
2
|
+
percent: number;
|
|
3
|
+
color: string;
|
|
4
|
+
};
|
|
5
|
+
type GradientColorInfo = {
|
|
6
|
+
type: "linear" | "radial";
|
|
7
|
+
points: GradientPoint[];
|
|
8
|
+
};
|
|
9
|
+
export type LinearGradientColorInfo = GradientColorInfo & {
|
|
10
|
+
type: "linear";
|
|
11
|
+
degrees: number;
|
|
12
|
+
};
|
|
13
|
+
export type RadialGradientColorInfo = GradientColorInfo & {
|
|
14
|
+
type: "radial";
|
|
15
|
+
};
|
|
16
|
+
type AliasColorInfo = {
|
|
17
|
+
type: "alias";
|
|
18
|
+
value: string;
|
|
19
|
+
};
|
|
20
|
+
type HexColorInfo = {
|
|
21
|
+
type: "hex";
|
|
22
|
+
value: string;
|
|
23
|
+
};
|
|
24
|
+
export type ColorInfo = AliasColorInfo | HexColorInfo;
|
|
25
|
+
export type ColorGradientInfo = ColorInfo | LinearGradientColorInfo | RadialGradientColorInfo;
|
|
26
|
+
export type ColorScheme = {
|
|
27
|
+
light: ColorInfo;
|
|
28
|
+
dark?: ColorInfo | null;
|
|
29
|
+
};
|
|
30
|
+
export type ColorGradientScheme = {
|
|
31
|
+
light: ColorGradientInfo;
|
|
32
|
+
dark?: ColorGradientInfo | null;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ImageProps, StackProps, TextNodeProps, TimelineProps } from "../data/entities";
|
|
2
|
+
import type { ButtonProps } from "./components/button";
|
|
3
|
+
import type { FooterProps } from "./components/footer";
|
|
4
|
+
import type { PackageProps } from "./components/package";
|
|
5
|
+
import type { PurchaseButtonProps } from "./components/purchase-button";
|
|
6
|
+
export type Component = ButtonProps | FooterProps | ImageProps | PackageProps | PurchaseButtonProps | StackProps | TextNodeProps | TimelineProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { BaseComponent, StackProps } from "../../data/entities";
|
|
2
|
+
interface RestorePurchasesAction {
|
|
3
|
+
type: "restore_purchases";
|
|
4
|
+
}
|
|
5
|
+
interface NavigateBackAction {
|
|
6
|
+
type: "navigate_back";
|
|
7
|
+
}
|
|
8
|
+
interface NavigateToAction {
|
|
9
|
+
type: "navigate_to";
|
|
10
|
+
destination: "customer_center" | "offer_code";
|
|
11
|
+
}
|
|
12
|
+
interface NavigateToSheetAction {
|
|
13
|
+
type: "navigate_to";
|
|
14
|
+
destination: "sheet";
|
|
15
|
+
sheet?: unknown;
|
|
16
|
+
}
|
|
17
|
+
interface NavigateToWebPurchase {
|
|
18
|
+
type: "navigate_to";
|
|
19
|
+
destination: "web_paywall_link";
|
|
20
|
+
custom_url_options?: unknown;
|
|
21
|
+
}
|
|
22
|
+
interface NavigateToUrlAction {
|
|
23
|
+
type: "navigate_to";
|
|
24
|
+
destination: "privacy_policy" | "terms" | "url";
|
|
25
|
+
url: {
|
|
26
|
+
url_lid: string;
|
|
27
|
+
method: "deep_link" | "external_browser" | "in_app_browser";
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export type Action = RestorePurchasesAction | NavigateBackAction | NavigateToAction | NavigateToSheetAction | NavigateToWebPurchase | NavigateToUrlAction;
|
|
31
|
+
export interface ButtonProps extends BaseComponent {
|
|
32
|
+
type: "button";
|
|
33
|
+
action: Action;
|
|
34
|
+
stack: StackProps;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BaseComponent, StackProps } from "../../data/entities";
|
|
2
|
+
export interface PackageProps extends BaseComponent {
|
|
3
|
+
type: "package";
|
|
4
|
+
package_id: string;
|
|
5
|
+
is_selected_by_default: boolean;
|
|
6
|
+
apple_promo_offer_product_code?: string | null;
|
|
7
|
+
stack: StackProps;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ImageFiles = {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
original: string;
|
|
5
|
+
heic: string;
|
|
6
|
+
heic_low_res: string;
|
|
7
|
+
webp: string;
|
|
8
|
+
webp_low_res: string;
|
|
9
|
+
};
|
|
10
|
+
export type ImageInfo = {
|
|
11
|
+
light: ImageFiles;
|
|
12
|
+
dark: ImageFiles | null;
|
|
13
|
+
};
|
|
14
|
+
export type VideoInfo = {
|
|
15
|
+
light: string;
|
|
16
|
+
dark: string | null;
|
|
17
|
+
};
|
|
18
|
+
export type ImageObjectFit = "fit" | "fill";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
+
import type { ColorScheme } from "./types/colors";
|
|
1
2
|
export type ColorMode = "light" | "dark";
|
|
2
|
-
export type ColorStop = {
|
|
3
|
-
color: string;
|
|
4
|
-
percent: number;
|
|
5
|
-
};
|
|
6
|
-
export type Color = {
|
|
7
|
-
type: "hex" | "alias" | "linear" | "radial";
|
|
8
|
-
value?: string;
|
|
9
|
-
degrees?: number;
|
|
10
|
-
points?: ColorStop[];
|
|
11
|
-
};
|
|
12
|
-
export type ColorType = {
|
|
13
|
-
dark?: Color;
|
|
14
|
-
light: Color;
|
|
15
|
-
};
|
|
16
3
|
export declare enum FontSizeTags {
|
|
17
4
|
body_s = "p",
|
|
18
5
|
body_m = "p",
|
|
@@ -58,13 +45,13 @@ export type SizeType = {
|
|
|
58
45
|
height: Size;
|
|
59
46
|
};
|
|
60
47
|
export type Size = FixedSize | RelativeSize;
|
|
61
|
-
export type FitTypes = "fit" | "fill";
|
|
62
48
|
type FixedSize = {
|
|
63
49
|
type: "fixed";
|
|
64
50
|
value: number;
|
|
65
51
|
};
|
|
66
52
|
type RelativeSize = {
|
|
67
|
-
type:
|
|
53
|
+
type: "fit" | "fill";
|
|
54
|
+
value?: null;
|
|
68
55
|
};
|
|
69
56
|
export type ShapeType = RectangleShape | PillShape;
|
|
70
57
|
export type RectangleShape = {
|
|
@@ -78,7 +65,7 @@ type PillShape = {
|
|
|
78
65
|
type: "pill";
|
|
79
66
|
};
|
|
80
67
|
export type BorderType = {
|
|
81
|
-
color:
|
|
68
|
+
color: ColorScheme;
|
|
82
69
|
width: number;
|
|
83
70
|
};
|
|
84
71
|
export type Spacing = {
|
|
@@ -93,29 +80,12 @@ export type CornerRadiusType = {
|
|
|
93
80
|
top_leading: number;
|
|
94
81
|
top_trailing: number;
|
|
95
82
|
};
|
|
96
|
-
export type DimensionType = VerticalAlignment | HorizontalAlignment | ZAlignment;
|
|
97
|
-
type VerticalAlignment = {
|
|
98
|
-
type: "vertical";
|
|
99
|
-
alignment: "top" | "center" | "bottom";
|
|
100
|
-
distribution?: Distribution;
|
|
101
|
-
};
|
|
102
|
-
type HorizontalAlignment = {
|
|
103
|
-
type: "horizontal";
|
|
104
|
-
alignment: "leading" | "center" | "trailing";
|
|
105
|
-
distribution?: Distribution;
|
|
106
|
-
};
|
|
107
83
|
export type AlignmentType = "top_leading" | "top" | "top_trailing" | "leading" | "center" | "trailing" | "bottom_leading" | "bottom" | "bottom_trailing";
|
|
108
|
-
export type ZAlignment = {
|
|
109
|
-
type: "zlayer";
|
|
110
|
-
alignment: AlignmentType;
|
|
111
|
-
distribution?: never;
|
|
112
|
-
};
|
|
113
|
-
type Distribution = "space_between" | "space_around" | "space_evenly" | "start" | "center" | "end";
|
|
114
84
|
export type ShadowType = {
|
|
115
85
|
x: number;
|
|
116
86
|
y: number;
|
|
117
87
|
radius: number;
|
|
118
|
-
color:
|
|
88
|
+
color: ColorScheme;
|
|
119
89
|
};
|
|
120
90
|
export declare enum StackDirection {
|
|
121
91
|
vertical = "column",
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { default as Typography } from "../../ui/atoms/typography.svelte";
|
|
3
|
-
import {
|
|
4
|
-
type Args,
|
|
5
|
-
defineMeta,
|
|
6
|
-
setTemplate,
|
|
7
|
-
} from "@storybook/addon-svelte-csf";
|
|
1
|
+
<script module lang="ts">
|
|
8
2
|
import { withLayout } from "../../stories/with-layout";
|
|
3
|
+
import { default as Typography } from "./typography.svelte";
|
|
4
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
5
|
+
import { type ComponentProps } from "svelte";
|
|
9
6
|
import { brandingViewportModes } from "../../../../.storybook/modes";
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
const { Story } = defineMeta({
|
|
12
9
|
component: Typography,
|
|
13
10
|
title: "Atoms/Typography",
|
|
14
11
|
// @ts-expect-error ignore typing of decorator
|
|
@@ -35,16 +32,13 @@
|
|
|
35
32
|
modes: brandingViewportModes,
|
|
36
33
|
},
|
|
37
34
|
},
|
|
35
|
+
render: template,
|
|
38
36
|
});
|
|
39
37
|
|
|
40
38
|
const baseContent = "The quick brown fox jumps over the lazy dog";
|
|
41
39
|
</script>
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
setTemplate(template);
|
|
45
|
-
</script>
|
|
46
|
-
|
|
47
|
-
{#snippet template({ size = "body-base" }: Args<typeof Story>)}
|
|
41
|
+
{#snippet template({ size = "body-base" }: ComponentProps<typeof Typography>)}
|
|
48
42
|
<Typography {size}>
|
|
49
43
|
{#snippet children()}
|
|
50
44
|
Default text
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { default as Typography } from "
|
|
1
|
+
import { default as Typography } from "./typography.svelte";
|
|
2
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
3
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
4
|
$$bindings?: Bindings;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { Theme } from "../theme/theme";
|
|
3
2
|
import { onMount } from "svelte";
|
|
4
|
-
import
|
|
3
|
+
import { Theme } from "../theme/theme";
|
|
5
4
|
import type { BrandingAppearance } from "../utils/branding";
|
|
5
|
+
import SectionLayout from "./section-layout.svelte";
|
|
6
6
|
|
|
7
7
|
export let brandingAppearance: BrandingAppearance | null | undefined =
|
|
8
8
|
undefined;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
<script module>
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
import { brandingAppearances } from "../../stories/fixtures";
|
|
3
|
-
import { default as Button } from "./button.svelte";
|
|
4
|
-
import {
|
|
5
|
-
type Args,
|
|
6
|
-
defineMeta,
|
|
7
|
-
setTemplate,
|
|
8
|
-
type StoryContext,
|
|
9
|
-
} from "@storybook/addon-svelte-csf";
|
|
10
3
|
import { withLayout } from "../../stories/with-layout";
|
|
4
|
+
import { defineMeta, type StoryContext } from "@storybook/addon-svelte-csf";
|
|
5
|
+
import type { ComponentProps } from "svelte";
|
|
6
|
+
import { default as Button } from "./button.svelte";
|
|
11
7
|
|
|
12
|
-
|
|
8
|
+
const { Story } = defineMeta({
|
|
13
9
|
component: Button,
|
|
14
10
|
title: "Molecules/Button",
|
|
15
11
|
// @ts-expect-error ignore typing of decorator
|
|
@@ -20,6 +16,7 @@
|
|
|
20
16
|
options: ["primary", undefined],
|
|
21
17
|
},
|
|
22
18
|
},
|
|
19
|
+
render: template,
|
|
23
20
|
});
|
|
24
21
|
|
|
25
22
|
const args = {
|
|
@@ -30,13 +27,9 @@
|
|
|
30
27
|
};
|
|
31
28
|
</script>
|
|
32
29
|
|
|
33
|
-
<script lang="ts">
|
|
34
|
-
setTemplate(template);
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
30
|
{#snippet template(
|
|
38
|
-
{ ...args }:
|
|
39
|
-
context: StoryContext<typeof
|
|
31
|
+
{ ...args }: ComponentProps<typeof Button>,
|
|
32
|
+
context: StoryContext<typeof Button>,
|
|
40
33
|
)}
|
|
41
34
|
{@const brandingInfo = brandingAppearances[context.globals.brandingName]}
|
|
42
35
|
<Button {...args} brandingAppearance={brandingInfo ?? undefined}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import ProcessingAnimation from "../utils/processing-animation.svelte";
|
|
3
2
|
import Typography from "../atoms/typography.svelte";
|
|
4
3
|
import { Theme } from "../theme/theme";
|
|
4
|
+
import ProcessingAnimation from "../utils/processing-animation.svelte";
|
|
5
5
|
import type { UIButtonProps } from "./types";
|
|
6
6
|
|
|
7
7
|
const {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
loading = false,
|
|
14
14
|
brandingAppearance,
|
|
15
15
|
styleOverrides,
|
|
16
|
+
children,
|
|
16
17
|
}: UIButtonProps = $props();
|
|
17
18
|
|
|
18
19
|
const theme = $derived(new Theme(brandingAppearance));
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
{#if loading}
|
|
40
41
|
<ProcessingAnimation size="small" />
|
|
41
42
|
{:else}
|
|
42
|
-
<Typography size="body-base"
|
|
43
|
+
<Typography size="body-base">{@render children?.()}</Typography>
|
|
43
44
|
{/if}
|
|
44
45
|
</button>
|
|
45
46
|
|
|
@@ -1,28 +1,4 @@
|
|
|
1
1
|
import type { UIButtonProps } from "./types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports & {
|
|
10
|
-
$set?: any;
|
|
11
|
-
$on?: any;
|
|
12
|
-
};
|
|
13
|
-
z_$$bindings?: Bindings;
|
|
14
|
-
}
|
|
15
|
-
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
16
|
-
default: any;
|
|
17
|
-
} ? Props extends Record<string, never> ? any : {
|
|
18
|
-
children?: any;
|
|
19
|
-
} : {});
|
|
20
|
-
declare const Button: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<UIButtonProps, {
|
|
21
|
-
default: {};
|
|
22
|
-
}>, {
|
|
23
|
-
[evt: string]: CustomEvent<any>;
|
|
24
|
-
}, {
|
|
25
|
-
default: {};
|
|
26
|
-
}, {}, "">;
|
|
27
|
-
type Button = InstanceType<typeof Button>;
|
|
2
|
+
declare const Button: import("svelte").Component<UIButtonProps, {}, "">;
|
|
3
|
+
type Button = ReturnType<typeof Button>;
|
|
28
4
|
export default Button;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
1
2
|
import type { BrandingAppearance } from "../utils/branding";
|
|
2
3
|
export interface UIButtonProps {
|
|
3
4
|
onclick?: (event: any) => void;
|
|
4
|
-
children?:
|
|
5
|
+
children?: Snippet;
|
|
5
6
|
intent?: "primary";
|
|
6
7
|
disabled?: boolean;
|
|
7
8
|
testId?: string | undefined;
|
package/dist/ui/theme/theme.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Shape } from "./shapes";
|
|
2
|
-
import type { Colors } from "./colors";
|
|
3
1
|
import type { BrandingAppearance } from "../utils/branding";
|
|
2
|
+
import type { Colors } from "./colors";
|
|
3
|
+
import type { Shape } from "./shapes";
|
|
4
4
|
export declare class Theme {
|
|
5
5
|
private readonly brandingAppearance;
|
|
6
6
|
constructor(brandingAppearance?: BrandingAppearance | null | undefined);
|
package/dist/ui/theme/theme.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { toFormColors, toFormStyleVar, toProductInfoStyleVar, toShape, toSpacingVars, toTextStyleVar, } from "./utils";
|
|
2
|
-
import { DEFAULT_TEXT_STYLES } from "./text";
|
|
3
1
|
import { DEFAULT_SPACING } from "./spacing";
|
|
2
|
+
import { DEFAULT_TEXT_STYLES } from "./text";
|
|
3
|
+
import { toFormColors, toFormStyleVar, toProductInfoStyleVar, toShape, toSpacingVars, toTextStyleVar, } from "./utils";
|
|
4
4
|
export class Theme {
|
|
5
5
|
brandingAppearance;
|
|
6
6
|
constructor(brandingAppearance) {
|
package/dist/ui/theme/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { BrandingAppearance } from "../utils/branding";
|
|
1
2
|
import { type Colors } from "./colors";
|
|
2
3
|
import { type Shape } from "./shapes";
|
|
3
|
-
import { type TextStyles } from "./text";
|
|
4
4
|
import type { Spacing } from "./spacing";
|
|
5
|
-
import type
|
|
5
|
+
import { type TextStyles } from "./text";
|
|
6
6
|
export declare const DEFAULT_LUMINANCE_THRESHOLD = 0.37;
|
|
7
7
|
/**
|
|
8
8
|
* Applies an alpha value to a color.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ComponentState, ImageMaskShapeType, ImageProps, PaywallData, TextNodeProps } from "../data/entities.js";
|
|
2
|
-
import
|
|
2
|
+
import type { Dimension } from "../types/alignment.js";
|
|
3
|
+
import type { ColorGradientScheme, ColorScheme } from "../types/colors.js";
|
|
4
|
+
import { type BorderType, type ColorMode, type CornerRadiusType, FontSizeTags, type ShadowType, type ShapeType, type SizeType, type Spacing } from "../types.js";
|
|
3
5
|
type MarginVariables = {
|
|
4
6
|
"--margin-block-start": string;
|
|
5
7
|
"--margin-inline-end": string;
|
|
@@ -26,7 +28,7 @@ export declare function getTextComponentTag(fontSize: keyof typeof FontSizeTags)
|
|
|
26
28
|
* @returns Color value as string
|
|
27
29
|
*/
|
|
28
30
|
export declare function getColor({ colorMap, colorMode, fallback, }: {
|
|
29
|
-
colorMap?:
|
|
31
|
+
colorMap?: ColorGradientScheme | null;
|
|
30
32
|
colorMode?: ColorMode;
|
|
31
33
|
fallback?: string;
|
|
32
34
|
}): string;
|
|
@@ -63,12 +65,12 @@ type ComponentStyleVariables = {
|
|
|
63
65
|
export declare function getComponentStyles({ background_color, border, margin, padding, color, colorMode, shape, shadow, }: {
|
|
64
66
|
padding?: Spacing;
|
|
65
67
|
margin?: Spacing;
|
|
66
|
-
background_color?:
|
|
67
|
-
color?:
|
|
68
|
-
border?: BorderType;
|
|
68
|
+
background_color?: ColorGradientScheme | null;
|
|
69
|
+
color?: ColorScheme;
|
|
70
|
+
border?: BorderType | null;
|
|
69
71
|
colorMode?: ColorMode;
|
|
70
|
-
shape?: ShapeType;
|
|
71
|
-
shadow?: ShadowType;
|
|
72
|
+
shape?: ShapeType | null;
|
|
73
|
+
shadow?: ShadowType | null;
|
|
72
74
|
}): ComponentStyleVariables;
|
|
73
75
|
type SizeStyleVariables = {
|
|
74
76
|
"--width": string;
|
|
@@ -85,7 +87,7 @@ type InsetStyleVariables = {
|
|
|
85
87
|
"--inset": string;
|
|
86
88
|
"--transform": string;
|
|
87
89
|
};
|
|
88
|
-
export declare function getInsetStyles(dimension:
|
|
90
|
+
export declare function getInsetStyles(dimension: Dimension): InsetStyleVariables;
|
|
89
91
|
type DimensionVariableType = {
|
|
90
92
|
"--direction": string;
|
|
91
93
|
"--alignment": string;
|
|
@@ -99,7 +101,7 @@ type DimensionVariableType = {
|
|
|
99
101
|
* @param dimension - Dimension configuration object
|
|
100
102
|
* @returns CSS style object with flex layout properties
|
|
101
103
|
*/
|
|
102
|
-
export declare function getDimensionStyle(dimension:
|
|
104
|
+
export declare function getDimensionStyle(dimension: Dimension): DimensionVariableType;
|
|
103
105
|
type TextStyleVariables = {
|
|
104
106
|
"--text-align": string;
|
|
105
107
|
"--font-weight": number | string;
|
|
@@ -115,7 +117,7 @@ type TextStyleVariables = {
|
|
|
115
117
|
* @param colorMode - The currently selected ColorMode (dark/light)
|
|
116
118
|
* @returns CSS style object with text formatting properties
|
|
117
119
|
*/
|
|
118
|
-
export declare function getTextStyles(props: TextNodeProps
|
|
120
|
+
export declare function getTextStyles(props: TextNodeProps): TextStyleVariables;
|
|
119
121
|
/**
|
|
120
122
|
* Converts a style object to a CSS string
|
|
121
123
|
* @param styles - Object containing CSS properties and values
|
|
@@ -147,7 +149,7 @@ type MaskStyleVariables = {
|
|
|
147
149
|
* @returns CSS style object with mask properties
|
|
148
150
|
*/
|
|
149
151
|
export declare const getMaskStyle: (maskShape?: ImageMaskShapeType) => MaskStyleVariables;
|
|
150
|
-
export declare function getLinearGradientAngle(props: ImageProps & {
|
|
152
|
+
export declare function getLinearGradientAngle(colorMode: ColorMode, props: ImageProps & {
|
|
151
153
|
imageAspectRatio: number;
|
|
152
154
|
}): {
|
|
153
155
|
x1: string;
|