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