-
Notifications
You must be signed in to change notification settings - Fork 22
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
Niloofar/Added menu item component #189
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
Pull Request Test Coverage Report for Build 9011988756Details
💛 - Coveralls |
.deriv-menu-item { | ||
display: flex; | ||
align-items: center; | ||
height: 100%; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this?
because without any parents this won't be applied on the element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @shayan-deriv it's better to be there cause we are using menuItem in the div and it definitely have a parent so we need this.
type TMenuItem = ComponentProps<"a" | "button"> & { | ||
as: "a" | "button"; | ||
leftComponent?: ReactNode; | ||
rightComponent?: ReactNode; | ||
disableHover?: boolean; | ||
active?: boolean; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type TMenuItem = ComponentProps<"a" | "button"> & { | |
as: "a" | "button"; | |
leftComponent?: ReactNode; | |
rightComponent?: ReactNode; | |
disableHover?: boolean; | |
active?: boolean; | |
}; | |
// Base Props for MenuItem without the 'as' property | |
interface BaseMenuItemProps { | |
leftComponent?: ReactNode; | |
rightComponent?: ReactNode; | |
disableHover?: boolean; | |
active?: boolean; | |
} | |
// Conditional props that extract the correct attributes for 'a' or 'button' | |
type ConditionalProps<T extends "a" | "button"> = ComponentProps<T> & BaseMenuItemProps & { | |
as: T; | |
}; | |
// TMenuItem type that uses conditional types based on the 'as' property | |
type TMenuItem = ConditionalProps<"a"> | ConditionalProps<"button">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to send href
attribute when as
property was set to button
. This type will prevent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @hasan-deriv that's a great suggestion but as we talked we have an issue with ref type and since we are going to deliver this component ASAP I'm going to ignore this for now later we can improve the types 🙏
Deploying deriv-ui with Cloudflare Pages
|
🎉 This PR is included in version 1.21.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR introduces the
MenuItem
component, designed to render dynamically as either a<button>
or an<a>
tag based on the passed props.This flexibility allows the component to function in various contexts throughout our application, such as navigating to different pages or performing in-page actions.
Screen.Recording.2024-05-09.at.11.34.09.AM.mov