MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / SearchPathResult

Function SearchPathResult

app/components/SearchPalette.tsx:289–378  ·  view source on GitHub ↗
({
  path,
  searchResult,
  isHighlighted,
  maxWeight = 90,
}: {
  path: JSONHeroPath;
  isHighlighted: boolean;
  searchResult: SearchResult<string>;
  maxWeight?: number;
})

Source from the content-addressed store, hash-verified

287//
288// If combined component strings are too long, then we need to choose some components to hide behind an ellipsis, making sure we don't hide matches
289function SearchPathResult({
290 path,
291 searchResult,
292 isHighlighted,
293 maxWeight = 90,
294}: {
295 path: JSONHeroPath;
296 isHighlighted: boolean;
297 searchResult: SearchResult<string>;
298 maxWeight?: number;
299}) {
300 const description = searchResult.score.description;
301 const label = searchResult.score.label;
302
303 const labelMatches = searchResult.score.labelMatch;
304 const descriptionMatches = searchResult.score.descriptionMatch;
305
306 const descriptionSlices = getComponentSlices(
307 description ?? "",
308 (descriptionMatches ?? []).map(({ start, end }) => ({
309 start,
310 end: end - 1,
311 })),
312 maxWeight
313 );
314
315 return (
316 <>
317 {label && (
318 <SearchResultValue
319 isHighlighted={isHighlighted}
320 stringValue={label}
321 matches={labelMatches}
322 textSize="text-lg"
323 className={classnames(
324 "mr-3 text-lg",
325 isHighlighted ? `text-white` : "text-slate-900 dark:text-white"
326 )}
327 key="label"
328 />
329 )}
330 {descriptionSlices.map((slice, i) =>
331 slice.type === "component" ? (
332 <span
333 key={i}
334 className={
335 slice.slice.isMatch
336 ? classnames(
337 "text-base",
338 isHighlighted
339 ? "text-white underline underline-offset-1"
340 : "text-indigo-600 dark:text-indigo-400"
341 )
342 : classnames(
343 "text-base",
344 isHighlighted
345 ? "text-white"
346 : "text-slate-800 dark:text-slate-400"

Callers

nothing calls this directly

Calls 2

getComponentSlicesFunction · 0.90
classnamesFunction · 0.85

Tested by

no test coverage detected