-
-
Notifications
You must be signed in to change notification settings - Fork 226
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
Added dynamic icons to filters in tools page[Closes #1260] #1309
base: main
Are you sure you want to change the base?
Changes from 7 commits
723fe15
02ac24c
63d02df
8b5c652
b41272d
8e903d7
3ff4de1
1a79e9c
1641011
7b8c534
42f75f2
71bdeca
bd07ca3
c90a0a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How are these changes relevant to the linked issue for Tools Page? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import React, { Dispatch, SetStateAction, useRef } from 'react'; | ||
import FilterIcon from '~/public/icons/filter.svg'; | ||
import LanguageIcon from '~/public/icons/language.svg'; | ||
import ToolingIcon from '~/public/icons/tooling.svg'; | ||
import EnvironmentIcon from '~/public/icons/environment.svg'; | ||
import DialectIcon from '~/public/icons/dialect.svg'; | ||
import LicenseIcon from '~/public/icons/license.svg'; | ||
import DropdownMenu from './ui/DropdownMenu'; | ||
import Checkbox from './ui/Checkbox'; | ||
import SearchBar from './SearchBar'; | ||
|
@@ -8,6 +12,14 @@ import type { Transform } from '../hooks/useToolsTransform'; | |
import type { FilterCriteriaFields } from '../index.page'; | ||
import { postAnalytics } from '../lib/postAnalytics'; | ||
|
||
const filterIcons = { | ||
languages: LanguageIcon, | ||
toolingTypes: ToolingIcon, | ||
environments: EnvironmentIcon, | ||
drafts: DialectIcon, | ||
licenses: LicenseIcon, | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This object is redundant, it would better managed with |
||
interface SidebarProps { | ||
filterCriteria: Record<FilterCriteriaFields, string[]>; | ||
transform: Transform; | ||
|
@@ -79,8 +91,14 @@ export default function Sidebar({ | |
<SearchBar transform={transform} /> | ||
{filters.map(({ label, accessorKey }) => { | ||
const checkedValues = transform[accessorKey as keyof Transform] || []; | ||
const IconComponent = | ||
filterIcons[accessorKey as keyof typeof filterIcons]; | ||
return ( | ||
<DropdownMenu key={accessorKey} label={label} icon={<FilterIcon />}> | ||
<DropdownMenu | ||
key={accessorKey} | ||
label={label} | ||
icon={IconComponent && <IconComponent />} | ||
> | ||
{filterCriteria[accessorKey as FilterCriteriaFields] | ||
?.map(String) | ||
.map((filterOption) => ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,15 +26,15 @@ export default function DropdownMenu({ | |
}, [router]); | ||
|
||
return ( | ||
<div className='my-2 bg-slate-200 dark:bg-slate-900 p-2 rounded'> | ||
<div className='my-2 bg-slate-200 dark:bg-slate-900 p-2 rounded cursor-pointer'> | ||
<div | ||
className='w-full flex justify-between items-center align-middle' | ||
onClick={() => { | ||
setIsDropdownOpen((prev) => !prev); | ||
}} | ||
> | ||
{React.cloneElement(icon, { | ||
className: 'mr-2', | ||
className: 'mr-2 ml-2', | ||
})} | ||
<div className='text-slate-900 dark:text-slate-300 font-bold mr-auto'> | ||
{label} | ||
|
@@ -64,8 +64,11 @@ export default function DropdownMenu({ | |
<div | ||
className={classnames( | ||
'tools-dropdown-menu', | ||
'ml-0 mt-4 overflow-x-hidden overscroll-y-auto max-h-80', | ||
{ hidden: !isDropdownOpen }, | ||
'ml-0 mt-0 overflow-hidden transition-all duration-500 ease-in-out', | ||
{ | ||
'max-h-0 opacity-0 invisible': !isDropdownOpen, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this make it more complicated? |
||
'max-h-80 overflow-y-auto opacity-100 visible': isDropdownOpen, | ||
}, | ||
)} | ||
> | ||
{children} | ||
|
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.
Can you please revert the changes in the community submodule?
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.
Yes, i have reverted The Changes.