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

chore: added className props to the PlatformSwitcher component #217

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/AppLayout/PlatformSwitcher/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useState,
JSX,
} from "react";
import clsx from "clsx";
import { useOnClickOutside } from "usehooks-ts";
import { PlatformSwitcherButton } from "./PlatformSwitcherButton";
import { ContextMenu } from "../../ContextMenu";
Expand All @@ -17,6 +18,7 @@ type TPlatformSwitcher = {
>;
bottomLinkLabel?: string | JSX.Element;
bottomLinkProps?: ComponentProps<"a">;
itemsWrapperClassName?: string;
};

/**
Expand All @@ -29,6 +31,7 @@ type TPlatformSwitcher = {
* @param {React.ReactNode} props.children - The children elements to be rendered inside the context menu. These could be additional links, buttons, or other interactive elements.
* @param {string | JSX.Element} [props.bottomLinkLabel] - Optional label for a bottom link in the context menu, can be a string or JSX element.
* @param {ComponentProps<"a">} [props.bottomLinkProps] - Optional props for the bottom link, assuming it's rendered as an `<a>` tag.
* @param {string} props.itemsWrapperClassName - Optional prop for adding additional className to the item's wrapper.
*
* @example
* <PlatformSwitcher
Expand All @@ -45,6 +48,7 @@ export const PlatformSwitcher = ({
children,
bottomLinkLabel,
bottomLinkProps,
itemsWrapperClassName,
}: PropsWithChildren<TPlatformSwitcher>) => {
const [isExpanded, setExpanded] = useState(false);
const ref = useRef(null);
Expand All @@ -69,7 +73,10 @@ export const PlatformSwitcher = ({
{isExpanded && <div className="deriv-platform-switcher__overlay" />}
<ContextMenu
ref={ref}
className="deriv-platform-switcher__context-menu"
className={clsx(
"deriv-platform-switcher__context-menu",
itemsWrapperClassName,
)}
isOpen={isExpanded}
>
<div className="deriv-platform-switcher__context-menu__wrapper">
Expand Down
Loading