@mbao01/common 0.0.6 → 0.0.7

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.
@@ -0,0 +1,14 @@
1
+ import type { AvatarProps, AvatarImageProps, AvatarFallbackProps } from "./types";
2
+ declare const Avatar: {
3
+ ({ className, size, status, ...props }: AvatarProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string | undefined;
5
+ Image: {
6
+ ({ className, ring, shape, variant, ...props }: AvatarImageProps): import("react/jsx-runtime").JSX.Element;
7
+ displayName: string | undefined;
8
+ };
9
+ Fallback: {
10
+ ({ className, size, ring, shape, variant, ...props }: AvatarFallbackProps): import("react/jsx-runtime").JSX.Element;
11
+ displayName: string | undefined;
12
+ };
13
+ };
14
+ export { Avatar };
@@ -0,0 +1,15 @@
1
+ export declare const getAvatarClasses: (props?: ({
2
+ size?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
3
+ status?: "online" | "offline" | null | undefined;
4
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
5
+ export declare const getAvatarImageClasses: (props?: ({
6
+ variant?: "accent" | "default" | "error" | "ghost" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
7
+ shape?: "circle" | "round" | "hexagon" | "triangle" | "television" | null | undefined;
8
+ ring?: boolean | null | undefined;
9
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
10
+ export declare const getAvatarFallbackClasses: (props?: ({
11
+ size?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
12
+ variant?: "accent" | "default" | "error" | "ghost" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
13
+ shape?: "circle" | "round" | "hexagon" | "triangle" | "television" | null | undefined;
14
+ ring?: boolean | null | undefined;
15
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Avatar } from "./Avatar";
@@ -0,0 +1,6 @@
1
+ import * as AvatarPrimitive from "@radix-ui/react-avatar";
2
+ import { type VariantProps } from "../../libs";
3
+ import { getAvatarClasses, getAvatarFallbackClasses, getAvatarImageClasses } from "./constants";
4
+ export type AvatarProps = Omit<React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>, "asChild" | "size"> & VariantProps<typeof getAvatarClasses>;
5
+ export type AvatarImageProps = Omit<React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>, "asChild"> & VariantProps<typeof getAvatarImageClasses>;
6
+ export type AvatarFallbackProps = Omit<React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>, "asChild"> & VariantProps<typeof getAvatarFallbackClasses>;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import * as ProgressPrimitive from "@radix-ui/react-progress";
3
+ export declare const Progress: React.ForwardRefExoticComponent<Omit<Omit<ProgressPrimitive.ProgressProps & React.RefAttributes<HTMLDivElement>, "ref">, "asChild"> & import("class-variance-authority").VariantProps<(props?: ({
4
+ variant?: "accent" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,6 @@
1
+ export declare const getProgressClasses: (props?: ({
2
+ variant?: "accent" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
3
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
4
+ export declare const getProgressIndicatorClasses: (props?: ({
5
+ variant?: "accent" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Progress } from "./Progress";
@@ -0,0 +1,4 @@
1
+ import * as ProgressPrimitive from "@radix-ui/react-progress";
2
+ import { type VariantProps } from "../../libs";
3
+ import { getProgressClasses } from "./constants";
4
+ export type ProgressProps = Omit<React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>, "asChild"> & VariantProps<typeof getProgressClasses>;
@@ -0,0 +1,2 @@
1
+ import { type SeparatorProps } from "./types";
2
+ export declare const Separator: ({ className, orientation, decorative, ...props }: SeparatorProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare const getSeparatorClasses: (props?: ({
2
+ orientation?: "horizontal" | "vertical" | null | undefined;
3
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Separator } from "./Separator";
@@ -0,0 +1,2 @@
1
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
2
+ export type SeparatorProps = React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>;
@@ -1,6 +1,6 @@
1
1
  export declare const getSkeletonClasses: (props?: ({
2
2
  variant?: "pulse" | null | undefined;
3
- width?: "full" | 4 | 2 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
4
- height?: "full" | 4 | 2 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
3
+ width?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | 2 | "full" | null | undefined;
4
+ height?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | 2 | "full" | null | undefined;
5
5
  round?: boolean | null | undefined;
6
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -2,9 +2,12 @@
2
2
  export * from "./components/Button";
3
3
  export * from "./components/Breadcrumbs";
4
4
  /** data display */
5
+ export * from "./components/Avatar";
5
6
  export * from "./components/Badge";
6
7
  export * from "./components/Card";
7
8
  export * from "./components/Description";
9
+ export * from "./components/Progress";
10
+ export * from "./components/Separator";
8
11
  export * from "./components/Text";
9
12
  /** data input */
10
13
  /** feedback */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -60,7 +60,10 @@
60
60
  "test:coverage": "vitest run --coverage"
61
61
  },
62
62
  "dependencies": {
63
+ "@radix-ui/react-avatar": "^1.0.4",
63
64
  "@radix-ui/react-icons": "^1.3.0",
65
+ "@radix-ui/react-progress": "^1.0.3",
66
+ "@radix-ui/react-separator": "^1.0.3",
64
67
  "@radix-ui/react-slot": "^1.0.2",
65
68
  "@radix-ui/react-tooltip": "^1.0.7",
66
69
  "class-variance-authority": "^0.7.0",
@@ -114,5 +117,5 @@
114
117
  "react-dom": "^18.2.0",
115
118
  "typescript": "^5.2.2"
116
119
  },
117
- "gitHead": "ceb6cef48e8547b4da5c51dda329bd6edee73c0b"
120
+ "gitHead": "5a26b3e951c2b2a1a6cf5cb597129bc25a336a2d"
118
121
  }
@@ -0,0 +1,59 @@
1
+ "use client";
2
+
3
+ import * as AvatarPrimitive from "@radix-ui/react-avatar";
4
+ import type {
5
+ AvatarProps,
6
+ AvatarImageProps,
7
+ AvatarFallbackProps,
8
+ } from "./types";
9
+ import { cn } from "../../utilities";
10
+ import {
11
+ getAvatarClasses,
12
+ getAvatarImageClasses,
13
+ getAvatarFallbackClasses,
14
+ } from "./constants";
15
+
16
+ const Avatar = ({ className, size, status, ...props }: AvatarProps) => (
17
+ <AvatarPrimitive.Root
18
+ className={cn(getAvatarClasses({ size, status }), className)}
19
+ {...props}
20
+ />
21
+ );
22
+ Avatar.displayName = AvatarPrimitive.Root.displayName;
23
+
24
+ const AvatarImage = ({
25
+ className,
26
+ ring,
27
+ shape,
28
+ variant,
29
+ ...props
30
+ }: AvatarImageProps) => (
31
+ <AvatarPrimitive.Image
32
+ className={cn(getAvatarImageClasses({ ring, shape, variant }), className)}
33
+ {...props}
34
+ />
35
+ );
36
+ AvatarImage.displayName = AvatarPrimitive.Image.displayName;
37
+
38
+ const AvatarFallback = ({
39
+ className,
40
+ size,
41
+ ring,
42
+ shape,
43
+ variant,
44
+ ...props
45
+ }: AvatarFallbackProps) => (
46
+ <AvatarPrimitive.Fallback
47
+ className={cn(
48
+ getAvatarFallbackClasses({ ring, size, shape, variant }),
49
+ className
50
+ )}
51
+ {...props}
52
+ />
53
+ );
54
+ AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
55
+
56
+ Avatar.Image = AvatarImage;
57
+ Avatar.Fallback = AvatarFallback;
58
+
59
+ export { Avatar };
@@ -0,0 +1,69 @@
1
+ import { cva } from "../../libs";
2
+
3
+ export const getAvatarClasses = cva("avatar", {
4
+ variants: {
5
+ size: {
6
+ 4: "w-4 h-4",
7
+ 8: "w-8 h-8",
8
+ 12: "w-12 h-12",
9
+ 16: "w-16 h-16",
10
+ 24: "w-24 h-24",
11
+ 32: "w-32 h-32",
12
+ 48: "w-48 h-48",
13
+ 64: "w-64 h-64",
14
+ },
15
+ status: {
16
+ online: "online",
17
+ offline: "offline",
18
+ },
19
+ },
20
+ });
21
+
22
+ const classesConfig = {
23
+ variants: {
24
+ variant: {
25
+ accent: "bg-accent text-accent-content ring-accent",
26
+ default: "bg-default text-default-content ring-default",
27
+ error: "bg-error text-error-content ring-error",
28
+ ghost: "bg-ghost text-ghost-content ring-ghost",
29
+ info: "bg-info text-info-content ring-info",
30
+ neutral: "bg-neutral text-neutral-content ring-neutral",
31
+ primary: "bg-primary text-primary-content ring-primary",
32
+ secondary: "bg-secondary text-secondary-content ring-secondary",
33
+ success: "bg-success text-success-content ring-success",
34
+ warning: "bg-warning text-warning-content ring-warning",
35
+ },
36
+ shape: {
37
+ round: "rounded",
38
+ circle: "rounded-full",
39
+ hexagon: "mask mask-hexagon",
40
+ triangle: "mask mask-triangle",
41
+ television: "mask mask-squircle",
42
+ },
43
+ ring: {
44
+ true: "ring ring-offset-base-100 ring-offset-2",
45
+ },
46
+ },
47
+ };
48
+
49
+ export const getAvatarImageClasses = cva("", classesConfig);
50
+
51
+ export const getAvatarFallbackClasses = cva(
52
+ "flex items-center justify-center w-full",
53
+ {
54
+ ...classesConfig,
55
+ variants: {
56
+ ...classesConfig.variants,
57
+ size: {
58
+ 4: "text-[4px]",
59
+ 8: "text-base",
60
+ 12: "text-lg",
61
+ 16: "text-xl",
62
+ 24: "text-2xl",
63
+ 32: "text-3xl",
64
+ 48: "text-4xl",
65
+ 64: "text-5xl",
66
+ },
67
+ },
68
+ }
69
+ );
@@ -0,0 +1 @@
1
+ export { Avatar } from "./Avatar";
@@ -0,0 +1,25 @@
1
+ import * as AvatarPrimitive from "@radix-ui/react-avatar";
2
+ import { type VariantProps } from "../../libs";
3
+ import {
4
+ getAvatarClasses,
5
+ getAvatarFallbackClasses,
6
+ getAvatarImageClasses,
7
+ } from "./constants";
8
+
9
+ export type AvatarProps = Omit<
10
+ React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>,
11
+ "asChild" | "size"
12
+ > &
13
+ VariantProps<typeof getAvatarClasses>;
14
+
15
+ export type AvatarImageProps = Omit<
16
+ React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>,
17
+ "asChild"
18
+ > &
19
+ VariantProps<typeof getAvatarImageClasses>;
20
+
21
+ export type AvatarFallbackProps = Omit<
22
+ React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>,
23
+ "asChild"
24
+ > &
25
+ VariantProps<typeof getAvatarFallbackClasses>;
@@ -0,0 +1,31 @@
1
+ "use client";
2
+
3
+ import React from "react";
4
+ import * as ProgressPrimitive from "@radix-ui/react-progress";
5
+ import { type ProgressProps } from "./types";
6
+ import { cn } from "../../utilities";
7
+ import { getProgressClasses, getProgressIndicatorClasses } from "./constants";
8
+
9
+ export const Progress = React.forwardRef<
10
+ React.ElementRef<typeof ProgressPrimitive.Root>,
11
+ ProgressProps
12
+ >(({ className, value, max = 100, variant, ...props }, ref) => (
13
+ <ProgressPrimitive.Root
14
+ ref={ref}
15
+ max={max}
16
+ value={value}
17
+ className={cn(getProgressClasses({ variant }), className)}
18
+ {...props}
19
+ >
20
+ <ProgressPrimitive.Indicator
21
+ className={cn(getProgressIndicatorClasses({ variant }))}
22
+ style={{
23
+ transform: `translateX(-${
24
+ (100 * (max - Math.max(Math.min(value ?? 0, max), 0))) / max
25
+ }%)`,
26
+ }}
27
+ />
28
+ </ProgressPrimitive.Root>
29
+ ));
30
+
31
+ Progress.displayName = ProgressPrimitive.Root.displayName;
@@ -0,0 +1,49 @@
1
+ import { cva } from "../../libs";
2
+
3
+ export const getProgressClasses = cva(
4
+ "relative h-2 w-full overflow-hidden rounded-full",
5
+ {
6
+ variants: {
7
+ variant: {
8
+ accent: "bg-accent/20",
9
+ base: "bg-base-content/20",
10
+ error: "bg-error/20",
11
+ ghost: "bg-ghost/20",
12
+ info: "bg-info/20",
13
+ link: "bg-link/20",
14
+ neutral: "bg-neutral/20",
15
+ primary: "bg-primary/20",
16
+ secondary: "bg-secondary/20",
17
+ success: "bg-success/20",
18
+ warning: "bg-warning/20",
19
+ },
20
+ },
21
+ defaultVariants: {
22
+ variant: "base",
23
+ },
24
+ }
25
+ );
26
+
27
+ export const getProgressIndicatorClasses = cva(
28
+ "h-full w-full flex-1 transition-all",
29
+ {
30
+ variants: {
31
+ variant: {
32
+ accent: "bg-accent",
33
+ base: "bg-base-content",
34
+ error: "bg-error",
35
+ ghost: "bg-ghost",
36
+ info: "bg-info",
37
+ link: "bg-link",
38
+ neutral: "bg-neutral",
39
+ primary: "bg-primary",
40
+ secondary: "bg-secondary",
41
+ success: "bg-success",
42
+ warning: "bg-warning",
43
+ },
44
+ },
45
+ defaultVariants: {
46
+ variant: "base",
47
+ },
48
+ }
49
+ );
@@ -0,0 +1 @@
1
+ export { Progress } from "./Progress";
@@ -0,0 +1,9 @@
1
+ import * as ProgressPrimitive from "@radix-ui/react-progress";
2
+ import { type VariantProps } from "../../libs";
3
+ import { getProgressClasses } from "./constants";
4
+
5
+ export type ProgressProps = Omit<
6
+ React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>,
7
+ "asChild"
8
+ > &
9
+ VariantProps<typeof getProgressClasses>;
@@ -0,0 +1,20 @@
1
+ "use client";
2
+
3
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
4
+ import { type SeparatorProps } from "./types";
5
+ import { getSeparatorClasses } from "./constants";
6
+ import { cn } from "../../utilities";
7
+
8
+ export const Separator = ({
9
+ className,
10
+ orientation = "horizontal",
11
+ decorative = true,
12
+ ...props
13
+ }: SeparatorProps) => (
14
+ <SeparatorPrimitive.Root
15
+ decorative={decorative}
16
+ orientation={orientation}
17
+ className={cn(getSeparatorClasses({ orientation }), className)}
18
+ {...props}
19
+ />
20
+ );
@@ -0,0 +1,10 @@
1
+ import { cva } from "../../libs";
2
+
3
+ export const getSeparatorClasses = cva("shrink-0 bg-base-300", {
4
+ variants: {
5
+ orientation: {
6
+ horizontal: "h-[1px] w-full",
7
+ vertical: "h-full w-[1px]",
8
+ },
9
+ },
10
+ });
@@ -0,0 +1 @@
1
+ export { Separator } from "./Separator";
@@ -0,0 +1,5 @@
1
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
2
+
3
+ export type SeparatorProps = React.ComponentPropsWithoutRef<
4
+ typeof SeparatorPrimitive.Root
5
+ >;
package/src/index.ts CHANGED
@@ -3,9 +3,12 @@ export * from "./components/Button";
3
3
  export * from "./components/Breadcrumbs";
4
4
 
5
5
  /** data display */
6
+ export * from "./components/Avatar";
6
7
  export * from "./components/Badge";
7
8
  export * from "./components/Card";
8
9
  export * from "./components/Description";
10
+ export * from "./components/Progress";
11
+ export * from "./components/Separator";
9
12
  export * from "./components/Text";
10
13
 
11
14
  /** data input */