@orsetra/shared-ui 1.11.5 → 1.11.8
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.
|
@@ -28,7 +28,7 @@ export function EnvironmentSwitcher({ createHref }: EnvironmentSwitcherProps) {
|
|
|
28
28
|
disabled={status === "loading"}
|
|
29
29
|
title="Change environment"
|
|
30
30
|
aria-haspopup="dialog"
|
|
31
|
-
className="h-8
|
|
31
|
+
className="h-8 w-40 flex-shrink-0 ml-2 flex items-center justify-between gap-1.5 px-2.5 bg-gray-200/70 text-gray-600 hover:bg-gray-200 hover:text-gray-900 transition-colors disabled:cursor-default"
|
|
32
32
|
>
|
|
33
33
|
{label ? (
|
|
34
34
|
<span className="truncate text-xs font-medium uppercase tracking-wider">{label}</span>
|
|
@@ -3,40 +3,27 @@
|
|
|
3
3
|
import { useEffect, useRef } from "react"
|
|
4
4
|
import { usePathname } from "next/navigation"
|
|
5
5
|
import { useQuickAccess } from "../../../hooks/use-quick-access"
|
|
6
|
+
import { quickAccessHref } from "../../../lib/quick-access-href"
|
|
6
7
|
|
|
7
8
|
interface QuickAccessTrackerProps {
|
|
8
|
-
/** Human-readable label shown in the quick-access list */
|
|
9
9
|
label: string
|
|
10
|
-
/** Icon name (resolved via resolveIcon). Defaults to "Box". */
|
|
11
10
|
icon?: string
|
|
12
|
-
/** Set to false to skip tracking this page (e.g. list/index pages) */
|
|
13
11
|
enabled?: boolean
|
|
14
|
-
/**
|
|
15
|
-
* Canonical href for this resource — overrides the current page URL.
|
|
16
|
-
* Pass the resource root (e.g. "/my-app") so that visiting any tab of
|
|
17
|
-
* the same resource tracks a single entry instead of one per tab.
|
|
18
|
-
* Absolute URL or path relative to the current origin.
|
|
19
|
-
*/
|
|
20
12
|
href?: string
|
|
21
13
|
}
|
|
22
14
|
|
|
23
|
-
/**
|
|
24
|
-
* Drop this inside any page or layout to register that page in the
|
|
25
|
-
* sidebar's quick-access list. Tracks on mount and whenever pathname changes.
|
|
26
|
-
* Renders nothing.
|
|
27
|
-
*/
|
|
28
15
|
export function QuickAccessTracker({ label, icon, enabled = true, href: hrefProp }: QuickAccessTrackerProps) {
|
|
29
16
|
const pathname = usePathname()
|
|
30
17
|
const { addItem } = useQuickAccess()
|
|
31
|
-
// Stable ref so the effect doesn't re-run when addItem reference changes
|
|
32
18
|
const addRef = useRef(addItem)
|
|
33
19
|
addRef.current = addItem
|
|
34
20
|
|
|
35
21
|
useEffect(() => {
|
|
36
22
|
if (!enabled || !label || !pathname) return
|
|
37
|
-
const href =
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
const href = quickAccessHref(
|
|
24
|
+
{ origin: window.location.origin, locationPath: window.location.pathname, routerPath: pathname },
|
|
25
|
+
hrefProp,
|
|
26
|
+
)
|
|
40
27
|
addRef.current({ label, href, icon })
|
|
41
28
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
29
|
}, [pathname, label, icon, enabled, hrefProp])
|
package/components/ui/logo.tsx
CHANGED
|
@@ -26,7 +26,7 @@ const MonogramIcon = ({ className }: { className?: string }) => (
|
|
|
26
26
|
const Wordmark = ({ className }: { className?: string }) => (
|
|
27
27
|
<svg
|
|
28
28
|
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
-
viewBox="0 0
|
|
29
|
+
viewBox="0 0 125.37 32"
|
|
30
30
|
className={cn("inline-block flex-shrink-0", className)}
|
|
31
31
|
style={{ height: "1.15em", width: "auto" }}
|
|
32
32
|
role="img"
|
|
@@ -35,8 +35,8 @@ const Wordmark = ({ className }: { className?: string }) => (
|
|
|
35
35
|
<polygon fill="#161616" points="0,5 3.67,5 9.17,16 3.67,27 0,27 5.5,16" />
|
|
36
36
|
<polygon fill="#161616" points="24.75,5 21.08,5 15.58,16 21.08,27 24.75,27 19.25,16" />
|
|
37
37
|
<rect fill="#0F62FE" x="10.08" y="13.71" width="4.58" height="4.58" />
|
|
38
|
-
<path fill="#161616" d="M41.52 23.94Q40 23.94 38.78 23.45Q37.56 22.95 36.69 21.96Q35.82 20.97 35.36 19.51Q34.89 18.05 34.89 16.11Q34.89 14.17 35.36 12.67Q35.82 11.16 36.69 10.14Q37.56 9.11 38.78 8.59Q40 8.06 41.52 8.06Q43.58 8.06 44.95 8.94Q46.31 9.82 47.13 11.6L44.64 12.92Q44.31 11.89 43.56 11.26Q42.81 10.63 41.52 10.63Q39.89 10.63 38.93 11.73Q37.97 12.83 37.97 14.81V17.23Q37.97 19.23 38.93 20.3Q39.89 21.37 41.52 21.37Q42.81 21.37 43.64 20.66Q44.46 19.96 44.84 18.93L47.19 20.31Q46.36 22.03 44.97 22.98Q43.58 23.94 41.52 23.94Z
|
|
39
|
-
<path fill="#0F62FE" d="
|
|
38
|
+
<path fill="#161616" d="M41.52 23.94Q40 23.94 38.78 23.45Q37.56 22.95 36.69 21.96Q35.82 20.97 35.36 19.51Q34.89 18.05 34.89 16.11Q34.89 14.17 35.36 12.67Q35.82 11.16 36.69 10.14Q37.56 9.11 38.78 8.59Q40 8.06 41.52 8.06Q43.58 8.06 44.95 8.94Q46.31 9.82 47.13 11.6L44.64 12.92Q44.31 11.89 43.56 11.26Q42.81 10.63 41.52 10.63Q39.89 10.63 38.93 11.73Q37.97 12.83 37.97 14.81V17.23Q37.97 19.23 38.93 20.3Q39.89 21.37 41.52 21.37Q42.81 21.37 43.64 20.66Q44.46 19.96 44.84 18.93L47.19 20.31Q46.36 22.03 44.97 22.98Q43.58 23.94 41.52 23.94Z M59.18 23.68 57.95 19.76H52.49L51.28 23.68H48.34L53.48 8.32H57.09L62.2 23.68ZM55.27 10.96H55.16L53.2 17.28H57.25Z M76.06 12.66H75.97L74.78 15.1L71.63 20.91L68.49 15.1L67.3 12.66H67.21V23.68H64.46V8.32H67.74L71.68 15.82H71.77L75.66 8.32H78.81V23.68H76.06Z M82.41 23.68V8.32H92.53V10.9H85.32V14.61H91.7V17.19H85.32V21.1H92.53V23.68Z M95.61 23.68V8.32H98.52V21.1H104.57V23.68Z" />
|
|
39
|
+
<path fill="#0F62FE" d="M124.48 23.68H121.09L117.57 17.78H117.5L114.03 23.68H110.86L115.83 15.8L111.08 8.32H114.47L117.72 13.78H117.79L121.09 8.32H124.26L119.46 15.8Z" />
|
|
40
40
|
</svg>
|
|
41
41
|
)
|
|
42
42
|
|
package/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './lib/config-selection'
|
|
|
7
7
|
export * from './lib/environment-context'
|
|
8
8
|
export * from './lib/environment-controller'
|
|
9
9
|
export * from './lib/project-requirement'
|
|
10
|
+
export * from './lib/quick-access-href'
|
|
10
11
|
export * from './lib/status-indicator'
|
|
11
12
|
export { createPlatformConfigSource, templateFilter, configOfHit, environmentWithTargets, type ConfigSource } from './lib/config-source'
|
|
12
13
|
export { default as HttpClient, useHttpClient, ApiError } from './lib/http-client'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface QuickAccessLocation {
|
|
2
|
+
origin: string
|
|
3
|
+
locationPath: string
|
|
4
|
+
routerPath: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const withoutTrailingSlash = (path: string): string => path.replace(/\/+$/, "")
|
|
8
|
+
|
|
9
|
+
export function appBasePath({ locationPath, routerPath }: Pick<QuickAccessLocation, "locationPath" | "routerPath">): string {
|
|
10
|
+
const full = withoutTrailingSlash(locationPath)
|
|
11
|
+
const inner = withoutTrailingSlash(routerPath)
|
|
12
|
+
if (!inner) return full
|
|
13
|
+
return full.endsWith(inner) ? full.slice(0, full.length - inner.length) : ""
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function quickAccessHref(location: QuickAccessLocation, target?: string): string {
|
|
17
|
+
if (!target) return location.origin + location.locationPath
|
|
18
|
+
if (/^https?:\/\//i.test(target)) return target
|
|
19
|
+
const path = target.startsWith("/") ? target : `/${target}`
|
|
20
|
+
return location.origin + appBasePath(location) + path
|
|
21
|
+
}
|