fix: styling of dropdown component (#6440)

* fix: styling of dropdown component

Signed-off-by: Udit Takkar <[email protected]>

* Apply suggestions from code review

* fix: use dropdown item in all pages

Signed-off-by: Udit Takkar <[email protected]>

* chore: undo

Signed-off-by: Udit Takkar <[email protected]>

Signed-off-by: Udit Takkar <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
Udit TakkarandPeer Richelsen authored and GitHub committed 2023-01-15 11:40:40 +00:00
1 parent 34a61214d3
commit 636e88d467
17 files changed
+189 -183

No files matched your search

@@ -34,6 +34,7 @@ import {
Dropdown,
DropdownMenuTrigger,
DropdownMenuItem,
DropdownItem,
DropdownMenuContent,
Button,
} from "@calcom/ui";
@@ -393,7 +394,7 @@ export default function ToolbarPlugin(props: TextEditorProps) {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
}
}, [editor, isLink]);
console.log("TEST", blockTypeToBlockName[blockType]);
return (
<div className="toolbar flex" ref={toolbarRef}>
<>
@@ -5,6 +5,7 @@ import { ComponentProps, forwardRef } from "react";
import { classNames } from "@calcom/lib";
import { SVGComponent } from "@calcom/types/SVGComponent";
import { ButtonProps } from "@calcom/ui";
export const Dropdown = DropdownMenuPrimitive.Root;
@@ -36,7 +37,10 @@ export const DropdownMenuContent = forwardRef<HTMLDivElement, DropdownMenuConten
align={align}
{...props}
sideOffset={sideOffset}
className="shadow-dropdown w-50 relative z-10 origin-top-right rounded-md border border-gray-200 bg-white text-sm"
className={classNames(
"shadow-dropdown w-50 relative z-10 origin-top-right rounded-md border border-gray-200 bg-white text-sm",
"[&>*:first-child]:mt-1 [&>*:last-child]:mb-1"
)}
ref={forwardedRef}>
{children}
</DropdownMenuPrimitive.Content>
@@ -98,7 +102,7 @@ DropdownMenuRadioItem.displayName = "DropdownMenuRadioItem";
type DropdownItemProps = {
children: React.ReactNode;
color?: "destructive";
color?: ButtonProps["color"];
StartIcon?: SVGComponent;
EndIcon?: SVGComponent;
href?: string;
@@ -131,17 +135,29 @@ export const DropdownItem = (props: DropdownItemProps) => {
{...props}
className={classNames(
"inline-flex w-full items-center px-3 py-2 text-gray-700 hover:text-gray-900",
props.color === "destructive" ? "hover:bg-red-100 hover:text-red-700" : " hover:bg-gray-100"
props.color === "destructive" ? "hover:bg-red-100 hover:text-red-700" : "hover:bg-gray-100"
)}>
<>
{StartIcon && <StartIcon />}
<div className="mx-2">{props.children}</div>
{EndIcon && <EndIcon />}
{StartIcon && <StartIcon className="h-4 w-4" />}
<div className="mx-3 text-sm font-medium leading-5">{props.children}</div>
{EndIcon && <EndIcon className="h-4 w-4" />}
</>
</ButtonOrLink>
);
};
export const DropdownMenuSeparator = DropdownMenuPrimitive.Separator;
type DropdownMenuSeparatorProps = ComponentProps<typeof DropdownMenuPrimitive["Separator"]>;
export const DropdownMenuSeparator = forwardRef<HTMLDivElement, DropdownMenuSeparatorProps>(
({ className = "", ...props }, forwardedRef) => {
return (
<DropdownMenuPrimitive.Separator
className={classNames("my-1 h-px bg-gray-200", className)}
{...props}
ref={forwardedRef}
/>
);
}
);
DropdownMenuSeparator.displayName = "DropdownMenuSeparator";
export default Dropdown;
@@ -6,6 +6,7 @@ import {
Dropdown,
DropdownMenuContent,
DropdownMenuItem,
DropdownItem,
DropdownMenuPortal,
DropdownMenuTrigger,
ButtonBaseProps,
@@ -53,16 +54,15 @@ export const DropdownActions = ({
<DropdownMenuContent>
{actions.map((action) => (
<DropdownMenuItem key={action.id}>
<Button
<DropdownItem
type="button"
color={action.color || "minimal"}
className="w-full rounded-none font-normal"
href={action.href}
color={action.color}
data-testid={action.id}
StartIcon={action.icon}
onClick={action.onClick || defaultAction}
data-testid={action.id}>
href={action.href}
onClick={action.onClick || defaultAction}>
{action.label}
</Button>
</DropdownItem>
</DropdownMenuItem>
))}
</DropdownMenuContent>