Skip to content

Commit

Permalink
fix: search filter bug, update SVG attributes (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
barjin authored Jan 3, 2024
1 parent 348d12a commit 1efe9c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions src/components/ApifySearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ function Autocomplete(props: any) {
})
)).flat()
).flat()
.filter((item: any, i: number, a: any[]) => {
const hierarchyMatches : any[] = Object.values(item?._highlightResult.hierarchy);
// .filter((item: any, i: number, a: any[]) => {

// const hierarchyMatches : any[] = Object.values(item?._highlightResult.hierarchy);

return item?._highlightResult.content.matchLevel === 'full'
|| hierarchyMatches[hierarchyMatches.length - 1].matchLevel === 'full'
|| a.slice(0, i).some((x: any) => (countFamily(x, item) === 2));
}),
// // show the item only if:
// return item?._highlightResult.content.matchLevel === 'full' // the query is a substring of the "content"
// || hierarchyMatches[hierarchyMatches.length - 1].matchLevel === 'full' // the query is a substring of the last item in the "hierarchy" (i.e the retrieved article/heading "name")
// || a.slice(0, i).some((x: any) => (countFamily(x, item) === 2)); // the item is a child of the previous item
// }),
];
}
});
Expand Down
10 changes: 5 additions & 5 deletions src/utils/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function DocumentIcon() {
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M17 6v12c0 .52-.2 1-1 1H4c-.7 0-1-.33-1-1V2c0-.55.42-1 1-1h8l5 5zM14 8h-3.13c-.51 0-.87-.34-.87-.87V4" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linejoin="round">
<path d="M17 6v12c0 .52-.2 1-1 1H4c-.7 0-1-.33-1-1V2c0-.55.42-1 1-1h8l5 5zM14 8h-3.13c-.51 0-.87-.34-.87-.87V4" stroke="currentColor" fill="none" fillRule="evenodd" strokeLinejoin="round">
</path>
</svg>
)
Expand Down Expand Up @@ -53,7 +53,7 @@ export function SearchIcon() {
export function EnterIcon() {
return (
<svg width="15" height="15" aria-label="Enter key" role="img">
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2">
<g fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.2">
<path d="M12 3.53088v3c0 1-1 2-2 2H4M7 11.53088l-3-3 3-3"></path>
</g>
</svg>
Expand All @@ -63,7 +63,7 @@ export function EnterIcon() {
export function ArrowUpIcon() {
return (
<svg width="15" height="15" aria-label="Arrow down" role="img">
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2">
<g fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.2">
<path d="M7.5 3.5v8M10.5 8.5l-3 3-3-3">
</path>
</g>
Expand All @@ -74,7 +74,7 @@ export function ArrowUpIcon() {
export function ArrowDownIcon() {
return (
<svg width="15" height="15" aria-label="Arrow up" role="img">
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2">
<g fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.2">
<path d="M7.5 11.5v-8M10.5 6.5l-3-3-3 3">
</path>
</g>
Expand All @@ -85,7 +85,7 @@ export function ArrowDownIcon() {
export function EscapeIcon() {
return (
<svg width="15" height="15" aria-label="Escape key" role="img">
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2">
<g fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.2">
<path d="M13.6167 8.936c-.1065.3583-.6883.962-1.4875.962-.7993 0-1.653-.9165-1.653-2.1258v-.5678c0-1.2548.7896-2.1016 1.653-2.1016.8634 0 1.3601.4778 1.4875 1.0724M9 6c-.1352-.4735-.7506-.9219-1.46-.8972-.7092.0246-1.344.57-1.344 1.2166s.4198.8812 1.3445.9805C8.465 7.3992 8.968 7.9337 9 8.5c.032.5663-.454 1.398-1.4595 1.398C6.6593 9.898 6 9 5.963 8.4851m-1.4748.5368c-.2635.5941-.8099.876-1.5443.876s-1.7073-.6248-1.7073-2.204v-.4603c0-1.0416.721-2.131 1.7073-2.131.9864 0 1.6425 1.031 1.5443 2.2492h-2.956">
</path>
</g>
Expand Down

0 comments on commit 1efe9c3

Please sign in to comment.