cf-elements 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/cf-elements.js +31 -7
  2. package/package.json +1 -1
package/cf-elements.js CHANGED
@@ -1054,9 +1054,10 @@
1054
1054
  * bg-style - Background image style: cover, cover-center (default), parallax, w100, w100h100, no-repeat, repeat, repeat-x, repeat-y
1055
1055
  * gradient - CSS gradient
1056
1056
  * overlay - Overlay color (rgba)
1057
- * text-color - Default text color
1057
+ * text-color - Default text color (inherited by child elements)
1058
1058
  * link-color - Default link color
1059
- * font-family - Default font family (e.g., '"Roboto", sans-serif')
1059
+ * font - Default font family (e.g., "Roboto") - inherited by child elements
1060
+ * font-family - Alias for font
1060
1061
  * font-weight - Default font weight
1061
1062
  * header-code - Custom header HTML/scripts
1062
1063
  * footer-code - Custom footer HTML/scripts
@@ -1071,7 +1072,8 @@
1071
1072
  const overlay = attr(this, "overlay");
1072
1073
  const textColor = attr(this, "text-color", "#334155");
1073
1074
  const linkColor = attr(this, "link-color", "#3b82f6");
1074
- const fontFamily = attr(this, "font-family");
1075
+ // Support both "font" (simple) and "font-family" (explicit) attributes
1076
+ const font = attr(this, "font") || attr(this, "font-family");
1075
1077
  const fontWeight = attr(this, "font-weight");
1076
1078
  const headerCode = attr(this, "header-code");
1077
1079
  const footerCode = attr(this, "footer-code");
@@ -1081,8 +1083,15 @@
1081
1083
  width: "100%",
1082
1084
  "min-height": "100vh",
1083
1085
  position: "relative",
1086
+ // Apply text color and font for CSS inheritance
1087
+ color: textColor,
1084
1088
  };
1085
1089
 
1090
+ // Apply font-family for inheritance by child elements
1091
+ if (font) {
1092
+ styles["font-family"] = `"${font}", sans-serif`;
1093
+ }
1094
+
1086
1095
  if (gradient) {
1087
1096
  styles["background"] = gradient;
1088
1097
  } else if (bg) {
@@ -1108,7 +1117,7 @@
1108
1117
 
1109
1118
  // Build optional data attributes for settings
1110
1119
  let optionalAttrs = "";
1111
- if (fontFamily) optionalAttrs += ` data-font-family="${fontFamily}"`;
1120
+ if (font) optionalAttrs += ` data-font="${font}"`;
1112
1121
  if (fontWeight) optionalAttrs += ` data-font-weight="${fontWeight}"`;
1113
1122
  if (headerCode)
1114
1123
  optionalAttrs += ` data-header-code="${encodeURIComponent(
@@ -2168,6 +2177,7 @@
2168
2177
  */
2169
2178
  class CFHeadline extends CFElement {
2170
2179
  render() {
2180
+ const elementId = attr(this, "element-id");
2171
2181
  const size = attr(this, "size", "48px");
2172
2182
  const weight = attr(this, "weight", "bold");
2173
2183
  const font = attr(this, "font");
@@ -2213,6 +2223,7 @@
2213
2223
  // Build data attributes for round-trip conversion
2214
2224
  // Store original size (preset or px) for reliable roundtrip
2215
2225
  let dataAttrs = 'data-type="Headline/V1"';
2226
+ if (elementId) dataAttrs += ` data-element-id="${elementId}"`;
2216
2227
  dataAttrs += ` data-size="${size}"`;
2217
2228
  dataAttrs += ` data-weight="${weight}"`;
2218
2229
  if (hasExplicitColor && color) {
@@ -2229,6 +2240,9 @@
2229
2240
  if (icon) dataAttrs += ` data-icon="${icon}"`;
2230
2241
  if (icon && iconAlign !== "left") dataAttrs += ` data-icon-align="${iconAlign}"`;
2231
2242
 
2243
+ // Build ID attribute for scroll-to and show-hide targeting
2244
+ const idAttr = elementId ? ` id="${elementId}"` : "";
2245
+
2232
2246
  // Build icon HTML if present
2233
2247
  let iconHtml = "";
2234
2248
  if (icon) {
@@ -2246,7 +2260,7 @@
2246
2260
  dataAttrs += animationAttrs;
2247
2261
 
2248
2262
  this.outerHTML = `
2249
- <div ${dataAttrs} style="${buildStyle(wrapperStyles)}">
2263
+ <div${idAttr} ${dataAttrs} style="${buildStyle(wrapperStyles)}">
2250
2264
  <${tag} style="${buildStyle(textStyles)}">${textWithIcon}</${tag}>
2251
2265
  </div>
2252
2266
  `;
@@ -2259,6 +2273,7 @@
2259
2273
  */
2260
2274
  class CFSubheadline extends CFElement {
2261
2275
  render() {
2276
+ const elementId = attr(this, "element-id");
2262
2277
  const size = attr(this, "size", "24px");
2263
2278
  const weight = attr(this, "weight", "normal");
2264
2279
  const font = attr(this, "font");
@@ -2302,6 +2317,7 @@
2302
2317
  // Build data attributes for round-trip conversion
2303
2318
  // Store original size (preset or px) for reliable roundtrip
2304
2319
  let dataAttrs = 'data-type="SubHeadline/V1"';
2320
+ if (elementId) dataAttrs += ` data-element-id="${elementId}"`;
2305
2321
  dataAttrs += ` data-size="${size}"`;
2306
2322
  dataAttrs += ` data-weight="${weight}"`;
2307
2323
  if (hasExplicitColor && color) {
@@ -2318,6 +2334,9 @@
2318
2334
  if (icon) dataAttrs += ` data-icon="${icon}"`;
2319
2335
  if (icon && iconAlign !== "left") dataAttrs += ` data-icon-align="${iconAlign}"`;
2320
2336
 
2337
+ // Build ID attribute for scroll-to and show-hide targeting
2338
+ const idAttr = elementId ? ` id="${elementId}"` : "";
2339
+
2321
2340
  // Build icon HTML if present
2322
2341
  let iconHtml = "";
2323
2342
  if (icon) {
@@ -2335,7 +2354,7 @@
2335
2354
  dataAttrs += animationAttrs;
2336
2355
 
2337
2356
  this.outerHTML = `
2338
- <div ${dataAttrs} style="${buildStyle(wrapperStyles)}">
2357
+ <div${idAttr} ${dataAttrs} style="${buildStyle(wrapperStyles)}">
2339
2358
  <${tag} style="${buildStyle(textStyles)}">${textWithIcon}</${tag}>
2340
2359
  </div>
2341
2360
  `;
@@ -2348,6 +2367,7 @@
2348
2367
  */
2349
2368
  class CFParagraph extends CFElement {
2350
2369
  render() {
2370
+ const elementId = attr(this, "element-id");
2351
2371
  const size = attr(this, "size", "16px");
2352
2372
  const weight = attr(this, "weight", "normal");
2353
2373
  const font = attr(this, "font");
@@ -2399,6 +2419,7 @@
2399
2419
  // Build data attributes for round-trip conversion
2400
2420
  // Store original size (preset or px) for reliable roundtrip
2401
2421
  let dataAttrs = 'data-type="Paragraph/V1"';
2422
+ if (elementId) dataAttrs += ` data-element-id="${elementId}"`;
2402
2423
  dataAttrs += ` data-size="${size}"`;
2403
2424
  dataAttrs += ` data-weight="${weight}"`;
2404
2425
  if (hasExplicitColor && color) {
@@ -2417,6 +2438,9 @@
2417
2438
  if (icon) dataAttrs += ` data-icon="${icon}"`;
2418
2439
  if (icon && iconAlign !== "left") dataAttrs += ` data-icon-align="${iconAlign}"`;
2419
2440
 
2441
+ // Build ID attribute for scroll-to and show-hide targeting
2442
+ const idAttr = elementId ? ` id="${elementId}"` : "";
2443
+
2420
2444
  // Build icon HTML if present
2421
2445
  let iconHtml = "";
2422
2446
  if (icon) {
@@ -2434,7 +2458,7 @@
2434
2458
  dataAttrs += animationAttrs;
2435
2459
 
2436
2460
  this.outerHTML = `
2437
- <div ${dataAttrs} style="${buildStyle(wrapperStyles)}">
2461
+ <div${idAttr} ${dataAttrs} style="${buildStyle(wrapperStyles)}">
2438
2462
  <p style="${buildStyle(textStyles)}">${textWithIcon}</p>
2439
2463
  </div>
2440
2464
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-elements",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Zero-dependency markup library that generates ClickFunnels compatible HTML with inline styles",
5
5
  "main": "cf-elements.js",
6
6
  "browser": "cf-elements.js",