Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,33 @@
import "@testing-library/jest-dom";
import { fireEvent, render, screen } from "@testing-library/react";
import { MemoryRouter } from "react-router";
import { describe, expect, it } from "vitest";
import { HoverEffect } from "./HoverEffect";
describe("HoverEffect accessibility", () => {
it("names image preview and modal external-link controls by action", async () => {
render(
<MemoryRouter>
<HoverEffect
items={[
{
name: "Analytics",
description: "View reporting snapshots.",
img: "/analytics.png",
link: {
href: "/analytics",
},
subFeatures: [{ name: "Reports" }],
},
]}
/>
</MemoryRouter>
);
fireEvent.click(screen.getByRole("button", { name: "preview image for Analytics" }));
const externalLink = await screen.findByRole("link", { name: "open Analytics" });
expect(externalLink).toHaveAttribute("href", "/analytics");
});
});
@@ -0,0 +1,197 @@
import { AnimatePresence, motion } from "framer-motion";
import { t as i18nT } from "i18next";
import { useState } from "react";
import LinkOrAhref from "../ui/buttons/LinkOrAhref";
import clsx from "clsx";
import CheckIcon from "../ui/icons/CheckIcon";
import { Colors } from "~/application/enums/shared/Colors";
import Modal from "../ui/modals/Modal";
import XIcon from "../ui/icons/XIcon";
import ExternalLinkEmptyIcon from "../ui/icons/ExternalLinkEmptyIcon";
import { Link } from "react-router";
export interface HoverEffectItem {
name: string;
description?: string;
img?: string;
className?: string;
link?: {
text?: string;
href: string;
target?: undefined | "_blank";
};
subFeatures?: {
name: string;
description?: string;
}[];
highlight?: {
text: string;
color?: Colors;
};
disabled?: boolean;
}
export const HoverEffect = ({ items }: { items: HoverEffectItem[] }) => {
let [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
const [selectedImage, setSelectedImage] = useState<HoverEffectItem | null>(null);
const [showImage, setShowImage] = useState<boolean>(false);
return (
<div
className={clsx(
"grid w-full grid-cols-1",
items.length > 1 && "md:grid-cols-2",
items.length === 2 && "lg:grid-cols-2",
items.length === 3 && "lg:grid-cols-3",
items.length === 4 && "lg:grid-cols-4",
items.length > 4 && "lg:grid-cols-3"
)}
>
{items.map((item, idx) => (
<LinkOrAhref
key={idx}
to={item?.link?.href}
target={item?.link?.target}
className="group relative block h-full w-full p-2"
onMouseEnter={() => setHoveredIndex(idx)}
onMouseLeave={() => setHoveredIndex(null)}
>
<AnimatePresence>
{hoveredIndex === idx && (
<motion.span
className="absolute inset-0 block h-full w-full rounded-3xl bg-slate-200/[0.8] dark:bg-slate-800/[0.8]"
layoutId="hoverBackground" // required for the background to follow
initial={{ opacity: 0 }}
animate={{
opacity: 1,
transition: { duration: 0.15 },
}}
exit={{
opacity: 0,
transition: { duration: 0.15, delay: 0.2 },
}}
/>
)}
</AnimatePresence>
<div
className={clsx(
"relative h-full w-full overflow-hidden rounded-2xl border border-transparent bg-linear-to-br p-3",
item.className || "text-muted-foreground bg-slate-900/5 dark:bg-white/5"
)}
>
<div className="relative">
<div className="p-4">
<div className="mt-4 flex items-center justify-between space-x-2">
<h4 className="text-foreground font-bold tracking-wide">
<div className="flex items-center space-x-2">
<Name item={item} />
</div>
</h4>
{item.highlight && (
<div
className={clsx(
"border-border inline-flex cursor-default items-center truncate rounded-md border px-2 py-1 text-sm font-medium",
item.highlight.color &&
clsx(
item.highlight.color === Colors.GREEN && "bg-teal-500/30 text-teal-800 dark:text-teal-100",
item.highlight.color === Colors.ROSE && "bg-rose-500/30 text-rose-800 dark:text-rose-100",
item.highlight.color === Colors.VIOLET && "bg-violet-500/30 text-violet-800 dark:text-violet-100",
item.highlight.color === Colors.BLUE && "bg-blue-500/30 text-blue-800 dark:text-blue-100",
item.highlight.color === Colors.YELLOW && "bg-yellow-500/30 text-yellow-800 dark:text-yellow-100",
item.highlight.color === Colors.RED && "bg-red-500/30 text-red-800 dark:text-red-100",
item.highlight.color === Colors.ORANGE && "bg-orange-500/30 text-orange-800 dark:text-orange-100",
item.highlight.color === Colors.CYAN && "bg-cyan-500/30 text-cyan-800 dark:text-cyan-100",
item.highlight.color === Colors.INDIGO && "bg-indigo-500/30 text-indigo-800 dark:text-indigo-100",
item.highlight.color === Colors.PINK && "bg-pink-500/30 text-pink-800 dark:text-pink-100",
item.highlight.color === Colors.PURPLE && "bg-purple-500/30 text-purple-800 dark:text-purple-100",
item.highlight.color === Colors.LIME && "bg-lime-500/30 text-lime-800 dark:text-lime-100",
item.highlight.color === Colors.EMERALD && "bg-emerald-500/30 text-emerald-800 dark:text-emerald-100",
item.highlight.color === Colors.AMBER && "bg-amber-500/30 text-amber-800 dark:text-amber-100",
item.highlight.color === Colors.GRAY && "bg-gray-500/30 text-gray-800 dark:text-gray-100",
item.highlight.color === Colors.SLATE && "bg-slate-500/30 text-slate-800 dark:text-slate-100",
item.highlight.color === Colors.GRAY && "bg-gray-500/30 text-gray-800 dark:text-gray-100",
item.highlight.color === Colors.NEUTRAL && "bg-neutral-500/30 text-neutral-800 dark:text-neutral-100"
)
)}
>
{item.highlight.text}
</div>
)}
</div>
<p className="mt-4 text-sm leading-relaxed tracking-wide">{item.description}</p>
{item.img && (
<div className="hidden xl:block">
<button
type="button"
aria-label={`preview image for ${item.name}`}
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
setSelectedImage(item);
setShowImage(true);
}}
className="mt-4 block w-full"
>
<img src={item.img} alt={item.name} className={clsx("w-full rounded-lg object-cover", items.length === 1 ? "h-full" : "h-44")} />
</button>
</div>
)}
{item.subFeatures && (
<div className="mt-4 flex flex-wrap gap-2">
{item.subFeatures.map((subFeature, idx) => (
<div
key={idx}
className={clsx("text-muted-foreground bg-muted/30 border-border flex space-x-1 rounded-md border px-2 py-1 text-xs font-medium")}
>
<CheckIcon className="text-muted-foreground/50 h-4 w-4" aria-hidden="true" />
<div>{subFeature.name}</div>
</div>
))}
</div>
)}
</div>
</div>
</div>
</LinkOrAhref>
))}
<Modal open={showImage} setOpen={() => setShowImage(false)}>
<div>
<div className="flex justify-between space-x-2">
<h1 className="text-2xl font-bold">{selectedImage?.name}</h1>
<div className="flex items-center space-x-4">
{selectedImage?.link && (
<div>
<Link to={selectedImage.link.href} target={selectedImage.link.target} aria-label={`open ${selectedImage.name}`}>
<div className="text-muted-foreground hover:text-foreground focus:ring-ring hover:bg-secondary rounded-md p-2 focus:ring-2 focus:ring-offset-2 focus:outline-hidden">
<ExternalLinkEmptyIcon className="h-6 w-6" aria-hidden="true" />
</div>
</Link>
</div>
)}
<button
type="button"
className="text-muted-foreground hover:text-foreground focus:ring-ring hover:bg-secondary rounded-md p-2 focus:ring-2 focus:ring-offset-2 focus:outline-hidden"
onClick={() => setShowImage(false)}
>
<span className="sr-only">{i18nT("shared.close")}</span>
<XIcon className="h-6 w-6" aria-hidden="true" />
</button>
</div>
</div>
<p className="text-muted-foreground mt-2">{selectedImage?.description}</p>
</div>
{selectedImage && <img src={selectedImage.img} alt={selectedImage.name} className="mt-4 h-full w-full rounded-lg object-cover" />}
</Modal>
</div>
);
};
function Name({ item }: { item: HoverEffectItem }) {
switch (item.name) {
default:
return item.name;
}
}
@@ -0,0 +1,73 @@
import React, { useRef } from "react";
import { t as i18nT } from "i18next";
import { motion, useScroll, useSpring, useTransform } from "framer-motion";
export const MovingLine = () => {
const transition = {
duration: 14,
ease: "easeInOut",
};
const ref = useRef<any>(null);
// Track scroll progress, lies between 0 and 1.
const { scrollYProgress } = useScroll({
target: ref,
offset: ["end end", "start start"],
});
// when scroll progress reached 1, path length becomes 0.
const pathLengthValue = useTransform(scrollYProgress, [0, 1], [1, 0]);
const PATH = "M0.5 0.980671L0.5 1566.02";
return (
<div className="mx-auto flex w-full max-w-4xl flex-row items-start space-x-10" ref={ref}>
<svg width="1" height="1567" viewBox="0 0 1 1567" fill="none" xmlns="http://www.w3.org/2000/svg" className="shrink-0">
<path d={PATH} stroke="url(#paint0_linear_207_38)" />
<defs>
<linearGradient id="paint0_linear_207_38" x1="1" y1="-102.823" x2="1" y2="1566.02" gradientUnits="userSpaceOnUse">
<stop stop-color="#3879E7" stop-opacity="0" />
<stop offset="1" stop-color="#3879E7" />
</linearGradient>
</defs>
<motion.path
// animatng pathLength value, goes from 1 to 0
style={{
pathLength: useSpring(pathLengthValue, {
stiffness: 500,
damping: 100,
}),
}}
transition={transition}
d={PATH}
stroke="var(--blue-500)"
strokeOpacity="1"
strokeLinecap={"round"}
strokeWidth="3"
/>
</svg>
<div className="flex w-full flex-col">
<Content />
<Content />
<Content />
</div>
</div>
);
};
{
/* dummy content to fill up the screen */
}
export const Content = () => {
return (
<div className="content mb-10 w-full">
<p className="text-2xl font-bold text-white">{i18nT("components.aceternity.movingLine.title")}</p>
<p className="text-base font-normal text-neutral-300">{i18nT("components.aceternity.movingLine.description")}</p>
<div className="flex w-full space-x-4">
<div className="mt-4 h-40 w-full rounded-md bg-linear-to-tr from-slate-800 to-slate-700 md:h-96" />
<div className="mt-4 h-40 w-full rounded-md bg-linear-to-tr from-slate-800 to-slate-700 md:h-96" />
</div>
</div>
);
};
@@ -0,0 +1,232 @@
"use client";
import React, { useEffect, useState } from "react";
import { cn } from "~/lib/utils";
import ButtonEvent from "../ui/buttons/ButtonEvent";
import UserAvatarBadge from "../core/users/UserAvatarBadge";
import LinkOrAhref from "../ui/buttons/LinkOrAhref";
import clsx from "clsx";
import { useTranslation } from "react-i18next";
import { useLocaleFormatters } from "~/locale/format";
export type InfiniteMovingCardItem = {
company?: string;
companyUrl?: string;
title?: string;
quote: string;
name: string;
personalWebsite?: string;
avatar: string;
role?: string;
createdAt?: Date;
quoteUrl?: string;
};
function Stars({ color = "text-yellow-400" }: { color?: string }) {
return (
<div className="flex items-center">
{[0, 1, 2, 3, 4].map((item) => (
<svg key={item} className={cn("ms-1 size-4", color)} aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 22 20">
<path d="M20.924 7.625a1.523 1.523 0 0 0-1.238-1.044l-5.051-.734-2.259-4.577a1.534 1.534 0 0 0-2.752 0L7.365 5.847l-5.051.734A1.535 1.535 0 0 0 1.463 9.2l3.656 3.563-.863 5.031a1.532 1.532 0 0 0 2.226 1.616L11 17.033l4.518 2.375a1.534 1.534 0 0 0 2.226-1.617l-.863-5.03L20.537 9.2a1.523 1.523 0 0 0 .387-1.575Z" />
</svg>
))}
</div>
);
}
export const InfiniteMovingCards = ({
items,
direction = "left",
speed = "fast",
pauseOnHover = true,
className,
}: {
items: InfiniteMovingCardItem[];
direction?: "left" | "right";
speed?: "fast" | "normal" | "slow";
pauseOnHover?: boolean;
className?: string;
}) => {
const { t } = useTranslation();
const formatters = useLocaleFormatters();
const containerRef = React.useRef<HTMLDivElement>(null);
const scrollerRef = React.useRef<HTMLUListElement>(null);
useEffect(() => {
addAnimation();
}, []);
const [start, setStart] = useState(false);
function addAnimation() {
if (containerRef.current && scrollerRef.current) {
const scrollerContent = Array.from(scrollerRef.current.children);
scrollerContent.forEach((item) => {
const duplicatedItem = item.cloneNode(true);
if (scrollerRef.current) {
scrollerRef.current.appendChild(duplicatedItem);
}
});
getDirection();
getSpeed();
setStart(true);
}
}
const getDirection = () => {
if (containerRef.current) {
if (direction === "left") {
containerRef.current.style.setProperty("--animation-direction", "forwards");
} else {
containerRef.current.style.setProperty("--animation-direction", "reverse");
}
}
};
const getSpeed = () => {
if (containerRef.current) {
if (speed === "fast") {
containerRef.current.style.setProperty("--animation-duration", "20s");
} else if (speed === "normal") {
containerRef.current.style.setProperty("--animation-duration", "40s");
} else {
containerRef.current.style.setProperty("--animation-duration", "100s");
}
}
};
const colors = [
"text-green-400",
"text-yellow-400",
"text-purple-400",
"text-blue-400",
"text-red-400",
"text-cyan-400",
"text-indigo-400",
"text-pink-400",
"text-rose-400",
"text-violet-400",
"text-lime-400",
"text-emerald-400",
];
return (
<div
ref={containerRef}
className={cn(
"scroller relative z-20 max-w-7xl overflow-hidden [mask-image:linear-gradient(to_right,transparent,white_20%,white_80%,transparent)]",
className
)}
>
<ul
ref={scrollerRef}
className={cn(
" flex w-max min-w-full shrink-0 flex-nowrap gap-4 py-4",
start && "animate-scroll ",
pauseOnHover && "hover:[animation-play-state:paused]"
)}
>
{items.map((testimonial, idx) => {
let randomColor = "text-yellow-400";
if (idx < colors.length) {
randomColor = colors[idx];
} else {
const randomIdx = Math.floor(Math.random() * colors.length);
randomColor = colors[randomIdx];
}
return (
<li
className={clsx(
"relative flex w-[350px] max-w-full shrink-0 flex-col justify-between rounded-2xl border border-slate-700 px-8 py-6 md:w-[300px]"
)}
style={{
background: "linear-gradient(180deg, var(--slate-800), var(--slate-900)",
}}
key={testimonial.name}
>
{testimonial.quoteUrl && (
<ButtonEvent
event={{ action: "click", category: "testimonials", label: "quote", value: testimonial.name }}
target="_blank"
rel="noreferrer"
className="absolute inset-0 z-10"
to={testimonial.quoteUrl}
/>
)}
<blockquote>
<div
aria-hidden="true"
className="user-select-none -z-1 pointer-events-none absolute -left-0.5 -top-0.5 h-[calc(100%_+_4px)] w-[calc(100%_+_4px)]"
></div>
<div className="relative z-20 mt-6 flex flex-row items-center">
<span className="flex flex-col gap-3">
{/* <span className=" text-muted-foreground text-sm font-normal leading-[1.6]">{testimonial.name}</span> */}
<div className=" -mx-1">
<Stars color={randomColor} />
</div>
<span className=" text-foreground text-sm font-black leading-[1.6]">{testimonial.title}</span>
</span>
</div>
<span className="line-clamp-6 text-sm font-normal leading-[1.6]">
{/* <ShowMoreLinesText lines="4"> */}
{testimonial.quote}
{/* </ShowMoreLinesText> */}
</span>
</blockquote>
<div className="mt-4 inline-flex items-center">
{testimonial.avatar ? (
<img alt="testimonial" src={testimonial.avatar} className="h-6 w-6 shrink-0 rounded-full object-cover object-center" />
) : (
<UserAvatarBadge avatar={undefined} className="h-6 w-6 shrink-0 rounded-full object-cover object-center" />
)}
<span className="flex grow flex-col pl-4">
<LinkOrAhref
to={testimonial.personalWebsite}
target="_blank"
rel="noreferrer"
className={clsx("title-font text-left text-xs font-medium", testimonial.personalWebsite && "hover:underline")}
// event={{ action: "click", category: "testimonial-user", label: testimonial.name, value: testimonial.personalWebsite ?? "" }}
>
{testimonial.name}
</LinkOrAhref>
<span className="text-muted-foreground flex items-center space-x-1 truncate text-sm">
{testimonial.role && <div className="truncate">{t(testimonial.role)}</div>}
{testimonial.company && (
<>
<div>@</div>
<div className="text-muted-foreground truncate text-sm">
{testimonial.companyUrl ? (
<ButtonEvent
to={testimonial.companyUrl}
target="_blank"
rel="noreferrer"
className="hover:underline"
event={{ action: "click", category: "testimonial-company", label: testimonial.company, value: testimonial.companyUrl ?? "" }}
>
{testimonial.company}
</ButtonEvent>
) : (
testimonial.company
)}
</div>
</>
)}
{testimonial.createdAt && (
<time
className="truncate"
dateTime={new Date(testimonial.createdAt).toISOString()}
title={formatters.dateTime(testimonial.createdAt, { timeStyle: "medium" })}
>
{formatters.relativeDate(testimonial.createdAt)}
</time>
)}
</span>
</span>
</div>
</li>
);
})}
</ul>
</div>
);
};