@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.
@@ -12,12 +12,12 @@ function styleToRadius(style, baseRadius) {
12
12
  if (baseRadius !== undefined)
13
13
  return `${baseRadius}px`;
14
14
  switch (style) {
15
- case 'pill':
16
- return '9999px';
17
- case 'rounded':
18
- return '8px';
19
- case 'sharp':
20
- return '0';
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['--ah-color-primary'] = branding.colors.primary;
34
+ vars["--ah-color-primary"] = branding.colors.primary;
35
35
  // Generate hover variant (slightly darker)
36
- vars['--ah-color-primary-hover'] = branding.colors.primary;
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 === 'solid' && bg.start) {
42
- vars['--ah-page-bg'] = bg.start;
41
+ if (bg.type === "solid" && bg.start) {
42
+ vars["--ah-page-bg"] = bg.start;
43
43
  }
44
- else if (bg.type === 'gradient' && bg.start && bg.end) {
44
+ else if (bg.type === "gradient" && bg.start && bg.end) {
45
45
  const angle = bg.angle_deg ?? 180;
46
- vars['--ah-page-bg'] = `linear-gradient(${angle}deg, ${bg.start}, ${bg.end})`;
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['--ah-logo-url'] = `url(${branding.logo_url})`;
52
+ vars["--ah-logo-url"] = `url(${branding.logo_url})`;
52
53
  }
53
54
  // Font URL
54
55
  if (branding.font?.url) {
55
- vars['--ah-font-url'] = branding.font.url;
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['--ah-widget-radius'] = `${b.widget_corner_radius}px`;
72
+ vars["--ah-widget-radius"] = `${b.widget_corner_radius}px`;
72
73
  }
73
74
  if (b.widget_border_weight !== undefined) {
74
- vars['--ah-widget-border-width'] = `${b.widget_border_weight}px`;
75
+ vars["--ah-widget-border-width"] = `${b.widget_border_weight}px`;
75
76
  }
76
77
  if (b.show_widget_shadow === false) {
77
- vars['--ah-widget-shadow'] = 'none';
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['--ah-btn-radius'] = btnRadius;
83
+ vars["--ah-btn-radius"] = btnRadius;
83
84
  }
84
85
  if (b.button_border_weight !== undefined) {
85
- vars['--ah-btn-border-width'] = `${b.button_border_weight}px`;
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['--ah-input-radius'] = inputRadius;
91
+ vars["--ah-input-radius"] = inputRadius;
91
92
  }
92
93
  if (b.input_border_weight !== undefined) {
93
- vars['--ah-input-border-width'] = `${b.input_border_weight}px`;
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['--ah-color-primary'] = c.primary_button;
102
- vars['--ah-color-primary-hover'] = c.primary_button;
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['--ah-btn-primary-text'] = c.primary_button_label;
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['--ah-btn-secondary-border'] = c.secondary_button_border;
110
+ vars["--ah-btn-secondary-border"] = c.secondary_button_border;
110
111
  }
111
112
  if (c.secondary_button_label) {
112
- vars['--ah-btn-secondary-text'] = c.secondary_button_label;
113
+ vars["--ah-btn-secondary-text"] = c.secondary_button_label;
113
114
  }
114
115
  // Text colors
115
116
  if (c.body_text) {
116
- vars['--ah-color-text'] = c.body_text;
117
+ vars["--ah-color-text"] = c.body_text;
117
118
  }
118
119
  if (c.header) {
119
- vars['--ah-color-text-header'] = c.header;
120
+ vars["--ah-color-text-header"] = c.header;
120
121
  }
121
122
  if (c.input_labels_placeholders) {
122
- vars['--ah-color-text-label'] = c.input_labels_placeholders;
123
- vars['--ah-color-text-muted'] = c.input_labels_placeholders;
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['--ah-color-input-text'] = c.input_filled_text;
127
+ vars["--ah-color-input-text"] = c.input_filled_text;
127
128
  }
128
129
  // Backgrounds
129
130
  if (c.widget_background) {
130
- vars['--ah-color-bg'] = c.widget_background;
131
+ vars["--ah-color-bg"] = c.widget_background;
131
132
  }
132
133
  if (c.input_background) {
133
- vars['--ah-color-input-bg'] = c.input_background;
134
+ vars["--ah-color-input-bg"] = c.input_background;
134
135
  }
135
136
  // Borders
136
137
  if (c.widget_border) {
137
- vars['--ah-widget-border-color'] = c.widget_border;
138
+ vars["--ah-widget-border-color"] = c.widget_border;
138
139
  }
139
140
  if (c.input_border) {
140
- vars['--ah-color-border'] = c.input_border;
141
+ vars["--ah-color-border"] = c.input_border;
141
142
  }
142
143
  // Links
143
144
  if (c.links_focused_components) {
144
- vars['--ah-color-link'] = c.links_focused_components;
145
+ vars["--ah-color-link"] = c.links_focused_components;
145
146
  }
146
147
  // Focus/hover
147
148
  if (c.base_focus_color) {
148
- vars['--ah-color-focus-ring'] = c.base_focus_color;
149
+ vars["--ah-color-focus-ring"] = c.base_focus_color;
149
150
  }
150
151
  if (c.base_hover_color) {
151
- vars['--ah-color-primary-hover'] = c.base_hover_color;
152
+ vars["--ah-color-primary-hover"] = c.base_hover_color;
152
153
  }
153
154
  // Semantic colors
154
155
  if (c.error) {
155
- vars['--ah-color-error'] = c.error;
156
+ vars["--ah-color-error"] = c.error;
156
157
  }
157
158
  if (c.success) {
158
- vars['--ah-color-success'] = c.success;
159
+ vars["--ah-color-success"] = c.success;
159
160
  }
160
161
  // Icons
161
162
  if (c.icons) {
162
- vars['--ah-color-icon'] = c.icons;
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['--ah-font-url'] = f.font_url;
172
+ vars["--ah-font-url"] = f.font_url;
172
173
  }
173
174
  if (f.reference_text_size) {
174
- vars['--ah-font-size-base'] = `${f.reference_text_size}px`;
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['--ah-font-size-title'] = `${titlePx}px`;
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['--ah-font-size-subtitle'] = `${subtitlePx}px`;
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['--ah-font-size-body'] = `${bodyPx}px`;
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['--ah-font-size-label'] = `${labelPx}px`;
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['--ah-font-size-btn'] = `${btnPx}px`;
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['--ah-font-size-link'] = `${linkPx}px`;
200
+ vars["--ah-font-size-link"] = `${linkPx}px`;
200
201
  }
201
- if (f.links_style === 'underlined') {
202
- vars['--ah-link-decoration'] = 'underline';
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['--ah-font-weight-title'] = f.title.bold ? '700' : '400';
207
+ vars["--ah-font-weight-title"] = f.title.bold ? "700" : "400";
207
208
  }
208
209
  if (f.subtitle?.bold !== undefined) {
209
- vars['--ah-font-weight-subtitle'] = f.subtitle.bold ? '700' : '400';
210
+ vars["--ah-font-weight-subtitle"] = f.subtitle.bold ? "700" : "400";
210
211
  }
211
212
  if (f.body_text?.bold !== undefined) {
212
- vars['--ah-font-weight-body'] = f.body_text.bold ? '700' : '400';
213
+ vars["--ah-font-weight-body"] = f.body_text.bold ? "700" : "400";
213
214
  }
214
215
  if (f.input_labels?.bold !== undefined) {
215
- vars['--ah-font-weight-label'] = f.input_labels.bold ? '700' : '400';
216
+ vars["--ah-font-weight-label"] = f.input_labels.bold ? "700" : "400";
216
217
  }
217
218
  if (f.buttons_text?.bold !== undefined) {
218
- vars['--ah-font-weight-btn'] = f.buttons_text.bold ? '600' : '400';
219
+ vars["--ah-font-weight-btn"] = f.buttons_text.bold ? "600" : "400";
219
220
  }
220
221
  if (f.links?.bold !== undefined) {
221
- vars['--ah-font-weight-link'] = f.links.bold ? '700' : '400';
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['--ah-title-align'] = w.header_text_alignment;
229
+ vars["--ah-title-align"] = w.header_text_alignment;
229
230
  }
230
231
  if (w.logo_height) {
231
- vars['--ah-logo-height'] = `${w.logo_height}px`;
232
+ vars["--ah-logo-height"] = `${w.logo_height}px`;
232
233
  }
233
234
  if (w.logo_position) {
234
235
  const positionMap = {
235
- center: 'center',
236
- left: 'flex-start',
237
- right: 'flex-end',
236
+ center: "center",
237
+ left: "flex-start",
238
+ right: "flex-end",
238
239
  };
239
- if (w.logo_position === 'none') {
240
- vars['--ah-logo-display'] = 'none';
240
+ if (w.logo_position === "none") {
241
+ vars["--ah-logo-display"] = "none";
241
242
  }
242
243
  else {
243
- vars['--ah-logo-align'] = positionMap[w.logo_position] ?? 'center';
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 === 'top') {
250
- vars['--ah-social-order'] = '0';
251
- vars['--ah-divider-order'] = '1';
252
- vars['--ah-fields-order'] = '2';
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['--ah-social-order'] = '2';
256
- vars['--ah-divider-order'] = '1';
257
- vars['--ah-fields-order'] = '0';
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['--ah-page-bg'] = pb.background_color;
266
+ vars["--ah-page-bg"] = pb.background_color;
266
267
  }
267
268
  if (pb.background_image_url) {
268
- vars['--ah-page-bg-image'] = `url(${pb.background_image_url})`;
269
+ vars["--ah-page-bg-image"] = `url(${pb.background_image_url})`;
269
270
  }
270
271
  }
271
272
  return vars;