@mbao01/ui 0.1.1 → 0.1.3

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.
Files changed (33) hide show
  1. package/README.md +6 -5
  2. package/dist/types/components/Badge/Badge.d.ts +2 -0
  3. package/dist/types/components/Badge/constants.d.ts +5 -0
  4. package/dist/types/components/Badge/index.d.ts +1 -0
  5. package/dist/types/components/Badge/types.d.ts +7 -0
  6. package/dist/types/components/Card/Card.d.ts +8 -0
  7. package/dist/types/components/Card/index.d.ts +1 -0
  8. package/dist/types/components/Card/types.d.ts +24 -0
  9. package/dist/types/components/Detail/Detail.d.ts +2 -0
  10. package/dist/types/components/Detail/index.d.ts +1 -0
  11. package/dist/types/components/Detail/types.d.ts +5 -0
  12. package/dist/types/components/Tooltip/Tooltip.d.ts +2 -0
  13. package/dist/types/components/Tooltip/constants.d.ts +5 -0
  14. package/dist/types/components/Tooltip/index.d.ts +1 -0
  15. package/dist/types/components/Tooltip/types.d.ts +10 -0
  16. package/dist/types/index.d.ts +4 -0
  17. package/package.json +37 -34
  18. package/plugin.js +2 -9
  19. package/src/components/Badge/Badge.tsx +28 -0
  20. package/src/components/Badge/constants.ts +31 -0
  21. package/src/components/Badge/index.ts +1 -0
  22. package/src/components/Badge/types.ts +18 -0
  23. package/src/components/Card/Card.tsx +64 -0
  24. package/src/components/Card/index.ts +1 -0
  25. package/src/components/Card/types.ts +26 -0
  26. package/src/components/Detail/Detail.tsx +10 -0
  27. package/src/components/Detail/index.ts +1 -0
  28. package/src/components/Detail/types.ts +6 -0
  29. package/src/components/Tooltip/Tooltip.tsx +11 -0
  30. package/src/components/Tooltip/constants.ts +33 -0
  31. package/src/components/Tooltip/index.ts +1 -0
  32. package/src/components/Tooltip/types.ts +24 -0
  33. package/src/index.ts +4 -0
package/README.md CHANGED
@@ -30,13 +30,14 @@ npm install @mbao01/ui
30
30
  3. Configure tailwind
31
31
 
32
32
  ```typescript
33
- const plugin = require("@mbao01/ui/plugin") // -> import the library plugin
34
-
35
33
  export default {
36
- ...plugin.config, // -> add the library plugin config
37
34
  content: [
38
- "./src/**/*.{js,ts,jsx,tsx,mdx}",
39
- "node_modules/@mbao01/ui/src/**/*.{js,ts,jsx,tsx,mdx}" // -> ensure to add this to allow tailwind to scan the library for classes
35
+ "node_modules/@mbao01/ui/src/**/*", // -> ensure to add this to allow tailwind to scan the library for classes
36
+ ...
37
+ ],
38
+ "plugins": [
39
+ require("@mbao01/ui/plugin"), // -> import the library plugin
40
+ ...
40
41
  ]
41
42
  }
42
43
  ```
@@ -0,0 +1,2 @@
1
+ import { type BadgeProps } from "./types";
2
+ export declare const Badge: ({ size, outline, variant, children, className, ...props }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import type { BadgeSize, BadgeVariant } from "./types";
2
+ export declare const getBadgeClasses: ({ size, variant, }: {
3
+ size?: BadgeSize | undefined;
4
+ variant?: BadgeVariant | undefined;
5
+ }) => string;
@@ -0,0 +1 @@
1
+ export { Badge } from './Badge';
@@ -0,0 +1,7 @@
1
+ export type BadgeSize = "xs" | "sm" | "md" | "lg";
2
+ export type BadgeVariant = "neutral" | "primary" | "secondary" | "accent" | "ghost" | "info" | "success" | "warning" | "error";
3
+ export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> & {
4
+ size?: BadgeSize;
5
+ outline?: boolean;
6
+ variant?: BadgeVariant;
7
+ };
@@ -0,0 +1,8 @@
1
+ import { CardContentProps, CardDescriptionProps, CardFooterProps, CardHeaderProps, CardImageProps, CardProps } from "./types";
2
+ declare const Card: ({ compact, bordered, horizontal, overlay, className, ...props }: CardProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const CardHeader: ({ className, ...props }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
4
+ declare const CardDescription: ({ className, ...props }: CardDescriptionProps) => import("react/jsx-runtime").JSX.Element;
5
+ declare const CardContent: ({ className, ...props }: CardContentProps) => import("react/jsx-runtime").JSX.Element;
6
+ declare const CardImage: ({ className, src, alt, ...props }: CardImageProps) => import("react/jsx-runtime").JSX.Element;
7
+ declare const CardFooter: ({ className, ...props }: CardFooterProps) => import("react/jsx-runtime").JSX.Element;
8
+ export { Card, CardHeader, CardFooter, CardDescription, CardContent, CardImage, };
@@ -0,0 +1 @@
1
+ export * from "./Card";
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ export type CardProps = {
3
+ /**
4
+ * applies smaller padding to the card.
5
+ */
6
+ compact?: boolean;
7
+ /**
8
+ * applies border to the card.
9
+ */
10
+ bordered?: boolean;
11
+ /**
12
+ * shows the card horizontally with image to the right or left of it.
13
+ */
14
+ horizontal?: boolean;
15
+ /**
16
+ * overlay is used to make the image full width with the content on top.
17
+ */
18
+ overlay?: boolean;
19
+ } & React.HTMLAttributes<HTMLDivElement>;
20
+ export type CardContentProps = React.HTMLAttributes<HTMLDivElement>;
21
+ export type CardImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
22
+ export type CardHeaderProps = React.HTMLAttributes<HTMLDivElement>;
23
+ export type CardFooterProps = React.HTMLAttributes<HTMLDivElement>;
24
+ export type CardDescriptionProps = React.HTMLAttributes<HTMLParagraphElement>;
@@ -0,0 +1,2 @@
1
+ import { type DetailProps } from './types';
2
+ export declare const Detail: ({ term, children }: DetailProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { Detail } from './Detail';
@@ -0,0 +1,5 @@
1
+ import { type ReactNode } from 'react';
2
+ export type DetailProps = {
3
+ term: string;
4
+ children: ReactNode;
5
+ };
@@ -0,0 +1,2 @@
1
+ import { type TooltipProps } from './types';
2
+ export declare const Tooltip: ({ tip, children, variant, position, className }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import type { TooltipPosition, TooltipVariant } from "./types";
2
+ export declare const getTooltipClasses: ({ variant, position, }: {
3
+ variant?: TooltipVariant | undefined;
4
+ position?: TooltipPosition | undefined;
5
+ }) => string;
@@ -0,0 +1 @@
1
+ export { Tooltip } from './Tooltip';
@@ -0,0 +1,10 @@
1
+ import { type ReactNode } from 'react';
2
+ export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
3
+ export type TooltipVariant = 'default' | 'neutral' | 'primary' | 'secondary' | 'accent' | 'ghost' | 'link' | 'info' | 'success' | 'warning' | 'error';
4
+ export type TooltipProps = {
5
+ tip: string;
6
+ children: ReactNode;
7
+ variant?: TooltipVariant;
8
+ position?: TooltipPosition;
9
+ className?: string;
10
+ };
@@ -1,4 +1,8 @@
1
+ export * from "./components/Badge";
1
2
  export * from "./components/Breadcrumbs";
2
3
  export * from "./components/Button";
4
+ export * from "./components/Card";
5
+ export * from "./components/Detail";
3
6
  export * from "./components/Link";
4
7
  export * from "./components/Text";
8
+ export * from "./components/Tooltip";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/ui",
3
3
  "private": false,
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -26,7 +26,9 @@
26
26
  "type": "git",
27
27
  "url": "git+https://github.com/mbao01/mbao01.git"
28
28
  },
29
- "sideEffects": false,
29
+ "sideEffects": [
30
+ "*.css"
31
+ ],
30
32
  "scripts": {
31
33
  "dev": "storybook dev -p 6006",
32
34
  "build": "tsc && vite build",
@@ -39,50 +41,51 @@
39
41
  "test:coverage": "vitest run --coverage"
40
42
  },
41
43
  "dependencies": {
42
- "autoprefixer": "^10.4.16",
43
- "clsx": "^2.0.0",
44
- "daisyui": "^4.4.24"
44
+ "@mbao01/common": "^0.0.2",
45
+ "autoprefixer": "^10.4.17",
46
+ "clsx": "^2.1.0",
47
+ "daisyui": "^4.6.2"
45
48
  },
46
49
  "devDependencies": {
47
50
  "@heroicons/react": "^2.1.1",
48
- "@storybook/addon-essentials": "^7.6.6",
49
- "@storybook/addon-interactions": "^7.6.6",
50
- "@storybook/addon-links": "^7.6.6",
51
- "@storybook/addon-onboarding": "^1.0.10",
52
- "@storybook/addon-themes": "^7.6.6",
53
- "@storybook/blocks": "^7.6.6",
54
- "@storybook/react": "^7.6.6",
55
- "@storybook/react-vite": "^7.6.6",
56
- "@storybook/test": "^7.6.6",
57
- "@testing-library/jest-dom": "^6.1.6",
58
- "@testing-library/react": "^14.1.2",
51
+ "@storybook/addon-essentials": "^7.6.14",
52
+ "@storybook/addon-interactions": "^7.6.14",
53
+ "@storybook/addon-links": "^7.6.14",
54
+ "@storybook/addon-onboarding": "^1.0.11",
55
+ "@storybook/addon-themes": "^7.6.14",
56
+ "@storybook/blocks": "^7.6.14",
57
+ "@storybook/react": "^7.6.14",
58
+ "@storybook/react-vite": "^7.6.14",
59
+ "@storybook/test": "^7.6.14",
60
+ "@testing-library/jest-dom": "^6.4.2",
61
+ "@testing-library/react": "^14.2.1",
59
62
  "@testing-library/user-event": "^14.5.2",
60
- "@types/node": "^20.10.5",
61
- "@types/react": "^18.2.43",
62
- "@types/react-dom": "^18.2.17",
63
- "@typescript-eslint/eslint-plugin": "^6.14.0",
64
- "@typescript-eslint/parser": "^6.14.0",
63
+ "@types/node": "^20.11.17",
64
+ "@types/react": "^18.2.55",
65
+ "@types/react-dom": "^18.2.19",
66
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
67
+ "@typescript-eslint/parser": "^6.21.0",
65
68
  "@vitejs/plugin-react": "^4.2.1",
66
- "@vitest/coverage-v8": "^1.1.1",
67
- "@vitest/ui": "^1.1.1",
68
- "eslint": "^8.55.0",
69
+ "@vitest/coverage-v8": "^1.2.2",
70
+ "@vitest/ui": "^1.2.2",
71
+ "eslint": "^8.56.0",
69
72
  "eslint-plugin-react": "^7.33.2",
70
73
  "eslint-plugin-react-hooks": "^4.6.0",
71
74
  "eslint-plugin-react-refresh": "^0.4.5",
72
75
  "eslint-plugin-storybook": "^0.6.15",
73
- "jsdom": "^23.0.1",
76
+ "jsdom": "^23.2.0",
74
77
  "path": "^0.12.7",
75
- "postcss": "^8.4.32",
78
+ "postcss": "^8.4.35",
76
79
  "react": "^18.2.0",
77
80
  "react-dom": "^18.2.0",
78
- "react-router-dom": "^6.21.3",
79
- "storybook": "^7.6.10",
81
+ "react-router-dom": "^6.22.0",
82
+ "storybook": "^7.6.14",
80
83
  "storybook-addon-react-router-v6": "^2.0.10",
81
- "tailwindcss": "^3.4.0",
82
- "typescript": "^5.2.2",
83
- "vite": "^5.0.8",
84
- "vite-plugin-dts": "^3.7.0",
85
- "vitest": "^1.1.1"
84
+ "tailwindcss": "^3.4.1",
85
+ "typescript": "^5.3.3",
86
+ "vite": "^5.1.1",
87
+ "vite-plugin-dts": "^3.7.2",
88
+ "vitest": "^1.2.2"
86
89
  },
87
90
  "peerDependencies": {
88
91
  "@heroicons/react": "^2.1.1",
@@ -93,5 +96,5 @@
93
96
  "tailwindcss": "^3.4.0",
94
97
  "typescript": "^5.2.2"
95
98
  },
96
- "gitHead": "a8f9e309d549d280a3c3b1048ab7946d554744bd"
99
+ "gitHead": "00988bf0b2318917bab272a8fb5920e451f67edf"
97
100
  }
package/plugin.js CHANGED
@@ -1,10 +1,3 @@
1
- const plugin = require("tailwindcss/plugin");
2
- const config = require("./tailwind.config");
1
+ const daisyui = require("daisyui");
3
2
 
4
- const { theme, plugins, daisyui } = config;
5
-
6
- module.exports = plugin(() => null, {
7
- theme,
8
- plugins,
9
- daisyui,
10
- });
3
+ module.exports = daisyui;
@@ -0,0 +1,28 @@
1
+ import c from "clsx";
2
+ import { getBadgeClasses } from "./constants";
3
+ import { type BadgeProps } from "./types";
4
+
5
+ export const Badge = ({
6
+ size,
7
+ outline,
8
+ variant = "ghost",
9
+ children,
10
+ className,
11
+ ...props
12
+ }: BadgeProps) => {
13
+ return (
14
+ <span
15
+ {...props}
16
+ className={c(
17
+ getBadgeClasses({ size, variant }),
18
+ {
19
+ "badge-outline": outline,
20
+ "text-base-200": !["ghost", "neutral"].includes(variant),
21
+ },
22
+ className
23
+ )}
24
+ >
25
+ {children}
26
+ </span>
27
+ );
28
+ };
@@ -0,0 +1,31 @@
1
+ import c from "clsx";
2
+ import type { BadgeSize, BadgeVariant } from "./types";
3
+
4
+ const BADGE_SIZE = {
5
+ xs: c("badge-xs"),
6
+ sm: c("badge-sm"),
7
+ md: c("badge-md"),
8
+ lg: c("badge-lg"),
9
+ } satisfies Record<BadgeSize, string>;
10
+
11
+ const BADGE_VARIANTS = {
12
+ accent: c("badge-accent"),
13
+ error: c("badge-error"),
14
+ ghost: c("badge-ghost"),
15
+ info: c("badge-info"),
16
+ neutral: c("badge-neutral"),
17
+ primary: c("badge-primary"),
18
+ secondary: c("badge-secondary"),
19
+ success: c("badge-success"),
20
+ warning: c("badge-warning"),
21
+ } satisfies Record<BadgeVariant, string>;
22
+
23
+ export const getBadgeClasses = ({
24
+ size,
25
+ variant,
26
+ }: {
27
+ size?: BadgeSize;
28
+ variant?: BadgeVariant;
29
+ }) => {
30
+ return c("badge", BADGE_VARIANTS[variant!], BADGE_SIZE[size!]);
31
+ };
@@ -0,0 +1 @@
1
+ export { Badge } from './Badge';
@@ -0,0 +1,18 @@
1
+ export type BadgeSize = "xs" | "sm" | "md" | "lg";
2
+
3
+ export type BadgeVariant =
4
+ | "neutral"
5
+ | "primary"
6
+ | "secondary"
7
+ | "accent"
8
+ | "ghost"
9
+ | "info"
10
+ | "success"
11
+ | "warning"
12
+ | "error";
13
+
14
+ export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> & {
15
+ size?: BadgeSize;
16
+ outline?: boolean;
17
+ variant?: BadgeVariant;
18
+ };
@@ -0,0 +1,64 @@
1
+ import c from "clsx";
2
+ import {
3
+ CardContentProps,
4
+ CardDescriptionProps,
5
+ CardFooterProps,
6
+ CardHeaderProps,
7
+ CardImageProps,
8
+ CardProps,
9
+ } from "./types";
10
+
11
+ const Card = ({
12
+ compact,
13
+ bordered,
14
+ horizontal,
15
+ overlay,
16
+ className,
17
+ ...props
18
+ }: CardProps) => (
19
+ <div
20
+ className={c(
21
+ "card",
22
+ {
23
+ "card-bordered": bordered,
24
+ "card-compact": compact,
25
+ "card-normal": !compact,
26
+ "image-full": overlay,
27
+ "card-side": horizontal,
28
+ },
29
+ className
30
+ )}
31
+ {...props}
32
+ />
33
+ );
34
+
35
+ const CardHeader = ({ className, ...props }: CardHeaderProps) => (
36
+ <h3 className={c("card-title", className)} {...props} />
37
+ );
38
+
39
+ const CardDescription = ({ className, ...props }: CardDescriptionProps) => (
40
+ <p className={c("text-sm text-muted-foreground", className)} {...props} />
41
+ );
42
+
43
+ const CardContent = ({ className, ...props }: CardContentProps) => (
44
+ <div className={c("card-body p-6 pt-0", className)} {...props} />
45
+ );
46
+
47
+ const CardImage = ({ className, src, alt, ...props }: CardImageProps) => (
48
+ <figure>
49
+ <img className={className} src={src} alt={alt} {...props} />
50
+ </figure>
51
+ );
52
+
53
+ const CardFooter = ({ className, ...props }: CardFooterProps) => (
54
+ <div className={c("card-actions", className)} {...props} />
55
+ );
56
+
57
+ export {
58
+ Card,
59
+ CardHeader,
60
+ CardFooter,
61
+ CardDescription,
62
+ CardContent,
63
+ CardImage,
64
+ };
@@ -0,0 +1 @@
1
+ export * from "./Card";
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+
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>;
21
+
22
+ export type CardContentProps = React.HTMLAttributes<HTMLDivElement>;
23
+ export type CardImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
24
+ export type CardHeaderProps = React.HTMLAttributes<HTMLDivElement>;
25
+ export type CardFooterProps = React.HTMLAttributes<HTMLDivElement>;
26
+ export type CardDescriptionProps = React.HTMLAttributes<HTMLParagraphElement>;
@@ -0,0 +1,10 @@
1
+ import { type DetailProps } from './types';
2
+
3
+ export const Detail = ({ term, children }: DetailProps) => {
4
+ return (
5
+ <dl>
6
+ <dt className="mb-1 py-2 text-sm font-medium">{term}</dt>
7
+ <dd className="text-base">{children}</dd>
8
+ </dl>
9
+ );
10
+ };
@@ -0,0 +1 @@
1
+ export { Detail } from './Detail';
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from 'react';
2
+
3
+ export type DetailProps = {
4
+ term: string;
5
+ children: ReactNode;
6
+ };
@@ -0,0 +1,11 @@
1
+ import c from 'clsx';
2
+ import { getTooltipClasses } from './constants';
3
+ import { type TooltipProps } from './types';
4
+
5
+ export const Tooltip = ({ tip, children, variant, position, className }: TooltipProps) => {
6
+ return (
7
+ <div className={c(getTooltipClasses({ variant, position }), className)} data-tip={tip}>
8
+ {children}
9
+ </div>
10
+ );
11
+ };
@@ -0,0 +1,33 @@
1
+ import c from "clsx";
2
+ import type { TooltipPosition, TooltipVariant } from "./types";
3
+
4
+ const TOOLTIP_POSITION = {
5
+ top: c("tooltip-top"),
6
+ right: c("tooltip-right"),
7
+ bottom: c("tooltip-bottom"),
8
+ left: c("tooltip-left"),
9
+ } satisfies Record<TooltipPosition, string>;
10
+
11
+ const TOOLTIP_VARIANTS = {
12
+ accent: c("tooltip-accent"),
13
+ default: c("tooltip-default"),
14
+ error: c("tooltip-error"),
15
+ ghost: c("tooltip-ghost"),
16
+ info: c("tooltip-info"),
17
+ link: c("tooltip-link"),
18
+ neutral: c("tooltip-neutral"),
19
+ primary: c("tooltip-primary"),
20
+ secondary: c("tooltip-secondary"),
21
+ success: c("tooltip-success"),
22
+ warning: c("tooltip-warning"),
23
+ } satisfies Record<TooltipVariant, string>;
24
+
25
+ export const getTooltipClasses = ({
26
+ variant,
27
+ position,
28
+ }: {
29
+ variant?: TooltipVariant;
30
+ position?: TooltipPosition;
31
+ }) => {
32
+ return c("tooltip", TOOLTIP_VARIANTS[variant!], TOOLTIP_POSITION[position!]);
33
+ };
@@ -0,0 +1 @@
1
+ export { Tooltip } from './Tooltip';
@@ -0,0 +1,24 @@
1
+ import { type ReactNode } from 'react';
2
+
3
+ export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
4
+
5
+ export type TooltipVariant =
6
+ | 'default'
7
+ | 'neutral'
8
+ | 'primary'
9
+ | 'secondary'
10
+ | 'accent'
11
+ | 'ghost'
12
+ | 'link'
13
+ | 'info'
14
+ | 'success'
15
+ | 'warning'
16
+ | 'error';
17
+
18
+ export type TooltipProps = {
19
+ tip: string;
20
+ children: ReactNode;
21
+ variant?: TooltipVariant;
22
+ position?: TooltipPosition;
23
+ className?: string;
24
+ };
package/src/index.ts CHANGED
@@ -1,4 +1,8 @@
1
+ export * from "./components/Badge";
1
2
  export * from "./components/Breadcrumbs";
2
3
  export * from "./components/Button";
4
+ export * from "./components/Card";
5
+ export * from "./components/Detail";
3
6
  export * from "./components/Link";
4
7
  export * from "./components/Text";
8
+ export * from "./components/Tooltip";