@tangle-network/ui 11.19.0 → 11.20.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @tangle-network/ui
|
|
2
2
|
|
|
3
|
+
## 11.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 24ea445: IconTile gains `xl` (64px) and `2xl` (80px) sizes for page and profile headers, so an app can show an entity's face at header scale without a local avatar component.
|
|
8
|
+
|
|
3
9
|
## 11.19.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -17,7 +17,12 @@ import * as React from "react";
|
|
|
17
17
|
export interface IconTileProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
18
18
|
/** Defaults to a tone derived from `name`, or violet when there is no name. */
|
|
19
19
|
tone?: CategoryTone;
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* `xs` to `lg` (20 to 40px) sit in rows and cards. `xl` (64px) and `2xl`
|
|
22
|
+
* (80px) are for a page or profile header, where the tile is the thing's
|
|
23
|
+
* face rather than a list marker.
|
|
24
|
+
*/
|
|
25
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
21
26
|
src?: string;
|
|
22
27
|
icon?: React.ReactNode;
|
|
23
28
|
/** The thing's name. Supplies the initials and the derived tone. */
|
|
@@ -7,7 +7,9 @@ const SIZE = {
|
|
|
7
7
|
xs: "size-5 rounded-[5px] text-[10px] [&_svg]:size-3",
|
|
8
8
|
sm: "size-6 rounded-md text-[11px] [&_svg]:size-3.5",
|
|
9
9
|
md: "size-8 rounded-md text-xs [&_svg]:size-4",
|
|
10
|
-
lg: "size-10 rounded-lg text-sm [&_svg]:size-5"
|
|
10
|
+
lg: "size-10 rounded-lg text-sm [&_svg]:size-5",
|
|
11
|
+
xl: "size-16 rounded-2xl text-xl [&_svg]:size-8",
|
|
12
|
+
"2xl": "size-20 rounded-2xl text-2xl [&_svg]:size-10"
|
|
11
13
|
};
|
|
12
14
|
/** Up to two initials: the first letters of the first two words, or of the one word. */
|
|
13
15
|
function initialsOf(name) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/ui",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.20.0",
|
|
4
4
|
"description": "Generic React UI components for Tangle products — primitives, chat, run, files, editor, markdown.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
"peerDependencies": {
|
|
150
150
|
"@hocuspocus/provider": ">=2.15.0 <5.0.0",
|
|
151
151
|
"@nanostores/react": ">=0.8.4 <3.0.0",
|
|
152
|
-
"@tangle-network/brand": "^1.
|
|
152
|
+
"@tangle-network/brand": "^1.15.1",
|
|
153
153
|
"@tiptap/core": ">=3.20.4 <4.0.0",
|
|
154
154
|
"@tiptap/extension-collaboration": ">=3.20.4 <4.0.0",
|
|
155
155
|
"@tiptap/extension-collaboration-caret": ">=3.7.0 <4.0.0",
|
|
@@ -62,10 +62,10 @@ export const Sizes: Story = {
|
|
|
62
62
|
render: () => (
|
|
63
63
|
<BothThemes>
|
|
64
64
|
<div className="flex items-end gap-3">
|
|
65
|
-
{(["xs", "sm", "md", "lg"] as const).map((size) => (
|
|
65
|
+
{(["xs", "sm", "md", "lg", "xl", "2xl"] as const).map((size) => (
|
|
66
66
|
<IconTile key={size} size={size} name="Tangle Network" />
|
|
67
67
|
))}
|
|
68
|
-
{(["xs", "sm", "md", "lg"] as const).map((size) => (
|
|
68
|
+
{(["xs", "sm", "md", "lg", "xl", "2xl"] as const).map((size) => (
|
|
69
69
|
<IconTile key={`g-${size}`} size={size} tone="cyan" icon={<Globe />} />
|
|
70
70
|
))}
|
|
71
71
|
</div>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import { Globe } from "lucide-react";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { IconTile, initialsOf } from "./icon-tile";
|
|
5
|
+
|
|
6
|
+
describe("IconTile", () => {
|
|
7
|
+
it.each([
|
|
8
|
+
["xs", "size-5"],
|
|
9
|
+
["sm", "size-6"],
|
|
10
|
+
["md", "size-8"],
|
|
11
|
+
["lg", "size-10"],
|
|
12
|
+
["xl", "size-16"],
|
|
13
|
+
["2xl", "size-20"],
|
|
14
|
+
] as const)("renders size %s as %s", (size, cls) => {
|
|
15
|
+
const { container } = render(<IconTile size={size} name="Tangle Network" />);
|
|
16
|
+
expect(container.firstElementChild).toHaveClass(cls);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("scales the glyph with the large sizes", () => {
|
|
20
|
+
const { container } = render(<IconTile size="2xl" tone="cyan" icon={<Globe />} />);
|
|
21
|
+
expect(container.firstElementChild?.className).toContain("[&_svg]:size-10");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("shows initials and is decorative without a label", () => {
|
|
25
|
+
const { container } = render(<IconTile size="xl" name="Acme Robotics" />);
|
|
26
|
+
const tile = container.firstElementChild;
|
|
27
|
+
expect(tile).toHaveTextContent("AR");
|
|
28
|
+
expect(tile).toHaveAttribute("aria-hidden", "true");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("is an image with an accessible name when labelled", () => {
|
|
32
|
+
const { getByRole } = render(<IconTile size="xl" name="Acme" label="Acme" />);
|
|
33
|
+
expect(getByRole("img", { name: "Acme" })).toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("keeps an emoji whole in the initials", () => {
|
|
37
|
+
expect(initialsOf("🦊")).toBe("🦊");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -18,7 +18,12 @@ import { type CategoryTone, TONE_CLASSES, toneFor } from "./tone";
|
|
|
18
18
|
export interface IconTileProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
19
19
|
/** Defaults to a tone derived from `name`, or violet when there is no name. */
|
|
20
20
|
tone?: CategoryTone;
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* `xs` to `lg` (20 to 40px) sit in rows and cards. `xl` (64px) and `2xl`
|
|
23
|
+
* (80px) are for a page or profile header, where the tile is the thing's
|
|
24
|
+
* face rather than a list marker.
|
|
25
|
+
*/
|
|
26
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
22
27
|
src?: string;
|
|
23
28
|
icon?: React.ReactNode;
|
|
24
29
|
/** The thing's name. Supplies the initials and the derived tone. */
|
|
@@ -32,6 +37,8 @@ const SIZE = {
|
|
|
32
37
|
sm: "size-6 rounded-md text-[11px] [&_svg]:size-3.5",
|
|
33
38
|
md: "size-8 rounded-md text-xs [&_svg]:size-4",
|
|
34
39
|
lg: "size-10 rounded-lg text-sm [&_svg]:size-5",
|
|
40
|
+
xl: "size-16 rounded-2xl text-xl [&_svg]:size-8",
|
|
41
|
+
"2xl": "size-20 rounded-2xl text-2xl [&_svg]:size-10",
|
|
35
42
|
} as const;
|
|
36
43
|
|
|
37
44
|
/** Up to two initials: the first letters of the first two words, or of the one word. */
|