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

Function createOutputForMatch

app/components/SearchPalette.tsx:415–451  ·  view source on GitHub ↗
(
  stringValue: string,
  isHighlighted: boolean,
  textSize: "text-xs" | "text-sm" | "text-base" | "text-lg" = "text-base",
  matches?: Array<Match>,
  maxLength: number = 68
)

Source from the content-addressed store, hash-verified

413}
414
415function createOutputForMatch(
416 stringValue: string,
417 isHighlighted: boolean,
418 textSize: "text-xs" | "text-sm" | "text-base" | "text-lg" = "text-base",
419 matches?: Array<Match>,
420 maxLength: number = 68
421): JSX.Element {
422 if (!matches || matches.length === 0) {
423 return <>{truncate(stringValue, { length: maxLength })}</>;
424 }
425
426 const stringSlices = getStringSlices(stringValue, matches, maxLength);
427
428 return (
429 <>
430 {stringSlices.map((s, index) => {
431 return (
432 <span
433 key={index}
434 className={
435 s.isMatch
436 ? classnames(
437 textSize,
438 isHighlighted
439 ? "text-white underline underline-offset-1"
440 : "text-indigo-600 dark:text-indigo-400"
441 )
442 : ""
443 }
444 >
445 {s.slice}
446 </span>
447 );
448 })}
449 </>
450 );
451}

Callers 1

SearchResultValueFunction · 0.85

Calls 2

getStringSlicesFunction · 0.90
classnamesFunction · 0.85

Tested by

no test coverage detected