@enigmax/primitives 0.15.0 → 0.16.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enigmax/primitives",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Headless components: the behaviour, the timing and the accessibility, with no styles of their own. Framework-agnostic core plus thin adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -14,9 +14,22 @@ import { useMarquee, type MarqueeHover } from "@enigmax/primitives/react";
14
14
  */
15
15
 
16
16
  export type LogoItem =
17
+ /**
18
+ * A URL, which is the whole entry for most logos:
19
+ * `logos={["/logos/claude.svg", "/logos/openai.svg"]}`.
20
+ *
21
+ * It carries no `alt` - an alt guessed from a file name is a fabricated one, and a
22
+ * wrong alt is worse than an empty one. Use the object form where a mark needs a name.
23
+ */
24
+ | string
17
25
  | { kind: "img"; src: string; alt?: string; /** Override the shared height for one that reads small. */ height?: number; }
18
26
  | { kind: "node"; node: ReactNode; key?: string; };
19
27
 
28
+ /** The object form of whatever was passed. A bare URL is an image with no alt. */
29
+ function normalize(item: LogoItem): Exclude<LogoItem, string> {
30
+ return typeof item === "string" ? { kind: "img", src: item } : item;
31
+ }
32
+
20
33
  export interface LogoMarqueeProps {
21
34
  logos: LogoItem[];
22
35
  /**
@@ -61,7 +74,9 @@ export function LogoMarquee({
61
74
  }: LogoMarqueeProps) {
62
75
  const { laneRef, trackRef, copies, dragging } = useMarquee({ speed, hover, reverse });
63
76
 
64
- const render = (item: LogoItem, index: number): ReactNode => (
77
+ const render = (raw: LogoItem, index: number): ReactNode => {
78
+ const item = normalize(raw);
79
+ return (
65
80
  <span className="logo-marquee__item" key={item.kind === "node" ? item.key ?? index : index}>
66
81
  {item.kind === "img"
67
82
  ? <img
@@ -77,7 +92,8 @@ export function LogoMarquee({
77
92
  />
78
93
  : item.node}
79
94
  </span>
80
- );
95
+ );
96
+ };
81
97
 
82
98
  return (
83
99
  <div