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

Added dynamic icons to filters in tools page[Closes #1260] #1309

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _includes/community
Copy link
Member

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?

Copy link
Contributor Author

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.

36 changes: 32 additions & 4 deletions components/Sidebar.tsx
Copy link
Member

Choose a reason for hiding this comment

The 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
Expand Up @@ -355,7 +355,14 @@ export const DocsNav = ({
</svg>
</div>
<div
className={classnames('ml-6', { hidden: !active.getDocs })}
className={classnames(
'ml-6',
'transition-all duration-500 ease-in-out',
{
'max-h-0 opacity-0 overflow-hidden': !active.getDocs,
'max-h-80 opacity-100': active.getDocs,
},
)}
id='overview'
>
<DocLink
Expand Down Expand Up @@ -431,7 +438,14 @@ export const DocsNav = ({
</svg>
</div>
<div
className={classnames('ml-6', { hidden: !active.getStarted })}
className={classnames(
'ml-6',
'transition-all duration-500 ease-in-out',
{
'max-h-0 opacity-0 overflow-hidden': !active.getStarted,
'max-h-80 opacity-100': active.getStarted,
},
)}
id='getStarted'
>
<DocLink uri='/learn' label='Overview' setOpen={setOpen} />
Expand Down Expand Up @@ -498,7 +512,14 @@ export const DocsNav = ({
</svg>
</div>
<div
className={classnames('ml-6', { hidden: !active.getReference })}
className={classnames(
'ml-6',
'transition-all duration-500 ease-in-out',
{
'max-h-0 opacity-0 overflow-hidden': !active.getReference,
'max-h-80 overflow-y-auto opacity-100': active.getReference,
},
)}
id='reference'
>
<DocLink
Expand Down Expand Up @@ -687,7 +708,14 @@ export const DocsNav = ({
</svg>
</div>
<div
className={classnames('ml-6', { hidden: !active.getSpecification })}
className={classnames(
'ml-6',
'transition-all duration-500 ease-in-out',
{
'max-h-0 opacity-0 overflow-hidden': !active.getSpecification,
'max-h-80 opacity-100': active.getSpecification,
},
)}
id='specification'
>
<DocLink uri='/specification' label='Overview' setOpen={setOpen} />
Expand Down
22 changes: 20 additions & 2 deletions pages/tools/components/Sidebar.tsx
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';
Expand All @@ -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,
};

Copy link
Member

Choose a reason for hiding this comment

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

This object is redundant, it would better managed with filters object.

interface SidebarProps {
filterCriteria: Record<FilterCriteriaFields, string[]>;
transform: Transform;
Expand Down Expand Up @@ -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) => (
Expand Down
11 changes: 7 additions & 4 deletions pages/tools/components/ui/DropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The 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}
Expand Down
1 change: 1 addition & 0 deletions public/icons/dialect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/environment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/language.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions public/icons/license.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/tooling.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading