@revenuecat/purchases-ui-js 0.0.21 → 1.0.0
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 +9 -0
- package/dist/components/button/ButtonNode.svelte +7 -5
- package/dist/components/paywall/Paywall.svelte +0 -7
- package/dist/components/purchase-button/PurchaseButton.svelte +3 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/stories/fixtures.d.ts +2 -0
- package/dist/stories/fixtures.js +36 -0
- package/dist/stories/with-layout.d.ts +10 -0
- package/dist/stories/with-layout.js +15 -0
- package/dist/stories/with-layout.svelte +33 -0
- package/dist/stories/with-layout.svelte.d.ts +10 -0
- package/dist/ui/atoms/typography.stories.svelte +202 -0
- package/dist/ui/atoms/typography.stories.svelte.d.ts +19 -0
- package/dist/ui/atoms/typography.svelte +132 -0
- package/dist/ui/atoms/typography.svelte.d.ts +9 -0
- package/dist/ui/globals.d.ts +9 -0
- package/dist/ui/globals.js +3 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +4 -0
- package/dist/ui/layout/container.svelte +73 -0
- package/dist/ui/layout/container.svelte.d.ts +24 -0
- package/dist/ui/layout/layout.svelte +45 -0
- package/dist/ui/layout/layout.svelte.d.ts +22 -0
- package/dist/ui/layout/main-block.svelte +32 -0
- package/dist/ui/layout/main-block.svelte.d.ts +23 -0
- package/dist/ui/layout/section-layout.svelte +73 -0
- package/dist/ui/layout/section-layout.svelte.d.ts +23 -0
- package/dist/ui/molecules/button.stories.svelte +49 -0
- package/dist/ui/molecules/button.stories.svelte.d.ts +19 -0
- package/dist/ui/molecules/button.svelte +101 -0
- package/dist/ui/molecules/button.svelte.d.ts +28 -0
- package/dist/ui/molecules/types.d.ts +13 -0
- package/dist/ui/molecules/types.js +1 -0
- package/dist/ui/theme/colors.d.ts +37 -0
- package/dist/ui/theme/colors.js +54 -0
- package/dist/ui/theme/shapes.d.ts +8 -0
- package/dist/ui/theme/shapes.js +13 -0
- package/dist/ui/theme/spacing.d.ts +7 -0
- package/dist/ui/theme/spacing.js +42 -0
- package/dist/ui/theme/text.d.ts +19 -0
- package/dist/ui/theme/text.js +173 -0
- package/dist/ui/theme/theme.d.ts +15 -0
- package/dist/ui/theme/theme.js +38 -0
- package/dist/ui/theme/utils.d.ts +37 -0
- package/dist/ui/theme/utils.js +191 -0
- package/dist/ui/utils/branding.d.ts +16 -0
- package/dist/ui/utils/branding.js +1 -0
- package/dist/ui/utils/processing-animation.svelte +57 -0
- package/dist/ui/utils/processing-animation.svelte.d.ts +20 -0
- package/dist/web-components/index.js +2264 -0
- package/package.json +10 -4
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type Snippet } from "svelte";
|
|
3
|
+
import { Theme } from "../theme/theme";
|
|
4
|
+
|
|
5
|
+
import type { BrandingAppearance } from "../utils/branding";
|
|
6
|
+
|
|
7
|
+
export let brandingAppearance: BrandingAppearance | null | undefined =
|
|
8
|
+
undefined;
|
|
9
|
+
export let isInElement: boolean = false;
|
|
10
|
+
|
|
11
|
+
// Make styles reactive to changes in brandingAppearance
|
|
12
|
+
$: textStyle = new Theme(brandingAppearance).textStyleVars;
|
|
13
|
+
$: spacingStyle = new Theme(brandingAppearance).spacingStyleVars;
|
|
14
|
+
// $: formStyle = new Theme(brandingAppearance).formStyleVars;
|
|
15
|
+
|
|
16
|
+
$: style = [textStyle, spacingStyle].join("; ");
|
|
17
|
+
|
|
18
|
+
export let children: Snippet;
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div
|
|
22
|
+
class="rcb-ui-container"
|
|
23
|
+
class:fullscreen={!isInElement}
|
|
24
|
+
class:inside={isInElement}
|
|
25
|
+
{style}
|
|
26
|
+
>
|
|
27
|
+
{@render children?.()}
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<style>
|
|
31
|
+
.rcb-ui-container {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
inset: 0;
|
|
35
|
+
color-scheme: none;
|
|
36
|
+
line-height: 1.5em;
|
|
37
|
+
font-family:
|
|
38
|
+
-apple-system,
|
|
39
|
+
BlinkMacSystemFont,
|
|
40
|
+
avenir next,
|
|
41
|
+
avenir,
|
|
42
|
+
segoe ui,
|
|
43
|
+
helvetica neue,
|
|
44
|
+
helvetica,
|
|
45
|
+
Cantarell,
|
|
46
|
+
Ubuntu,
|
|
47
|
+
roboto,
|
|
48
|
+
noto,
|
|
49
|
+
arial,
|
|
50
|
+
sans-serif;
|
|
51
|
+
overflow-x: hidden;
|
|
52
|
+
overflow-y: auto;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.rcb-ui-container.fullscreen {
|
|
56
|
+
position: fixed;
|
|
57
|
+
top: 0;
|
|
58
|
+
left: 0;
|
|
59
|
+
right: 0;
|
|
60
|
+
bottom: 0;
|
|
61
|
+
overscroll-behavior: none;
|
|
62
|
+
z-index: 1000001;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.rcb-ui-container.inside {
|
|
66
|
+
position: relative;
|
|
67
|
+
width: 100%;
|
|
68
|
+
z-index: unset;
|
|
69
|
+
height: 100%;
|
|
70
|
+
top: 0;
|
|
71
|
+
left: 0;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Snippet } from "svelte";
|
|
2
|
+
import type { BrandingAppearance } from "../utils/branding";
|
|
3
|
+
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> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: Props & {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
13
|
+
};
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
15
|
+
}
|
|
16
|
+
declare const Container: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
+
brandingAppearance?: BrandingAppearance | null | undefined;
|
|
18
|
+
isInElement?: boolean;
|
|
19
|
+
children: Snippet;
|
|
20
|
+
}, {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
}, {}, {}, string>;
|
|
23
|
+
type Container = InstanceType<typeof Container>;
|
|
24
|
+
export default Container;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type Snippet } from "svelte";
|
|
3
|
+
|
|
4
|
+
export let style = "";
|
|
5
|
+
export let children: Snippet;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<div id="layout-query-container">
|
|
9
|
+
<div class="rcb-ui-layout" {style}>
|
|
10
|
+
{@render children?.()}
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
#layout-query-container {
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
container-type: size;
|
|
19
|
+
container-name: layout-query-container;
|
|
20
|
+
overflow-y: auto;
|
|
21
|
+
overscroll-behavior: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.rcb-ui-layout {
|
|
25
|
+
width: 100%;
|
|
26
|
+
min-height: 100%;
|
|
27
|
+
display: flex;
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
overflow-y: auto;
|
|
31
|
+
overscroll-behavior: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@container layout-query-container (width < 768px) {
|
|
35
|
+
.rcb-ui-layout {
|
|
36
|
+
flex-grow: 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@container layout-query-container (width >= 768px) {
|
|
41
|
+
.rcb-ui-layout {
|
|
42
|
+
flex-direction: row;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Snippet } from "svelte";
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Layout: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
style?: string;
|
|
17
|
+
children: Snippet;
|
|
18
|
+
}, {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
}, {}, {}, string>;
|
|
21
|
+
type Layout = InstanceType<typeof Layout>;
|
|
22
|
+
export default Layout;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Theme } from "../theme/theme";
|
|
3
|
+
import { onMount } from "svelte";
|
|
4
|
+
import SectionLayout from "./section-layout.svelte";
|
|
5
|
+
import type { BrandingAppearance } from "../utils/branding";
|
|
6
|
+
|
|
7
|
+
export let brandingAppearance: BrandingAppearance | null | undefined =
|
|
8
|
+
undefined;
|
|
9
|
+
// Make style reactive to changes in brandingAppearance
|
|
10
|
+
$: style = new Theme(brandingAppearance).formStyleVars;
|
|
11
|
+
|
|
12
|
+
export let body;
|
|
13
|
+
export let header: (() => any) | null = null;
|
|
14
|
+
|
|
15
|
+
let showContent = true;
|
|
16
|
+
// This makes the tests fail
|
|
17
|
+
onMount(() => {
|
|
18
|
+
setTimeout(() => (showContent = true), 10);
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div class="rcb-ui-main" {style}>
|
|
23
|
+
<SectionLayout show={showContent} layoutStyle="" {header} {body} />
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<style>
|
|
27
|
+
.rcb-ui-main {
|
|
28
|
+
flex: 1;
|
|
29
|
+
display: flex;
|
|
30
|
+
background-color: var(--rc-color-background);
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BrandingAppearance } from "../utils/branding";
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const MainBlock: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
brandingAppearance?: BrandingAppearance | null | undefined;
|
|
17
|
+
body: any;
|
|
18
|
+
header?: (() => any) | null;
|
|
19
|
+
}, {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
}, {}, {}, string>;
|
|
22
|
+
type MainBlock = InstanceType<typeof MainBlock>;
|
|
23
|
+
export default MainBlock;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fade } from "svelte/transition";
|
|
3
|
+
|
|
4
|
+
export let show: boolean = true;
|
|
5
|
+
export let layoutStyle: string | undefined = undefined;
|
|
6
|
+
|
|
7
|
+
export let header: (() => any) | null = null;
|
|
8
|
+
export let body: (() => any) | null = null;
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class="layout-wrapper-outer" style={layoutStyle}>
|
|
12
|
+
{#if show}
|
|
13
|
+
<div class="layout-wrapper">
|
|
14
|
+
<div
|
|
15
|
+
class="layout-content"
|
|
16
|
+
transition:fade={{ duration: 500, delay: 50 }}
|
|
17
|
+
>
|
|
18
|
+
{#if header}
|
|
19
|
+
{@render header()}
|
|
20
|
+
{/if}
|
|
21
|
+
{#if body}
|
|
22
|
+
{@render body()}
|
|
23
|
+
{/if}
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
{/if}
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
.layout-wrapper-outer {
|
|
31
|
+
flex: 1;
|
|
32
|
+
display: flex;
|
|
33
|
+
background-color: var(--rc-color-background);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.layout-wrapper {
|
|
37
|
+
width: 100%;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.layout-content {
|
|
41
|
+
box-sizing: border-box;
|
|
42
|
+
background-color: var(--rc-color-background);
|
|
43
|
+
color: var(--rc-color-grey-text-dark);
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
padding: var(--rc-spacing-outerPadding-mobile);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@container layout-query-container (width >= 768px) {
|
|
50
|
+
.layout-wrapper {
|
|
51
|
+
min-height: 100vh;
|
|
52
|
+
flex-basis: 600px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.layout-content {
|
|
56
|
+
padding: var(--rc-spacing-outerPadding-desktop);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@container layout-query-container (width < 768px) {
|
|
61
|
+
.layout-wrapper {
|
|
62
|
+
width: 100%;
|
|
63
|
+
min-width: 300px;
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-grow: 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.layout-content {
|
|
69
|
+
flex-grow: 1;
|
|
70
|
+
height: 100%;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
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> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const SectionLayout: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
show?: boolean;
|
|
16
|
+
layoutStyle?: string | undefined;
|
|
17
|
+
header?: (() => any) | null;
|
|
18
|
+
body?: (() => any) | null;
|
|
19
|
+
}, {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
}, {}, {}, string>;
|
|
22
|
+
type SectionLayout = InstanceType<typeof SectionLayout>;
|
|
23
|
+
export default SectionLayout;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script module>
|
|
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
|
+
import { withLayout } from "../../stories/with-layout";
|
|
11
|
+
|
|
12
|
+
let { Story } = defineMeta<typeof Button>({
|
|
13
|
+
component: Button,
|
|
14
|
+
title: "Molecules/Button",
|
|
15
|
+
// @ts-expect-error ignore typing of decorator
|
|
16
|
+
decorators: [withLayout],
|
|
17
|
+
argTypes: {
|
|
18
|
+
intent: {
|
|
19
|
+
control: "radio",
|
|
20
|
+
options: ["primary", undefined],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const args = {
|
|
26
|
+
intent: "primary" as const,
|
|
27
|
+
disabled: false,
|
|
28
|
+
loading: false,
|
|
29
|
+
onclick: () => {},
|
|
30
|
+
};
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<script lang="ts">
|
|
34
|
+
setTemplate(template);
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
{#snippet template(
|
|
38
|
+
{ ...args }: Args<typeof Story>,
|
|
39
|
+
context: StoryContext<typeof Story>,
|
|
40
|
+
)}
|
|
41
|
+
{@const brandingInfo = brandingAppearances[context.globals.brandingName]}
|
|
42
|
+
<Button {...args} brandingAppearance={brandingInfo ?? undefined}
|
|
43
|
+
>Click Me</Button
|
|
44
|
+
>
|
|
45
|
+
{/snippet}
|
|
46
|
+
|
|
47
|
+
<Story name="Default" {args} />
|
|
48
|
+
<Story name="Disabled" args={{ ...args, disabled: true }} />
|
|
49
|
+
<Story name="Loading" args={{ ...args, loading: true }} />
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as Button } from "./button.svelte";
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Button: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Button = InstanceType<typeof Button>;
|
|
19
|
+
export default Button;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<svelte:options customElement="ui-button" />
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import ProcessingAnimation from "../utils/processing-animation.svelte";
|
|
5
|
+
import Typography from "../atoms/typography.svelte";
|
|
6
|
+
import { Theme } from "../theme/theme";
|
|
7
|
+
import type { UIButtonProps } from "./types";
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
onclick,
|
|
11
|
+
intent = "primary",
|
|
12
|
+
disabled = false,
|
|
13
|
+
testId,
|
|
14
|
+
type,
|
|
15
|
+
loading = false,
|
|
16
|
+
brandingAppearance,
|
|
17
|
+
styleOverrides,
|
|
18
|
+
}: UIButtonProps = $props();
|
|
19
|
+
|
|
20
|
+
const theme = $derived(new Theme(brandingAppearance));
|
|
21
|
+
const textStyle = $derived(theme.textStyleVars);
|
|
22
|
+
const spacingStyle = $derived(theme.spacingStyleVars);
|
|
23
|
+
const productInfoStyle = $derived(theme.productInfoStyleVars);
|
|
24
|
+
const formStyle = $derived(theme.formStyleVars);
|
|
25
|
+
|
|
26
|
+
const combinedStyle = $derived(
|
|
27
|
+
[styleOverrides, textStyle, spacingStyle, productInfoStyle, formStyle].join(
|
|
28
|
+
"; ",
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<button
|
|
34
|
+
{onclick}
|
|
35
|
+
class={`intent-${intent}`}
|
|
36
|
+
{disabled}
|
|
37
|
+
data-testid={testId}
|
|
38
|
+
{type}
|
|
39
|
+
style={combinedStyle}
|
|
40
|
+
>
|
|
41
|
+
{#if loading}
|
|
42
|
+
<ProcessingAnimation size="small" />
|
|
43
|
+
{:else}
|
|
44
|
+
<Typography size="body-base"><slot></slot></Typography>
|
|
45
|
+
{/if}
|
|
46
|
+
</button>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
button {
|
|
50
|
+
border: none;
|
|
51
|
+
border-radius: var(--rc-shape-input-button-border-radius);
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
height: var(--rc-spacing-inputHeight-mobile);
|
|
54
|
+
color: var(--rc-color-grey-text-dark);
|
|
55
|
+
background-color: var(--rc-color-grey-ui-dark);
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
60
|
+
-webkit-tap-highlight-color: transparent;
|
|
61
|
+
transition: background-color 0.15s ease-in-out;
|
|
62
|
+
user-select: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@container layout-query-container (width >= 768px) {
|
|
66
|
+
button {
|
|
67
|
+
height: var(--rc-spacing-inputHeight-desktop);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* focus-visible is triggered only when focused with keyboard/reader */
|
|
72
|
+
button:focus-visible {
|
|
73
|
+
outline: 2px solid var(--rc-color-focus);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
button.intent-primary {
|
|
77
|
+
background-color: var(--rc-color-primary);
|
|
78
|
+
color: var(--rc-color-primary-text);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
button:disabled {
|
|
82
|
+
color: var(--rc-color-grey-text-light);
|
|
83
|
+
background-color: var(--rc-color-grey-ui-dark);
|
|
84
|
+
outline: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
button.intent-primary:not(:disabled):hover {
|
|
88
|
+
background-color: var(--rc-color-primary-hover);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
button.intent-primary:not(:disabled):active,
|
|
92
|
+
button:active {
|
|
93
|
+
background-color: var(--rc-color-primary-pressed);
|
|
94
|
+
outline: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
button.intent-primary:disabled {
|
|
98
|
+
color: var(--rc-color-grey-text-light);
|
|
99
|
+
background-color: var(--rc-color-grey-ui-dark);
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { UIButtonProps } from "./types";
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: 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>;
|
|
28
|
+
export default Button;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BrandingAppearance } from "../utils/branding";
|
|
2
|
+
export interface UIButtonProps {
|
|
3
|
+
onclick?: (event: any) => void;
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
intent?: "primary";
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
testId?: string | undefined;
|
|
8
|
+
type?: "reset" | "submit" | "button" | null | undefined;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
brandingAppearance?: BrandingAppearance;
|
|
11
|
+
styleOverrides?: string;
|
|
12
|
+
style?: Record<string, string> | string | undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BrandingAppearance } from "../utils/branding";
|
|
2
|
+
/**
|
|
3
|
+
* All those colors get translated in --rc-color-<property_name> css variables.
|
|
4
|
+
* i.e. --rc-color-error or --rc-color-input-background
|
|
5
|
+
*/
|
|
6
|
+
export interface Colors {
|
|
7
|
+
error: string;
|
|
8
|
+
warning: string;
|
|
9
|
+
focus: string;
|
|
10
|
+
accent: string;
|
|
11
|
+
primary: string;
|
|
12
|
+
"primary-hover": string;
|
|
13
|
+
"primary-pressed": string;
|
|
14
|
+
"primary-text": string;
|
|
15
|
+
white: string;
|
|
16
|
+
"grey-text-dark": string;
|
|
17
|
+
"grey-text-light": string;
|
|
18
|
+
"grey-ui-dark": string;
|
|
19
|
+
"grey-ui-light": string;
|
|
20
|
+
"input-background": string;
|
|
21
|
+
background: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const DEFAULT_FORM_COLORS: Colors;
|
|
24
|
+
export declare const DEFAULT_INFO_COLORS: Colors;
|
|
25
|
+
/**
|
|
26
|
+
* Mappings from the colors defined above and the colors downloaded from the BrandingAppearance.
|
|
27
|
+
* Bear in mind that font colors are calculated dynamically given the resulting background color.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ColorsToBrandingAppearanceMapping: Record<string, keyof BrandingAppearance>;
|
|
30
|
+
export declare const FormColorsToBrandingAppearanceMapping: {
|
|
31
|
+
"input-background": string;
|
|
32
|
+
background: string;
|
|
33
|
+
};
|
|
34
|
+
export declare const InfoColorsToBrandingAppearanceMapping: {
|
|
35
|
+
"input-background": string;
|
|
36
|
+
background: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const DEFAULT_FORM_COLORS = {
|
|
2
|
+
error: "#B0171F",
|
|
3
|
+
warning: "#f4e971",
|
|
4
|
+
focus: "#1148B8",
|
|
5
|
+
accent: "#767676",
|
|
6
|
+
primary: "#576CDB",
|
|
7
|
+
"primary-hover": "rgba(87, 108, 219, .8)",
|
|
8
|
+
"primary-pressed": "rgba(87, 108, 219, .9)",
|
|
9
|
+
"primary-text": "#ffffff",
|
|
10
|
+
white: "#ffffff",
|
|
11
|
+
"grey-text-dark": "rgba(0,0,0,1)",
|
|
12
|
+
"grey-text-light": "rgba(0,0,0,0.7)",
|
|
13
|
+
"grey-ui-dark": "rgba(0,0,0,0.3)",
|
|
14
|
+
"grey-ui-light": "rgba(0,0,0,0.1)",
|
|
15
|
+
"input-background": "white",
|
|
16
|
+
background: "white",
|
|
17
|
+
};
|
|
18
|
+
export const DEFAULT_INFO_COLORS = {
|
|
19
|
+
error: "#B0171F",
|
|
20
|
+
warning: "#f4e971",
|
|
21
|
+
focus: "#1148B8",
|
|
22
|
+
accent: "#767676",
|
|
23
|
+
primary: "#576CDB",
|
|
24
|
+
"primary-hover": "rgba(87, 108, 219, .8)",
|
|
25
|
+
"primary-pressed": "rgba(87, 108, 219, .9)",
|
|
26
|
+
"primary-text": "#ffffff",
|
|
27
|
+
white: "#ffffff",
|
|
28
|
+
"grey-text-dark": "rgba(0,0,0,1)",
|
|
29
|
+
"grey-text-light": "rgba(0,0,0,0.7)",
|
|
30
|
+
"grey-ui-dark": "rgba(0,0,0,0.3)",
|
|
31
|
+
"grey-ui-light": "rgba(0,0,0,0.1)",
|
|
32
|
+
"input-background": "white",
|
|
33
|
+
background: "#EFF3FA",
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Mappings from the colors defined above and the colors downloaded from the BrandingAppearance.
|
|
37
|
+
* Bear in mind that font colors are calculated dynamically given the resulting background color.
|
|
38
|
+
*/
|
|
39
|
+
export const ColorsToBrandingAppearanceMapping = {
|
|
40
|
+
error: "color_error",
|
|
41
|
+
focus: "color_accent",
|
|
42
|
+
accent: "color_accent",
|
|
43
|
+
primary: "color_buttons_primary",
|
|
44
|
+
};
|
|
45
|
+
export const FormColorsToBrandingAppearanceMapping = {
|
|
46
|
+
...ColorsToBrandingAppearanceMapping,
|
|
47
|
+
"input-background": "color_form_bg",
|
|
48
|
+
background: "color_form_bg",
|
|
49
|
+
};
|
|
50
|
+
export const InfoColorsToBrandingAppearanceMapping = {
|
|
51
|
+
...ColorsToBrandingAppearanceMapping,
|
|
52
|
+
"input-background": "color_product_info_bg",
|
|
53
|
+
background: "color_product_info_bg",
|
|
54
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface Shape {
|
|
2
|
+
"input-border-radius": string;
|
|
3
|
+
"input-button-border-radius": string;
|
|
4
|
+
}
|
|
5
|
+
export declare const RoundedShape: Shape;
|
|
6
|
+
export declare const RectangularShape: Shape;
|
|
7
|
+
export declare const PillsShape: Shape;
|
|
8
|
+
export declare const DefaultShape: Shape;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const RoundedShape = {
|
|
2
|
+
"input-border-radius": "4px",
|
|
3
|
+
"input-button-border-radius": "8px",
|
|
4
|
+
};
|
|
5
|
+
export const RectangularShape = {
|
|
6
|
+
"input-border-radius": "0px",
|
|
7
|
+
"input-button-border-radius": "0px",
|
|
8
|
+
};
|
|
9
|
+
export const PillsShape = {
|
|
10
|
+
"input-border-radius": "12px",
|
|
11
|
+
"input-button-border-radius": "9999px",
|
|
12
|
+
};
|
|
13
|
+
export const DefaultShape = RoundedShape;
|