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

Add zIndex and appendTo to ActionMenuButton components #787

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import {
stenaAngleDown,
} from "@stenajs-webui/elements";
import { useBoolean } from "@stenajs-webui/core";
import { ControlledPopover, PopoverProps } from "@stenajs-webui/tooltip";
import {
ControlledPopover,
ControlledPopoverProps,
PopoverProps,
} from "@stenajs-webui/tooltip";

export interface ActionMenuButtonProps
extends Omit<
Expand All @@ -22,6 +26,10 @@ export interface ActionMenuButtonProps
renderItems: (close: () => void) => ReactNode;
/** The placement of the Action Menu. */
placement?: PopoverProps["placement"];
/** Z-index of the Action Menu */
zIndex?: number;
/** Portal target, HTML element. If not set, portal is not used. */
appendTo?: ControlledPopoverProps["appendTo"];
menuWidth?: ActionMenuProps["width"];
menuTop?: ActionMenuProps["top"];
buttonComponent:
Expand All @@ -42,6 +50,8 @@ export const ActionMenuButton: React.FC<ActionMenuButtonProps> = ({
onClick,
disableArrow = false,
buttonRef,
appendTo,
zIndex,
...buttonProps
}) => {
const [isOpen, open, close, toggle] = useBoolean(false);
Expand Down Expand Up @@ -75,6 +85,8 @@ export const ActionMenuButton: React.FC<ActionMenuButtonProps> = ({
open={isOpen}
onRequestClose={close}
placement={placement}
appendTo={appendTo}
zIndex={zIndex}
>
{isOpen && (
<ActionMenu width={menuWidth} top={menuTop} trapFocus>
Expand Down
35 changes: 22 additions & 13 deletions packages/panels/src/components/nav-bar/NavBarNotificationButton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { FlatButtonProps, stenaBellFilled } from "@stenajs-webui/elements";
import {
BaseButton,
FlatButtonProps,
stenaBellFilled,
} from "@stenajs-webui/elements";
import * as React from "react";
import { forwardRef } from "react";
import cx from "classnames";
import styles from "./NavBarNotificationButton.module.css";
import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
import { BaseButton } from "@stenajs-webui/elements";

export interface NavBarNotificationButtonProps
extends Omit<FlatButtonProps, "leftIcon" | "rightIcon" | "label"> {
Expand All @@ -12,22 +16,27 @@ export interface NavBarNotificationButtonProps
icon?: IconDefinition;
}

export const NavBarNotificationButton: React.FC<
export const NavBarNotificationButton = forwardRef<
HTMLButtonElement,
NavBarNotificationButtonProps
> = ({
count,
unread = false,
className,
labelClassName,
iconClassName,
icon = stenaBellFilled,
...buttonProps
}) => {
>(function (
{
count,
unread = false,
className,
labelClassName,
iconClassName,
icon = stenaBellFilled,
...buttonProps
},
ref
) {
const hasCount = count > 1;

return (
<BaseButton
{...buttonProps}
ref={ref}
leftIcon={icon}
className={cx(
styles.navBarNotificationButton,
Expand All @@ -40,4 +49,4 @@ export const NavBarNotificationButton: React.FC<
iconClassName={cx(iconClassName, styles.icon)}
/>
);
};
});
Loading