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

Niloofar/Added menu item component #189

Merged
merged 2 commits into from
May 9, 2024
Merged

Niloofar/Added menu item component #189

merged 2 commits into from
May 9, 2024

Conversation

niloofar-deriv
Copy link
Contributor

@niloofar-deriv niloofar-deriv commented May 8, 2024

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

Screenshot 2024-05-08 at 6 14 15 PM
Screenshot 2024-05-08 at 6 14 24 PM

Copy link

github-actions bot commented May 8, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@coveralls
Copy link

coveralls commented May 8, 2024

Pull Request Test Coverage Report for Build 9011988756

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 60.929%

Totals Coverage Status
Change from base Build 8997153876: 0.0%
Covered Lines: 219
Relevant Lines: 347

💛 - Coveralls

.deriv-menu-item {
display: flex;
align-items: center;
height: 100%;
Copy link
Contributor

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.

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 @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.

Comment on lines 19 to 25
type TMenuItem = ComponentProps<"a" | "button"> & {
as: "a" | "button";
leftComponent?: ReactNode;
rightComponent?: ReactNode;
disableHover?: boolean;
active?: boolean;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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">;

Copy link
Contributor

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

Copy link
Contributor Author

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 🙏

Copy link

cloudflare-workers-and-pages bot commented May 9, 2024

Deploying deriv-ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7e45efe
Status: ✅  Deploy successful!
Preview URL: https://7398830d.deriv-ui.pages.dev
Branch Preview URL: https://niloofar-menu-item.deriv-ui.pages.dev

View logs

@shayan-deriv shayan-deriv merged commit 114fa34 into main May 9, 2024
7 checks passed
@shayan-deriv shayan-deriv deleted the niloofar/menu-item branch May 9, 2024 03:39
Copy link

github-actions bot commented May 9, 2024

🎉 This PR is included in version 1.21.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants