Skip to content

Open-source status page, incident response and uptime monitoring

1.9 KB
Raw Blame
import Link from "next/link";
import type React from "react";

import { cn } from "../../lib/utils";

export function ContentBoxLink({
  href,
  children,
  className,
  target,
  rel,
  ...props
}: React.ComponentProps<typeof Link>) {
  const hrefString = typeof href === "string" ? href : href.toString();
  const isExternal = hrefString.startsWith("http");

  return (
    <Link
      href={href}
      target={target ?? (isExternal ? "_blank" : undefined)}
      rel={rel ?? (isExternal ? "noopener noreferrer" : undefined)}
      className={cn("group hover:bg-muted no-underline!", className)}
      {...props}
    >
      {children}
    </Link>
  );
}

export function ContentBoxContainer({
  children,
  className,
  ...props
}: React.ComponentProps<"div">) {
  return (
    <div
      className={cn(
        "border-border border p-3",
        "[&>*:first-child]:!mt-0 [&>*:last-child]:!mb-0",
        className,
      )}
      {...props}
    >
      {children}
    </div>
  );
}

export function ContentBoxTitle({
  children,
  className,
  ...props
}: React.ComponentProps<"p">) {
  return (
    <p className={cn(className)} {...props}>
      <strong>{children}</strong>
    </p>
  );
}

export function ContentBoxDescription({
  children,
  className,
  ...props
}: React.ComponentProps<"p">) {
  return (
    <p className={cn("text-muted-foreground", className)} {...props}>
      {children}
    </p>
  );
}

export function ContentBoxUrl({
  url,
  className,
  ...props
}: {
  url: string;
  className?: string;
} & Omit<React.ComponentProps<"div">, "children">) {
  const displayUrl = url.replace(/^https:\/\/(www\.)?/, "");

  return (
    <div
      className={cn(
        "decoration-muted-foreground/50 group-hover:decoration-muted-foreground underline decoration-2 underline-offset-2 transition-all",
        className,
      )}
      {...props}
    >
      {displayUrl}
    </div>
  );
}