Skip to content
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

Feature search results #92

Merged
merged 34 commits into from
Feb 11, 2025
Merged

Conversation

nicklitvin
Copy link
Contributor

Changes

  • Created Search Results component
  • Create Stories page to showcase appearance with different props

Usage

SearchResults contains several props for customization.

  • groupBy will return the name of the group/category that a SearchResult will be placed into
  • className is tailwind that is applied to the entire Accordion element
  • HeaderComponent will replace the default component that renders the name of the group and can be clicked on to open/close the content
  • RowComponent will replace the default component that renders each SearchResult
  • ContentWrapper will replace the default wrapper around all the RowComponents in one group

The Components and Wrapper will receive props that may be useful for conditional rendering of certain parts if desired

@robxbob
Copy link
Collaborator

robxbob commented Oct 24, 2024

The accordian content overlaps when collapsing. Also, is there a reason why you aren't using the accordian from shadcn? Which would make your code alot simpler and not need openCategories and isLast.

Your solution of passing in components directly isn't bad at all; was just hoping for it to have a similar design structure as the model components like so:

interface SearchResults<Category extends string> {
  data: SearchResult[];
  groupBy: (searchResult: SearchResult) => Category
  getLabel: ({ category: Category, items: SearchResult[] }) => ReactNode
  getContent: ({ category: Category, items: SearchResult[] }) => ReactNode
}

You can see how much more powerful the customization of the label and content can become as it now has direct access to the content and category.

@nicklitvin
Copy link
Contributor Author

nicklitvin commented Oct 25, 2024

2nd round of changes:

  • replaced radix accordion with shadcn accordion
  • refactored SearchResults props
  • added generic Category type to pass into SearchResults
  • removed collpase all button
  • utilized forward ref for component
  • added sortby prop

Comment on lines 62 to 69
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
'accordion-down': {
from: {
height: '0'
},
to: {
height: 'var(--radix-accordion-content-height)'
}
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you make these changes or was it something from a tailwind update lol.

Copy link
Contributor Author

@nicklitvin nicklitvin Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might have been from the install of a shadcn component that needed accordion and/or our formatter. Should I revert the change?

@robxbob robxbob merged commit c7951da into autoinvent:dev Feb 11, 2025
robxbob pushed a commit that referenced this pull request Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants