@orsetra/shared-ui 1.15.0 → 1.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/components/ui/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { Avatar, AvatarImage, AvatarFallback } from './avatar'
|
|
|
6
6
|
export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from './dropdown-menu'
|
|
7
7
|
export { Separator } from './separator'
|
|
8
8
|
export { Logo } from './logo'
|
|
9
|
+
export { ProductMark, PRODUCT_IDENTITIES, type ProductId, type ProductMarkProps, type ProductMarkVariant } from './product-mark'
|
|
9
10
|
export { UserMenu, type UserMenuItem, type UserMenuConfig } from './user-menu'
|
|
10
11
|
export { Input } from './input'
|
|
11
12
|
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from './tooltip'
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mark of a service of the platform: its pictogram on a square tile, and optionally its code.
|
|
3
|
+
* Drawn from graphic/product/svg; the rules are in graphic/BRAND-GUIDELINES.md, Product Identities.
|
|
4
|
+
*/
|
|
5
|
+
import { cn } from "../../lib/utils"
|
|
6
|
+
|
|
7
|
+
export type ProductId = "cis" | "cms" | "apim"
|
|
8
|
+
export type ProductMarkVariant = "mark" | "tile" | "gray"
|
|
9
|
+
|
|
10
|
+
export const PRODUCT_IDENTITIES: Record<ProductId, { code: string; name: string; color: string; tint: string }> = {
|
|
11
|
+
cis: { code: "CIS", name: "Camel Integration Service", color: "#0F62FE", tint: "#EDF5FF" },
|
|
12
|
+
cms: { code: "CMS", name: "Camel Messaging Service", color: "#007D79", tint: "#D9FBFB" },
|
|
13
|
+
apim: { code: "APIM", name: "API Management", color: "#8A3FFC", tint: "#F6F2FF" },
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function Pictogram({ product, ink }: { product: ProductId; ink: string }) {
|
|
17
|
+
const line = { fill: "none", stroke: ink, strokeWidth: 2, strokeLinecap: "square" as const, strokeLinejoin: "miter" as const }
|
|
18
|
+
if (product === "cis") {
|
|
19
|
+
return (
|
|
20
|
+
<g>
|
|
21
|
+
<rect x="6" y="19" width="8" height="10" {...line} />
|
|
22
|
+
<path d="M14 24h4" {...line} />
|
|
23
|
+
<path d="M24 17l7 7-7 7-7-7z" fill={ink} />
|
|
24
|
+
<path d="M31 24h6" {...line} />
|
|
25
|
+
<path d="M34 21l3 3-3 3" {...line} />
|
|
26
|
+
<rect x="38" y="19" width="4" height="10" {...line} />
|
|
27
|
+
</g>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
if (product === "cms") {
|
|
31
|
+
return (
|
|
32
|
+
<g>
|
|
33
|
+
<rect x="7" y="9" width="8" height="8" {...line} />
|
|
34
|
+
<rect x="20" y="9" width="8" height="8" {...line} />
|
|
35
|
+
<rect x="33" y="9" width="8" height="8" {...line} />
|
|
36
|
+
<path d="M11 17v12M24 17v12M37 17v12" {...line} />
|
|
37
|
+
<rect x="7" y="29" width="34" height="10" fill={ink} />
|
|
38
|
+
</g>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
return (
|
|
42
|
+
<g>
|
|
43
|
+
<path d="M17 40V8h14v32" {...line} />
|
|
44
|
+
<path d="M6 24h34" {...line} />
|
|
45
|
+
<path d="M37 21l3 3-3 3" {...line} />
|
|
46
|
+
<rect x="21" y="12" width="6" height="6" fill={ink} />
|
|
47
|
+
</g>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ProductMarkProps {
|
|
52
|
+
product: ProductId
|
|
53
|
+
/** Side of the tile, in pixels. */
|
|
54
|
+
size?: number
|
|
55
|
+
variant?: ProductMarkVariant
|
|
56
|
+
/** Shows the code of the service next to the tile, from 32px. */
|
|
57
|
+
withCode?: boolean
|
|
58
|
+
/** Names the mark for assistive technologies; without it the mark is decorative. */
|
|
59
|
+
label?: string
|
|
60
|
+
className?: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function ProductMark({ product, size = 40, variant = "mark", withCode = false, label, className }: ProductMarkProps) {
|
|
64
|
+
const identity = PRODUCT_IDENTITIES[product]
|
|
65
|
+
const ground = variant === "tile" ? identity.color : variant === "gray" ? "#F4F4F4" : identity.tint
|
|
66
|
+
const ink = variant === "tile" ? "#FFFFFF" : variant === "gray" ? "#6F6F6F" : identity.color
|
|
67
|
+
return (
|
|
68
|
+
<span className={cn("inline-flex items-center gap-2.5 align-middle", className)}>
|
|
69
|
+
<svg
|
|
70
|
+
width={size}
|
|
71
|
+
height={size}
|
|
72
|
+
viewBox="0 0 48 48"
|
|
73
|
+
className="block flex-shrink-0"
|
|
74
|
+
role={label ? "img" : undefined}
|
|
75
|
+
aria-label={label}
|
|
76
|
+
aria-hidden={label ? undefined : true}
|
|
77
|
+
>
|
|
78
|
+
<rect width="48" height="48" fill={ground} />
|
|
79
|
+
<Pictogram product={product} ink={ink} />
|
|
80
|
+
</svg>
|
|
81
|
+
{withCode && size >= 32 && (
|
|
82
|
+
<span
|
|
83
|
+
className="font-mono text-[11px] font-semibold tracking-wider leading-tight px-1.5 py-0.5 border"
|
|
84
|
+
style={{ color: identity.color, borderColor: identity.color }}
|
|
85
|
+
>
|
|
86
|
+
{identity.code}
|
|
87
|
+
</span>
|
|
88
|
+
)}
|
|
89
|
+
</span>
|
|
90
|
+
)
|
|
91
|
+
}
|