Skip to content

Commit

Permalink
Merge pull request stakwork#2427 from aliraza556/Search-Filtering
Browse files Browse the repository at this point in the history
[Search Filtering]: `View More` for Node Types Rendering with Default Limit of `4 Rows`
  • Loading branch information
Rassl authored Nov 8, 2024
2 parents 4486153 + 7fcf501 commit 2f3d3f1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/App/SideBar/FilterSearch/NodeTypes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ type Props = {
export const NodeTypes = ({ handleSchemaTypeClick, selectedTypes, schemaAll }: Props) => {
const [showAllSchemas, setShowAllSchemas] = useState(false)

const uniqueSchemas = (showAllSchemas ? schemaAll : schemaAll.slice(0, 4)).filter(
const schemasPerRow = 3
const MAX_ROWS = 4
const maxVisibleSchemas = schemasPerRow * MAX_ROWS

const uniqueSchemas = (showAllSchemas ? schemaAll : schemaAll.slice(0, maxVisibleSchemas)).filter(
(schema, index, self) => index === self.findIndex((s) => s.type === schema.type),
)

Expand All @@ -40,7 +44,7 @@ export const NodeTypes = ({ handleSchemaTypeClick, selectedTypes, schemaAll }: P
</SchemaType>
))}
</SchemaTypeWrapper>
{!showAllSchemas && schemaAll.length > 4 && (
{!showAllSchemas && schemaAll.length > maxVisibleSchemas && (
<ViewMoreButton onClick={() => setShowAllSchemas(true)}>
<PlusIconWrapper>
<PlusIcon /> View More
Expand Down

0 comments on commit 2f3d3f1

Please sign in to comment.