@mbao01/common 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/types/components/Badge/Badge.d.ts +1 -1
- package/dist/types/components/Badge/constants.d.ts +5 -5
- package/dist/types/components/Badge/types.d.ts +3 -7
- package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts +3 -0
- package/dist/types/components/Breadcrumbs/index.d.ts +1 -0
- package/dist/types/components/Breadcrumbs/types.d.ts +2 -0
- package/dist/types/components/Button/Button.d.ts +11 -2
- package/dist/types/components/Button/constants.d.ts +7 -8
- package/dist/types/components/Button/types.d.ts +6 -12
- package/dist/types/components/Card/Card.d.ts +1 -1
- package/dist/types/components/Card/constants.d.ts +6 -0
- package/dist/types/components/Card/types.d.ts +3 -18
- package/dist/types/components/Description/Description.d.ts +2 -2
- package/dist/types/components/Loading/Loading.d.ts +2 -0
- package/dist/types/components/Loading/constants.d.ts +5 -0
- package/dist/types/components/Loading/index.d.ts +1 -0
- package/dist/types/components/Loading/types.d.ts +3 -0
- package/dist/types/components/Skeleton/Skeleton.d.ts +1 -1
- package/dist/types/components/Skeleton/constants.d.ts +6 -5
- package/dist/types/components/Skeleton/types.d.ts +3 -7
- package/dist/types/components/Text/Text.d.ts +2 -4
- package/dist/types/components/Text/constants.d.ts +4 -5
- package/dist/types/components/Text/types.d.ts +4 -9
- package/dist/types/components/Tooltip/Tooltip.d.ts +14 -2
- package/dist/types/components/Tooltip/constants.d.ts +6 -5
- package/dist/types/components/Tooltip/types.d.ts +5 -10
- package/dist/types/index.d.ts +2 -0
- package/dist/types/libs/cva.d.ts +1 -0
- package/dist/types/libs/index.d.ts +1 -0
- package/dist/types/utilities/cn.d.ts +2 -0
- package/dist/types/utilities/getSubpaths/getSubpaths.d.ts +6 -0
- package/dist/types/utilities/getSubpaths/index.d.ts +1 -0
- package/dist/types/utilities/index.d.ts +2 -0
- package/package.json +11 -4
- package/plugin.js +1 -3
- package/src/components/Badge/Badge.tsx +4 -14
- package/src/components/Badge/constants.ts +28 -30
- package/src/components/Badge/types.ts +4 -17
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +13 -0
- package/src/components/Breadcrumbs/index.ts +1 -0
- package/src/components/Breadcrumbs/types.ts +3 -0
- package/src/components/Button/Button.tsx +51 -37
- package/src/components/Button/constants.ts +39 -43
- package/src/components/Button/types.ts +7 -25
- package/src/components/Card/Card.tsx +9 -15
- package/src/components/Card/constants.ts +22 -0
- package/src/components/Card/types.ts +4 -18
- package/src/components/Description/Description.tsx +11 -6
- package/src/components/Loading/Loading.tsx +18 -0
- package/src/components/Loading/constants.ts +30 -0
- package/src/components/Loading/index.ts +1 -0
- package/src/components/Loading/types.ts +5 -0
- package/src/components/Skeleton/Skeleton.tsx +7 -11
- package/src/components/Skeleton/constants.ts +39 -37
- package/src/components/Skeleton/types.ts +4 -7
- package/src/components/Text/Text.tsx +24 -9
- package/src/components/Text/constants.ts +26 -28
- package/src/components/Text/types.ts +9 -20
- package/src/components/Tooltip/Tooltip.tsx +35 -21
- package/src/components/Tooltip/constants.ts +32 -31
- package/src/components/Tooltip/types.ts +13 -22
- package/src/index.ts +2 -0
- package/src/libs/cva.ts +1 -0
- package/src/libs/index.ts +1 -0
- package/src/utilities/cn.ts +6 -0
- package/src/utilities/getSubpaths/getSubpaths.ts +34 -0
- package/src/utilities/getSubpaths/index.ts +1 -0
- package/src/utilities/index.ts +2 -0
- package/vitest-setup.ts +11 -1
|
@@ -1,44 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ButtonSize, ButtonVariant } from './types';
|
|
1
|
+
import { cva } from "../../libs";
|
|
3
2
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'min-h-fit h-10': !size,
|
|
43
|
-
});
|
|
44
|
-
};
|
|
3
|
+
export const getButtonClasses = cva("btn", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
accent: "btn-accent",
|
|
7
|
+
default: "btn-default",
|
|
8
|
+
error: "btn-error",
|
|
9
|
+
ghost: "btn-ghost",
|
|
10
|
+
info: "btn-info",
|
|
11
|
+
link: "btn-link",
|
|
12
|
+
neutral: "btn-neutral",
|
|
13
|
+
primary: "btn-primary",
|
|
14
|
+
secondary: "btn-secondary",
|
|
15
|
+
success: "btn-success",
|
|
16
|
+
warning: "btn-warning",
|
|
17
|
+
},
|
|
18
|
+
outline: {
|
|
19
|
+
true: "btn-outline",
|
|
20
|
+
},
|
|
21
|
+
wide: {
|
|
22
|
+
true: "btn-wide",
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
xs: "btn-xs",
|
|
26
|
+
sm: "btn-sm",
|
|
27
|
+
md: "btn-md",
|
|
28
|
+
lg: "btn-lg",
|
|
29
|
+
},
|
|
30
|
+
isLoading: {
|
|
31
|
+
true: "relative overflow-hidden",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
compoundVariants: [
|
|
35
|
+
{
|
|
36
|
+
size: undefined,
|
|
37
|
+
className: "min-h-fit h-10",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type VariantProps } from "../../libs";
|
|
2
|
+
import { type ButtonHTMLAttributes } from "react";
|
|
3
|
+
import { getButtonClasses } from "./constants";
|
|
2
4
|
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
| 'neutral'
|
|
8
|
-
| 'primary'
|
|
9
|
-
| 'secondary'
|
|
10
|
-
| 'accent'
|
|
11
|
-
| 'ghost'
|
|
12
|
-
| 'link'
|
|
13
|
-
| 'info'
|
|
14
|
-
| 'success'
|
|
15
|
-
| 'warning'
|
|
16
|
-
| 'error';
|
|
17
|
-
|
|
18
|
-
export type ButtonProps = {
|
|
19
|
-
size?: ButtonSize;
|
|
20
|
-
wide?: boolean;
|
|
21
|
-
label: ReactNode;
|
|
22
|
-
loading?: boolean;
|
|
23
|
-
outline?: boolean;
|
|
24
|
-
variant?: ButtonVariant;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
} & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
5
|
+
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &
|
|
6
|
+
VariantProps<typeof getButtonClasses> & {
|
|
7
|
+
as?: keyof Pick<JSX.IntrinsicElements, "a" | "span" | "p">;
|
|
8
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type {
|
|
3
2
|
CardContentProps,
|
|
4
3
|
CardDescriptionProps,
|
|
5
4
|
CardFooterProps,
|
|
@@ -7,6 +6,8 @@ import {
|
|
|
7
6
|
CardImageProps,
|
|
8
7
|
CardProps,
|
|
9
8
|
} from "./types";
|
|
9
|
+
import { cn } from "../../utilities";
|
|
10
|
+
import { getCardClasses } from "./constants";
|
|
10
11
|
|
|
11
12
|
const Card = ({
|
|
12
13
|
compact,
|
|
@@ -17,15 +18,8 @@ const Card = ({
|
|
|
17
18
|
...props
|
|
18
19
|
}: CardProps) => (
|
|
19
20
|
<div
|
|
20
|
-
className={
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
"card-bordered": bordered,
|
|
24
|
-
"card-compact": compact,
|
|
25
|
-
"card-normal": !compact,
|
|
26
|
-
"image-full": overlay,
|
|
27
|
-
"card-side": horizontal,
|
|
28
|
-
},
|
|
21
|
+
className={cn(
|
|
22
|
+
getCardClasses({ bordered, compact, horizontal, overlay }),
|
|
29
23
|
className
|
|
30
24
|
)}
|
|
31
25
|
{...props}
|
|
@@ -33,15 +27,15 @@ const Card = ({
|
|
|
33
27
|
);
|
|
34
28
|
|
|
35
29
|
const CardHeader = ({ className, ...props }: CardHeaderProps) => (
|
|
36
|
-
<h3 className={
|
|
30
|
+
<h3 className={cn("card-title", className)} {...props} />
|
|
37
31
|
);
|
|
38
32
|
|
|
39
33
|
const CardDescription = ({ className, ...props }: CardDescriptionProps) => (
|
|
40
|
-
<p className={
|
|
34
|
+
<p className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
41
35
|
);
|
|
42
36
|
|
|
43
37
|
const CardContent = ({ className, ...props }: CardContentProps) => (
|
|
44
|
-
<div className={
|
|
38
|
+
<div className={cn("card-body p-6 pt-0", className)} {...props} />
|
|
45
39
|
);
|
|
46
40
|
|
|
47
41
|
const CardImage = ({ className, src, alt, ...props }: CardImageProps) => (
|
|
@@ -51,7 +45,7 @@ const CardImage = ({ className, src, alt, ...props }: CardImageProps) => (
|
|
|
51
45
|
);
|
|
52
46
|
|
|
53
47
|
const CardFooter = ({ className, ...props }: CardFooterProps) => (
|
|
54
|
-
<div className={
|
|
48
|
+
<div className={cn("card-actions", className)} {...props} />
|
|
55
49
|
);
|
|
56
50
|
|
|
57
51
|
Card.Header = CardHeader;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getCardClasses = cva("card", {
|
|
4
|
+
variants: {
|
|
5
|
+
bordered: {
|
|
6
|
+
true: "card-bordered",
|
|
7
|
+
},
|
|
8
|
+
compact: {
|
|
9
|
+
true: "card-compact",
|
|
10
|
+
false: "card-normal",
|
|
11
|
+
},
|
|
12
|
+
horizontal: {
|
|
13
|
+
true: "card-side",
|
|
14
|
+
},
|
|
15
|
+
overlay: {
|
|
16
|
+
true: "image-full",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
compact: false,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { type VariantProps } from "../../libs";
|
|
3
|
+
import { getCardClasses } from "./constants";
|
|
2
4
|
|
|
3
|
-
export type CardProps =
|
|
4
|
-
|
|
5
|
-
* applies smaller padding to the card.
|
|
6
|
-
*/
|
|
7
|
-
compact?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* applies border to the card.
|
|
10
|
-
*/
|
|
11
|
-
bordered?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* shows the card horizontally with image to the right or left of it.
|
|
14
|
-
*/
|
|
15
|
-
horizontal?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* overlay is used to make the image full width with the content on top.
|
|
18
|
-
*/
|
|
19
|
-
overlay?: boolean;
|
|
20
|
-
} & React.HTMLAttributes<HTMLDivElement>;
|
|
5
|
+
export type CardProps = React.HTMLAttributes<HTMLDivElement> &
|
|
6
|
+
VariantProps<typeof getCardClasses>;
|
|
21
7
|
|
|
22
8
|
export type CardContentProps = React.HTMLAttributes<HTMLDivElement>;
|
|
23
9
|
export type CardImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import c from "clsx";
|
|
2
1
|
import type {
|
|
3
2
|
DescriptionProps,
|
|
4
3
|
DescriptionTermProps,
|
|
5
4
|
DescriptionDetailProps,
|
|
6
5
|
} from "./types";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
7
|
|
|
8
8
|
const Description = (props: DescriptionProps) => {
|
|
9
9
|
return <dl role="list" {...props} />;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
const DescriptionTerm = (props: DescriptionTermProps) => {
|
|
12
|
+
const DescriptionTerm = ({ className, ...props }: DescriptionTermProps) => {
|
|
13
13
|
return (
|
|
14
14
|
<dt
|
|
15
|
-
{...props}
|
|
16
15
|
role="listitem"
|
|
17
|
-
className={
|
|
16
|
+
className={cn("py-2 text-sm font-semibold", className)}
|
|
17
|
+
{...props}
|
|
18
18
|
/>
|
|
19
19
|
);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const DescriptionDetail = (props: DescriptionDetailProps) => {
|
|
23
|
-
return
|
|
22
|
+
const DescriptionDetail = ({ className, ...props }: DescriptionDetailProps) => {
|
|
23
|
+
return (
|
|
24
|
+
<dd
|
|
25
|
+
className={cn("text-base [&:not(:last-child)]:mb-1", className)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
24
29
|
};
|
|
25
30
|
|
|
26
31
|
Description.Term = DescriptionTerm;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getLoadingClasses } from "./constants";
|
|
2
|
+
import { type LoadingProps } from "./types";
|
|
3
|
+
import { cn } from "../../utilities";
|
|
4
|
+
|
|
5
|
+
export const Loading = ({
|
|
6
|
+
size,
|
|
7
|
+
intent,
|
|
8
|
+
variant,
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: LoadingProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<span
|
|
14
|
+
className={cn(getLoadingClasses({ intent, size, variant }), className)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getLoadingClasses = cva("loading", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
spinner: "loading-spinner",
|
|
7
|
+
dots: "loading-dots",
|
|
8
|
+
ring: "loading-ring",
|
|
9
|
+
ball: "loading-ball",
|
|
10
|
+
bars: "loading-bars",
|
|
11
|
+
infinity: "loading-infinity",
|
|
12
|
+
},
|
|
13
|
+
intent: {
|
|
14
|
+
primary: "text-primary",
|
|
15
|
+
secondary: "text-secondary",
|
|
16
|
+
accent: "text-accent",
|
|
17
|
+
neutral: "text-neutral",
|
|
18
|
+
info: "text-info",
|
|
19
|
+
success: "text-success",
|
|
20
|
+
warning: "text-warning",
|
|
21
|
+
error: "text-error",
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
xs: "loading-xs",
|
|
25
|
+
sm: "loading-sm",
|
|
26
|
+
md: "loading-md",
|
|
27
|
+
lg: "loading-lg",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Loading } from "./Loading";
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import c from "clsx";
|
|
2
1
|
import { type SkeletonProps } from "./types";
|
|
3
|
-
import {
|
|
2
|
+
import { getSkeletonClasses } from "./constants";
|
|
3
|
+
import { cn } from "../../utilities";
|
|
4
4
|
|
|
5
5
|
export const Skeleton = ({
|
|
6
|
-
className,
|
|
7
6
|
round,
|
|
8
7
|
width,
|
|
9
8
|
height,
|
|
9
|
+
variant,
|
|
10
|
+
className,
|
|
10
11
|
...props
|
|
11
12
|
}: SkeletonProps) => {
|
|
12
13
|
return (
|
|
13
14
|
<div
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
"skeleton",
|
|
17
|
-
getSkeletonSize({ width, height }),
|
|
18
|
-
{
|
|
19
|
-
"rounded-md": !round,
|
|
20
|
-
"rounded-full": round,
|
|
21
|
-
},
|
|
15
|
+
className={cn(
|
|
16
|
+
getSkeletonClasses({ width, height, round, variant }),
|
|
22
17
|
className
|
|
23
18
|
)}
|
|
19
|
+
{...props}
|
|
24
20
|
/>
|
|
25
21
|
);
|
|
26
22
|
};
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Size } from "./types";
|
|
1
|
+
import { cva } from "../../libs";
|
|
3
2
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
3
|
+
export const getSkeletonClasses = cva("skeleton", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: { pulse: "animate-pulse" },
|
|
6
|
+
width: {
|
|
7
|
+
2: "w-2",
|
|
8
|
+
4: "w-4",
|
|
9
|
+
8: "w-8",
|
|
10
|
+
12: "w-12",
|
|
11
|
+
16: "w-16",
|
|
12
|
+
24: "w-24",
|
|
13
|
+
32: "w-32",
|
|
14
|
+
48: "w-48",
|
|
15
|
+
64: "w-64",
|
|
16
|
+
full: "w-full",
|
|
17
|
+
},
|
|
18
|
+
height: {
|
|
19
|
+
2: "h-2",
|
|
20
|
+
4: "h-4",
|
|
21
|
+
8: "h-8",
|
|
22
|
+
12: "h-12",
|
|
23
|
+
16: "h-16",
|
|
24
|
+
24: "h-24",
|
|
25
|
+
32: "h-32",
|
|
26
|
+
48: "h-48",
|
|
27
|
+
64: "h-64",
|
|
28
|
+
full: "h-full",
|
|
29
|
+
},
|
|
30
|
+
round: {
|
|
31
|
+
true: "rounded-full",
|
|
32
|
+
false: "rounded-md",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
width: "full",
|
|
37
|
+
height: 4,
|
|
38
|
+
round: false,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type VariantProps } from "../../libs";
|
|
2
|
+
import { getSkeletonClasses } from "./constants";
|
|
2
3
|
|
|
3
|
-
export type SkeletonProps = React.HTMLAttributes<HTMLDivElement> &
|
|
4
|
-
|
|
5
|
-
height?: Size;
|
|
6
|
-
round?: boolean;
|
|
7
|
-
className?: string;
|
|
8
|
-
};
|
|
4
|
+
export type SkeletonProps = React.HTMLAttributes<HTMLDivElement> &
|
|
5
|
+
VariantProps<typeof getSkeletonClasses>;
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type TextProps } from "./types";
|
|
3
|
+
import { getTextClasses } from "./constants";
|
|
4
|
+
import { cn } from "../../utilities";
|
|
5
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
6
|
|
|
6
|
-
export const Text = ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export const Text = ({
|
|
8
|
+
as,
|
|
9
|
+
size,
|
|
10
|
+
variant,
|
|
11
|
+
children,
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}: TextProps) => {
|
|
15
|
+
const Comp = as ? Slot : "span";
|
|
16
|
+
const SlotChild = as ? as : React.Fragment;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Comp
|
|
20
|
+
className={cn(getTextClasses({ size, variant }), className)}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
{/* slot merges it's prop into it's immediate child */}
|
|
24
|
+
<SlotChild>{children}</SlotChild>
|
|
25
|
+
</Comp>
|
|
11
26
|
);
|
|
12
27
|
};
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { TextSize, TextVariant } from './types';
|
|
1
|
+
import { cva } from "../../libs";
|
|
3
2
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
3
|
+
export const getTextClasses = cva("", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
info: "text-info",
|
|
7
|
+
error: "text-error",
|
|
8
|
+
success: "text-success",
|
|
9
|
+
warning: "text-warning",
|
|
10
|
+
primary: "text-primary",
|
|
11
|
+
secondary: "text-secondary",
|
|
12
|
+
accent: "text-accent",
|
|
13
|
+
neutral: "text-neutral",
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
xs: "text-xs",
|
|
17
|
+
sm: "text-sm",
|
|
18
|
+
base: "text-base",
|
|
19
|
+
lg: "text-lg",
|
|
20
|
+
xl: "text-xl",
|
|
21
|
+
"2xl": "text-2xl",
|
|
22
|
+
"3xl": "text-3xl",
|
|
23
|
+
"4xl": "text-4xl",
|
|
24
|
+
"5xl": "text-5xl",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { type VariantProps } from "../../libs";
|
|
2
|
+
import { getTextClasses } from "./constants";
|
|
2
3
|
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
| 'primary'
|
|
11
|
-
| 'secondary'
|
|
12
|
-
| 'accent'
|
|
13
|
-
| 'neutral';
|
|
14
|
-
|
|
15
|
-
export type TextProps = {
|
|
16
|
-
as?: TextTag;
|
|
17
|
-
size?: TextSize;
|
|
18
|
-
variant?: TextVariant;
|
|
19
|
-
children: React.ReactNode;
|
|
20
|
-
className?: string;
|
|
21
|
-
};
|
|
4
|
+
export type TextProps = React.HTMLAttributes<HTMLSpanElement> &
|
|
5
|
+
VariantProps<typeof getTextClasses> & {
|
|
6
|
+
as?: keyof Pick<
|
|
7
|
+
JSX.IntrinsicElements,
|
|
8
|
+
"h1" | "h2" | "h3" | "h4" | "h5" | "p"
|
|
9
|
+
>;
|
|
10
|
+
};
|
|
@@ -1,22 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
3
|
+
import type { TooltipArrowProps, TooltipContentProps } from "./types";
|
|
4
|
+
import { getTooltipArrowClasses, getTooltipContentClasses } from "./constants";
|
|
5
|
+
import { cn } from "../../utilities";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
7
|
+
const Tooltip = (props: TooltipPrimitive.TooltipProps) => (
|
|
8
|
+
<TooltipPrimitive.Root {...props} />
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const TooltipArrow = ({ className, variant, ...props }: TooltipArrowProps) => (
|
|
12
|
+
<TooltipPrimitive.Arrow
|
|
13
|
+
className={cn(getTooltipArrowClasses({ variant }), className)}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const TooltipContent = React.forwardRef<
|
|
19
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
20
|
+
TooltipContentProps
|
|
21
|
+
>(({ className, variant, ...props }, ref) => (
|
|
22
|
+
<TooltipPrimitive.Content
|
|
23
|
+
ref={ref}
|
|
24
|
+
className={cn(getTooltipContentClasses({ variant }), className)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
));
|
|
28
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
29
|
+
|
|
30
|
+
Tooltip.Content = TooltipContent;
|
|
31
|
+
Tooltip.Arrow = TooltipArrow;
|
|
32
|
+
Tooltip.Portal = TooltipPrimitive.Portal;
|
|
33
|
+
Tooltip.Provider = TooltipPrimitive.Provider;
|
|
34
|
+
Tooltip.Trigger = TooltipPrimitive.Trigger;
|
|
35
|
+
|
|
36
|
+
export { Tooltip };
|