-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1607 add llm genrated tag #1655
Draft
HuanFengYeh
wants to merge
19
commits into
codeforboston:main
Choose a base branch
from
HuanFengYeh:1607_Add_LLM_Genrated_Tag
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
272c23e
add hierarchicalMenu(fake data)
HuanFengYeh 13bc0fc
Update HierarchialMenu
HuanFengYeh f850598
Update menu with llm data
HuanFengYeh 462947f
Create useHierarchicalMenu and fix add padding to the left of child
HuanFengYeh b579b49
Craete a customize HierarchicalMenuWidget
HuanFengYeh 163e9ff
update css for llm tag menu
HuanFengYeh 98ecb3c
Delete the parent counting and sort parent Alphabetical
HuanFengYeh 6e9e6c2
Baypass typesense error
HuanFengYeh f601ed7
Merge remote-tracking branch 'upstream/main' into 1607_Add_LLM_Genrat…
HuanFengYeh 64dc72c
Delete the algoliasearch dependncy
HuanFengYeh 025ab05
Add Col to testimony Search
HuanFengYeh 3491c7a
Add refinement
HuanFengYeh 3fd6bdb
Implement sorting logic for llm tags display
HuanFengYeh cd6b761
Extract the subtitle for filter tags
HuanFengYeh f5e6315
Add updated facets into getItems and remove redinment from useHierara…
HuanFengYeh d1150f4
Run prettier
HuanFengYeh c349abf
Change the iteration and detelet the downlevelIteration
HuanFengYeh 07e3e6c
Merge remote-tracking branch 'upstream/main' into 1607_Add_LLM_Genrat…
HuanFengYeh bfdb433
Add filter to getWidgetSearchParameter
HuanFengYeh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,156 @@ | ||
import React, { useState } from "react" | ||
import styled from "styled-components" | ||
|
||
const StyledMenu = styled.div` | ||
font-family: "Nunito"; | ||
|
||
.category { | ||
cursor: pointer; | ||
font-size: 1rem; | ||
font-weight: bold; | ||
margin: 8px 0; | ||
padding: 8px; | ||
background-color: white; | ||
border-radius: 4px; | ||
border-bottom: dashed 1px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.category:hover { | ||
background-color: #f5f5f5; | ||
} | ||
|
||
.category--expanded::before { | ||
content: "-"; | ||
margin-right: 10px; | ||
font-size: 20px; | ||
color: var(--bs-blue); | ||
} | ||
|
||
.category--collapsed::before { | ||
content: "+"; | ||
margin-right: 10px; | ||
font-size: 20px; | ||
color: var(--bs-blue); | ||
} | ||
|
||
.child-list { | ||
padding-left: 1rem; | ||
margin-top: 8px; | ||
list-style-type: none; | ||
background-color: white; | ||
border-radius: 4px; | ||
padding: 1rem; | ||
border: 1px solid #ddd; | ||
} | ||
|
||
.child-item { | ||
margin: 4px 0; | ||
display: flex; | ||
align-items: center; | ||
font-size: 1rem; | ||
cursor: pointer; | ||
} | ||
|
||
.child-item input { | ||
margin-right: 8px; | ||
} | ||
|
||
.child-item:hover { | ||
background-color: #f9f9f9; | ||
border-radius: 4px; | ||
padding: 4px; | ||
} | ||
|
||
.child-item--selected { | ||
font-weight: bold; | ||
color: var(--bs-blue); | ||
} | ||
` | ||
|
||
export interface HierarchicalItem { | ||
id: string | ||
label: string | ||
items: { value: string; label: string; isSelected?: boolean }[] | ||
} | ||
|
||
interface HierarchicalMenuWidgetProps { | ||
categories: HierarchicalItem[] | ||
onSelectionChange?: ( | ||
categoryId: string, | ||
selectedItems: { value: string; label: string }[] | ||
) => void | ||
} | ||
|
||
const HierarchicalMenuWidget: React.FC<HierarchicalMenuWidgetProps> = ({ | ||
categories, | ||
onSelectionChange | ||
}) => { | ||
const [expandedCategories, setExpandedCategories] = useState<string[]>([]) | ||
|
||
const toggleCategory = (id: string) => { | ||
setExpandedCategories(prev => | ||
prev.includes(id) ? prev.filter(catId => catId !== id) : [...prev, id] | ||
) | ||
} | ||
|
||
const handleChildSelection = ( | ||
categoryId: string, | ||
selectedItem: { value: string; label: string }, | ||
isSelected: boolean | ||
) => { | ||
if (onSelectionChange) { | ||
const updatedItem = { ...selectedItem, isSelected } | ||
onSelectionChange(categoryId, [updatedItem]) | ||
} | ||
} | ||
|
||
return ( | ||
<StyledMenu> | ||
{categories.map(category => ( | ||
<div key={category.id}> | ||
{/* Category */} | ||
<div | ||
className={`category ${ | ||
expandedCategories.includes(category.id) | ||
? "category--expanded" | ||
: "category--collapsed" | ||
}`} | ||
onClick={() => toggleCategory(category.id)} | ||
> | ||
{category.label} | ||
</div> | ||
|
||
{/* Child Items */} | ||
{expandedCategories.includes(category.id) && ( | ||
<ul className="child-list"> | ||
{category.items.map(item => ( | ||
<li | ||
key={item.value} | ||
className={`child-item ${ | ||
item.isSelected ? "child-item--selected" : "" | ||
}`} | ||
onClick={() => | ||
handleChildSelection(category.id, item, !item.isSelected) | ||
} | ||
> | ||
<input | ||
type="checkbox" | ||
checked={item.isSelected || false} | ||
onChange={e => | ||
e.stopPropagation() | ||
} /* Prevent click propagation */ | ||
/> | ||
{item.label} | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
</div> | ||
))} | ||
</StyledMenu> | ||
) | ||
} | ||
|
||
export default HierarchicalMenuWidget |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For each item under .ais-HierarchicalMenu-list--child, could you add padding to the left, so we can differentiate between the parent and child tags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current version is close to what UI team design, but I also think add padding will help the readability.