Skip to content

Commit

Permalink
fix: rounded mark + little tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
abernier committed Sep 14, 2024
1 parent 4d7ffd3 commit baba3b7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ main :target {
}
}

mark {
@apply -m-[--pad] rounded-sm p-[--pad] [--pad:0.05rem];
}

/**
* Pmndrs theme for JavaScript, CSS and HTML
* Loosely based on https://marketplace.visualstudio.com/items?itemName=pmndrs.pmndrs
Expand Down
2 changes: 2 additions & 0 deletions src/components/Search/SearchItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ function SearchItem({
className,
search,
result,
...props
}: Omit<ComponentProps<typeof Link>, 'href'> & SearchItemProps) {
return (
<Link
{...props}
href={result.url}
className={cn(className, 'block no-underline')}
target={result.url.startsWith('http') ? '_blank' : undefined}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Search/SearchModalContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const SearchModalContainer = ({ className }: ComponentProps<'search'>) =>
onSelect={router.push}
className="rounded-md transition-colors data-[selected=true]:bg-surface-container-high"
>
<SearchItem search={query} result={result} />
<SearchItem search={query} result={result} tabIndex={-1} />
</Command.Item>
)
})}
Expand Down
4 changes: 3 additions & 1 deletion src/utils/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ export const escape = (text: string) => text.replace(/[|\\{}()[\]^$+*?.]/g, '\\$
* Bolds matching text, returning HTML.
*/
export const highlight = (text: string, target: string) =>
text.replace(new RegExp(target, 'gi'), (match: string) => `<mark>${match}</mark>`)
target.length > 0
? text.replace(new RegExp(target, 'gi'), (match: string) => `<mark>${match}</mark>`)
: text

0 comments on commit baba3b7

Please sign in to comment.