minka-ds 0.3.11 → 0.3.12
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 +1 -1
- package/src/components/ui/avatar.tsx +47 -0
- package/src/components/ui/sidebar.tsx +34 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cn } from "../../lib/utils"
|
|
3
|
+
|
|
4
|
+
const SIZE: Record<NonNullable<AvatarProps["size"]>, string> = {
|
|
5
|
+
sm: "size-7 text-caption-serif",
|
|
6
|
+
md: "size-9 text-body-sm-serif",
|
|
7
|
+
lg: "size-12 text-body-serif",
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface AvatarProps {
|
|
11
|
+
/** Image URL. When absent, initials (or a fallback) are shown. */
|
|
12
|
+
src?: string
|
|
13
|
+
/** Full name — used for alt text and to derive initials. */
|
|
14
|
+
name?: string
|
|
15
|
+
/** Explicit initials override; otherwise derived from `name`. */
|
|
16
|
+
initials?: string
|
|
17
|
+
size?: "sm" | "md" | "lg"
|
|
18
|
+
/** Background for the initials state. Defaults to a brand color. */
|
|
19
|
+
background?: string
|
|
20
|
+
className?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function deriveInitials(name?: string): string {
|
|
24
|
+
if (!name) return "?"
|
|
25
|
+
return name.trim().split(/\s+/).map(p => p[0]).join("").slice(0, 2).toUpperCase()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function Avatar({ src, name, initials, size = "md", background, className }: AvatarProps) {
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
data-slot="avatar"
|
|
32
|
+
className={cn(
|
|
33
|
+
"shrink-0 rounded-full flex items-center justify-center overflow-hidden text-[var(--color-text-inverse)]",
|
|
34
|
+
SIZE[size],
|
|
35
|
+
className
|
|
36
|
+
)}
|
|
37
|
+
style={{ background: src ? undefined : (background ?? "var(--color-brand-blue)") }}
|
|
38
|
+
>
|
|
39
|
+
{src
|
|
40
|
+
? <img src={src} alt={name ?? ""} className="size-full object-cover" />
|
|
41
|
+
: <span className="leading-none">{initials ?? deriveInitials(name)}</span>}
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Avatar }
|
|
47
|
+
export type { AvatarProps }
|
|
@@ -7,6 +7,7 @@ import { Slot } from "radix-ui"
|
|
|
7
7
|
|
|
8
8
|
import { useIsMobile } from "../../hooks/use-mobile"
|
|
9
9
|
import { cn } from "../../lib/utils"
|
|
10
|
+
import { Avatar } from "./avatar"
|
|
10
11
|
import { Button } from "./button"
|
|
11
12
|
import { Input } from "./input"
|
|
12
13
|
import { Separator } from "./separator"
|
|
@@ -368,6 +369,38 @@ function SidebarSeparator({
|
|
|
368
369
|
)
|
|
369
370
|
}
|
|
370
371
|
|
|
372
|
+
// Footer user block: avatar + name/role, with an optional trailing action
|
|
373
|
+
// (e.g. a kebab dropdown trigger). Composed for the sidebar footer.
|
|
374
|
+
function SidebarUser({
|
|
375
|
+
name,
|
|
376
|
+
role,
|
|
377
|
+
avatarSrc,
|
|
378
|
+
avatarBackground,
|
|
379
|
+
action,
|
|
380
|
+
className,
|
|
381
|
+
}: {
|
|
382
|
+
name: string
|
|
383
|
+
role?: string
|
|
384
|
+
avatarSrc?: string
|
|
385
|
+
avatarBackground?: string
|
|
386
|
+
action?: React.ReactNode
|
|
387
|
+
className?: string
|
|
388
|
+
}) {
|
|
389
|
+
return (
|
|
390
|
+
<div
|
|
391
|
+
data-slot="sidebar-user"
|
|
392
|
+
className={cn("flex items-center gap-2.5 px-2 py-1.5", className)}
|
|
393
|
+
>
|
|
394
|
+
<Avatar name={name} src={avatarSrc} background={avatarBackground} />
|
|
395
|
+
<div className="flex flex-col gap-0.5 flex-1 min-w-0">
|
|
396
|
+
<span className="text-body-sm text-[var(--color-text-default)] truncate">{name}</span>
|
|
397
|
+
{role && <span className="text-caption-light text-[var(--color-text-muted)] truncate">{role}</span>}
|
|
398
|
+
</div>
|
|
399
|
+
{action}
|
|
400
|
+
</div>
|
|
401
|
+
)
|
|
402
|
+
}
|
|
403
|
+
|
|
371
404
|
function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
372
405
|
return (
|
|
373
406
|
<div
|
|
@@ -722,5 +755,6 @@ export {
|
|
|
722
755
|
SidebarRail,
|
|
723
756
|
SidebarSeparator,
|
|
724
757
|
SidebarTrigger,
|
|
758
|
+
SidebarUser,
|
|
725
759
|
useSidebar,
|
|
726
760
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { usePlatform } from "./hooks/use-platform"
|
|
|
6
6
|
|
|
7
7
|
// Components
|
|
8
8
|
export * from "./components/ui/alert"
|
|
9
|
+
export * from "./components/ui/avatar"
|
|
9
10
|
export * from "./components/ui/badge"
|
|
10
11
|
export * from "./components/ui/breadcrumb"
|
|
11
12
|
export * from "./components/ui/calendar"
|