@meltingspot/widget 0.1.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/stylesheet.css ADDED
@@ -0,0 +1,142 @@
1
+ /* Open state of the dialog */
2
+ :where(dialog.ms-dialog)[open] {
3
+ opacity: 1;
4
+ }
5
+
6
+ /* prevent scrolling on body when dialog open */
7
+ body:has(dialog.ms-dialog[open]) {
8
+ overflow: hidden;
9
+ }
10
+
11
+ /* Default state of the dialog */
12
+ :where(dialog.ms-dialog) {
13
+ border: 0;
14
+ position: fixed;
15
+ inset: 0;
16
+ padding: 0;
17
+
18
+ overflow: hidden;
19
+
20
+ max-width: 100%;
21
+ max-height: 100%;
22
+
23
+ opacity: 0;
24
+ transition:
25
+ opacity 0.2s ease-out,
26
+ overlay 0.2s ease-out allow-discrete,
27
+ display 0.2s ease-out allow-discrete;
28
+ /* Equivalent to
29
+ transition: all 0.7s allow-discrete; */
30
+ }
31
+
32
+ /* Close button inside dialog */
33
+ :where(dialog.ms-dialog) .ms-dialog-close-button {
34
+ position: absolute;
35
+ top: 8px;
36
+ right: 8px;
37
+
38
+ font-size: 16px;
39
+ border: 0;
40
+ border-radius: 4px;
41
+ background: none;
42
+
43
+ box-sizing: border-box;
44
+ width: 2rem;
45
+ height: 2rem;
46
+ min-width: 2rem;
47
+ min-height: 2rem;
48
+ padding: 0;
49
+ color: white;
50
+ }
51
+
52
+ :where(dialog.ms-dialog) .ms-dialog-close-button span {
53
+ mix-blend-mode: difference;
54
+ }
55
+
56
+ :where(dialog.ms-dialog) .ms-dialog-close-button svg {
57
+ transform: translate3d(0, 0, 0);
58
+ mix-blend-mode: difference;
59
+ margin: auto;
60
+ }
61
+
62
+ :where(dialog.ms-dialog) .ms-dialog-close-button:hover {
63
+ background: rgba(200, 200, 200, 0.1);
64
+ background-blend-mode: difference;
65
+ }
66
+
67
+ /* Before-open state */
68
+ /**
69
+ * Needs to be after the previous dialog[open] rule to take effect,
70
+ * as the specificity is the same
71
+ */
72
+ @starting-style {
73
+ :where(dialog.ms-dialog)[open] {
74
+ opacity: 0;
75
+ }
76
+ }
77
+
78
+ /* Transition the :backdrop when the dialog modal is promoted to the top layer */
79
+ :where(dialog.ms-dialog)::backdrop {
80
+ background-color: rgb(0 0 0 / 0%);
81
+ transition:
82
+ display 0.2s allow-discrete,
83
+ overlay 0.2s allow-discrete,
84
+ background-color 0.2s;
85
+ /* Equivalent to
86
+ transition: all 0.7s allow-discrete; */
87
+ }
88
+
89
+ :where(dialog.ms-dialog)[open]::backdrop {
90
+ background-color: rgb(0 0 0 / 25%);
91
+ }
92
+
93
+ /**
94
+ * This starting-style rule cannot be nested inside the above selector
95
+ * because the nesting selector cannot represent pseudo-elements.
96
+ */
97
+ @starting-style {
98
+ :where(dialog.ms-dialog)[open]::backdrop {
99
+ background-color: rgb(0 0 0 / 0%);
100
+ }
101
+ }
102
+
103
+ :where(.ms-modal) {
104
+ width: 100%;
105
+ height: 100%;
106
+
107
+ margin: 0;
108
+
109
+ border-radius: 0;
110
+ }
111
+
112
+ :where(.ms-drawer) {
113
+ max-width: 640px;
114
+ width: 100%;
115
+ height: 100%;
116
+ box-sizing: border-box;
117
+ }
118
+
119
+ :where(.ms-drawer)[data-position='left'] {
120
+ margin: 0 auto 0 0;
121
+ }
122
+
123
+ :where(.ms-drawer)[data-position='right'] {
124
+ margin: 0 0 0 auto;
125
+ }
126
+
127
+ @media (min-width: 640px) {
128
+ :where(.ms-modal) {
129
+ width: 640px;
130
+ height: 80vh;
131
+
132
+ margin: auto;
133
+
134
+ border-radius: 8px;
135
+ }
136
+ }
137
+
138
+ @media (min-width: 1280px) {
139
+ :where(.ms-modal) {
140
+ width: 50vw;
141
+ }
142
+ }
package/widget.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { UtmParameters, ThemeMode, Nullable } from '../../core/src/index.ts';
2
+ import { EmbedContent } from '../../embed/src/index.ts';
3
+ import { DialogContent } from './rendering/dialog';
4
+ export interface WidgetArgs {
5
+ /**
6
+ * The spot ID.
7
+ */
8
+ spotId: string;
9
+ /**
10
+ * The widget ID.
11
+ */
12
+ widgetId: string;
13
+ /**
14
+ * An SSO auth token.
15
+ */
16
+ authToken?: Nullable<string>;
17
+ /**
18
+ * The theme mode to force apply.
19
+ */
20
+ themeMode?: ThemeMode;
21
+ /**
22
+ * UTM parameters to append to the widget URL.
23
+ */
24
+ utmParameters?: UtmParameters;
25
+ /**
26
+ * The domain key to use for the widget links.
27
+ */
28
+ domain?: string;
29
+ /**
30
+ * The base URL to use for the widget links.
31
+ */
32
+ baseURL: string;
33
+ /**
34
+ * The root document to use for the widget injection.
35
+ */
36
+ rootDocument?: Document;
37
+ }
38
+ export declare class Widget implements DialogContent, EmbedContent {
39
+ readonly baseURL: string;
40
+ readonly spotId: string;
41
+ readonly widgetId: string;
42
+ readonly authToken: Nullable<string>;
43
+ readonly themeMode: ThemeMode;
44
+ readonly domain: Nullable<string>;
45
+ readonly utmParameters: Nullable<UtmParameters>;
46
+ readonly rootDocument?: Document;
47
+ constructor(args: WidgetArgs);
48
+ get iframe(): HTMLIFrameElement;
49
+ }
@@ -0,0 +1,63 @@
1
+ import { Nullable, ThemeMode, UtmParameters } from '../../core/src/index.ts';
2
+ import { DialogContent } from './rendering/dialog';
3
+ export interface WidgetContentArgs {
4
+ /**
5
+ * The spot ID.
6
+ */
7
+ spotId: string;
8
+ /**
9
+ * The widget content ID.
10
+ */
11
+ widgetContentId: string;
12
+ /**
13
+ * The ID of the widget list of content
14
+ */
15
+ widgetId: string;
16
+ /**
17
+ * The type of content
18
+ */
19
+ contentType: string;
20
+ /**
21
+ * The ID of content
22
+ */
23
+ contentId: string;
24
+ /**
25
+ * An SSO auth token.
26
+ */
27
+ authToken?: Nullable<string>;
28
+ /**
29
+ * The theme mode to force apply.
30
+ */
31
+ themeMode?: ThemeMode;
32
+ /**
33
+ * UTM parameters to append to the widget URL.
34
+ */
35
+ utmParameters?: UtmParameters;
36
+ /**
37
+ * The domain key to use for the widget links.
38
+ */
39
+ domain?: string;
40
+ /**
41
+ * The base URL to use for the widget links.
42
+ */
43
+ baseURL: string;
44
+ /**
45
+ * The root document to use for the widget content injection.
46
+ */
47
+ rootDocument?: Document;
48
+ }
49
+ export declare class WidgetContent implements DialogContent {
50
+ readonly baseURL: string;
51
+ readonly spotId: string;
52
+ readonly widgetContentId: string;
53
+ readonly contentId: string;
54
+ readonly widgetId: string;
55
+ readonly contentType: string;
56
+ readonly authToken: Nullable<string>;
57
+ readonly themeMode: ThemeMode;
58
+ readonly domain: Nullable<string>;
59
+ readonly utmParameters: Nullable<UtmParameters>;
60
+ readonly rootDocument?: Document;
61
+ constructor(args: WidgetContentArgs);
62
+ get iframe(): HTMLIFrameElement;
63
+ }