@opensite/ui 0.0.7 → 0.0.9
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/README.md +46 -0
- package/dist/button-variants-CSFRwdBy.d.cts +14 -0
- package/dist/button-variants-CSFRwdBy.d.ts +14 -0
- package/dist/button.cjs +1 -1
- package/dist/button.cjs.map +1 -1
- package/dist/button.d.cts +2 -5
- package/dist/button.d.ts +2 -5
- package/dist/button.js +1 -1
- package/dist/button.js.map +1 -1
- package/dist/components.cjs +430 -26
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +5 -2
- package/dist/components.d.ts +5 -2
- package/dist/components.js +425 -23
- package/dist/components.js.map +1 -1
- package/dist/dynamic-icon.cjs +90 -19
- package/dist/dynamic-icon.cjs.map +1 -1
- package/dist/dynamic-icon.d.cts +12 -6
- package/dist/dynamic-icon.d.ts +12 -6
- package/dist/dynamic-icon.js +90 -19
- package/dist/dynamic-icon.js.map +1 -1
- package/dist/feature-showcase.cjs +123 -66
- package/dist/feature-showcase.cjs.map +1 -1
- package/dist/feature-showcase.js +119 -62
- package/dist/feature-showcase.js.map +1 -1
- package/dist/hooks.cjs +207 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.d.cts +2 -0
- package/dist/hooks.d.ts +2 -0
- package/dist/hooks.js +185 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.cjs +432 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +426 -23
- package/dist/index.js.map +1 -1
- package/dist/media-hover-ctas.cjs +75 -0
- package/dist/media-hover-ctas.cjs.map +1 -0
- package/dist/media-hover-ctas.d.cts +83 -0
- package/dist/media-hover-ctas.d.ts +83 -0
- package/dist/media-hover-ctas.js +73 -0
- package/dist/media-hover-ctas.js.map +1 -0
- package/dist/pressable.cjs +332 -0
- package/dist/pressable.cjs.map +1 -0
- package/dist/pressable.d.cts +132 -0
- package/dist/pressable.d.ts +132 -0
- package/dist/pressable.js +310 -0
- package/dist/pressable.js.map +1 -0
- package/dist/registry.cjs +240 -66
- package/dist/registry.cjs.map +1 -1
- package/dist/registry.js +237 -63
- package/dist/registry.js.map +1 -1
- package/dist/types.d.cts +58 -1
- package/dist/types.d.ts +58 -1
- package/dist/use-navigation.cjs +206 -0
- package/dist/use-navigation.cjs.map +1 -0
- package/dist/use-navigation.d.cts +49 -0
- package/dist/use-navigation.d.ts +49 -0
- package/dist/use-navigation.js +184 -0
- package/dist/use-navigation.js.map +1 -0
- package/package.json +22 -1
package/dist/components.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as React4 from 'react';
|
|
2
|
+
import React4__default, { useId, useRef, useEffect } from 'react';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
5
5
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
@@ -8,6 +8,7 @@ import { useOnClickOutside } from '@opensite/hooks';
|
|
|
8
8
|
import { Slot } from '@radix-ui/react-slot';
|
|
9
9
|
import { cva } from 'class-variance-authority';
|
|
10
10
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
11
|
+
import { Img } from '@page-speed/img';
|
|
11
12
|
|
|
12
13
|
// components/ui/container.tsx
|
|
13
14
|
function cn(...inputs) {
|
|
@@ -22,7 +23,7 @@ var maxWidthStyles = {
|
|
|
22
23
|
"4xl": "max-w-[1536px]",
|
|
23
24
|
full: "max-w-full"
|
|
24
25
|
};
|
|
25
|
-
var Container =
|
|
26
|
+
var Container = React4__default.forwardRef(
|
|
26
27
|
({ children, maxWidth = "xl", className, as = "div", ...props }, ref) => {
|
|
27
28
|
const Component = as;
|
|
28
29
|
return /* @__PURE__ */ jsx(
|
|
@@ -56,7 +57,7 @@ var spacingStyles = {
|
|
|
56
57
|
lg: "py-20 md:py-32",
|
|
57
58
|
xl: "py-24 md:py-40"
|
|
58
59
|
};
|
|
59
|
-
var Section =
|
|
60
|
+
var Section = React4__default.forwardRef(
|
|
60
61
|
({
|
|
61
62
|
id,
|
|
62
63
|
title,
|
|
@@ -497,6 +498,7 @@ function PopoverContent({
|
|
|
497
498
|
}
|
|
498
499
|
) });
|
|
499
500
|
}
|
|
501
|
+
var svgCache = /* @__PURE__ */ new Map();
|
|
500
502
|
function DynamicIcon({
|
|
501
503
|
name,
|
|
502
504
|
size = 28,
|
|
@@ -504,32 +506,372 @@ function DynamicIcon({
|
|
|
504
506
|
className,
|
|
505
507
|
alt
|
|
506
508
|
}) {
|
|
507
|
-
const
|
|
509
|
+
const [svgContent, setSvgContent] = React4.useState(null);
|
|
510
|
+
const [isLoading, setIsLoading] = React4.useState(true);
|
|
511
|
+
const [error, setError] = React4.useState(null);
|
|
512
|
+
const { url, iconName } = React4.useMemo(() => {
|
|
508
513
|
const separator = name.includes("/") ? "/" : ":";
|
|
509
|
-
const [prefix,
|
|
510
|
-
const
|
|
511
|
-
const baseUrl = `https://icons.opensite.ai/api/icon/${prefix}/${iconName}?format=svg&width=${size}&height=${size}&`;
|
|
514
|
+
const [prefix, iconName2] = name.split(separator);
|
|
515
|
+
const baseUrl = `https://icons.opensite.ai/api/icon/${prefix}/${iconName2}?format=svg&width=${size}&height=${size}`;
|
|
512
516
|
return {
|
|
513
|
-
url:
|
|
514
|
-
iconName
|
|
517
|
+
url: baseUrl,
|
|
518
|
+
iconName: iconName2
|
|
515
519
|
};
|
|
516
|
-
}, [name, size
|
|
520
|
+
}, [name, size]);
|
|
521
|
+
React4.useEffect(() => {
|
|
522
|
+
let isMounted = true;
|
|
523
|
+
const fetchSvg = async () => {
|
|
524
|
+
const cached = svgCache.get(url);
|
|
525
|
+
if (cached) {
|
|
526
|
+
if (isMounted) {
|
|
527
|
+
setSvgContent(cached);
|
|
528
|
+
setIsLoading(false);
|
|
529
|
+
}
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
try {
|
|
533
|
+
setIsLoading(true);
|
|
534
|
+
setError(null);
|
|
535
|
+
const response = await fetch(url);
|
|
536
|
+
if (!response.ok) {
|
|
537
|
+
throw new Error(`Failed to fetch icon: ${response.status}`);
|
|
538
|
+
}
|
|
539
|
+
let svg = await response.text();
|
|
540
|
+
svg = processSvgForCurrentColor(svg);
|
|
541
|
+
svgCache.set(url, svg);
|
|
542
|
+
if (isMounted) {
|
|
543
|
+
setSvgContent(svg);
|
|
544
|
+
setIsLoading(false);
|
|
545
|
+
}
|
|
546
|
+
} catch (err) {
|
|
547
|
+
if (isMounted) {
|
|
548
|
+
setError(err instanceof Error ? err.message : "Failed to load icon");
|
|
549
|
+
setIsLoading(false);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
fetchSvg();
|
|
554
|
+
return () => {
|
|
555
|
+
isMounted = false;
|
|
556
|
+
};
|
|
557
|
+
}, [url]);
|
|
558
|
+
if (isLoading) {
|
|
559
|
+
return /* @__PURE__ */ jsx(
|
|
560
|
+
"span",
|
|
561
|
+
{
|
|
562
|
+
className: cn("inline-block", className),
|
|
563
|
+
style: { width: size, height: size },
|
|
564
|
+
"aria-hidden": "true"
|
|
565
|
+
}
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
if (error || !svgContent) {
|
|
569
|
+
return /* @__PURE__ */ jsx(
|
|
570
|
+
"span",
|
|
571
|
+
{
|
|
572
|
+
className: cn("inline-block", className),
|
|
573
|
+
style: { width: size, height: size },
|
|
574
|
+
role: "img",
|
|
575
|
+
"aria-label": alt || iconName
|
|
576
|
+
}
|
|
577
|
+
);
|
|
578
|
+
}
|
|
517
579
|
return /* @__PURE__ */ jsx(
|
|
518
|
-
"
|
|
580
|
+
"span",
|
|
519
581
|
{
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
582
|
+
className: cn("inline-flex items-center justify-center", className),
|
|
583
|
+
style: {
|
|
584
|
+
width: size,
|
|
585
|
+
height: size,
|
|
586
|
+
color: color || "inherit"
|
|
587
|
+
},
|
|
588
|
+
role: "img",
|
|
589
|
+
"aria-label": alt || iconName,
|
|
590
|
+
dangerouslySetInnerHTML: { __html: svgContent }
|
|
526
591
|
}
|
|
527
592
|
);
|
|
528
593
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
594
|
+
function processSvgForCurrentColor(svg) {
|
|
595
|
+
let processed = svg;
|
|
596
|
+
processed = processed.replace(
|
|
597
|
+
/stroke=["'](#000000|#000|black)["']/gi,
|
|
598
|
+
'stroke="currentColor"'
|
|
599
|
+
);
|
|
600
|
+
processed = processed.replace(
|
|
601
|
+
/fill=["'](#000000|#000|black)["']/gi,
|
|
602
|
+
'fill="currentColor"'
|
|
603
|
+
);
|
|
604
|
+
return processed;
|
|
605
|
+
}
|
|
606
|
+
function normalizePhoneNumber(input) {
|
|
607
|
+
const trimmed = input.trim();
|
|
608
|
+
if (trimmed.toLowerCase().startsWith("tel:")) {
|
|
609
|
+
return trimmed;
|
|
610
|
+
}
|
|
611
|
+
const match = trimmed.match(/^[\s\+\-\(\)]*(\d[\d\s\-\(\)\.]*\d)[\s\-]*(x|ext\.?|extension)?[\s\-]*(\d+)?$/i);
|
|
612
|
+
if (match) {
|
|
613
|
+
const mainNumber = match[1].replace(/[\s\-\(\)\.]/g, "");
|
|
614
|
+
const extension = match[3];
|
|
615
|
+
const normalized = mainNumber.length >= 10 && !trimmed.startsWith("+") ? `+${mainNumber}` : mainNumber;
|
|
616
|
+
const withExtension = extension ? `${normalized};ext=${extension}` : normalized;
|
|
617
|
+
return `tel:${withExtension}`;
|
|
618
|
+
}
|
|
619
|
+
const cleaned = trimmed.replace(/[\s\-\(\)\.]/g, "");
|
|
620
|
+
return `tel:${cleaned}`;
|
|
621
|
+
}
|
|
622
|
+
function normalizeEmail(input) {
|
|
623
|
+
const trimmed = input.trim();
|
|
624
|
+
if (trimmed.toLowerCase().startsWith("mailto:")) {
|
|
625
|
+
return trimmed;
|
|
626
|
+
}
|
|
627
|
+
return `mailto:${trimmed}`;
|
|
628
|
+
}
|
|
629
|
+
function isEmail(input) {
|
|
630
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
631
|
+
return emailRegex.test(input.trim());
|
|
632
|
+
}
|
|
633
|
+
function isPhoneNumber(input) {
|
|
634
|
+
const trimmed = input.trim();
|
|
635
|
+
if (trimmed.toLowerCase().startsWith("tel:")) {
|
|
636
|
+
return true;
|
|
637
|
+
}
|
|
638
|
+
const phoneRegex = /^[\s\+\-\(\)]*\d[\d\s\-\(\)\.]*\d[\s\-]*(x|ext\.?|extension)?[\s\-]*\d*$/i;
|
|
639
|
+
return phoneRegex.test(trimmed);
|
|
640
|
+
}
|
|
641
|
+
function isInternalUrl(href) {
|
|
642
|
+
if (typeof window === "undefined") {
|
|
643
|
+
return href.startsWith("/") && !href.startsWith("//");
|
|
644
|
+
}
|
|
645
|
+
const trimmed = href.trim();
|
|
646
|
+
if (trimmed.startsWith("/") && !trimmed.startsWith("//")) {
|
|
647
|
+
return true;
|
|
648
|
+
}
|
|
649
|
+
try {
|
|
650
|
+
const url = new URL(trimmed, window.location.href);
|
|
651
|
+
const currentOrigin = window.location.origin;
|
|
652
|
+
const normalizeOrigin = (origin) => origin.replace(/^(https?:\/\/)(www\.)?/, "$1");
|
|
653
|
+
return normalizeOrigin(url.origin) === normalizeOrigin(currentOrigin);
|
|
654
|
+
} catch {
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
function toRelativePath(href) {
|
|
659
|
+
if (typeof window === "undefined") {
|
|
660
|
+
return href;
|
|
661
|
+
}
|
|
662
|
+
const trimmed = href.trim();
|
|
663
|
+
if (trimmed.startsWith("/") && !trimmed.startsWith("//")) {
|
|
664
|
+
return trimmed;
|
|
665
|
+
}
|
|
666
|
+
try {
|
|
667
|
+
const url = new URL(trimmed, window.location.href);
|
|
668
|
+
const currentOrigin = window.location.origin;
|
|
669
|
+
const normalizeOrigin = (origin) => origin.replace(/^(https?:\/\/)(www\.)?/, "$1");
|
|
670
|
+
if (normalizeOrigin(url.origin) === normalizeOrigin(currentOrigin)) {
|
|
671
|
+
return url.pathname + url.search + url.hash;
|
|
672
|
+
}
|
|
673
|
+
} catch {
|
|
674
|
+
}
|
|
675
|
+
return trimmed;
|
|
676
|
+
}
|
|
677
|
+
function useNavigation({
|
|
678
|
+
href,
|
|
679
|
+
onClick
|
|
680
|
+
} = {}) {
|
|
681
|
+
const linkType = React4.useMemo(() => {
|
|
682
|
+
if (!href || href.trim() === "") {
|
|
683
|
+
return onClick ? "none" : "none";
|
|
684
|
+
}
|
|
685
|
+
const trimmed = href.trim();
|
|
686
|
+
if (trimmed.toLowerCase().startsWith("mailto:") || isEmail(trimmed)) {
|
|
687
|
+
return "mailto";
|
|
688
|
+
}
|
|
689
|
+
if (trimmed.toLowerCase().startsWith("tel:") || isPhoneNumber(trimmed)) {
|
|
690
|
+
return "tel";
|
|
691
|
+
}
|
|
692
|
+
if (isInternalUrl(trimmed)) {
|
|
693
|
+
return "internal";
|
|
694
|
+
}
|
|
695
|
+
try {
|
|
696
|
+
new URL(trimmed, typeof window !== "undefined" ? window.location.href : "http://localhost");
|
|
697
|
+
return "external";
|
|
698
|
+
} catch {
|
|
699
|
+
return "internal";
|
|
700
|
+
}
|
|
701
|
+
}, [href, onClick]);
|
|
702
|
+
const normalizedHref = React4.useMemo(() => {
|
|
703
|
+
if (!href || href.trim() === "") {
|
|
704
|
+
return void 0;
|
|
705
|
+
}
|
|
706
|
+
const trimmed = href.trim();
|
|
707
|
+
switch (linkType) {
|
|
708
|
+
case "tel":
|
|
709
|
+
return normalizePhoneNumber(trimmed);
|
|
710
|
+
case "mailto":
|
|
711
|
+
return normalizeEmail(trimmed);
|
|
712
|
+
case "internal":
|
|
713
|
+
return toRelativePath(trimmed);
|
|
714
|
+
case "external":
|
|
715
|
+
return trimmed;
|
|
716
|
+
default:
|
|
717
|
+
return trimmed;
|
|
718
|
+
}
|
|
719
|
+
}, [href, linkType]);
|
|
720
|
+
const target = React4.useMemo(() => {
|
|
721
|
+
switch (linkType) {
|
|
722
|
+
case "external":
|
|
723
|
+
return "_blank";
|
|
724
|
+
case "internal":
|
|
725
|
+
return "_self";
|
|
726
|
+
case "mailto":
|
|
727
|
+
case "tel":
|
|
728
|
+
return void 0;
|
|
729
|
+
default:
|
|
730
|
+
return void 0;
|
|
731
|
+
}
|
|
732
|
+
}, [linkType]);
|
|
733
|
+
const rel = React4.useMemo(() => {
|
|
734
|
+
if (linkType === "external") {
|
|
735
|
+
return "noopener noreferrer";
|
|
736
|
+
}
|
|
737
|
+
return void 0;
|
|
738
|
+
}, [linkType]);
|
|
739
|
+
const isExternal = linkType === "external";
|
|
740
|
+
const isInternal = linkType === "internal";
|
|
741
|
+
const shouldUseRouter = isInternal && typeof normalizedHref === "string" && normalizedHref.startsWith("/");
|
|
742
|
+
const handleClick = React4.useCallback(
|
|
743
|
+
(event) => {
|
|
744
|
+
if (onClick) {
|
|
745
|
+
try {
|
|
746
|
+
onClick(event);
|
|
747
|
+
} catch (error) {
|
|
748
|
+
console.error("Error in user onClick handler:", error);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if (event.defaultPrevented) {
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
if (shouldUseRouter && normalizedHref && event.button === 0 && // left-click only
|
|
755
|
+
!event.metaKey && !event.altKey && !event.ctrlKey && !event.shiftKey) {
|
|
756
|
+
if (typeof window !== "undefined") {
|
|
757
|
+
const handler = window.__opensiteNavigationHandler;
|
|
758
|
+
if (typeof handler === "function") {
|
|
759
|
+
try {
|
|
760
|
+
const handled = handler(normalizedHref, event.nativeEvent || event);
|
|
761
|
+
if (handled !== false) {
|
|
762
|
+
event.preventDefault();
|
|
763
|
+
}
|
|
764
|
+
} catch (error) {
|
|
765
|
+
console.error("Error in navigation handler:", error);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
[onClick, shouldUseRouter, normalizedHref]
|
|
772
|
+
);
|
|
773
|
+
return {
|
|
774
|
+
linkType,
|
|
775
|
+
normalizedHref,
|
|
776
|
+
target,
|
|
777
|
+
rel,
|
|
778
|
+
isExternal,
|
|
779
|
+
isInternal,
|
|
780
|
+
shouldUseRouter,
|
|
781
|
+
handleClick
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
var Pressable = React4.forwardRef(
|
|
785
|
+
({
|
|
786
|
+
children,
|
|
787
|
+
className,
|
|
788
|
+
href,
|
|
789
|
+
onClick,
|
|
790
|
+
variant,
|
|
791
|
+
size,
|
|
792
|
+
asButton = false,
|
|
793
|
+
fallbackComponentType = "span",
|
|
794
|
+
componentType,
|
|
795
|
+
"aria-label": ariaLabel,
|
|
796
|
+
"aria-describedby": ariaDescribedby,
|
|
797
|
+
id,
|
|
798
|
+
...props
|
|
799
|
+
}, ref) => {
|
|
800
|
+
const navigation = useNavigation({ href, onClick });
|
|
801
|
+
const {
|
|
802
|
+
normalizedHref,
|
|
803
|
+
target,
|
|
804
|
+
rel,
|
|
805
|
+
linkType,
|
|
806
|
+
isInternal,
|
|
807
|
+
handleClick
|
|
808
|
+
} = navigation;
|
|
809
|
+
const shouldRenderLink = normalizedHref && linkType !== "none";
|
|
810
|
+
const shouldRenderButton = !shouldRenderLink && onClick;
|
|
811
|
+
const effectiveComponentType = componentType || (shouldRenderLink ? "a" : shouldRenderButton ? "button" : fallbackComponentType);
|
|
812
|
+
const finalComponentType = isInternal && shouldRenderLink ? "a" : effectiveComponentType;
|
|
813
|
+
const shouldApplyButtonStyles = asButton || variant || size;
|
|
814
|
+
const combinedClassName = cn(
|
|
815
|
+
shouldApplyButtonStyles && buttonVariants({ variant, size }),
|
|
816
|
+
className
|
|
817
|
+
);
|
|
818
|
+
const commonProps = {
|
|
819
|
+
className: combinedClassName,
|
|
820
|
+
onClick: handleClick,
|
|
821
|
+
"aria-label": ariaLabel,
|
|
822
|
+
"aria-describedby": ariaDescribedby,
|
|
823
|
+
id,
|
|
824
|
+
...Object.fromEntries(
|
|
825
|
+
Object.entries(props).filter(([key]) => key.startsWith("data-"))
|
|
826
|
+
)
|
|
827
|
+
};
|
|
828
|
+
if (finalComponentType === "a" && shouldRenderLink) {
|
|
829
|
+
return /* @__PURE__ */ jsx(
|
|
830
|
+
"a",
|
|
831
|
+
{
|
|
832
|
+
ref,
|
|
833
|
+
href: normalizedHref,
|
|
834
|
+
target,
|
|
835
|
+
rel,
|
|
836
|
+
...commonProps,
|
|
837
|
+
...props,
|
|
838
|
+
children
|
|
839
|
+
}
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
if (finalComponentType === "button") {
|
|
843
|
+
return /* @__PURE__ */ jsx(
|
|
844
|
+
"button",
|
|
845
|
+
{
|
|
846
|
+
ref,
|
|
847
|
+
type: props.type || "button",
|
|
848
|
+
...commonProps,
|
|
849
|
+
...props,
|
|
850
|
+
children
|
|
851
|
+
}
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
if (finalComponentType === "div") {
|
|
855
|
+
return /* @__PURE__ */ jsx(
|
|
856
|
+
"div",
|
|
857
|
+
{
|
|
858
|
+
ref,
|
|
859
|
+
...commonProps,
|
|
860
|
+
children
|
|
861
|
+
}
|
|
862
|
+
);
|
|
863
|
+
}
|
|
864
|
+
return /* @__PURE__ */ jsx(
|
|
865
|
+
"span",
|
|
866
|
+
{
|
|
867
|
+
ref,
|
|
868
|
+
...commonProps,
|
|
869
|
+
children
|
|
870
|
+
}
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
);
|
|
874
|
+
Pressable.displayName = "Pressable";
|
|
533
875
|
function AlternatingBlocks({
|
|
534
876
|
sections,
|
|
535
877
|
title,
|
|
@@ -570,7 +912,67 @@ function AlternatingBlocks({
|
|
|
570
912
|
}
|
|
571
913
|
);
|
|
572
914
|
}
|
|
915
|
+
function MediaHoverCtas(props) {
|
|
916
|
+
const { sectionClassName, gridClassName, items, optixFlowConfig } = props;
|
|
917
|
+
const resolvedItems = items ?? [];
|
|
918
|
+
return /* @__PURE__ */ jsx("section", { className: cn("py-32", sectionClassName), children: /* @__PURE__ */ jsx(
|
|
919
|
+
"div",
|
|
920
|
+
{
|
|
921
|
+
className: cn(
|
|
922
|
+
"grid min-h-100 grid-cols-1 gap-1 lg:grid-cols-2",
|
|
923
|
+
gridClassName
|
|
924
|
+
),
|
|
925
|
+
children: resolvedItems.map((item, index) => {
|
|
926
|
+
const CardComponent = item.cardHref ? "a" : "div";
|
|
927
|
+
const hasHoverImage = Boolean(item.onHoverImgSrc);
|
|
928
|
+
const applyHoverBackground = Boolean(
|
|
929
|
+
item.onHoverBackgroundColor && !hasHoverImage
|
|
930
|
+
);
|
|
931
|
+
const cardStyle = item.initialBackgroundColor || applyHoverBackground ? {
|
|
932
|
+
...item.initialBackgroundColor ? { "--media-hover-cta-bg": item.initialBackgroundColor } : {},
|
|
933
|
+
...applyHoverBackground ? {
|
|
934
|
+
"--media-hover-cta-hover-bg": item.onHoverBackgroundColor
|
|
935
|
+
} : {}
|
|
936
|
+
} : void 0;
|
|
937
|
+
const baseBackgroundClassName = item.initialBackgroundColor ? "bg-[var(--media-hover-cta-bg)]" : "bg-muted-foreground/10";
|
|
938
|
+
const hoverBackgroundClassName = applyHoverBackground ? "group-hover:bg-[var(--media-hover-cta-hover-bg)]" : "";
|
|
939
|
+
const hoverImageAltText = item.altText ?? "";
|
|
940
|
+
return /* @__PURE__ */ jsxs(
|
|
941
|
+
CardComponent,
|
|
942
|
+
{
|
|
943
|
+
...item.cardHref ? { href: item.cardHref } : {},
|
|
944
|
+
className: cn(
|
|
945
|
+
"group relative flex min-h-100 cursor-pointer items-center overflow-hidden justify-start p-10 transition-colors duration-500",
|
|
946
|
+
index % 2 === 0 ? "md:justify-center" : "md:justify-start md:pl-24",
|
|
947
|
+
baseBackgroundClassName,
|
|
948
|
+
hoverBackgroundClassName
|
|
949
|
+
),
|
|
950
|
+
style: cardStyle,
|
|
951
|
+
children: [
|
|
952
|
+
item.onHoverImgSrc ? /* @__PURE__ */ jsx(
|
|
953
|
+
Img,
|
|
954
|
+
{
|
|
955
|
+
src: item.onHoverImgSrc,
|
|
956
|
+
alt: hoverImageAltText,
|
|
957
|
+
"aria-hidden": item.altText ? void 0 : true,
|
|
958
|
+
className: cn(
|
|
959
|
+
"absolute top-0 left-0 z-[-1] h-full w-full object-cover opacity-0 transition-opacity duration-500 group-hover:opacity-100",
|
|
960
|
+
item.imgHoverClassName
|
|
961
|
+
),
|
|
962
|
+
loading: "lazy",
|
|
963
|
+
optixFlowConfig
|
|
964
|
+
}
|
|
965
|
+
) : null,
|
|
966
|
+
item.content
|
|
967
|
+
]
|
|
968
|
+
},
|
|
969
|
+
index
|
|
970
|
+
);
|
|
971
|
+
})
|
|
972
|
+
}
|
|
973
|
+
) });
|
|
974
|
+
}
|
|
573
975
|
|
|
574
|
-
export { AlternatingBlocks, AnimatedDialog, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Container, DynamicIcon, PageHeroBanner, Popover, PopoverContent, PopoverTrigger, Section };
|
|
976
|
+
export { AlternatingBlocks, AnimatedDialog, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Container, DynamicIcon, MediaHoverCtas, PageHeroBanner, Popover, PopoverContent, PopoverTrigger, Pressable, Section };
|
|
575
977
|
//# sourceMappingURL=components.js.map
|
|
576
978
|
//# sourceMappingURL=components.js.map
|