-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added additional button component to make the pnael auto closable
- Loading branch information
coderwelsch
committed
Aug 6, 2024
1 parent
c842ffb
commit 56fa27c
Showing
4 changed files
with
94 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from "react"; | ||
import { PopoverButton as HeadlessUiPopoverButton } from "@headlessui/react"; | ||
import { classNames } from "../../util/class-names"; | ||
|
||
const itemIntents = { | ||
neutral: "text-neutral-700 fill-neutral-700 hover:bg-primary-100", | ||
danger: "text-danger-500 fill-danger-500 hover:bg-danger-100", | ||
}; | ||
|
||
const activeItemIntents = { | ||
neutral: "bg-primary-100 fill-primary-400 text-primary-400 before:bg-primary-400", | ||
danger: "bg-danger-100 fill-danger-400 text-danger-500 before:bg-danger-400", | ||
}; | ||
|
||
export interface PopoverMenuPanelButtonProps { | ||
children: React.ReactNode; | ||
onClick?: () => void; | ||
Icon?: React.ComponentType<{ className: string }>; | ||
variant?: keyof typeof itemIntents; | ||
active?: boolean; | ||
} | ||
|
||
export const PopoverMenuPanelButton = ({ | ||
children, | ||
onClick, | ||
Icon, | ||
variant = "neutral", | ||
active, | ||
}: PopoverMenuPanelButtonProps) => { | ||
return ( | ||
<HeadlessUiPopoverButton | ||
className={classNames( | ||
"relative flex w-full cursor-pointer flex-row items-center gap-3 overflow-hidden px-4 py-2 text-sm font-normal focus:ring-2 focus:ring-primary-200", | ||
itemIntents[variant], | ||
active && activeItemIntents[variant], | ||
active && | ||
"before:absolute before:left-0 before:top-0 before:h-full before:w-0.5 before:rounded-r-md" | ||
)} | ||
onClick={onClick} | ||
> | ||
{Icon && <Icon className={classNames("h-3.5 w-3.5")} />} | ||
{children} | ||
</HeadlessUiPopoverButton> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters