Skip to content

Commit 54cf881

Browse files
authored
docs: show badge for community integrations (medusajs#13691)
1 parent 62d340b commit 54cf881

File tree

1 file changed

+57
-43
lines changed
  • www/packages/docs-ui/src/components/Search/Hits

1 file changed

+57
-43
lines changed

www/packages/docs-ui/src/components/Search/Hits/index.tsx

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "react-instantsearch"
1313
import { SearchNoResult } from "../NoResults"
1414
import { useSearch } from "@/providers"
15-
import { Link, SearchHitGroupName } from "@/components"
15+
import { Badge, Link, SearchHitGroupName } from "@/components"
1616

1717
export type Hierarchy = "lvl0" | "lvl1" | "lvl2" | "lvl3" | "lvl4" | "lvl5"
1818

@@ -34,6 +34,7 @@ export type HitType = {
3434
__queryID?: string
3535
objectID: string
3636
description?: string
37+
integration_vendor?: string
3738
}
3839

3940
export type GroupedHitType = {
@@ -157,14 +158,14 @@ export const SearchHits = ({
157158
.join(" › ")
158159
return (
159160
<div
161+
key={index}
160162
className={clsx(
161-
"gap-docs_0.25 relative flex flex-1 flex-col p-docs_0.5",
162-
"overflow-x-hidden text-ellipsis whitespace-nowrap break-words",
163+
"p-docs_0.5",
163164
"hover:bg-medusa-bg-base-hover",
164165
"focus:bg-medusa-bg-base-hover",
165-
"focus:outline-none"
166+
"focus:outline-none",
167+
"flex justify-between items-center"
166168
)}
167-
key={index}
168169
tabIndex={index}
169170
data-hit
170171
onClick={(e) => {
@@ -174,49 +175,62 @@ export const SearchHits = ({
174175
}
175176
}}
176177
>
177-
<span
178+
<div
178179
className={clsx(
179-
"text-compact-small-plus text-medusa-fg-base",
180-
"max-w-full"
180+
"gap-docs_0.25 relative flex flex-1 flex-col",
181+
"overflow-x-hidden text-ellipsis whitespace-nowrap break-words"
181182
)}
182183
>
183-
{/* @ts-expect-error React v19 doesn't see this type as a React element */}
184-
<Snippet
185-
attribute={getHierarchySnippetAttribute(item)}
186-
hit={item}
187-
/>
188-
</span>
189-
<span className="text-compact-small text-medusa-fg-subtle text-ellipsis overflow-hidden">
190-
{item.type === "content" && (
191-
<>
192-
{/* @ts-expect-error React v19 doesn't see this type as a React element */}
193-
<Snippet attribute={"content"} hit={item} />
194-
</>
195-
)}
196-
{item.type !== "content" && item.description}
197-
</span>
184+
<span
185+
className={clsx(
186+
"text-compact-small-plus text-medusa-fg-base",
187+
"max-w-full"
188+
)}
189+
>
190+
{/* @ts-expect-error React v19 doesn't see this type as a React element */}
191+
<Snippet
192+
attribute={getHierarchySnippetAttribute(item)}
193+
hit={item}
194+
/>
195+
</span>
196+
<span className="text-compact-small text-medusa-fg-subtle text-ellipsis overflow-hidden">
197+
{item.type === "content" && (
198+
<>
199+
{/* @ts-expect-error React v19 doesn't see this type as a React element */}
200+
<Snippet attribute={"content"} hit={item} />
201+
</>
202+
)}
203+
{item.type !== "content" && item.description}
204+
</span>
198205

199-
<span
200-
className={clsx(
201-
"text-ellipsis overflow-hidden",
202-
"text-medusa-fg-muted items-center text-compact-x-small"
206+
<span
207+
className={clsx(
208+
"text-ellipsis overflow-hidden",
209+
"text-medusa-fg-muted items-center text-compact-x-small"
210+
)}
211+
>
212+
{hierarchies}
213+
</span>
214+
<Link
215+
href={item.url}
216+
className="absolute top-0 left-0 h-full w-full"
217+
target="_self"
218+
onClick={(e) => {
219+
sendEvent("click", item, "Search Result Clicked")
220+
if (checkIfInternal(item.url)) {
221+
e.preventDefault()
222+
window.location.href = item.url
223+
setIsOpen(false)
224+
}
225+
}}
226+
/>
227+
</div>
228+
{!!item.integration_vendor &&
229+
item.integration_vendor !== "Medusa" && (
230+
<Badge variant="blue" badgeType="shaded">
231+
Community
232+
</Badge>
203233
)}
204-
>
205-
{hierarchies}
206-
</span>
207-
<Link
208-
href={item.url}
209-
className="absolute top-0 left-0 h-full w-full"
210-
target="_self"
211-
onClick={(e) => {
212-
sendEvent("click", item, "Search Result Clicked")
213-
if (checkIfInternal(item.url)) {
214-
e.preventDefault()
215-
window.location.href = item.url
216-
setIsOpen(false)
217-
}
218-
}}
219-
/>
220234
</div>
221235
)
222236
})}

0 commit comments

Comments
 (0)