@igstack/app-catalog-frontend-core 0.10.0 → 0.11.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.
Files changed (88) hide show
  1. package/dist/esm/__tests__/integration/harness/given.d.ts +1 -0
  2. package/dist/esm/__tests__/integration/skewWarning.integration.test.d.ts +0 -0
  3. package/dist/esm/__tests__/integration/tools/AppDetailTools.d.ts +5 -0
  4. package/dist/esm/__tests__/integration/tools/CatalogTools.d.ts +15 -1
  5. package/dist/esm/__tests__/modules/appCatalog/utils/resolveHelpers.test.d.ts +1 -0
  6. package/dist/esm/modules/appCatalog/hooks/useSessionSyncedState.d.ts +40 -0
  7. package/dist/esm/modules/appCatalog/hooks/useSessionSyncedState.js +40 -0
  8. package/dist/esm/modules/appCatalog/hooks/useSessionSyncedState.js.map +1 -0
  9. package/dist/esm/modules/appCatalog/ui/components/AccessPrerequisiteChain.d.ts +17 -0
  10. package/dist/esm/modules/appCatalog/ui/components/AccessPrerequisiteChain.js +61 -0
  11. package/dist/esm/modules/appCatalog/ui/components/AccessPrerequisiteChain.js.map +1 -0
  12. package/dist/esm/modules/appCatalog/ui/components/AccessRequestSection.js +9 -2
  13. package/dist/esm/modules/appCatalog/ui/components/AccessRequestSection.js.map +1 -1
  14. package/dist/esm/modules/appCatalog/ui/components/OnboardingCard.js +1 -1
  15. package/dist/esm/modules/appCatalog/ui/components/OnboardingCard.js.map +1 -1
  16. package/dist/esm/modules/appCatalog/ui/components/SubResourcesSection.d.ts +9 -1
  17. package/dist/esm/modules/appCatalog/ui/components/SubResourcesSection.js +12 -3
  18. package/dist/esm/modules/appCatalog/ui/components/SubResourcesSection.js.map +1 -1
  19. package/dist/esm/modules/appCatalog/ui/context/AppCatalogFiltersContext.js +3 -2
  20. package/dist/esm/modules/appCatalog/ui/context/AppCatalogFiltersContext.js.map +1 -1
  21. package/dist/esm/modules/appCatalog/ui/grid/AppCatalogGrid.d.ts +5 -0
  22. package/dist/esm/modules/appCatalog/ui/grid/AppCatalogGrid.js +56 -10
  23. package/dist/esm/modules/appCatalog/ui/grid/AppCatalogGrid.js.map +1 -1
  24. package/dist/esm/modules/appCatalog/ui/launcher/LauncherDetailPanel.d.ts +12 -0
  25. package/dist/esm/modules/appCatalog/ui/launcher/LauncherDetailPanel.js +48 -0
  26. package/dist/esm/modules/appCatalog/ui/launcher/LauncherDetailPanel.js.map +1 -0
  27. package/dist/esm/modules/appCatalog/ui/launcher/LauncherHome.d.ts +19 -0
  28. package/dist/esm/modules/appCatalog/ui/launcher/LauncherHome.js +355 -0
  29. package/dist/esm/modules/appCatalog/ui/launcher/LauncherHome.js.map +1 -0
  30. package/dist/esm/modules/appCatalog/ui/launcher/ResourceIcon.d.ts +13 -0
  31. package/dist/esm/modules/appCatalog/ui/launcher/ResourceIcon.js +45 -0
  32. package/dist/esm/modules/appCatalog/ui/launcher/ResourceIcon.js.map +1 -0
  33. package/dist/esm/modules/appCatalog/ui/launcher/monogram.d.ts +4 -0
  34. package/dist/esm/modules/appCatalog/ui/launcher/monogram.js +41 -0
  35. package/dist/esm/modules/appCatalog/ui/launcher/monogram.js.map +1 -0
  36. package/dist/esm/modules/appCatalog/ui/pages/AppCatalogPage.js +40 -6
  37. package/dist/esm/modules/appCatalog/ui/pages/AppCatalogPage.js.map +1 -1
  38. package/dist/esm/modules/appCatalog/utils/markdownToPlainText.d.ts +1 -1
  39. package/dist/esm/modules/appCatalog/utils/markdownToPlainText.js.map +1 -1
  40. package/dist/esm/modules/appCatalog/utils/resolveHelpers.d.ts +10 -0
  41. package/dist/esm/modules/appCatalog/utils/resolveHelpers.js +17 -0
  42. package/dist/esm/modules/appCatalog/utils/resolveHelpers.js.map +1 -1
  43. package/dist/esm/routeTree.gen.d.ts +1 -1
  44. package/dist/esm/routes/_layout/app.$slug.d.ts +1 -1
  45. package/dist/esm/routes/_layout/app._slug.js +4 -3
  46. package/dist/esm/routes/_layout/app._slug.js.map +1 -1
  47. package/dist/esm/routes/_layout/catalog.apps.index.js +2 -1
  48. package/dist/esm/routes/_layout/catalog.apps.index.js.map +1 -1
  49. package/dist/esm/routes/_layout/index.js +2 -1
  50. package/dist/esm/routes/_layout/index.js.map +1 -1
  51. package/dist/esm/routes/_layout/service-desks.js +2 -1
  52. package/dist/esm/routes/_layout/service-desks.js.map +1 -1
  53. package/dist/esm/ui/components/header/Header.js +1 -1
  54. package/dist/esm/ui/components/header/Header.js.map +1 -1
  55. package/dist/index.css +73 -66
  56. package/package.json +4 -4
  57. package/src/__tests__/integration/appCatalog.integration.test.ts +106 -0
  58. package/src/__tests__/integration/appDeepLink.integration.test.ts +50 -24
  59. package/src/__tests__/integration/crossRefLinkListView.integration.test.ts +8 -8
  60. package/src/__tests__/integration/harness/given.tsx +9 -1
  61. package/src/__tests__/integration/replacementLink.integration.test.ts +6 -2
  62. package/src/__tests__/integration/searchDeprecatedFallback.integration.test.ts +21 -16
  63. package/src/__tests__/integration/setup/testSetup.ts +1 -0
  64. package/src/__tests__/integration/skewWarning.integration.test.ts +56 -0
  65. package/src/__tests__/integration/tools/AppDetailTools.ts +13 -0
  66. package/src/__tests__/integration/tools/CatalogTools.ts +60 -11
  67. package/src/__tests__/modules/appCatalog/utils/markdownToPlainText.test.ts +5 -5
  68. package/src/__tests__/modules/appCatalog/utils/resolveHelpers.test.ts +79 -0
  69. package/src/index.css +73 -66
  70. package/src/modules/appCatalog/hooks/useSessionSyncedState.ts +83 -0
  71. package/src/modules/appCatalog/ui/components/AccessPrerequisiteChain.tsx +89 -0
  72. package/src/modules/appCatalog/ui/components/AccessRequestSection.tsx +31 -2
  73. package/src/modules/appCatalog/ui/components/OnboardingCard.tsx +1 -1
  74. package/src/modules/appCatalog/ui/components/SubResourcesSection.tsx +22 -1
  75. package/src/modules/appCatalog/ui/context/AppCatalogFiltersContext.tsx +11 -5
  76. package/src/modules/appCatalog/ui/grid/AppCatalogGrid.tsx +68 -10
  77. package/src/modules/appCatalog/ui/launcher/LauncherDetailPanel.tsx +55 -0
  78. package/src/modules/appCatalog/ui/launcher/LauncherHome.tsx +497 -0
  79. package/src/modules/appCatalog/ui/launcher/ResourceIcon.tsx +54 -0
  80. package/src/modules/appCatalog/ui/launcher/monogram.ts +41 -0
  81. package/src/modules/appCatalog/ui/pages/AppCatalogPage.tsx +75 -13
  82. package/src/modules/appCatalog/utils/markdownToPlainText.ts +1 -1
  83. package/src/modules/appCatalog/utils/resolveHelpers.ts +31 -0
  84. package/src/routes/_layout/app.$slug.tsx +7 -4
  85. package/src/routes/_layout/catalog.apps.index.tsx +4 -1
  86. package/src/routes/_layout/index.tsx +5 -1
  87. package/src/routes/_layout/service-desks.tsx +4 -1
  88. package/src/ui/components/header/Header.tsx +3 -1
@@ -0,0 +1,497 @@
1
+ import type { Resource } from '@igstack/app-catalog-backend-core'
2
+ import { ArrowUpRight, Search } from 'lucide-react'
3
+ import { useEffect, useMemo, useRef, useState } from 'react'
4
+ import { cn } from '~/lib/utils'
5
+ import { useAppClickHistory } from '../../hooks/useAppClickHistory'
6
+ import { markdownToPlainText } from '../../utils/markdownToPlainText'
7
+ import { ResourceIcon } from './ResourceIcon'
8
+ import { searchResources } from '../../utils/searchApps'
9
+
10
+ /**
11
+ * Adaptive-home discovery spine (issue #38, increment 1) — matches the
12
+ * option-a-launcher prototype:
13
+ * Your apps (frequent) → New this week → Browse all
14
+ * Rendered by AppCatalogPage when there is no active search and no open detail.
15
+ * The hero search box drives the same `searchValue` used elsewhere; typing hands
16
+ * off to the results view (increment 2 refines the morph).
17
+ */
18
+
19
+ const typeLabel = (t?: string): string => {
20
+ if (!t || t === 'application') return 'App'
21
+ return t.charAt(0).toUpperCase() + t.slice(1)
22
+ }
23
+
24
+ export interface LauncherHomeProps {
25
+ /** All root (non-child) resources, already filtered for deprecated per settings. */
26
+ apps: Resource[]
27
+ /**
28
+ * All resources INCLUDING children/sub-resources. Passed to search so a query
29
+ * matching a sub-resource (e.g. an AWS account, an alias/account ID) surfaces
30
+ * its parent — preserving the existing cross-sub-resource search behavior.
31
+ * Falls back to `apps` when omitted.
32
+ */
33
+ allResources?: Resource[]
34
+ searchValue: string
35
+ onSearchChange: (v: string) => void
36
+ onAppClick: (app: Resource) => void
37
+ onLaunch: (app: Resource) => void
38
+ /** Total resource count for the "Browse all" label. */
39
+ totalCount: number
40
+ }
41
+
42
+ function LaunchButton({
43
+ app,
44
+ onLaunch,
45
+ className,
46
+ }: {
47
+ app: Resource
48
+ onLaunch: (app: Resource) => void
49
+ className?: string
50
+ }) {
51
+ if (!app.appUrl) return null
52
+ return (
53
+ <a
54
+ href={app.appUrl}
55
+ target="_blank"
56
+ rel="noopener noreferrer"
57
+ title={`Open ${app.displayName} in a new tab`}
58
+ aria-label={`Open ${app.displayName} in a new tab`}
59
+ onClick={(e) => {
60
+ e.stopPropagation()
61
+ onLaunch(app)
62
+ }}
63
+ className={cn(
64
+ 'grid place-items-center rounded-full border border-border bg-card text-muted-foreground',
65
+ 'hover:bg-primary hover:text-primary-foreground hover:border-primary transition-colors',
66
+ className,
67
+ )}
68
+ >
69
+ <ArrowUpRight className="size-3.5" />
70
+ </a>
71
+ )
72
+ }
73
+
74
+ function SectionHead({
75
+ title,
76
+ count,
77
+ action,
78
+ }: {
79
+ title: string
80
+ count?: string
81
+ action?: React.ReactNode
82
+ }) {
83
+ return (
84
+ <div className="flex items-center gap-2.5 mb-4">
85
+ <h2 className="font-serif font-semibold text-[15px] tracking-tight m-0">
86
+ {title}
87
+ </h2>
88
+ {count && (
89
+ <span className="text-[13px] text-muted-foreground bg-muted rounded-full px-2.5 py-0.5">
90
+ {count}
91
+ </span>
92
+ )}
93
+ {action && <div className="ml-auto">{action}</div>}
94
+ </div>
95
+ )
96
+ }
97
+
98
+ /** Small row used by "New this week" and "Browse all". */
99
+ function ResourceRow({
100
+ app,
101
+ onAppClick,
102
+ onLaunch,
103
+ showNew = false,
104
+ }: {
105
+ app: Resource
106
+ onAppClick: (app: Resource) => void
107
+ onLaunch: (app: Resource) => void
108
+ showNew?: boolean
109
+ }) {
110
+ return (
111
+ <button
112
+ type="button"
113
+ onClick={() => onAppClick(app)}
114
+ title={`View ${app.displayName}`}
115
+ className={cn(
116
+ 'group flex items-center gap-3.5 w-full text-left',
117
+ 'bg-card border border-border rounded-[var(--radius)] px-3.5 py-3',
118
+ 'hover:border-ring hover:shadow-sm transition-all',
119
+ )}
120
+ >
121
+ <ResourceIcon app={app} size={38} />
122
+ <span className="flex-1 min-w-0">
123
+ <span className="block text-[14.5px] font-semibold truncate">
124
+ {app.displayName}
125
+ </span>
126
+ {app.description && (
127
+ <span className="block text-[13px] text-muted-foreground truncate">
128
+ {markdownToPlainText(app.description)}
129
+ </span>
130
+ )}
131
+ </span>
132
+ {showNew && (
133
+ <span className="text-[11px] font-bold text-[#65a443] bg-[#65a443]/12 rounded-full px-2.5 py-0.5">
134
+ New
135
+ </span>
136
+ )}
137
+ <span className="text-[12px] text-muted-foreground bg-muted rounded-full px-2.5 py-0.5 whitespace-nowrap">
138
+ {typeLabel(app.type)}
139
+ </span>
140
+ <LaunchButton app={app} onLaunch={onLaunch} className="size-8" />
141
+ </button>
142
+ )
143
+ }
144
+
145
+ /**
146
+ * Keyboard-navigable search results list — increment 2 of the launcher redesign.
147
+ * Appears below the hero search box when the user types, replacing the
148
+ * discovery spine. Pressing ↑↓ navigates, ↵ opens detail, Esc clears.
149
+ */
150
+ function SearchResultsList({
151
+ apps,
152
+ searchValue,
153
+ onAppClick,
154
+ onLaunch,
155
+ onClear,
156
+ }: {
157
+ apps: Resource[]
158
+ searchValue: string
159
+ onAppClick: (app: Resource) => void
160
+ onLaunch: (app: Resource) => void
161
+ onClear: () => void
162
+ }) {
163
+ const [focusedIndex, setFocusedIndex] = useState(-1)
164
+
165
+ const results = useMemo(
166
+ () => searchResources(apps, searchValue),
167
+ [apps, searchValue],
168
+ )
169
+
170
+ // #11 deprecated fallback: when EVERY match is a deprecated app (i.e. there
171
+ // are no active matches for the query, only deprecated ones), surface a
172
+ // notice so the user understands why they're seeing archived tools. The
173
+ // deprecated apps are already in `results` because the launcher feeds search
174
+ // the full resource set; this just labels the situation.
175
+ const didDeprecatedFallback = useMemo(
176
+ () => results.length > 0 && results.every((r) => Boolean(r.deprecated)),
177
+ [results],
178
+ )
179
+
180
+ // Reset focus when results change
181
+ useEffect(() => {
182
+ setFocusedIndex(-1)
183
+ }, [searchValue])
184
+
185
+ useEffect(() => {
186
+ const onKey = (e: KeyboardEvent) => {
187
+ if (results.length === 0) return
188
+ if (e.key === 'ArrowDown') {
189
+ e.preventDefault()
190
+ setFocusedIndex((i) => Math.min(i + 1, results.length - 1))
191
+ } else if (e.key === 'ArrowUp') {
192
+ e.preventDefault()
193
+ setFocusedIndex((i) => Math.max(i - 1, 0))
194
+ } else if (e.key === 'Enter') {
195
+ if (focusedIndex >= 0 && results[focusedIndex]) {
196
+ onAppClick(results[focusedIndex])
197
+ }
198
+ } else if (e.key === 'Escape') {
199
+ onClear()
200
+ }
201
+ }
202
+ document.addEventListener('keydown', onKey)
203
+ return () => document.removeEventListener('keydown', onKey)
204
+ }, [results, focusedIndex, onAppClick, onClear])
205
+
206
+ return (
207
+ <div className="max-w-[620px] mx-auto mt-3">
208
+ {/* Meta line */}
209
+ <div className="text-[13px] text-muted-foreground mb-2 px-1">
210
+ {results.length === 0
211
+ ? `No results for "${searchValue}"`
212
+ : `${results.length} result${results.length === 1 ? '' : 's'}`}
213
+ </div>
214
+
215
+ {/* #11: deprecated-only fallback notice */}
216
+ {didDeprecatedFallback && (
217
+ <div
218
+ role="status"
219
+ className="text-[13px] text-muted-foreground mb-2 px-1"
220
+ >
221
+ No active apps for &quot;{searchValue}&quot; — showing deprecated
222
+ matches.
223
+ </div>
224
+ )}
225
+
226
+ {/* Results */}
227
+ <div
228
+ className="flex flex-col gap-1.5"
229
+ role="listbox"
230
+ aria-label="Search results"
231
+ >
232
+ {results.map((app, i) => (
233
+ <button
234
+ key={app.slug}
235
+ type="button"
236
+ role="option"
237
+ title={`View ${app.displayName}`}
238
+ aria-selected={focusedIndex === i}
239
+ onMouseEnter={() => setFocusedIndex(i)}
240
+ onClick={() => onAppClick(app)}
241
+ className={cn(
242
+ 'group flex items-center gap-3.5 w-full text-left',
243
+ 'bg-card border rounded-[var(--radius)] px-3.5 py-2.5',
244
+ 'transition-all',
245
+ focusedIndex === i
246
+ ? 'border-ring shadow-sm bg-muted/30'
247
+ : 'border-border hover:border-ring hover:shadow-sm',
248
+ )}
249
+ >
250
+ <ResourceIcon app={app} size={40} />
251
+ <span className="flex-1 min-w-0">
252
+ <span className="block text-[14px] font-semibold truncate">
253
+ {app.displayName}
254
+ {app.abbreviation && app.abbreviation !== app.displayName && (
255
+ <span className="ml-1.5 text-[12px] font-normal text-muted-foreground">
256
+ ({app.abbreviation})
257
+ </span>
258
+ )}
259
+ </span>
260
+ {app.description && (
261
+ <span className="block text-[12.5px] text-muted-foreground truncate">
262
+ {markdownToPlainText(app.description)}
263
+ </span>
264
+ )}
265
+ </span>
266
+ <span className="text-[11.5px] text-muted-foreground bg-muted rounded-full px-2.5 py-0.5 whitespace-nowrap shrink-0">
267
+ {typeLabel(app.type)}
268
+ </span>
269
+ <LaunchButton
270
+ app={app}
271
+ onLaunch={onLaunch}
272
+ className="size-7 shrink-0 opacity-0 group-hover:opacity-100"
273
+ />
274
+ </button>
275
+ ))}
276
+ </div>
277
+
278
+ {/* Keyboard hint */}
279
+ {results.length > 0 && (
280
+ <p className="text-[11.5px] text-muted-foreground/60 text-center mt-3">
281
+ ↑↓ navigate · ↵ view access · esc clear
282
+ </p>
283
+ )}
284
+ </div>
285
+ )
286
+ }
287
+
288
+ export function LauncherHome({
289
+ apps,
290
+ allResources,
291
+ searchValue,
292
+ onSearchChange,
293
+ onAppClick,
294
+ onLaunch,
295
+ totalCount,
296
+ }: LauncherHomeProps) {
297
+ const { getTopApps } = useAppClickHistory()
298
+ const [topSlugs, setTopSlugs] = useState<string[]>([])
299
+
300
+ useEffect(() => {
301
+ void getTopApps(5).then(setTopSlugs)
302
+ }, [getTopApps])
303
+
304
+ const bySlug = useMemo(() => {
305
+ const m = new Map<string, Resource>()
306
+ for (const a of apps) m.set(a.slug, a)
307
+ return m
308
+ }, [apps])
309
+
310
+ // Your apps: frequently-clicked (personalized). Empty on a cold new machine.
311
+ const frequent = useMemo(
312
+ () =>
313
+ topSlugs
314
+ .map((s) => bySlug.get(s))
315
+ .filter((a): a is Resource => Boolean(a))
316
+ .slice(0, 5),
317
+ [topSlugs, bySlug],
318
+ )
319
+
320
+ // New this week: apps whose sources were checked in the last 7 days, as a
321
+ // proxy for "recently added/updated" (frontend Resource has no createdAt yet;
322
+ // see #38). Falls back to empty (section hidden) when no freshness data.
323
+ const fresh = useMemo(() => {
324
+ const weekAgo = Date.now() - 7 * 24 * 60 * 60 * 1000
325
+ return apps
326
+ .filter((a) => {
327
+ const t = a.freshness?.lastCheckedAt
328
+ return t ? new Date(t).getTime() >= weekAgo : false
329
+ })
330
+ .sort((a, b) => {
331
+ const ta = new Date(a.freshness?.lastCheckedAt ?? 0).getTime()
332
+ const tb = new Date(b.freshness?.lastCheckedAt ?? 0).getTime()
333
+ return tb - ta
334
+ })
335
+ .slice(0, 6)
336
+ }, [apps])
337
+
338
+ // Browse all: everything not already promoted to "Your apps", alpha by name.
339
+ const browse = useMemo(() => {
340
+ const promoted = new Set(frequent.map((a) => a.slug))
341
+ return [...apps]
342
+ .filter((a) => !promoted.has(a.slug))
343
+ .sort((a, b) => a.displayName.localeCompare(b.displayName))
344
+ }, [apps, frequent])
345
+
346
+ const browseLeft = browse.filter((_, i) => i % 2 === 0)
347
+ const browseRight = browse.filter((_, i) => i % 2 === 1)
348
+
349
+ const isSearching = searchValue.trim() !== ''
350
+ const searchRef = useRef<HTMLInputElement>(null)
351
+
352
+ // ⌘K / Ctrl+K focuses the hero search box from anywhere on the page.
353
+ useEffect(() => {
354
+ const onKey = (e: KeyboardEvent) => {
355
+ if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
356
+ e.preventDefault()
357
+ searchRef.current?.focus()
358
+ }
359
+ }
360
+ document.addEventListener('keydown', onKey)
361
+ return () => document.removeEventListener('keydown', onKey)
362
+ }, [])
363
+
364
+ return (
365
+ <div className="mx-auto w-full max-w-[1000px] pb-24">
366
+ {/* hero */}
367
+ <div className="text-center pt-10 pb-1.5">
368
+ <h1 className="font-serif font-semibold text-[30px] tracking-tight m-0 mb-1.5">
369
+ What do you need to get into?
370
+ </h1>
371
+ <p className="text-muted-foreground m-0 mb-6 text-[15px]">
372
+ Find any tool, see how to request access, or jump straight in.
373
+ </p>
374
+ <div className="max-w-[620px] mx-auto">
375
+ <div className="flex items-center gap-3 bg-card border-[1.5px] border-input rounded-full px-5 h-14 shadow-sm focus-within:border-primary focus-within:ring-4 focus-within:ring-primary/15 transition-colors">
376
+ <Search className="size-5 shrink-0 text-muted-foreground" />
377
+ <input
378
+ type="text"
379
+ value={searchValue}
380
+ onChange={(e) => onSearchChange(e.target.value)}
381
+ placeholder="Search apps, databases, cloud accounts, account IDs…"
382
+ autoComplete="off"
383
+ autoFocus
384
+ ref={searchRef}
385
+ aria-label="Search apps"
386
+ className="flex-1 bg-transparent border-0 outline-none text-[16px] text-foreground placeholder:text-muted-foreground"
387
+ />
388
+ {!isSearching && (
389
+ <kbd className="hidden sm:inline-flex items-center gap-0.5 text-[11px] text-muted-foreground/60 border border-muted-foreground/20 rounded px-1.5 py-0.5 font-mono shrink-0">
390
+ {typeof navigator !== 'undefined' &&
391
+ navigator.platform.includes('Mac')
392
+ ? '⌘K'
393
+ : 'Ctrl+K'}
394
+ </kbd>
395
+ )}
396
+ </div>
397
+ </div>
398
+ </div>
399
+
400
+ {/* Search morph: when typing, show compact results list instead of the discovery spine */}
401
+ {isSearching && (
402
+ <SearchResultsList
403
+ apps={allResources ?? apps}
404
+ searchValue={searchValue}
405
+ onAppClick={onAppClick}
406
+ onLaunch={onLaunch}
407
+ onClear={() => onSearchChange('')}
408
+ />
409
+ )}
410
+
411
+ {/* Discovery spine: only shown when not searching */}
412
+ {!isSearching && (
413
+ <>
414
+ {/* Your apps */}
415
+ {frequent.length > 0 && (
416
+ <section className="mt-9">
417
+ <SectionHead title="Your apps" count="frequent" />
418
+ <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-3.5">
419
+ {frequent.map((app) => (
420
+ <button
421
+ type="button"
422
+ key={app.slug}
423
+ onClick={() => onAppClick(app)}
424
+ title={`View ${app.displayName}`}
425
+ className="group relative bg-card border border-border rounded-[var(--radius)] px-3.5 pt-[18px] pb-4 text-center shadow-sm hover:-translate-y-0.5 hover:shadow-md transition-all"
426
+ >
427
+ <LaunchButton
428
+ app={app}
429
+ onLaunch={onLaunch}
430
+ className="absolute top-2.5 right-2.5 size-[26px] opacity-0 group-hover:opacity-100"
431
+ />
432
+ <ResourceIcon
433
+ app={app}
434
+ size={46}
435
+ className="mx-auto mb-3"
436
+ />
437
+ <span className="block text-[13.5px] font-bold truncate">
438
+ {app.displayName}
439
+ </span>
440
+ </button>
441
+ ))}
442
+ </div>
443
+ </section>
444
+ )}
445
+
446
+ {/* New this week */}
447
+ {fresh.length > 0 && (
448
+ <section className="mt-9">
449
+ <SectionHead
450
+ title="New this week"
451
+ count={`${fresh.length} added`}
452
+ />
453
+ <div className="flex flex-col gap-2">
454
+ {fresh.map((app) => (
455
+ <ResourceRow
456
+ key={app.slug}
457
+ app={app}
458
+ onAppClick={onAppClick}
459
+ onLaunch={onLaunch}
460
+ showNew
461
+ />
462
+ ))}
463
+ </div>
464
+ </section>
465
+ )}
466
+
467
+ {/* Browse all */}
468
+ <section className="mt-9">
469
+ <SectionHead title="Browse all" count={`${totalCount} resources`} />
470
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-2">
471
+ <div className="flex flex-col gap-2">
472
+ {browseLeft.map((app) => (
473
+ <ResourceRow
474
+ key={app.slug}
475
+ app={app}
476
+ onAppClick={onAppClick}
477
+ onLaunch={onLaunch}
478
+ />
479
+ ))}
480
+ </div>
481
+ <div className="flex flex-col gap-2">
482
+ {browseRight.map((app) => (
483
+ <ResourceRow
484
+ key={app.slug}
485
+ app={app}
486
+ onAppClick={onAppClick}
487
+ onLaunch={onLaunch}
488
+ />
489
+ ))}
490
+ </div>
491
+ </div>
492
+ </section>
493
+ </>
494
+ )}
495
+ </div>
496
+ )
497
+ }
@@ -0,0 +1,54 @@
1
+ import { useState } from 'react'
2
+ import type { Resource } from '@igstack/app-catalog-backend-core'
3
+ import { cn } from '~/lib/utils'
4
+ import { monogramColor, monogramInitials } from './monogram'
5
+
6
+ /**
7
+ * Resource icon used across the launcher UI.
8
+ * - If the app has an `iconName`, render the served image (`/api/icons/<name>`).
9
+ * - Otherwise fall back to a flat crayon-colored monogram chip (prototype look),
10
+ * NOT a generic glyph, so every resource still has a recognizable "scent".
11
+ */
12
+ export function ResourceIcon({
13
+ app,
14
+ size = 40,
15
+ className,
16
+ rounded = 'rounded-[12px]',
17
+ }: {
18
+ app: Pick<Resource, 'iconName' | 'displayName' | 'abbreviation' | 'slug'>
19
+ size?: number
20
+ className?: string
21
+ rounded?: string
22
+ }) {
23
+ const [imageError, setImageError] = useState(false)
24
+ const dim = { width: size, height: size }
25
+
26
+ if (app.iconName && !imageError) {
27
+ return (
28
+ <img
29
+ src={`/api/icons/${app.iconName}`}
30
+ alt=""
31
+ aria-hidden="true"
32
+ style={dim}
33
+ className={cn(rounded, 'shrink-0 object-contain', className)}
34
+ onError={() => setImageError(true)}
35
+ />
36
+ )
37
+ }
38
+
39
+ const initials = monogramInitials(app.displayName, app.abbreviation)
40
+ const bg = monogramColor(app.slug || app.displayName)
41
+ return (
42
+ <span
43
+ aria-hidden="true"
44
+ style={{ ...dim, background: bg, fontSize: Math.round(size * 0.36) }}
45
+ className={cn(
46
+ rounded,
47
+ 'shrink-0 grid place-items-center font-semibold text-white font-serif tracking-tight select-none',
48
+ className,
49
+ )}
50
+ >
51
+ {initials}
52
+ </span>
53
+ )
54
+ }
@@ -0,0 +1,41 @@
1
+ // Deterministic crayon-palette monogram color for an app that has no icon.
2
+ // Mirrors the prototype's flat brand-color chips (option-a-launcher.html):
3
+ // a small warm palette drawn from the logo, picked stably by slug so the same
4
+ // app always gets the same color.
5
+
6
+ const CRAYON_PALETTE = [
7
+ '#dc6827', // orange
8
+ '#eca832', // amber
9
+ '#e4724a', // coral
10
+ '#f07a84', // pink
11
+ '#3782c2', // blue
12
+ '#388aca', // blue-2
13
+ '#65a443', // green
14
+ '#2c2622', // ink
15
+ ]
16
+
17
+ /** Stable hash → palette index, so a given slug always maps to one color. */
18
+ export function monogramColor(key: string): string {
19
+ let hash = 0
20
+ for (let i = 0; i < key.length; i++) {
21
+ hash = (hash * 31 + key.charCodeAt(i)) | 0
22
+ }
23
+ const idx = Math.abs(hash) % CRAYON_PALETTE.length
24
+ return CRAYON_PALETTE[idx] as string
25
+ }
26
+
27
+ /** Up-to-2-char initials from a display name / abbreviation. */
28
+ export function monogramInitials(name: string, abbreviation?: string): string {
29
+ const base = (abbreviation || name).trim()
30
+ if (!base) return '?'
31
+ // If an abbreviation is given, use its first 2 chars verbatim (e.g. "K8", "EH").
32
+ if (abbreviation) return abbreviation.slice(0, 2).toUpperCase()
33
+ const words = base
34
+ .replace(/[^A-Za-z0-9 ]/g, '')
35
+ .split(/\s+/)
36
+ .filter(Boolean)
37
+ if (words.length >= 2) {
38
+ return (words[0]![0]! + words[1]![0]!).toUpperCase()
39
+ }
40
+ return base.slice(0, 2).toUpperCase()
41
+ }