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

[filigran-ui] Add searchbar for icons #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hishekk
Copy link

@hishekk hishekk commented Jul 22, 2024

Summary
This pull request adds Searchbar and Code usage for icons.

Changes Made

Added searchbar component to search icons.

Added popup component to show code usage like MUI .

Screenshots
image

image

Please review the implementation and provide feedback on the design and functionality. Suggestions for improvement are welcome!

Copy link
Member

@jpkha jpkha left a comment

Choose a reason for hiding this comment

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

Overall, great implementation.
Some modifications to do but thank you for you help 👍

const [searchTerm, setSearchTerm] = useState('');

const handleIconClick = (Icon : React.ComponentType<any> ,icon : string) => {
setSelectedIcon(<Icon className="w-20 h-20"/>);
Copy link
Member

Choose a reason for hiding this comment

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

I think you can have only one state instead of 3.
You can use icon as a string.
If there is any icon set you can consider that you need to "open the modal" and from the popup you can get the Icon from the string.
It will avoid to have 3 state for one and the same purpose (showing the icon)

const allIcons = Object.keys(FiligranIcon).filter((key) => key !== 'default')

const filteredIcons = useMemo(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Great 👍 , nice to have put useMemo here 👍

setSelectedIcon(null);
setSelectedIconLabel('');
}

const allIcons = Object.keys(FiligranIcon).filter((key) => key !== 'default')
Copy link
Member

Choose a reason for hiding this comment

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

My mistake, but we can place the allIcons outside the component since we don't need to rerender it every time. We should also remove it from the dependencies of useMemo

const Icon = FiligranIcon[icon]
return <Icon className="h-16 w-16" />
const Icon = FiligranIcon[icon] as React.ComponentType<any>;
return <Icon className="h-16 w-16 hover:border-[1px] border-blue rounded-lg" onClick={() => handleIconClick(Icon,icon)} />
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to use border-primary border p-s
Border by default is 1px.
Padding would make a little spacing between the icon and the border.
Primary is still the blue you set but in case we are changing the theme I would prefer to set primary instead

}
return (
<div className='container'>
<SearchBar
value={searchTerm}
Copy link
Member

Choose a reason for hiding this comment

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

👍

}
return (
<div className='container'>
Copy link
Member

Choose a reason for hiding this comment

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

not sure that "container" is working anymore. I remove the tailwindcss-typography plugin I want to use our own theme now.
But in case that it's not really use, you can wrap with <></>


const handleCopy = () => {
const statement = `import { ${iconName} } from '@filigran-ui';`;
navigator.clipboard.writeText(statement)
Copy link
Member

Choose a reason for hiding this comment

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

could we use the toast component instead ?
https://filigranhq.github.io/filigran-ui/docs/components/toast
The implementation come from :
https://ui.shadcn.com/docs/components/toast

};

return (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black bg-opacity-50" onClick={handleBackgroundClick}>
Copy link
Member

Choose a reason for hiding this comment

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

You can use instead.
https://filigranhq.github.io/filigran-ui/docs/components/dialog
I would prefer to use our own component of the ui-library to make sense.

Docs :https://ui.shadcn.com/docs/components/dialog


const SearchBar: React.FC<SearchBarProps> = ({ value, onChange, placeholder = 'Search icons...' }) => {
return (
<div className="relative w-full max-w-md mx-auto mb-6">
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 use the input of the Filigran-ui ?

@jpkha jpkha force-pushed the main branch 4 times, most recently from 0221267 to 384b8b0 Compare September 9, 2024 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants