Open History to see the last commit
1import { splitProps } from 'solid-js'
2import type { ComponentProps } from 'solid-js'
3import { cn } from '@/utils'
4β
5function getLabel(
6 adapterName: string | undefined,
7 libraryName: string | undefined,
8 majorVersion: number | undefined,
9) {
10 let label = `${adapterName} ${libraryName}`
11 if (typeof majorVersion === 'number') {
12 label += ` v${majorVersion}`
13 }
14 return label.trim()
15}
16β
17interface LibraryLogoProps extends ComponentProps<'a'> {
18 brandColor: string
19 href: string
20 libraryName: string
21 adapter?: string
22 majorVersion?: number
23}
24β
25/**
26 * A TanStack library logo link with adapter, library, and version labeling.
27 *
28 * @example
29 * ```tsx
30 * <LibraryLogo
31 * href="https://tanstack.com/form"
32 * libraryName="Form"
33 * adapter="Solid"
34 * brandColor="#8b5cf6"
35 * />
36 * ```
37 */
38export function LibraryLogo(props: LibraryLogoProps) {
39 const [local, other] = splitProps(props, [
40 'adapter',
41 'majorVersion',
42 'libraryName',
43 'brandColor',
44 'class',
45 ])
46β
47 return (
48 <a
49 class={cn(
50 'flex flex-col items-center gap-0.5 focus-visible:rounded-sm focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring',
51 local.class,
52 )}
53 target="_blank"
54 {...other}
55 >
56 <span class="text-base leading-none font-bold whitespace-nowrap text-foreground">
57 TANSTACK
58 </span>
59 <span
60 class="text-sm leading-none font-semibold whitespace-nowrap"
61 style={{
62 color: local.brandColor,
63 }}
64 >
65 {getLabel(local.adapter, local.libraryName, local.majorVersion)}
66 </span>
67 </a>
68 )
69}