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:
80
apps/web/core/components/empty-state/comic-box-button.tsx
Normal file
80
apps/web/core/components/empty-state/comic-box-button.tsx
Normal file
@@ -0,0 +1,80 @@
|
||||
"use client";
|
||||
|
||||
import type { Ref } from "react";
|
||||
import { Fragment, useState } from "react";
|
||||
import { usePopper } from "react-popper";
|
||||
import { Popover } from "@headlessui/react";
|
||||
// popper
|
||||
// helper
|
||||
import { getButtonStyling } from "@plane/propel/button";
|
||||
|
||||
type Props = {
|
||||
label: string;
|
||||
icon?: any;
|
||||
title: string | undefined;
|
||||
description: string | undefined;
|
||||
onClick?: () => void;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
export const ComicBoxButton: React.FC<Props> = (props) => {
|
||||
const { label, icon, title, description, onClick, disabled = false } = props;
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
|
||||
const handleMouseEnter = () => {
|
||||
setIsHovered(true);
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
setIsHovered(false);
|
||||
};
|
||||
|
||||
const [referenceElement, setReferenceElement] = useState<HTMLButtonElement | null>(null);
|
||||
const [popperElement, setPopperElement] = useState<HTMLDivElement | null>();
|
||||
const { styles, attributes } = usePopper(referenceElement, popperElement, {
|
||||
placement: "right-end",
|
||||
modifiers: [
|
||||
{
|
||||
name: "offset",
|
||||
options: {
|
||||
offset: [0, 10],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
return (
|
||||
<Popover as="div" className="relative">
|
||||
<Popover.Button as={Fragment}>
|
||||
<button type="button" ref={setReferenceElement} onClick={onClick} disabled={disabled}>
|
||||
<div className={`flex items-center gap-2.5 ${getButtonStyling("primary", "lg", disabled)}`}>
|
||||
{icon}
|
||||
<span className="leading-4">{label}</span>
|
||||
<span className="relative h-2 w-2">
|
||||
<div
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
className={`absolute bg-blue-300 right-0 z-10 h-2.5 w-2.5 animate-ping rounded-full`}
|
||||
/>
|
||||
<div className={`absolute bg-blue-400/40 right-0 h-1.5 w-1.5 mt-0.5 mr-0.5 rounded-full`} />
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
</Popover.Button>
|
||||
{isHovered && (
|
||||
<Popover.Panel className="fixed z-10" static>
|
||||
<div
|
||||
className="flex flex-col rounded border border-custom-border-200 bg-custom-background-100 p-5 relative w-52 lg:w-60 xl:w-80"
|
||||
ref={setPopperElement as Ref<HTMLDivElement>}
|
||||
style={styles.popper}
|
||||
{...attributes.popper}
|
||||
>
|
||||
<div className="absolute w-2 h-2 bg-custom-background-100 border rounded-lb-sm border-custom-border-200 border-r-0 border-t-0 transform rotate-45 bottom-2 -left-[5px]" />
|
||||
<h3 className="text-lg font-semibold w-full">{title}</h3>
|
||||
<h4 className="mt-1 text-sm">{description}</h4>
|
||||
</div>
|
||||
</Popover.Panel>
|
||||
)}
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
@@ -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>
|
||||
);
|
||||
});
|
||||
2
apps/web/core/components/empty-state/helper.tsx
Normal file
2
apps/web/core/components/empty-state/helper.tsx
Normal file
@@ -0,0 +1,2 @@
|
||||
export const getEmptyStateImagePath = (category: string, type: string, isLightMode: boolean) =>
|
||||
`/empty-state/${category}/${type}-${isLightMode ? "light" : "dark"}.webp`;
|
||||
@@ -0,0 +1,31 @@
|
||||
"use client";
|
||||
|
||||
import type { FC } from "react";
|
||||
import { cn } from "@plane/utils";
|
||||
|
||||
type Props = {
|
||||
icon: React.ReactNode;
|
||||
title: string;
|
||||
description?: string;
|
||||
actionElement?: React.ReactNode;
|
||||
customClassName?: string;
|
||||
};
|
||||
|
||||
export const SectionEmptyState: FC<Props> = (props) => {
|
||||
const { title, description, icon, actionElement, customClassName } = props;
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col gap-4 items-center justify-center rounded-md border border-custom-border-200 p-10",
|
||||
customClassName
|
||||
)}
|
||||
>
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<div className="flex items-center justify-center size-8 bg-custom-background-80 rounded">{icon}</div>
|
||||
<span className="text-sm font-medium">{title}</span>
|
||||
{description && <span className="text-xs text-custom-text-300">{description}</span>}
|
||||
</div>
|
||||
{actionElement && <>{actionElement}</>}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,58 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import Image from "next/image";
|
||||
// utils
|
||||
import { cn } from "@plane/utils";
|
||||
|
||||
type EmptyStateSize = "sm" | "lg";
|
||||
|
||||
type Props = {
|
||||
title: string;
|
||||
description?: string;
|
||||
assetPath?: string;
|
||||
size?: EmptyStateSize;
|
||||
};
|
||||
|
||||
const sizeConfig = {
|
||||
sm: {
|
||||
container: "size-24",
|
||||
dimensions: 78,
|
||||
},
|
||||
lg: {
|
||||
container: "size-28",
|
||||
dimensions: 96,
|
||||
},
|
||||
} as const;
|
||||
|
||||
const getTitleClassName = (hasDescription: boolean) =>
|
||||
cn("font-medium whitespace-pre-line", {
|
||||
"text-sm text-custom-text-400": !hasDescription,
|
||||
"text-lg text-custom-text-300": hasDescription,
|
||||
});
|
||||
|
||||
export const SimpleEmptyState = observer((props: Props) => {
|
||||
const { title, description, size = "sm", assetPath } = props;
|
||||
|
||||
return (
|
||||
<div className="text-center flex flex-col gap-2.5 items-center">
|
||||
{assetPath && (
|
||||
<div className={sizeConfig[size].container}>
|
||||
<Image
|
||||
src={assetPath}
|
||||
alt={title}
|
||||
height={sizeConfig[size].dimensions}
|
||||
width={sizeConfig[size].dimensions}
|
||||
layout="responsive"
|
||||
lazyBoundary="100%"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<h3 className={getTitleClassName(!!description)}>{title}</h3>
|
||||
|
||||
{description && <p className="text-base font-medium text-custom-text-400 whitespace-pre-line">{description}</p>}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user