@limetry/ui 1.2.70 → 1.2.77
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": "@limetry/ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.77",
|
|
4
4
|
"description": "Shared design system for Limetry — components, icons, and design tokens.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"import": "./src/components/site-header.web.tsx",
|
|
29
29
|
"default": "./src/components/site-header.web.tsx"
|
|
30
30
|
},
|
|
31
|
+
"./site-footer-links": {
|
|
32
|
+
"types": "./src/lib/site-footer-links.ts",
|
|
33
|
+
"import": "./src/lib/site-footer-links.ts",
|
|
34
|
+
"default": "./src/lib/site-footer-links.ts"
|
|
35
|
+
},
|
|
31
36
|
"./theme-toggle": {
|
|
32
37
|
"types": "./src/components/theme-toggle.web.tsx",
|
|
33
38
|
"react-native": "./src/components/theme-toggle.tsx",
|
|
@@ -46,10 +51,7 @@
|
|
|
46
51
|
"scripts": {
|
|
47
52
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean --out-dir dist",
|
|
48
53
|
"typecheck": "yarn run -T tsgo -p tsconfig.json --noEmit",
|
|
49
|
-
"test": "vitest run"
|
|
50
|
-
"prepack": "node ../../scripts/rewrite-workspace-protocol.mjs prepare",
|
|
51
|
-
"postpack": "node ../../scripts/rewrite-workspace-protocol.mjs restore-after-pack",
|
|
52
|
-
"postpublish": "node ../../scripts/rewrite-workspace-protocol.mjs restore"
|
|
54
|
+
"test": "vitest run"
|
|
53
55
|
},
|
|
54
56
|
"publishConfig": {
|
|
55
57
|
"access": "public",
|
|
@@ -44,4 +44,9 @@ export type SiteHeaderProps = {
|
|
|
44
44
|
drawerClassName?: string
|
|
45
45
|
/** Offset between the header and the drawer. */
|
|
46
46
|
topOffset?: number
|
|
47
|
+
/**
|
|
48
|
+
* When true, use translucent glass chrome and hide the sticky header while
|
|
49
|
+
* scrolling down; show it again immediately when scrolling up.
|
|
50
|
+
*/
|
|
51
|
+
scrollHide?: boolean
|
|
47
52
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { ComponentType, JSX } from "react"
|
|
8
|
-
import { useCallback, useEffect, useMemo, useState } from "react"
|
|
8
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
9
9
|
|
|
10
10
|
import { cn } from "../lib/cn"
|
|
11
11
|
import { isNavItemActive } from "../navigation/types"
|
|
@@ -83,8 +83,11 @@ export function SiteHeader({
|
|
|
83
83
|
className,
|
|
84
84
|
drawerClassName,
|
|
85
85
|
topOffset = 64,
|
|
86
|
+
scrollHide = false,
|
|
86
87
|
}: SiteHeaderProps): JSX.Element {
|
|
87
88
|
const [internalMenuOpen, setInternalMenuOpen] = useState(false)
|
|
89
|
+
const [scrollHidden, setScrollHidden] = useState(false)
|
|
90
|
+
const lastScrollY = useRef(0)
|
|
88
91
|
const menuOpen = controlledMenuOpen ?? internalMenuOpen
|
|
89
92
|
const setMenuOpen = useCallback(
|
|
90
93
|
(open: boolean): void => {
|
|
@@ -114,11 +117,62 @@ export function SiteHeader({
|
|
|
114
117
|
onMenuOpenChange?.(false)
|
|
115
118
|
}, [pathname, onMenuOpenChange])
|
|
116
119
|
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (!scrollHide) {
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const host = globalThis as {
|
|
126
|
+
scrollY?: number
|
|
127
|
+
addEventListener?: (type: string, listener: () => void, options?: { passive?: boolean }) => void
|
|
128
|
+
removeEventListener?: (type: string, listener: () => void) => void
|
|
129
|
+
queueMicrotask?: (callback: () => void) => void
|
|
130
|
+
}
|
|
131
|
+
if (typeof host.addEventListener !== "function" || typeof host.removeEventListener !== "function") {
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
lastScrollY.current = typeof host.scrollY === "number" ? host.scrollY : 0
|
|
136
|
+
|
|
137
|
+
const onScroll = (): void => {
|
|
138
|
+
const y = typeof host.scrollY === "number" ? host.scrollY : 0
|
|
139
|
+
const previous = lastScrollY.current
|
|
140
|
+
if (y > previous + 4 && y > 64) {
|
|
141
|
+
setScrollHidden(true)
|
|
142
|
+
} else if (y < previous - 2) {
|
|
143
|
+
setScrollHidden(false)
|
|
144
|
+
}
|
|
145
|
+
lastScrollY.current = y
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
host.addEventListener("scroll", onScroll, { passive: true })
|
|
149
|
+
return () => {
|
|
150
|
+
host.removeEventListener?.("scroll", onScroll)
|
|
151
|
+
}
|
|
152
|
+
}, [scrollHide])
|
|
153
|
+
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (!scrollHide || !menuOpen) {
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
const schedule = (globalThis as { queueMicrotask?: (callback: () => void) => void }).queueMicrotask
|
|
159
|
+
?? ((callback: () => void) => {
|
|
160
|
+
setTimeout(callback, 0)
|
|
161
|
+
})
|
|
162
|
+
schedule(() => {
|
|
163
|
+
setScrollHidden(false)
|
|
164
|
+
})
|
|
165
|
+
}, [menuOpen, scrollHide])
|
|
166
|
+
|
|
117
167
|
return (
|
|
118
168
|
<>
|
|
119
169
|
<header
|
|
120
170
|
className={cn(
|
|
121
|
-
"sticky top-0 z-50 border-b
|
|
171
|
+
"sticky top-0 z-50 w-full border-b transition-transform duration-200 ease-out will-change-transform",
|
|
172
|
+
scrollHide
|
|
173
|
+
? "border-border/40 bg-background/55 backdrop-blur-xl supports-[backdrop-filter]:bg-background/45"
|
|
174
|
+
: "border-border/60 bg-background/95 backdrop-blur-xl",
|
|
175
|
+
scrollHide && scrollHidden && !menuOpen ? "-translate-y-full" : "translate-y-0",
|
|
122
176
|
className,
|
|
123
177
|
)}
|
|
124
178
|
>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest"
|
|
2
|
+
|
|
3
|
+
import { buildSiteFooterLinks } from "./site-footer-links"
|
|
4
|
+
|
|
5
|
+
describe("buildSiteFooterLinks", () => {
|
|
6
|
+
it("uses relative OSS paths on the OSS marketing site", () => {
|
|
7
|
+
const links = buildSiteFooterLinks({
|
|
8
|
+
ossWebOrigin: "https://limetry.org",
|
|
9
|
+
cloudAppOrigin: "https://app.limetry.com",
|
|
10
|
+
openApiHref: "https://api.limetry.org/openapi",
|
|
11
|
+
githubUrl: "https://github.com/limetry/limetry",
|
|
12
|
+
includeCloudLink: true,
|
|
13
|
+
ossLinksRelative: true,
|
|
14
|
+
})
|
|
15
|
+
expect(links.product[0]?.href).toBe("/docs/introduction")
|
|
16
|
+
expect(links.opensource.find((l) => l.label === "Changelog")?.href).toBe("/changelog")
|
|
17
|
+
expect(links.legal.privacy.href).toBe("/privacy")
|
|
18
|
+
expect(links.legal.terms.href).toBe("/terms")
|
|
19
|
+
expect(links.product.find((l) => l.label === "Limetry Cloud")?.href).toBe(
|
|
20
|
+
"https://app.limetry.com",
|
|
21
|
+
)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it("points Cloud and API surfaces at absolute OSS destinations", () => {
|
|
25
|
+
const links = buildSiteFooterLinks({
|
|
26
|
+
ossWebOrigin: "http://localhost:3800",
|
|
27
|
+
cloudAppOrigin: "http://localhost:3830",
|
|
28
|
+
openApiHref: "/openapi",
|
|
29
|
+
githubUrl: "https://github.com/limetry/sdk",
|
|
30
|
+
includeCloudLink: true,
|
|
31
|
+
ossLinksRelative: false,
|
|
32
|
+
})
|
|
33
|
+
expect(links.opensource.find((l) => l.label === "Blog")?.href).toBe("http://localhost:3800/blog")
|
|
34
|
+
expect(links.legal.privacy.href).toBe("http://localhost:3800/privacy")
|
|
35
|
+
expect(links.docs.find((l) => l.label === "Swagger UI")?.href).toBe("/openapi")
|
|
36
|
+
expect(links.docs.find((l) => l.label === "Swagger UI")?.external).toBeUndefined()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it("omits Limetry Cloud when includeCloudLink is false", () => {
|
|
40
|
+
const links = buildSiteFooterLinks({
|
|
41
|
+
ossWebOrigin: "https://limetry.org",
|
|
42
|
+
cloudAppOrigin: "https://app.limetry.com",
|
|
43
|
+
openApiHref: "/openapi",
|
|
44
|
+
githubUrl: "https://github.com/limetry/limetry",
|
|
45
|
+
includeCloudLink: false,
|
|
46
|
+
ossLinksRelative: true,
|
|
47
|
+
})
|
|
48
|
+
expect(links.product.find((l) => l.label === "Limetry Cloud")).toBeUndefined()
|
|
49
|
+
})
|
|
50
|
+
})
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical site footer link columns shared by Limetry web and API landings.
|
|
3
|
+
*
|
|
4
|
+
* OSS marketing pages (docs, community, blog, changelog, privacy, terms) always
|
|
5
|
+
* resolve to the OSS web origin. OpenAPI points at the caller's API surface.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* One footer destination.
|
|
10
|
+
*/
|
|
11
|
+
export type SiteFooterLink = {
|
|
12
|
+
href: string
|
|
13
|
+
label: string
|
|
14
|
+
/**
|
|
15
|
+
* When true, open in a new tab (third-party or cross-product origins).
|
|
16
|
+
*/
|
|
17
|
+
external?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Inputs for {@link buildSiteFooterLinks}.
|
|
22
|
+
*/
|
|
23
|
+
export type BuildSiteFooterLinksInput = {
|
|
24
|
+
/**
|
|
25
|
+
* Authoritative OSS marketing origin (`https://limetry.org` or local `:3800`).
|
|
26
|
+
*/
|
|
27
|
+
ossWebOrigin: string
|
|
28
|
+
/**
|
|
29
|
+
* Cloud portal / app origin for the Limetry Cloud product link.
|
|
30
|
+
*/
|
|
31
|
+
cloudAppOrigin: string
|
|
32
|
+
/**
|
|
33
|
+
* This surface's OpenAPI / Swagger UI href (may be same-origin `/openapi`).
|
|
34
|
+
*/
|
|
35
|
+
openApiHref: string
|
|
36
|
+
/**
|
|
37
|
+
* Public GitHub repository URL.
|
|
38
|
+
*/
|
|
39
|
+
githubUrl: string
|
|
40
|
+
/**
|
|
41
|
+
* When true, include the Limetry Cloud product link.
|
|
42
|
+
*/
|
|
43
|
+
includeCloudLink?: boolean
|
|
44
|
+
/**
|
|
45
|
+
* When true, OSS destinations use path-only hrefs (caller is the OSS site).
|
|
46
|
+
*/
|
|
47
|
+
ossLinksRelative?: boolean
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Footer column groups plus legal bar destinations.
|
|
52
|
+
*/
|
|
53
|
+
export type SiteFooterLinks = {
|
|
54
|
+
product: SiteFooterLink[]
|
|
55
|
+
opensource: SiteFooterLink[]
|
|
56
|
+
docs: SiteFooterLink[]
|
|
57
|
+
legal: {
|
|
58
|
+
privacy: SiteFooterLink
|
|
59
|
+
terms: SiteFooterLink
|
|
60
|
+
}
|
|
61
|
+
blurb: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Trims a trailing slash from an origin or URL.
|
|
66
|
+
*
|
|
67
|
+
* @param value - Origin or absolute URL.
|
|
68
|
+
* @returns Value without a trailing `/`.
|
|
69
|
+
*/
|
|
70
|
+
function trimOrigin(value: string): string {
|
|
71
|
+
return value.trim().replace(/\/$/, "")
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Builds an OSS marketing href (relative on the OSS site, absolute elsewhere).
|
|
76
|
+
*
|
|
77
|
+
* @param path - Absolute path beginning with `/`.
|
|
78
|
+
* @param input - Footer build inputs.
|
|
79
|
+
* @returns Href and whether it should open externally.
|
|
80
|
+
*/
|
|
81
|
+
function ossHref(
|
|
82
|
+
path: string,
|
|
83
|
+
input: BuildSiteFooterLinksInput,
|
|
84
|
+
): Pick<SiteFooterLink, "href" | "external"> {
|
|
85
|
+
if (input.ossLinksRelative) {
|
|
86
|
+
return { href: path }
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
href: `${trimOrigin(input.ossWebOrigin)}${path}`,
|
|
90
|
+
external: true,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* True when `href` is an absolute `http(s)` URL.
|
|
96
|
+
*
|
|
97
|
+
* @param href - Link destination.
|
|
98
|
+
* @returns Whether the href leaves the current document origin as an absolute URL.
|
|
99
|
+
*/
|
|
100
|
+
function isAbsoluteHttp(href: string): boolean {
|
|
101
|
+
return /^https?:\/\//i.test(href)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Builds the shared Product / Open Source / Docs / legal footer destinations.
|
|
106
|
+
*
|
|
107
|
+
* @param input - Origins and OpenAPI target for the current frontend.
|
|
108
|
+
* @returns Column link lists and legal bar links.
|
|
109
|
+
*/
|
|
110
|
+
export function buildSiteFooterLinks(input: BuildSiteFooterLinksInput): SiteFooterLinks {
|
|
111
|
+
const openApiExternal = isAbsoluteHttp(input.openApiHref)
|
|
112
|
+
const cloudApp = trimOrigin(input.cloudAppOrigin)
|
|
113
|
+
const github = trimOrigin(input.githubUrl)
|
|
114
|
+
|
|
115
|
+
const product: SiteFooterLink[] = [
|
|
116
|
+
{ label: "Docs", ...ossHref("/docs/introduction", input) },
|
|
117
|
+
{ label: "Examples", ...ossHref("/examples", input) },
|
|
118
|
+
{ label: "Quick start", ...ossHref("/docs/quick-start", input) },
|
|
119
|
+
]
|
|
120
|
+
if (input.includeCloudLink) {
|
|
121
|
+
product.push({
|
|
122
|
+
href: cloudApp,
|
|
123
|
+
label: "Limetry Cloud",
|
|
124
|
+
external: true,
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
product.push({
|
|
128
|
+
href: input.openApiHref,
|
|
129
|
+
label: "OpenAPI",
|
|
130
|
+
...(openApiExternal ? { external: true } : {}),
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
product,
|
|
135
|
+
opensource: [
|
|
136
|
+
{ href: github, label: "GitHub", external: true },
|
|
137
|
+
{ label: "Community", ...ossHref("/community", input) },
|
|
138
|
+
{ label: "Blog", ...ossHref("/blog", input) },
|
|
139
|
+
{ label: "Changelog", ...ossHref("/changelog", input) },
|
|
140
|
+
],
|
|
141
|
+
docs: [
|
|
142
|
+
{ label: "Quick Start", ...ossHref("/docs/quick-start", input) },
|
|
143
|
+
{ label: "SDK Reference", ...ossHref("/docs/sdk", input) },
|
|
144
|
+
{ label: "Deploy", ...ossHref("/docs/server/self-hosting", input) },
|
|
145
|
+
{
|
|
146
|
+
href: input.openApiHref,
|
|
147
|
+
label: "Swagger UI",
|
|
148
|
+
...(openApiExternal ? { external: true } : {}),
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
legal: {
|
|
152
|
+
privacy: { label: "Privacy", ...ossHref("/privacy", input) },
|
|
153
|
+
terms: { label: "Terms", ...ossHref("/terms", input) },
|
|
154
|
+
},
|
|
155
|
+
blurb:
|
|
156
|
+
"Agent action governance — evaluate, allow, deny, and audit tool calls before they land.",
|
|
157
|
+
}
|
|
158
|
+
}
|