ui.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import type { ReactNode } from "react";
  2. import { cn } from "@/lib/utils";
  3. /** Small sentence-case label above a title (Apple's eyebrow). */
  4. export function Eyebrow({
  5. children,
  6. accent,
  7. className,
  8. }: {
  9. children: ReactNode;
  10. accent?: boolean;
  11. className?: string;
  12. }) {
  13. return (
  14. <p className={cn("eyebrow", accent && "text-ember-ink", className)}>
  15. {children}
  16. </p>
  17. );
  18. }
  19. export function ArrowUpRight({ className }: { className?: string }) {
  20. return (
  21. <svg
  22. aria-hidden
  23. className={cn("size-3.5", className)}
  24. fill="none"
  25. viewBox="0 0 16 16"
  26. >
  27. <path
  28. d="M4.5 11.5 11.5 4.5M5.5 4.5h6v6"
  29. stroke="currentColor"
  30. strokeLinecap="round"
  31. strokeLinejoin="round"
  32. strokeWidth="1.6"
  33. />
  34. </svg>
  35. );
  36. }
  37. export function Chevron({ className }: { className?: string }) {
  38. return (
  39. <svg
  40. aria-hidden
  41. className={cn("size-3", className)}
  42. fill="none"
  43. viewBox="0 0 12 12"
  44. >
  45. <path
  46. d="M4.5 2.5 8 6l-3.5 3.5"
  47. stroke="currentColor"
  48. strokeLinecap="round"
  49. strokeLinejoin="round"
  50. strokeWidth="1.7"
  51. />
  52. </svg>
  53. );
  54. }
  55. /** Apple-style text link: "Learn more ›". */
  56. export function TextLink({
  57. href,
  58. children,
  59. className,
  60. label,
  61. cursor = "Open ↗",
  62. }: {
  63. href: string;
  64. children: ReactNode;
  65. className?: string;
  66. /** A fuller accessible name; it should start with the visible text. */
  67. label?: string;
  68. /** The cursor's label over an outside link. */
  69. cursor?: string;
  70. }) {
  71. const external = href.startsWith("http");
  72. return (
  73. <a
  74. aria-label={label}
  75. className={cn(
  76. "group/link inline-flex items-center gap-1 text-[15px] font-medium text-glacier-ink hover:underline hover:underline-offset-4",
  77. className,
  78. )}
  79. data-cursor={external ? cursor : undefined}
  80. href={href}
  81. rel={external ? "noopener noreferrer" : undefined}
  82. target={external ? "_blank" : undefined}
  83. >
  84. {children}
  85. <Chevron className="transition-transform duration-300 group-hover/link:translate-x-0.5" />
  86. </a>
  87. );
  88. }
  89. /** Frosted glass pill link (CSS-only glass, no JS). */
  90. export function GlassLink({
  91. href,
  92. children,
  93. className,
  94. cursor,
  95. }: {
  96. href: string;
  97. children: ReactNode;
  98. className?: string;
  99. cursor?: string;
  100. }) {
  101. const external = href.startsWith("http");
  102. return (
  103. <a
  104. className={cn(
  105. "lg group/link inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-[13px] font-medium transition-[scale] duration-300 hover:scale-[1.04] active:scale-[0.97]",
  106. className,
  107. )}
  108. data-cursor={cursor ?? (external ? "Open ↗" : undefined)}
  109. href={href}
  110. rel={external ? "noopener noreferrer" : undefined}
  111. target={external ? "_blank" : undefined}
  112. >
  113. <span aria-hidden className="lg-caustic" />
  114. <span>{children}</span>
  115. <ArrowUpRight className="transition-transform duration-300 group-hover/link:translate-x-0.5 group-hover/link:-translate-y-0.5" />
  116. </a>
  117. );
  118. }
  119. export function SampleNote({
  120. className,
  121. children = "Illustration with sample data",
  122. }: {
  123. className?: string;
  124. children?: ReactNode;
  125. }) {
  126. return <p className={cn("text-[11px] text-muted", className)}>{children}</p>;
  127. }