cf-elements 1.0.3 → 1.0.5
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/cf-elements.js +32 -7
- 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-
|
|
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
|
-
|
|
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,16 @@
|
|
|
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
|
+
// Use single quotes to avoid breaking the HTML style attribute
|
|
1092
|
+
if (font) {
|
|
1093
|
+
styles["font-family"] = `'${font}', sans-serif`;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1086
1096
|
if (gradient) {
|
|
1087
1097
|
styles["background"] = gradient;
|
|
1088
1098
|
} else if (bg) {
|
|
@@ -1108,7 +1118,7 @@
|
|
|
1108
1118
|
|
|
1109
1119
|
// Build optional data attributes for settings
|
|
1110
1120
|
let optionalAttrs = "";
|
|
1111
|
-
if (
|
|
1121
|
+
if (font) optionalAttrs += ` data-font="${font}"`;
|
|
1112
1122
|
if (fontWeight) optionalAttrs += ` data-font-weight="${fontWeight}"`;
|
|
1113
1123
|
if (headerCode)
|
|
1114
1124
|
optionalAttrs += ` data-header-code="${encodeURIComponent(
|
|
@@ -2168,6 +2178,7 @@
|
|
|
2168
2178
|
*/
|
|
2169
2179
|
class CFHeadline extends CFElement {
|
|
2170
2180
|
render() {
|
|
2181
|
+
const elementId = attr(this, "element-id");
|
|
2171
2182
|
const size = attr(this, "size", "48px");
|
|
2172
2183
|
const weight = attr(this, "weight", "bold");
|
|
2173
2184
|
const font = attr(this, "font");
|
|
@@ -2213,6 +2224,7 @@
|
|
|
2213
2224
|
// Build data attributes for round-trip conversion
|
|
2214
2225
|
// Store original size (preset or px) for reliable roundtrip
|
|
2215
2226
|
let dataAttrs = 'data-type="Headline/V1"';
|
|
2227
|
+
if (elementId) dataAttrs += ` data-element-id="${elementId}"`;
|
|
2216
2228
|
dataAttrs += ` data-size="${size}"`;
|
|
2217
2229
|
dataAttrs += ` data-weight="${weight}"`;
|
|
2218
2230
|
if (hasExplicitColor && color) {
|
|
@@ -2229,6 +2241,9 @@
|
|
|
2229
2241
|
if (icon) dataAttrs += ` data-icon="${icon}"`;
|
|
2230
2242
|
if (icon && iconAlign !== "left") dataAttrs += ` data-icon-align="${iconAlign}"`;
|
|
2231
2243
|
|
|
2244
|
+
// Build ID attribute for scroll-to and show-hide targeting
|
|
2245
|
+
const idAttr = elementId ? ` id="${elementId}"` : "";
|
|
2246
|
+
|
|
2232
2247
|
// Build icon HTML if present
|
|
2233
2248
|
let iconHtml = "";
|
|
2234
2249
|
if (icon) {
|
|
@@ -2246,7 +2261,7 @@
|
|
|
2246
2261
|
dataAttrs += animationAttrs;
|
|
2247
2262
|
|
|
2248
2263
|
this.outerHTML = `
|
|
2249
|
-
<div ${dataAttrs} style="${buildStyle(wrapperStyles)}">
|
|
2264
|
+
<div${idAttr} ${dataAttrs} style="${buildStyle(wrapperStyles)}">
|
|
2250
2265
|
<${tag} style="${buildStyle(textStyles)}">${textWithIcon}</${tag}>
|
|
2251
2266
|
</div>
|
|
2252
2267
|
`;
|
|
@@ -2259,6 +2274,7 @@
|
|
|
2259
2274
|
*/
|
|
2260
2275
|
class CFSubheadline extends CFElement {
|
|
2261
2276
|
render() {
|
|
2277
|
+
const elementId = attr(this, "element-id");
|
|
2262
2278
|
const size = attr(this, "size", "24px");
|
|
2263
2279
|
const weight = attr(this, "weight", "normal");
|
|
2264
2280
|
const font = attr(this, "font");
|
|
@@ -2302,6 +2318,7 @@
|
|
|
2302
2318
|
// Build data attributes for round-trip conversion
|
|
2303
2319
|
// Store original size (preset or px) for reliable roundtrip
|
|
2304
2320
|
let dataAttrs = 'data-type="SubHeadline/V1"';
|
|
2321
|
+
if (elementId) dataAttrs += ` data-element-id="${elementId}"`;
|
|
2305
2322
|
dataAttrs += ` data-size="${size}"`;
|
|
2306
2323
|
dataAttrs += ` data-weight="${weight}"`;
|
|
2307
2324
|
if (hasExplicitColor && color) {
|
|
@@ -2318,6 +2335,9 @@
|
|
|
2318
2335
|
if (icon) dataAttrs += ` data-icon="${icon}"`;
|
|
2319
2336
|
if (icon && iconAlign !== "left") dataAttrs += ` data-icon-align="${iconAlign}"`;
|
|
2320
2337
|
|
|
2338
|
+
// Build ID attribute for scroll-to and show-hide targeting
|
|
2339
|
+
const idAttr = elementId ? ` id="${elementId}"` : "";
|
|
2340
|
+
|
|
2321
2341
|
// Build icon HTML if present
|
|
2322
2342
|
let iconHtml = "";
|
|
2323
2343
|
if (icon) {
|
|
@@ -2335,7 +2355,7 @@
|
|
|
2335
2355
|
dataAttrs += animationAttrs;
|
|
2336
2356
|
|
|
2337
2357
|
this.outerHTML = `
|
|
2338
|
-
<div ${dataAttrs} style="${buildStyle(wrapperStyles)}">
|
|
2358
|
+
<div${idAttr} ${dataAttrs} style="${buildStyle(wrapperStyles)}">
|
|
2339
2359
|
<${tag} style="${buildStyle(textStyles)}">${textWithIcon}</${tag}>
|
|
2340
2360
|
</div>
|
|
2341
2361
|
`;
|
|
@@ -2348,6 +2368,7 @@
|
|
|
2348
2368
|
*/
|
|
2349
2369
|
class CFParagraph extends CFElement {
|
|
2350
2370
|
render() {
|
|
2371
|
+
const elementId = attr(this, "element-id");
|
|
2351
2372
|
const size = attr(this, "size", "16px");
|
|
2352
2373
|
const weight = attr(this, "weight", "normal");
|
|
2353
2374
|
const font = attr(this, "font");
|
|
@@ -2399,6 +2420,7 @@
|
|
|
2399
2420
|
// Build data attributes for round-trip conversion
|
|
2400
2421
|
// Store original size (preset or px) for reliable roundtrip
|
|
2401
2422
|
let dataAttrs = 'data-type="Paragraph/V1"';
|
|
2423
|
+
if (elementId) dataAttrs += ` data-element-id="${elementId}"`;
|
|
2402
2424
|
dataAttrs += ` data-size="${size}"`;
|
|
2403
2425
|
dataAttrs += ` data-weight="${weight}"`;
|
|
2404
2426
|
if (hasExplicitColor && color) {
|
|
@@ -2417,6 +2439,9 @@
|
|
|
2417
2439
|
if (icon) dataAttrs += ` data-icon="${icon}"`;
|
|
2418
2440
|
if (icon && iconAlign !== "left") dataAttrs += ` data-icon-align="${iconAlign}"`;
|
|
2419
2441
|
|
|
2442
|
+
// Build ID attribute for scroll-to and show-hide targeting
|
|
2443
|
+
const idAttr = elementId ? ` id="${elementId}"` : "";
|
|
2444
|
+
|
|
2420
2445
|
// Build icon HTML if present
|
|
2421
2446
|
let iconHtml = "";
|
|
2422
2447
|
if (icon) {
|
|
@@ -2434,7 +2459,7 @@
|
|
|
2434
2459
|
dataAttrs += animationAttrs;
|
|
2435
2460
|
|
|
2436
2461
|
this.outerHTML = `
|
|
2437
|
-
<div ${dataAttrs} style="${buildStyle(wrapperStyles)}">
|
|
2462
|
+
<div${idAttr} ${dataAttrs} style="${buildStyle(wrapperStyles)}">
|
|
2438
2463
|
<p style="${buildStyle(textStyles)}">${textWithIcon}</p>
|
|
2439
2464
|
</div>
|
|
2440
2465
|
`;
|
package/package.json
CHANGED