-
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add hierarchicalMenu(fake data) * Update HierarchialMenu * Update menu with llm data * Create useHierarchicalMenu and fix add padding to the left of child * Craete a customize HierarchicalMenuWidget * update css for llm tag menu * Delete the parent counting and sort parent Alphabetical * Baypass typesense error * Delete the algoliasearch dependncy * Add Col to testimony Search * Add refinement * Implement sorting logic for llm tags display * Extract the subtitle for filter tags * Add updated facets into getItems and remove redinment from useHierarachicalMenu * Run prettier * Change the iteration and detelet the downlevelIteration * Add filter to getWidgetSearchParameter
- Loading branch information
1 parent
eee343c
commit 491fb83
Showing
8 changed files
with
682 additions
and
12 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useHierarchicalMenu } from "../useHierarchicalMenu" | ||
|
||
export const useBillHierarchicalMenu = () => { | ||
const baseProps = { limit: 500, searchable: true } | ||
const propsList = [ | ||
{ | ||
attribute: "topics.lvl0", | ||
...baseProps | ||
}, | ||
{ | ||
attribute: "topics.lvl1", | ||
...baseProps | ||
} | ||
] | ||
|
||
return useHierarchicalMenu({ hierarchicalMenuProps: propsList }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { useInstantSearch } from "react-instantsearch" | ||
import { faFilter } from "@fortawesome/free-solid-svg-icons" | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" | ||
import { useCallback, useState } from "react" | ||
import styled from "styled-components" | ||
import { useMediaQuery } from "usehooks-ts" | ||
import { Button, Offcanvas } from "../bootstrap" | ||
import { SearchContainer } from "./SearchContainer" | ||
import { MultiselectHierarchicalMenu } from "./HierarchicalMenuWidget" | ||
export const FilterButton = styled(Button)` | ||
font-size: 1rem; | ||
line-height: 1rem; | ||
min-height: 2rem; | ||
padding: 0.25rem 0.5rem 0.25rem 0.5rem; | ||
align-self: flex-start; | ||
` | ||
const useHasRefinements = () => { | ||
const { results } = useInstantSearch() | ||
const refinements = results.getRefinements() | ||
return refinements.length !== 0 | ||
} | ||
|
||
export const useHierarchicalMenu = ({ | ||
hierarchicalMenuProps | ||
}: { | ||
hierarchicalMenuProps: any[] | ||
}) => { | ||
const inline = useMediaQuery("(min-width: 768px)") | ||
const [show, setShow] = useState(false) | ||
const handleClose = useCallback(() => setShow(false), []) | ||
const handleOpen = useCallback(() => setShow(true), []) | ||
|
||
const hierarchicalMenu = ( | ||
<> | ||
<MultiselectHierarchicalMenu | ||
attributes={[ | ||
hierarchicalMenuProps[0].attribute, | ||
hierarchicalMenuProps[1].attribute | ||
]} | ||
/> | ||
</> | ||
) | ||
const hasRefinements = useHasRefinements() | ||
|
||
return { | ||
options: inline ? ( | ||
<div>{hierarchicalMenu}</div> | ||
) : ( | ||
<Offcanvas show={show} onHide={handleClose}> | ||
<Offcanvas.Header closeButton> | ||
<Offcanvas.Title>Filter</Offcanvas.Title> | ||
</Offcanvas.Header> | ||
<Offcanvas.Body> | ||
<SearchContainer>{hierarchicalMenu}</SearchContainer> | ||
</Offcanvas.Body> | ||
</Offcanvas> | ||
), | ||
show: inline ? null : ( | ||
<FilterButton | ||
variant="secondary" | ||
active={show} | ||
onClick={handleOpen} | ||
className={hasRefinements ? "ais-FilterButton-has-refinements" : ""} | ||
> | ||
<FontAwesomeIcon icon={faFilter} /> Filter | ||
</FilterButton> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters