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

frontend: create reusable single & multi dropdown #3071

Closed
wants to merge 2 commits into from

Conversation

shonsirsha
Copy link
Collaborator

To improve codebase by reducing redundancy, we create a reusable
single & multi dropdown based on ReactSelect.

To improve codebase by reducing redundancy, we create a reusable
single & multi dropdown based on ReactSelect.
@shonsirsha shonsirsha marked this pull request as draft November 26, 2024 10:53
@shonsirsha
Copy link
Collaborator Author

Second commit, 8821fe1 is an example of how we're going to use our new reusable Dropdown component. WDYT @thisconnect

@thisconnect
Copy link
Collaborator

nice 🎉 cACK

defaultValue?: TOption<T> | TOption<T>[] | null; // selected default value(s)
value?: TOption<T> | TOption<T>[] | null; // selected value(s)
classNamePrefix?: string; // Prefix for custom class names
renderOptions: (selectedItem: TOption<T>) => ReactNode; // Function to render options
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This renderOptions prop provides a unified way to render both the selected option (in single dropdowns) and all available options in the dropdown list.

This allows for flexibility in customizing the rendering, such as including icons (e.g., checkmarks, flags) or any other ReactNode components. It also allows for custom styling to an extent. Basically we can add stuff into the option(s) without relying on fixed props like rightIcon or extraComponent.

Since renderOptions is applied to both the selected option and the dropdown options, they will share the same rendering logic. This consistency works well for our app, where selected options and dropdown options have always been rendered identically.

However, if there’s a need for more flexibility, such as rendering selected options and dropdown options differently lmk and we can add another prop.

@shonsirsha shonsirsha closed this Nov 26, 2024
@shonsirsha shonsirsha deleted the frontend-refactor-dropdown branch November 26, 2024 12:05
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