@authhero/widget 0.17.2 → 0.19.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/authhero-widget/authhero-widget.esm.js +1 -1
- package/dist/authhero-widget/index.esm.js +1 -1
- package/dist/cjs/authhero-widget.cjs.entry.js +75 -74
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/collection/components/authhero-node/authhero-node.js +1 -1
- package/dist/collection/components/authhero-widget/authhero-widget.js +2 -2
- package/dist/collection/index.js +1 -1
- package/dist/collection/themes/index.js +34 -30
- package/dist/collection/utils/branding.js +75 -74
- package/dist/components/index.js +1 -1
- package/dist/esm/authhero-widget.entry.js +75 -74
- package/dist/esm/index.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/themes/index.d.ts +2 -2
- package/dist/types/utils/branding.d.ts +8 -8
- package/hydrate/index.js +75 -74
- package/hydrate/index.mjs +75 -74
- package/package.json +2 -2
- /package/dist/authhero-widget/{p-409a28d3.entry.js → p-18d0a438.entry.js} +0 -0
|
@@ -12,12 +12,12 @@ function styleToRadius(style, baseRadius) {
|
|
|
12
12
|
if (baseRadius !== undefined)
|
|
13
13
|
return `${baseRadius}px`;
|
|
14
14
|
switch (style) {
|
|
15
|
-
case
|
|
16
|
-
return
|
|
17
|
-
case
|
|
18
|
-
return
|
|
19
|
-
case
|
|
20
|
-
return
|
|
15
|
+
case "pill":
|
|
16
|
+
return "9999px";
|
|
17
|
+
case "rounded":
|
|
18
|
+
return "8px";
|
|
19
|
+
case "sharp":
|
|
20
|
+
return "0";
|
|
21
21
|
default:
|
|
22
22
|
return undefined;
|
|
23
23
|
}
|
|
@@ -31,28 +31,29 @@ function brandingToCssVars(branding) {
|
|
|
31
31
|
const vars = {};
|
|
32
32
|
// Primary color
|
|
33
33
|
if (branding.colors?.primary) {
|
|
34
|
-
vars[
|
|
34
|
+
vars["--ah-color-primary"] = branding.colors.primary;
|
|
35
35
|
// Generate hover variant (slightly darker)
|
|
36
|
-
vars[
|
|
36
|
+
vars["--ah-color-primary-hover"] = branding.colors.primary;
|
|
37
37
|
}
|
|
38
38
|
// Page background
|
|
39
39
|
if (branding.colors?.page_background) {
|
|
40
40
|
const bg = branding.colors.page_background;
|
|
41
|
-
if (bg.type ===
|
|
42
|
-
vars[
|
|
41
|
+
if (bg.type === "solid" && bg.start) {
|
|
42
|
+
vars["--ah-page-bg"] = bg.start;
|
|
43
43
|
}
|
|
44
|
-
else if (bg.type ===
|
|
44
|
+
else if (bg.type === "gradient" && bg.start && bg.end) {
|
|
45
45
|
const angle = bg.angle_deg ?? 180;
|
|
46
|
-
vars[
|
|
46
|
+
vars["--ah-page-bg"] =
|
|
47
|
+
`linear-gradient(${angle}deg, ${bg.start}, ${bg.end})`;
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
// Logo URL (stored for reference, used via prop)
|
|
50
51
|
if (branding.logo_url) {
|
|
51
|
-
vars[
|
|
52
|
+
vars["--ah-logo-url"] = `url(${branding.logo_url})`;
|
|
52
53
|
}
|
|
53
54
|
// Font URL
|
|
54
55
|
if (branding.font?.url) {
|
|
55
|
-
vars[
|
|
56
|
+
vars["--ah-font-url"] = branding.font.url;
|
|
56
57
|
}
|
|
57
58
|
return vars;
|
|
58
59
|
}
|
|
@@ -68,29 +69,29 @@ function themeToCssVars(theme) {
|
|
|
68
69
|
const b = theme.borders;
|
|
69
70
|
// Widget
|
|
70
71
|
if (b.widget_corner_radius !== undefined) {
|
|
71
|
-
vars[
|
|
72
|
+
vars["--ah-widget-radius"] = `${b.widget_corner_radius}px`;
|
|
72
73
|
}
|
|
73
74
|
if (b.widget_border_weight !== undefined) {
|
|
74
|
-
vars[
|
|
75
|
+
vars["--ah-widget-border-width"] = `${b.widget_border_weight}px`;
|
|
75
76
|
}
|
|
76
77
|
if (b.show_widget_shadow === false) {
|
|
77
|
-
vars[
|
|
78
|
+
vars["--ah-widget-shadow"] = "none";
|
|
78
79
|
}
|
|
79
80
|
// Buttons
|
|
80
81
|
const btnRadius = styleToRadius(b.buttons_style, b.button_border_radius);
|
|
81
82
|
if (btnRadius) {
|
|
82
|
-
vars[
|
|
83
|
+
vars["--ah-btn-radius"] = btnRadius;
|
|
83
84
|
}
|
|
84
85
|
if (b.button_border_weight !== undefined) {
|
|
85
|
-
vars[
|
|
86
|
+
vars["--ah-btn-border-width"] = `${b.button_border_weight}px`;
|
|
86
87
|
}
|
|
87
88
|
// Inputs
|
|
88
89
|
const inputRadius = styleToRadius(b.inputs_style, b.input_border_radius);
|
|
89
90
|
if (inputRadius) {
|
|
90
|
-
vars[
|
|
91
|
+
vars["--ah-input-radius"] = inputRadius;
|
|
91
92
|
}
|
|
92
93
|
if (b.input_border_weight !== undefined) {
|
|
93
|
-
vars[
|
|
94
|
+
vars["--ah-input-border-width"] = `${b.input_border_weight}px`;
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
// Colors
|
|
@@ -98,68 +99,68 @@ function themeToCssVars(theme) {
|
|
|
98
99
|
const c = theme.colors;
|
|
99
100
|
// Primary button
|
|
100
101
|
if (c.primary_button) {
|
|
101
|
-
vars[
|
|
102
|
-
vars[
|
|
102
|
+
vars["--ah-color-primary"] = c.primary_button;
|
|
103
|
+
vars["--ah-color-primary-hover"] = c.primary_button;
|
|
103
104
|
}
|
|
104
105
|
if (c.primary_button_label) {
|
|
105
|
-
vars[
|
|
106
|
+
vars["--ah-btn-primary-text"] = c.primary_button_label;
|
|
106
107
|
}
|
|
107
108
|
// Secondary button
|
|
108
109
|
if (c.secondary_button_border) {
|
|
109
|
-
vars[
|
|
110
|
+
vars["--ah-btn-secondary-border"] = c.secondary_button_border;
|
|
110
111
|
}
|
|
111
112
|
if (c.secondary_button_label) {
|
|
112
|
-
vars[
|
|
113
|
+
vars["--ah-btn-secondary-text"] = c.secondary_button_label;
|
|
113
114
|
}
|
|
114
115
|
// Text colors
|
|
115
116
|
if (c.body_text) {
|
|
116
|
-
vars[
|
|
117
|
+
vars["--ah-color-text"] = c.body_text;
|
|
117
118
|
}
|
|
118
119
|
if (c.header) {
|
|
119
|
-
vars[
|
|
120
|
+
vars["--ah-color-text-header"] = c.header;
|
|
120
121
|
}
|
|
121
122
|
if (c.input_labels_placeholders) {
|
|
122
|
-
vars[
|
|
123
|
-
vars[
|
|
123
|
+
vars["--ah-color-text-label"] = c.input_labels_placeholders;
|
|
124
|
+
vars["--ah-color-text-muted"] = c.input_labels_placeholders;
|
|
124
125
|
}
|
|
125
126
|
if (c.input_filled_text) {
|
|
126
|
-
vars[
|
|
127
|
+
vars["--ah-color-input-text"] = c.input_filled_text;
|
|
127
128
|
}
|
|
128
129
|
// Backgrounds
|
|
129
130
|
if (c.widget_background) {
|
|
130
|
-
vars[
|
|
131
|
+
vars["--ah-color-bg"] = c.widget_background;
|
|
131
132
|
}
|
|
132
133
|
if (c.input_background) {
|
|
133
|
-
vars[
|
|
134
|
+
vars["--ah-color-input-bg"] = c.input_background;
|
|
134
135
|
}
|
|
135
136
|
// Borders
|
|
136
137
|
if (c.widget_border) {
|
|
137
|
-
vars[
|
|
138
|
+
vars["--ah-widget-border-color"] = c.widget_border;
|
|
138
139
|
}
|
|
139
140
|
if (c.input_border) {
|
|
140
|
-
vars[
|
|
141
|
+
vars["--ah-color-border"] = c.input_border;
|
|
141
142
|
}
|
|
142
143
|
// Links
|
|
143
144
|
if (c.links_focused_components) {
|
|
144
|
-
vars[
|
|
145
|
+
vars["--ah-color-link"] = c.links_focused_components;
|
|
145
146
|
}
|
|
146
147
|
// Focus/hover
|
|
147
148
|
if (c.base_focus_color) {
|
|
148
|
-
vars[
|
|
149
|
+
vars["--ah-color-focus-ring"] = c.base_focus_color;
|
|
149
150
|
}
|
|
150
151
|
if (c.base_hover_color) {
|
|
151
|
-
vars[
|
|
152
|
+
vars["--ah-color-primary-hover"] = c.base_hover_color;
|
|
152
153
|
}
|
|
153
154
|
// Semantic colors
|
|
154
155
|
if (c.error) {
|
|
155
|
-
vars[
|
|
156
|
+
vars["--ah-color-error"] = c.error;
|
|
156
157
|
}
|
|
157
158
|
if (c.success) {
|
|
158
|
-
vars[
|
|
159
|
+
vars["--ah-color-success"] = c.success;
|
|
159
160
|
}
|
|
160
161
|
// Icons
|
|
161
162
|
if (c.icons) {
|
|
162
|
-
vars[
|
|
163
|
+
vars["--ah-color-icon"] = c.icons;
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
// Fonts
|
|
@@ -168,93 +169,93 @@ function themeToCssVars(theme) {
|
|
|
168
169
|
// reference_text_size is the base font size in pixels (default 16px)
|
|
169
170
|
const baseSize = f.reference_text_size || 16;
|
|
170
171
|
if (f.font_url) {
|
|
171
|
-
vars[
|
|
172
|
+
vars["--ah-font-url"] = f.font_url;
|
|
172
173
|
}
|
|
173
174
|
if (f.reference_text_size) {
|
|
174
|
-
vars[
|
|
175
|
+
vars["--ah-font-size-base"] = `${f.reference_text_size}px`;
|
|
175
176
|
}
|
|
176
177
|
// Title, subtitle, etc. sizes are percentages of the base size
|
|
177
178
|
if (f.title?.size) {
|
|
178
179
|
const titlePx = Math.round((f.title.size / 100) * baseSize);
|
|
179
|
-
vars[
|
|
180
|
+
vars["--ah-font-size-title"] = `${titlePx}px`;
|
|
180
181
|
}
|
|
181
182
|
if (f.subtitle?.size) {
|
|
182
183
|
const subtitlePx = Math.round((f.subtitle.size / 100) * baseSize);
|
|
183
|
-
vars[
|
|
184
|
+
vars["--ah-font-size-subtitle"] = `${subtitlePx}px`;
|
|
184
185
|
}
|
|
185
186
|
if (f.body_text?.size) {
|
|
186
187
|
const bodyPx = Math.round((f.body_text.size / 100) * baseSize);
|
|
187
|
-
vars[
|
|
188
|
+
vars["--ah-font-size-body"] = `${bodyPx}px`;
|
|
188
189
|
}
|
|
189
190
|
if (f.input_labels?.size) {
|
|
190
191
|
const labelPx = Math.round((f.input_labels.size / 100) * baseSize);
|
|
191
|
-
vars[
|
|
192
|
+
vars["--ah-font-size-label"] = `${labelPx}px`;
|
|
192
193
|
}
|
|
193
194
|
if (f.buttons_text?.size) {
|
|
194
195
|
const btnPx = Math.round((f.buttons_text.size / 100) * baseSize);
|
|
195
|
-
vars[
|
|
196
|
+
vars["--ah-font-size-btn"] = `${btnPx}px`;
|
|
196
197
|
}
|
|
197
198
|
if (f.links?.size) {
|
|
198
199
|
const linkPx = Math.round((f.links.size / 100) * baseSize);
|
|
199
|
-
vars[
|
|
200
|
+
vars["--ah-font-size-link"] = `${linkPx}px`;
|
|
200
201
|
}
|
|
201
|
-
if (f.links_style ===
|
|
202
|
-
vars[
|
|
202
|
+
if (f.links_style === "underlined") {
|
|
203
|
+
vars["--ah-link-decoration"] = "underline";
|
|
203
204
|
}
|
|
204
205
|
// Font weights - bold option sets font-weight to 700
|
|
205
206
|
if (f.title?.bold !== undefined) {
|
|
206
|
-
vars[
|
|
207
|
+
vars["--ah-font-weight-title"] = f.title.bold ? "700" : "400";
|
|
207
208
|
}
|
|
208
209
|
if (f.subtitle?.bold !== undefined) {
|
|
209
|
-
vars[
|
|
210
|
+
vars["--ah-font-weight-subtitle"] = f.subtitle.bold ? "700" : "400";
|
|
210
211
|
}
|
|
211
212
|
if (f.body_text?.bold !== undefined) {
|
|
212
|
-
vars[
|
|
213
|
+
vars["--ah-font-weight-body"] = f.body_text.bold ? "700" : "400";
|
|
213
214
|
}
|
|
214
215
|
if (f.input_labels?.bold !== undefined) {
|
|
215
|
-
vars[
|
|
216
|
+
vars["--ah-font-weight-label"] = f.input_labels.bold ? "700" : "400";
|
|
216
217
|
}
|
|
217
218
|
if (f.buttons_text?.bold !== undefined) {
|
|
218
|
-
vars[
|
|
219
|
+
vars["--ah-font-weight-btn"] = f.buttons_text.bold ? "600" : "400";
|
|
219
220
|
}
|
|
220
221
|
if (f.links?.bold !== undefined) {
|
|
221
|
-
vars[
|
|
222
|
+
vars["--ah-font-weight-link"] = f.links.bold ? "700" : "400";
|
|
222
223
|
}
|
|
223
224
|
}
|
|
224
225
|
// Widget settings
|
|
225
226
|
if (theme.widget) {
|
|
226
227
|
const w = theme.widget;
|
|
227
228
|
if (w.header_text_alignment) {
|
|
228
|
-
vars[
|
|
229
|
+
vars["--ah-title-align"] = w.header_text_alignment;
|
|
229
230
|
}
|
|
230
231
|
if (w.logo_height) {
|
|
231
|
-
vars[
|
|
232
|
+
vars["--ah-logo-height"] = `${w.logo_height}px`;
|
|
232
233
|
}
|
|
233
234
|
if (w.logo_position) {
|
|
234
235
|
const positionMap = {
|
|
235
|
-
center:
|
|
236
|
-
left:
|
|
237
|
-
right:
|
|
236
|
+
center: "center",
|
|
237
|
+
left: "flex-start",
|
|
238
|
+
right: "flex-end",
|
|
238
239
|
};
|
|
239
|
-
if (w.logo_position ===
|
|
240
|
-
vars[
|
|
240
|
+
if (w.logo_position === "none") {
|
|
241
|
+
vars["--ah-logo-display"] = "none";
|
|
241
242
|
}
|
|
242
243
|
else {
|
|
243
|
-
vars[
|
|
244
|
+
vars["--ah-logo-align"] = positionMap[w.logo_position] ?? "center";
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
if (w.social_buttons_layout) {
|
|
247
248
|
// 'top' means social buttons above fields, 'bottom' means below
|
|
248
249
|
// Divider is always order 1 (middle)
|
|
249
|
-
if (w.social_buttons_layout ===
|
|
250
|
-
vars[
|
|
251
|
-
vars[
|
|
252
|
-
vars[
|
|
250
|
+
if (w.social_buttons_layout === "top") {
|
|
251
|
+
vars["--ah-social-order"] = "0";
|
|
252
|
+
vars["--ah-divider-order"] = "1";
|
|
253
|
+
vars["--ah-fields-order"] = "2";
|
|
253
254
|
}
|
|
254
255
|
else {
|
|
255
|
-
vars[
|
|
256
|
-
vars[
|
|
257
|
-
vars[
|
|
256
|
+
vars["--ah-social-order"] = "2";
|
|
257
|
+
vars["--ah-divider-order"] = "1";
|
|
258
|
+
vars["--ah-fields-order"] = "0";
|
|
258
259
|
}
|
|
259
260
|
}
|
|
260
261
|
}
|
|
@@ -262,10 +263,10 @@ function themeToCssVars(theme) {
|
|
|
262
263
|
if (theme.page_background) {
|
|
263
264
|
const pb = theme.page_background;
|
|
264
265
|
if (pb.background_color) {
|
|
265
|
-
vars[
|
|
266
|
+
vars["--ah-page-bg"] = pb.background_color;
|
|
266
267
|
}
|
|
267
268
|
if (pb.background_image_url) {
|
|
268
|
-
vars[
|
|
269
|
+
vars["--ah-page-bg-image"] = `url(${pb.background_image_url})`;
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
272
|
return vars;
|