Skip to content

Added Switch component to utils#86

Merged
DavidHDev merged 6 commits intoDavidHDev:mainfrom
MrNaceja:feat/85-add-switch-component-util
Jan 11, 2025
Merged

Added Switch component to utils#86
DavidHDev merged 6 commits intoDavidHDev:mainfrom
MrNaceja:feat/85-add-switch-component-util

Conversation

@MrNaceja
Copy link
Copy Markdown
Contributor

The Switch component can be used for complex conditional rendering. The component can be switch by multiple "cases" of components and an "default" component to render in case the given dynamic value does not match any case.
Render dynamic components cleanly using this component.

The Switch component accepts the following props:

  • value - the value to check with the cases to render the corresponding component.
  • components - the list of case components to be rendered when case matches.
  • defaultComponent - the "default" component to be rendered if the value does not match any of the given cases.

This component is useful for rendering a specific component as a dynamic value and can be written cleanly and explicitly

✅ Added Switch component
✅ Added Switch tests
✅ Added Switch docs page with demo
✅ Added demo-dropdown style to create dropdowns on demo page
✅ Added bounceIn animation

Comment thread lib/old_index.d.ts Outdated
Comment thread lib/utils/Switch.tsx Outdated
@DavidHDev
Copy link
Copy Markdown
Owner

Thanks for the contribution!

@DavidHDev DavidHDev merged commit 16e3b52 into DavidHDev:main Jan 11, 2025
@DavidHDev
Copy link
Copy Markdown
Owner

I'll do a release with this next week 💯

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