[WEB-4727] feat: propel cards (#7630)
* feat: add card component to propel package and update tooltip imports * refactor: remove @plane/ui dependency and update tooltip imports to use local card component * fix: lint * refactor: update import from @plane/ui to @plane/utils in command component * refactor: extend CardProps interface to include HTML attributes for better flexibility
This commit is contained in:
parent
c2464939fc
commit
8801ab0081
9 changed files with 84 additions and 8 deletions
|
|
@ -25,6 +25,7 @@
|
|||
"./combobox": "./src/combobox/index.ts",
|
||||
"./tooltip": "./src/tooltip/index.ts",
|
||||
"./styles/fonts": "./src/styles/fonts/index.css",
|
||||
"./card": "./src/card/index.ts",
|
||||
"./switch": "./src/switch/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
@ -32,7 +33,6 @@
|
|||
"@plane/constants": "workspace:*",
|
||||
"@plane/hooks": "workspace:*",
|
||||
"@plane/types": "workspace:*",
|
||||
"@plane/ui": "workspace:*",
|
||||
"@plane/utils": "workspace:*",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
|
|
|
|||
41
packages/propel/src/card/card.tsx
Normal file
41
packages/propel/src/card/card.tsx
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import * as React from "react";
|
||||
import { cn } from "@plane/utils";
|
||||
import {
|
||||
ECardDirection,
|
||||
ECardSpacing,
|
||||
ECardVariant,
|
||||
getCardStyle,
|
||||
TCardDirection,
|
||||
TCardSpacing,
|
||||
TCardVariant,
|
||||
} from "./helper";
|
||||
|
||||
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
variant?: TCardVariant;
|
||||
spacing?: TCardSpacing;
|
||||
direction?: TCardDirection;
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
const Card = React.forwardRef<HTMLDivElement, CardProps>((props, ref) => {
|
||||
const {
|
||||
variant = ECardVariant.WITH_SHADOW,
|
||||
direction = ECardDirection.COLUMN,
|
||||
className = "",
|
||||
spacing = ECardSpacing.LG,
|
||||
children,
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
const style = getCardStyle(variant, spacing, direction);
|
||||
return (
|
||||
<div ref={ref} className={cn(style, className)} {...rest}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
Card.displayName = "plane-ui-card";
|
||||
|
||||
export { Card, ECardVariant, ECardSpacing, ECardDirection };
|
||||
36
packages/propel/src/card/helper.tsx
Normal file
36
packages/propel/src/card/helper.tsx
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
export enum ECardVariant {
|
||||
WITHOUT_SHADOW = "without-shadow",
|
||||
WITH_SHADOW = "with-shadow",
|
||||
}
|
||||
export enum ECardDirection {
|
||||
ROW = "row",
|
||||
COLUMN = "column",
|
||||
}
|
||||
export enum ECardSpacing {
|
||||
SM = "sm",
|
||||
LG = "lg",
|
||||
}
|
||||
export type TCardVariant = ECardVariant.WITHOUT_SHADOW | ECardVariant.WITH_SHADOW;
|
||||
export type TCardDirection = ECardDirection.ROW | ECardDirection.COLUMN;
|
||||
export type TCardSpacing = ECardSpacing.SM | ECardSpacing.LG;
|
||||
|
||||
export interface ICardProperties {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
const DEFAULT_STYLE =
|
||||
"bg-custom-background-100 rounded-lg border-[0.5px] border-custom-border-200 w-full flex flex-col";
|
||||
export const containerStyle: ICardProperties = {
|
||||
[ECardVariant.WITHOUT_SHADOW]: "",
|
||||
[ECardVariant.WITH_SHADOW]: "hover:shadow-custom-shadow-4xl duration-300",
|
||||
};
|
||||
export const spacings = {
|
||||
[ECardSpacing.SM]: "p-4",
|
||||
[ECardSpacing.LG]: "p-6",
|
||||
};
|
||||
export const directions = {
|
||||
[ECardDirection.ROW]: "flex-row space-x-3",
|
||||
[ECardDirection.COLUMN]: "flex-col space-y-3",
|
||||
};
|
||||
export const getCardStyle = (variant: TCardVariant, spacing: TCardSpacing, direction: TCardDirection) =>
|
||||
DEFAULT_STYLE + " " + directions[direction] + " " + containerStyle[variant] + " " + spacings[spacing];
|
||||
1
packages/propel/src/card/index.ts
Normal file
1
packages/propel/src/card/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./card";
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { NameType, Payload, ValueType } from "recharts/types/component/DefaultTooltipContent";
|
||||
// plane imports
|
||||
import { Card, ECardSpacing } from "@plane/ui";
|
||||
import { Card, ECardSpacing } from "../../card";
|
||||
|
||||
import { cn } from "@plane/utils";
|
||||
|
||||
type Props = {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React from "react";
|
||||
import { NameType, Payload, ValueType } from "recharts/types/component/DefaultTooltipContent";
|
||||
// plane imports
|
||||
import { Card, ECardSpacing } from "@plane/ui";
|
||||
import { Card, ECardSpacing } from "../../card";
|
||||
|
||||
type Props = {
|
||||
dotColor?: string;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React from "react";
|
||||
// plane imports
|
||||
import { Card, ECardSpacing } from "@plane/ui";
|
||||
import { Card, ECardSpacing } from "../../card";
|
||||
|
||||
interface TreeMapTooltipProps {
|
||||
active: boolean | undefined;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
TCardVariant,
|
||||
} from "./helper";
|
||||
|
||||
export interface CardProps {
|
||||
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
variant?: TCardVariant;
|
||||
spacing?: TCardSpacing;
|
||||
direction?: TCardDirection;
|
||||
|
|
|
|||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
|
|
@ -961,9 +961,6 @@ importers:
|
|||
'@plane/types':
|
||||
specifier: workspace:*
|
||||
version: link:../types
|
||||
'@plane/ui':
|
||||
specifier: workspace:*
|
||||
version: link:../ui
|
||||
'@plane/utils':
|
||||
specifier: workspace:*
|
||||
version: link:../utils
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue