Skip to content

Commit cdfe4cb

Browse files
bhat-shubhambenjagmDhairyaMajmudar
authoredMar 16, 2025··
Added dynamic icons to filters in tools page[Closes #1260] (#1309)
* added dynamic icons to the filter in tools page * added dynamic icons to the filter in tools page * added dynamic icons to the filter in tools page * added dynamic icons to the filter in tools page * added dynamic icons to the filter in tools page * to save before switching * added proper icons to each filter on tools page * Revert "added dynamic icons to the filter in tools page" This reverts commit b41272d. * Revert "added dynamic icons to the filter in tools page" This reverts commit 8b5c652. * Revert "to save before switching" This reverts commit 8e903d7. * reverting changes * reverting the changes in sublodules * revert submodule changes * fixed prettier errors * Removed Irrelevant Icon Check Co-authored-by: Dhairya Majmudar <124715224+DhairyaMajmudar@users.noreply.github.com> --------- Co-authored-by: Benjamin Granados <40007659+benjagm@users.noreply.github.com> Co-authored-by: Dhairya Majmudar <124715224+DhairyaMajmudar@users.noreply.github.com>
1 parent ccad48c commit cdfe4cb

File tree

7 files changed

+28
-4
lines changed

7 files changed

+28
-4
lines changed
 

‎pages/tools/components/Sidebar.tsx

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import React, { Dispatch, SetStateAction, useRef } from 'react';
2-
import FilterIcon from '~/public/icons/filter.svg';
2+
import LanguageIcon from '~/public/icons/language.svg';
3+
import ToolingIcon from '~/public/icons/tooling.svg';
4+
import EnvironmentIcon from '~/public/icons/environment.svg';
5+
import DialectIcon from '~/public/icons/dialect.svg';
6+
import LicenseIcon from '~/public/icons/license.svg';
37
import DropdownMenu from './ui/DropdownMenu';
48
import Checkbox from './ui/Checkbox';
59
import SearchBar from './SearchBar';
@@ -8,6 +12,14 @@ import type { Transform } from '../hooks/useToolsTransform';
812
import type { FilterCriteriaFields } from '../index.page';
913
import { postAnalytics } from '../lib/postAnalytics';
1014

15+
const filterIcons = {
16+
languages: LanguageIcon,
17+
toolingTypes: ToolingIcon,
18+
environments: EnvironmentIcon,
19+
drafts: DialectIcon,
20+
licenses: LicenseIcon,
21+
};
22+
1123
interface SidebarProps {
1224
filterCriteria: Record<FilterCriteriaFields, string[]>;
1325
transform: Transform;
@@ -79,8 +91,14 @@ export default function Sidebar({
7991
<SearchBar transform={transform} />
8092
{filters.map(({ label, accessorKey }) => {
8193
const checkedValues = transform[accessorKey as keyof Transform] || [];
94+
const IconComponent =
95+
filterIcons[accessorKey as keyof typeof filterIcons];
8296
return (
83-
<DropdownMenu key={accessorKey} label={label} icon={<FilterIcon />}>
97+
<DropdownMenu
98+
key={accessorKey}
99+
label={label}
100+
icon={<IconComponent />}
101+
>
84102
{filterCriteria[accessorKey as FilterCriteriaFields]
85103
?.map(String)
86104
.map((filterOption) => (

‎pages/tools/components/ui/DropdownMenu.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ export default function DropdownMenu({
2626
}, [router]);
2727

2828
return (
29-
<div className='my-2 bg-slate-200 dark:bg-slate-900 p-2 rounded'>
29+
<div className='my-2 bg-slate-200 dark:bg-slate-900 p-2 rounded cursor-pointer'>
3030
<div
3131
className='w-full flex justify-between items-center align-middle cursor-pointer'
3232
onClick={() => {
3333
setIsDropdownOpen((prev) => !prev);
3434
}}
3535
>
3636
{React.cloneElement(icon, {
37-
className: 'mr-2',
37+
className: 'mr-2 ml-2',
3838
})}
3939
<div className='text-slate-900 dark:text-slate-300 font-bold mr-auto'>
4040
{label}

‎public/icons/dialect.svg

+1
Loading

‎public/icons/environment.svg

+1
Loading

‎public/icons/language.svg

+1
Loading

‎public/icons/license.svg

+2
Loading

‎public/icons/tooling.svg

+1
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.