introduced size="fab" prop to Button, added to CTA buttons (#6176)

* introduced size="fab" prop to Button, added to CTA buttons

* increased size of FAB

* nit
This commit is contained in:
Peer Richelsen authored and GitHub committed 2023-01-02 09:28:12 +01:00
1 parent 5503539856
commit 71ee9c72fe
9 files changed
+100 -76

No files matched your search

+5 -2
View File
@@ -14,8 +14,11 @@ function Teams() {
heading={t("teams")}
subtitle={t("create_manage_teams_collaborative")}
CTA={
<Button type="button" href={`${WEBAPP_URL}/settings/teams/new?returnTo=/teams`}>
<Icon.FiPlus className="inline-block h-3.5 w-3.5 text-white group-hover:text-black ltr:mr-2 rtl:ml-2" />
<Button
size="fab"
StartIcon={Icon.FiPlus}
type="button"
href={`${WEBAPP_URL}/settings/teams/new?returnTo=/teams`}>
{t("new")}
</Button>
}>
-18
View File
@@ -215,17 +215,6 @@ button[role="switch"][data-state="checked"] {
background: black;
}
/* add padding bottom to bottom nav on standalone mode */
@media all and (display-mode: standalone) {
.bottom-nav {
padding-bottom: 24px;
}
.cta {
bottom: 100px;
}
}
/* hide chat bubble on mobile */
@media only screen and (max-width: 768px) {
/* Intercom FAB*/
@@ -247,13 +236,6 @@ button[role="switch"][data-state="checked"] {
}
}
/* add padding bottom to bottom nav on standalone mode */
@media all and (display-mode: standalone) {
.bottom-nav {
padding-bottom: 24px;
}
}
.react-multi-email > [type="text"] {
@apply dark:placeholder:text-darkgray-600 focus:border-brand dark:border-darkgray-300 dark:text-darkgray-900 block w-full rounded-md border-gray-300 text-sm focus:ring-black disabled:bg-gray-200 disabled:hover:cursor-not-allowed dark:bg-transparent dark:selection:bg-green-500 disabled:dark:text-gray-500 dark:text-white;
}
@@ -36,7 +36,12 @@ export default function RoutingForms({
function NewFormButton() {
return (
<FormAction routingForm={null} data-testid="new-routing-form" StartIcon={Icon.FiPlus} action="create">
<FormAction
size="fab"
routingForm={null}
data-testid="new-routing-form"
StartIcon={Icon.FiPlus}
action="create">
{t("new")}
</FormAction>
);
@@ -43,6 +43,7 @@ function WorkflowsPage() {
CTA={
session.data?.hasValidLicense && data?.workflows && data?.workflows.length > 0 ? (
<Button
size="fab"
StartIcon={Icon.FiPlus}
onClick={() => createMutation.mutate()}
loading={createMutation.isLoading}>
@@ -157,6 +157,7 @@ export default function CreateEventTypeButton(props: CreateEventTypeBtnProps) {
onClick={() => openModal(props.options[0])}
data-testid="new-event-type"
StartIcon={Icon.FiPlus}
size="fab"
disabled={!props.canAddEvents}>
{t("new")}
</Button>
@@ -165,11 +166,12 @@ export default function CreateEventTypeButton(props: CreateEventTypeBtnProps) {
<DropdownMenuTrigger asChild>
<Button
EndIcon={Icon.FiChevronDown}
size="fab"
className="radix-state-open:!bg-brand-500 radix-state-open:ring-2 radix-state-open:ring-brand-500 ring-offset-2 focus:border-none">
{t("new")}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuContent sideOffset={14} align="end">
<DropdownMenuLabel>
<div className="max-w-48">{t("new_event_subtitle")}</div>
</DropdownMenuLabel>
@@ -58,7 +58,7 @@ export function NewScheduleButton({ name = "new-schedule" }: { name?: string })
return (
<Dialog name={name} clearQueryParamsOnClose={["copy-schedule-id"]}>
<DialogTrigger asChild>
<Button data-testid={name} StartIcon={Icon.FiPlus}>
<Button size="fab" data-testid={name} StartIcon={Icon.FiPlus}>
{t("new")}
</Button>
</DialogTrigger>
+32 -5
View File
@@ -6,6 +6,7 @@ import classNames from "@calcom/lib/classNames";
import { applyStyleToMultipleVariants } from "@calcom/lib/cva";
import { SVGComponent } from "@calcom/types/SVGComponent";
import { Tooltip } from "@calcom/ui";
import { Icon } from "@calcom/ui";
type InferredVariantProps = VariantProps<typeof buttonClasses>;
@@ -45,6 +46,9 @@ const buttonClasses = cva(
base: "h-9 px-4 py-2.5 ",
lg: "h-[36px] px-4 py-2.5 ",
icon: "flex justify-center min-h-[36px] min-w-[36px] ",
// fab = floating action button, used for the main action in a page.
// it uses the same primary classNames for desktop size
fab: "h-14 w-14 sm:h-9 sm:w-auto rounded-full justify-center sm:rounded-md sm:px-4 sm:py-2.5 radix-state-open:rotate-45 sm:radix-state-open:rotate-0 transition-transform radix-state-open:shadown-none radix-state-open:ring-0 !shadow-none",
},
loading: {
true: "cursor-wait",
@@ -176,11 +180,23 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
},
<>
{StartIcon && (
<StartIcon
className={classNames("inline-flex", size === "icon" ? "h-4 w-4 " : "mr-2 h-4 w-4 stroke-[1.5px]")}
/>
<>
{size === "fab" ? (
<>
<StartIcon className="mr-2 hidden h-4 w-4 stroke-[1.5px] sm:inline-flex" />
<Icon.FiPlus className="inline h-6 w-6 sm:hidden" />
</>
) : (
<StartIcon
className={classNames(
"inline-flex",
size === "icon" ? "h-4 w-4 " : "mr-2 h-4 w-4 stroke-[1.5px]"
)}
/>
)}
</>
)}
{props.children}
{size === "fab" ? <span className="hidden sm:inline">{props.children}</span> : props.children}
{loading && (
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 transform">
<svg
@@ -197,7 +213,18 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
</svg>
</div>
)}
{EndIcon && <EndIcon className="-mr-1 inline h-5 w-5 ltr:ml-2 rtl:mr-2" />}
{EndIcon && (
<>
{size === "fab" ? (
<>
<EndIcon className="-mr-1 hidden h-5 w-5 ltr:ml-2 rtl:mr-2 sm:inline" />
<Icon.FiPlus className="inline h-6 w-6 sm:hidden" />
</>
) : (
<EndIcon className="-mr-1 inline h-5 w-5 ltr:ml-2 rtl:mr-2" />
)}
</>
)}
</>
);
+4 -3
View File
@@ -15,7 +15,7 @@ export const DropdownMenuTrigger = forwardRef<HTMLButtonElement, DropdownMenuTri
{...props}
className={
props.asChild
? classNames(className, "radix-state-open:bg-gray-100 rounded-md ring-0")
? classNames(className, "rounded-md ring-0")
: `inline-flex items-center rounded-md bg-transparent px-3 py-2 text-sm font-medium text-gray-700 ring-0 hover:bg-gray-50 focus:bg-gray-100 group-hover:text-black ${className}`
}
ref={forwardedRef}
@@ -30,12 +30,13 @@ export const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
type DropdownMenuContentProps = ComponentProps<typeof DropdownMenuPrimitive["Content"]>;
export const DropdownMenuContent = forwardRef<HTMLDivElement, DropdownMenuContentProps>(
({ children, align = "end", ...props }, forwardedRef) => {
({ children, sideOffset = 2, align = "end", ...props }, forwardedRef) => {
return (
<DropdownMenuPrimitive.Content
align={align}
{...props}
className="shadow-dropdown w-50 relative z-10 mt-1 -ml-0 origin-top-right rounded-md border border-gray-200 bg-white text-sm"
sideOffset={sideOffset}
className="shadow-dropdown w-50 relative z-10 origin-top-right rounded-md border border-gray-200 bg-white text-sm"
ref={forwardedRef}>
{children}
</DropdownMenuPrimitive.Content>
+48 -45
View File
@@ -254,50 +254,53 @@ function UserDropdown({ small }: { small?: boolean }) {
}
return (
<Dropdown open={menuOpen}>
<DropdownMenuTrigger asChild onClick={() => setMenuOpen((menuOpen) => !menuOpen)}>
<button className="group flex w-full cursor-pointer appearance-none items-center rounded-full p-2 text-left outline-none hover:bg-gray-200 sm:pl-3 md:rounded lg:pl-2">
<span
className={classNames(
small ? "h-6 w-6" : "h-8 w-8 ltr:mr-2 rtl:ml-3",
"relative flex-shrink-0 rounded-full bg-gray-300 "
)}>
{
// eslint-disable-next-line @next/next/no-img-element
<img
className="rounded-full"
src={WEBAPP_URL + "/" + user.username + "/avatar.png"}
alt={user.username || "Nameless User"}
/>
}
{!user.away && (
<div className="absolute bottom-0 right-0 h-3 w-3 rounded-full border-2 border-white bg-green-500" />
)}
{user.away && (
<div className="absolute bottom-0 right-0 h-3 w-3 rounded-full border-2 border-white bg-yellow-500" />
)}
</span>
{!small && (
<span className="flex flex-grow items-center truncate">
<span className="flex-grow truncate text-sm">
<span className="block truncate font-medium text-gray-900">
{user.name || "Nameless User"}
</span>
<span className="block truncate font-normal text-gray-900">
{user.username
? process.env.NEXT_PUBLIC_WEBSITE_URL === "https://cal.com"
? `cal.com/${user.username}`
: `/${user.username}`
: "No public page"}
</span>
</span>
<Icon.FiMoreVertical
className="h-4 w-4 flex-shrink-0 text-gray-400 group-hover:text-gray-500"
aria-hidden="true"
/>
<div className="ltr:sm:-ml-5 rtl:sm:-mr-5">
<DropdownMenuTrigger asChild onClick={() => setMenuOpen((menuOpen) => !menuOpen)}>
<button className="group mx-0 flex w-full cursor-pointer appearance-none items-center rounded-full p-2 text-left outline-none hover:bg-gray-200 focus:outline-none focus:ring-0 sm:mx-2.5 sm:pl-3 md:rounded-none lg:rounded lg:pl-2">
<span
className={classNames(
small ? "h-6 w-6" : "h-8 w-8 ltr:mr-2 rtl:ml-3",
"relative flex-shrink-0 rounded-full bg-gray-300 "
)}>
{
// eslint-disable-next-line @next/next/no-img-element
<img
className="rounded-full"
src={WEBAPP_URL + "/" + user.username + "/avatar.png"}
alt={user.username || "Nameless User"}
/>
}
{!user.away && (
<div className="absolute bottom-0 right-0 h-3 w-3 rounded-full border-2 border-white bg-green-500" />
)}
{user.away && (
<div className="absolute bottom-0 right-0 h-3 w-3 rounded-full border-2 border-white bg-yellow-500" />
)}
</span>
)}
</button>
</DropdownMenuTrigger>
{!small && (
<span className="flex flex-grow items-center truncate">
<span className="flex-grow truncate text-sm">
<span className="block truncate font-medium text-gray-900">
{user.name || "Nameless User"}
</span>
<span className="block truncate font-normal text-gray-900">
{user.username
? process.env.NEXT_PUBLIC_WEBSITE_URL === "https://cal.com"
? `cal.com/${user.username}`
: `/${user.username}`
: "No public page"}
</span>
</span>
<Icon.FiMoreVertical
className="h-4 w-4 flex-shrink-0 text-gray-400 group-hover:text-gray-500 rtl:mr-2"
aria-hidden="true"
/>
</span>
)}
</button>
</DropdownMenuTrigger>
</div>
<DropdownMenuPortal>
<DropdownMenuContent
onInteractOutside={() => {
@@ -782,7 +785,7 @@ function SideBar() {
{isCalcom && <Tips />}
<div className="fixed left-1 bottom-0 w-4 bg-gray-50 before:absolute before:left-0 before:-top-20 before:h-20 before:w-48 before:bg-gradient-to-t before:from-gray-50 before:to-transparent lg:left-4 lg:w-48">
<div className="fixed bottom-0 w-4 bg-gray-50 before:absolute before:left-0 before:-top-20 before:h-20 before:w-48 before:bg-gradient-to-t before:from-gray-50 before:to-transparent ltr:left-1 rtl:right-1 md:w-14 md:px-2 lg:w-48 lg:px-0 ltr:lg:left-4 rtl:lg:right-4">
<div data-testid="user-dropdown-trigger">
<span className="hidden lg:inline">
<UserDropdown />
@@ -838,7 +841,7 @@ export function ShellMain(props: LayoutProps) {
{props.CTA && (
<div
className={classNames(
props.backPath ? "relative" : "fixed right-4 bottom-[88px] z-40 ",
props.backPath ? "relative" : " fixed right-4 bottom-[88px] z-40 sm:z-auto",
"flex-shrink-0 sm:relative sm:bottom-auto sm:right-auto"
)}>
{props.CTA}