Initial commit: Plane
Some checks failed
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Admin Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Codespell / Check for spelling errors (push) Has been cancelled
Sync Repositories / sync_changes (push) Has been cancelled
Some checks failed
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Admin Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Codespell / Check for spelling errors (push) Has been cancelled
Sync Repositories / sync_changes (push) Has been cancelled
Synced from upstream: 8853637e981ed7d8a6cff32bd98e7afe20f54362
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
// ui
|
||||
import { Button } from "@plane/propel/button";
|
||||
// utils
|
||||
import { cn } from "@plane/utils";
|
||||
|
||||
type EmptyStateSize = "sm" | "md" | "lg";
|
||||
|
||||
type ButtonConfig = {
|
||||
text: string;
|
||||
prependIcon?: React.ReactNode;
|
||||
appendIcon?: React.ReactNode;
|
||||
onClick?: () => void;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
title: string;
|
||||
description?: string;
|
||||
assetPath?: string;
|
||||
size?: EmptyStateSize;
|
||||
primaryButton?: ButtonConfig;
|
||||
secondaryButton?: ButtonConfig;
|
||||
customPrimaryButton?: React.ReactNode;
|
||||
customSecondaryButton?: React.ReactNode;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
const sizeClasses = {
|
||||
sm: "md:min-w-[24rem] max-w-[45rem]",
|
||||
md: "md:min-w-[28rem] max-w-[50rem]",
|
||||
lg: "md:min-w-[30rem] max-w-[60rem]",
|
||||
} as const;
|
||||
|
||||
const CustomButton = ({
|
||||
config,
|
||||
variant,
|
||||
size,
|
||||
}: {
|
||||
config: ButtonConfig;
|
||||
variant: "primary" | "neutral-primary";
|
||||
size: EmptyStateSize;
|
||||
}) => (
|
||||
<Button
|
||||
variant={variant}
|
||||
size={size}
|
||||
onClick={config.onClick}
|
||||
prependIcon={config.prependIcon}
|
||||
appendIcon={config.appendIcon}
|
||||
disabled={config.disabled}
|
||||
>
|
||||
{config.text}
|
||||
</Button>
|
||||
);
|
||||
|
||||
export const DetailedEmptyState: React.FC<Props> = observer((props) => {
|
||||
const {
|
||||
title,
|
||||
description,
|
||||
size = "lg",
|
||||
primaryButton,
|
||||
secondaryButton,
|
||||
customPrimaryButton,
|
||||
customSecondaryButton,
|
||||
assetPath,
|
||||
className,
|
||||
} = props;
|
||||
|
||||
const hasButtons = primaryButton || secondaryButton || customPrimaryButton || customSecondaryButton;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center justify-center min-h-full min-w-full overflow-y-auto py-10 md:px-20 px-5",
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div className={cn("flex flex-col gap-5", sizeClasses[size])}>
|
||||
<div className="flex flex-col gap-1.5 flex-shrink">
|
||||
<h3 className={cn("text-xl font-semibold", { "font-medium": !description })}>{title}</h3>
|
||||
{description && <p className="text-sm">{description}</p>}
|
||||
</div>
|
||||
|
||||
{assetPath && <img src={assetPath} alt={title} className="w-full h-auto" loading="lazy" />}
|
||||
|
||||
{hasButtons && (
|
||||
<div className="relative flex items-center justify-center gap-2 flex-shrink-0 w-full">
|
||||
{/* primary button */}
|
||||
{customPrimaryButton ??
|
||||
(primaryButton?.text && <CustomButton config={primaryButton} variant="primary" size={size} />)}
|
||||
{/* secondary button */}
|
||||
{customSecondaryButton ??
|
||||
(secondaryButton?.text && (
|
||||
<CustomButton config={secondaryButton} variant="neutral-primary" size={size} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user